Ask Question
10 November, 01:55

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

+3
Answers (1)
  1. 10 November, 02:12
    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 & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers