Ask Question
26 September, 06:27

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;

} / / end Foo constructor

public abstract int calculate ();

} / / end class Foo

Any concrete subclass that extends class Foo:

1) Must implement a method called calculate.

2) Will not be able to access the instance variable a.

3) Neither (a) nor (b).

4) Both (a) and (b).

+1
Answers (1)
  1. 26 September, 08:07
    0
    4) Both (a) and (b).

    Explanation:

    In addition to regular classes, Java has abstract classes. An abstract class is like a regular class. You can also define fields and methods in an abstract class, while at the same time, you cannot create an object or an instance of an abstract class. Abstract classes are designed to provide basic functionality for derived classes while derived classes required to implement this functionality.

    A derived class must override and implement all abstract methods that are in the base abstract class. Therefore answer a (1) is correct.

    Access modifier for the field a was private which means it has to be provided with accessor methods to obtain/modify its value. Therefor answer b (2) is correct as well.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Consider the abstract superclass below: public abstract class Foo { private int a; public int b; public Foo (int aVal, int bVal) { a = ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers