Oracle Certified Associate Java Se 8 Programmer · Free Practice Question Hard

Question 42

Consider the code of Test.java file:

What will be the result of compiling and executing Test class?

  • A

    null:0

  • B

    James:25

  • C

    An exception is thrown at runtime

  • D

    Compilation error

Reveal correct answer

Correct answer: D

Explanation

A constructor can call another constructor by using this(...) and not the constructor name.

Hence Student("James", 25); causes compilation error.

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