Oracle
1Z0-809 · Question #274
QUESTION 298 Given: public class Emp { public void calcLeave() { System.out.println("12"); } } and the code fragment: public class TestAnn { public static void main (String[] args) { // insert code…
The correct answer is B. Emp e = new Emp() { public void calcLeave() { System.out.println("13"); } }. You've hit your session limit · resets 5:20pm (America/New_York)
Question
QUESTION 298
Given:
public class Emp {
public void calcLeave() {
System.out.println("12");
}
}
and the code fragment:
public class TestAnn {
public static void main (String[] args) {
// insert code here
e.calcLeave();
}
}
Which code fragment can be inserted to print 13?
Options
- AEmp e = () -> { public void calcLeave() { System.out.println("13"); } };
- BEmp e = new Emp() { public void calcLeave() { System.out.println("13"); } };
- CEmp e = new Emp{ public void calcLeave() { System.out.println("13"); } } ();
- DEmp e = new Emp() { (static class Emp { public void calcLeave() { System.out.println("13"); } });
How the community answered
(46 responses)- A17% (8)
- B70% (32)
- C4% (2)
- D9% (4)
Explanation
You've hit your session limit · resets 5:20pm (America/New_York)
Community Discussion
No community discussion yet for this question.