Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Imagine that there is a class called VendingMachine that implemented Fillable. F

ID: 3728450 • Letter: I

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 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

Explanation / Answer

Answer for the above question :  (D) The program would fail to compile completely