Given:
and the code fragment:Which code fragment can be inserted to print 13?
A.
B.
C.
D.
Given:
and the code fragment:Which code fragment can be inserted to print 13?
A.
B.
C.
D.
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.
Answer B. Tested
B is correct.
B. Tested