Java OCA OCP Practice Question 382

Question

Given the following:

public abstract class MyClass { 
     abstract provideMe(); 
} 
public class MySubClass extends MyClass { } 

Which statements are true?

  • A. MyClass generates a compiler error.
  • B. MySubClass generates a compiler error.
  • C. If MySubClass were declared abstract, it would compile without error.
  • D. If MySubClass were declared abstract, it could be instantiated.
  • E. MyClass is a legal type for variables.


B, C, E.

Note

MyClass is a valid class; it contains an abstract method, so the class must also be abstract.

MySubClass must be declared abstract because it doesn't provide an implementation for the abstract method of its parent class.

An abstract class may not be instantiated but is a legal type for variables.




PreviousNext

Related