Question: Imagine that there is a class called VendingMachine that implemented Fillable. Furthermore, consider the declaration of VendingMachine as follows: public class VendingMachine implements Fillable{ private

Imagine that there is a class called VendingMachine that implemented Fillable. Furthermore, consider the declaration of VendingMachine as follows:

public class VendingMachine implements Fillable{

private int currentStock;

public VendingMachine(){

currentStock = 0;

}

public VendingMachine(int stock){

currentStock = stock;

}

public void fill(int qty){

currentStock += qty;

}

public int getMaximumCapacity(){

return 20;

}

}

What would be the result of running the following code segment?

Fillable a = new VendingMachine(40);

System.out.println(a.getMaximumCapacity());

(A) 0

(B) 20

(C) 40

(D) The program would fail to compile completely

(E) An error is thrown during run-time

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!