Oracle Certified Professional Java Se 8 Programmer · Free Practice Question Easy

Question 5

Consider below code of Child.java file: 

What is the result?

  • A Compilation error at Line 10
  • B Compilation error at Line 11
  • C Compilation error at Line 9
  • D Parent
Reveal correct answer

Correct answer: D

Explanation

Parent is a concrete class.

In java it is possible for abstract class to not have any abstract methods.

Class Child is abstract, it extends Parent and doesn't contain any abstract method. It contains special main method, so JVM can invoke this method.


Rest of the code is normal java code. new Parent().m(); creates an instance of Parent class and invokes method m() on that instance. "Parent" is printed on to the console.

Discussion

Think the marked answer is wrong, or have a better explanation? Share it below — comments appear after review.

You must be logged in to post a comment.

Preparing For

Your Certification?

255+ certifications
Detailed explanations
Free PDF samples

Has All The Questions You Need