What is the result?

Given the code fragment:

What is the result?
A. Jesse 25
Walter 52
B. Compilation fails only at line n1
C. Compilation fails only at line n2
D. Compilation fails at both line n1 and line n2

Download Printable PDF. VALID exam to help you PASS.

4 thoughts on “What is the result?

  1. Answer D:

    Line n1 fails because there is no no-args constructor.
    Line n2 fails because the code is calling the constructor by using the class name instead of this() keyword.

  2. D is the answer. In line 1 this() does not work because when you create any constructor default constructor will be canceled; therefore you cannot call it by using this(). When line 1 is the problem, line2 is being the problem automatically

Leave a Reply

Your email address will not be published. Required fields are marked *