Java OCA OCP Practice Question 987

Question

Which of the following statements are true?

Select 2 options

  • A. The extends keyword is used to specify inheritance.
  • B. subclass of a non-abstract class cannot be declared abstract.
  • C. subclass of an abstract class can be declared abstract.
  • D. subclass of a final class cannot be abstract.
  • E. A class, in which all the members are declared private, cannot be declared public.


Correct Options are  : A C

Note

final class cannot be subclassed.

E. is wrong. There is no such rule.

The extends clause is used to specify that a class extends another class and thereby inherits all non-private instance members of that class.

A subclass can be declared abstract regardless of whether the superclass was declared abstract.

A class cannot be declared abstract and final at the same time.

This restriction makes sense because abstract classes need to be subclassed to be useful and final forbids subclasses.

The visibility of the class is not limited by the visibility of its members.

A class with all the members declared private can still be declared public or a class having all public members may be declared private.




PreviousNext

Related