Page: 4
8. OOPs
Q: 16 Click the Exhibit button. Which three code fragments, added individually at line 29, produce the output 100? (Choose three.) 
A. n = 100; B. i.setX( 100 ); C. o.getY().setX( 100 ); D. i = new Inner(); i.setX( 100 ); E. o.setY( i ); i = new Inner(); i.setX( 100 ); F. i = new Inner(); i.setX( 100 ); o.setY( i ); Answer: B, C, F Q: 17 Given: 10. class One { 11. public One() { System.out.print(1); } 12. } 13. class Two extends One { 14. public Two() { System.out.print(2); } 15. } 16. class Three extends Two { 17. public Three() { System.out.print(3); } 18. } 19. public class Numbers{ 20. public static void main( String[] argv ) { new Three(); } 21. } What is the result when this code is executed? A. 1 B. 3 C. 123 D. 321 E. The code runs with no output. Answer: C Q: 18 Click the Exhibit button. What is the outcome of the code?  A. Compilation fails. B. Gobstopper Fizzylifting C. Gobstopper Scrumdiddlyumptious D. Scrumdiddlyumptious Fizzylifting E. Scrumdiddlyumptious
Answer: B Q: 19 Given: 10. class One { 11. public One foo() { return this; } 12. } 13. class Two extends One { 14. public One foo() { return this; } 15. } 16. class Three extends Two { 17. // insert method here 18. } Which two methods, inserted individually, correctly complete the Three class? (Choose two.) A. public void foo() {} B. public int foo() { return 3; } C. public Two foo() { return this; } D. public One foo() { return this; } E. public Object foo() { return this; } Answer: C, D
Page: 4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|