Exam 1z0-809 All QuestionsBrowse all questions from this exam
Question 201

Given:

and the code fragment:

Which code fragment can be inserted to print 13?

A.

B.

C.

D.

    Correct Answer:

    The correct code fragment that can be inserted to print '13' is: B. The reason is that option B uses an anonymous class to override the calcLeave method in the Emp class. The code within the brackets defines an anonymous class that extends Emp and overrides the calcLeave method to print '13' instead of '12'. This allows the e.calcLeave() call in the main method to execute the overridden version of the method, resulting in the output '13'. The other options either use incorrect syntax or do not achieve the desired outcome.

Discussion
jduarte

Answer B. Tested

steefaand

B is correct.

WilsonKKerll

B. Tested