179k views
3 votes
Consider the abstract superclass below: public abstract class Foo { private int a; public int b; public Foo(int aVal, int bVal) { ​ a = aVal; ​ b = bVal; } public abstract int calculate(); } Any concrete subclass that extends class Foo ________. Group of answer choices will not be able to access the instance variable a must implement a method called calculate Neither A nor B. Both A and B.

User Draemon
by
3.3k points

1 Answer

2 votes

Answer:

The answer is "Option Both (A) and (B)."

Step-by-step explanation:

In the given code an abstract class is defined, that contains two integer private method that is "a and b", and also defines a parameterized constructor, that uses above variable to hold the value, and at the last an abstract method "calculate" is defined.

This method is part of the abstract class, that means it defines outside the class, and this method doesn't use an instance of the class to access it, that's why option A and option B is correct and others were wrong.

User Zigu
by
3.6k points