Click here to load reader

SCJP ch09

Embed Size (px)

Citation preview

  • 1. 9 80%

2. 3. , , , , main() 4. 5. , , , , , , , , , , , , 6. , Java , , 7. 9-1 (Constructor) , (method), , , , new , , 8. 9-1-1 (Default Constructor) , , Java , 9. (Default Constructor) , Test , Java , 10. (Default Constructor) 5 6 , , , , , Java 11. 9-1-2 , , , , void , , , 12. , 13. 14. 14 new , Java 5 8 , x y , 15. , , , new 16. 17. , , new , , , , 18. 19. , 20. 9-1-3 (Overloading) , , , , , , , 21. (Overloading) 22. (Overloading) 23. (Overloading) , Test 3 , , 24. (Overloading) , Java , , , , , , , , , 25. 9-1-4 this , , , , (Shadowing) , this , , 26. this 27. this , this , , , 28. this 29. this 30. this 6 , x , Test() , , Java , , this , 31. this 32. this 6 , this , this , , this , , , , , , this , 33. 9-2 , , , main() , , (Information Hiding), ( main() ) ( ) 34. , , , , , , , ( ) 35. , , , , , , 36. , . . . , , , (Encapsulation) 37. 9-2-1 , , (Access Modifier) 38. protected 11 13 , private public private , , , , , ( ) , , 39. 40. 41. , i Test private , Test 21 , , private , , , , main() , show() modifyMember() , , main() 42. , Java (Default Access), (Package) 13 , , .class , , main() , 43. , , , 11 44. 9-2-2 , , , , , , 45. , , , private , 46. , getXXX, XXX , setXXX , , 47. , , , public get set , , private , , , public, private, new , 48. 49. 50. 10 13 , Test private x y , getX setX getY setY, 2 public , , private, , 51. 52. 53. 54. , main() , , main() 55. 9-2-3 , , private, , , , , , Point, Point , 56. 57. Circle getP() , , p , , Point setX() setY() , 58. 59. 60. 61. 20 Circle getP() , p , main() 36 getP() , 37 Point setX() X X 62. , Circle , , , p private, getP() , Circle , getP() , Point , Point 63. Point , Circle , 64. 65. 2 1. 15 18 Point , , 2. 25 27 getP() , Point , p, p , 66. , main() , Circle , , , toString() , , , , , "+" String 67. 9-2-4 JavaBean JavaBean Java (Component), Java ( NetBeans Eclipse), , JavaBean , JavaBean , SCJP ( JavaBean ) 68. JavaBean JavaBean (field), private, , , name isOpened readFileData , Getter ( ) Setter ( ) , 69. JavaBean , Listener ( ) , 3 Getter ( ) , public, type Xxx , , , public int getSize() public float getValue() 70. JavaBean , boolean, get is isReady() getReady() 71. JavaBean Setter ( ) , Setter Getter , void, , public void setSize(int x) public void setValue(float f) 72. JavaBean Listener (add) (remove) , public void, add remove, XxxListener, 73. 9-3 static , , , , static 74. static , , , , , , , , Java static , 75. 9-3-1 static static , , , 76. static 77. static 18 20 y , static , 3 y , , y, 60 , a b c y , 60 , x static, 78. 9-3-2 static static , Test , y 79. static 21 . y, 100, , y 100 80. static , , static 81. static 82. static , Test x 17 static y, , y , y 100 83. 9-3-3 static static , , static , static , Java static (Static Initializer), , static , static , static , 84. static 85. static 86. static static , , 5 7 static , Test ( 23 ) , 23 static y 100 87. static static , , , (Class Variable) , static , , (Instance Variable) (Instance) 88. 9-3-4 static static , static , static , , 89. static 90. static static , Java Math , static ( ) static ( ) 91. static , static , static , this , static , static , , static , this 92. main() main() , main() public static , 93. 9-3-5 final static , , , static , static , , 3 final , static , 94. final 95. final 2 x final, 9 , final , static , static static , , 96. 9-3-6 ( ), final ( , ), , 97. ( ) null, 98. , Test.z null, i f 99. , ( ) , , , , , 100. , (b) new ( ) , ( ), 7 new , 101. 9-A 9-B 102. 1. Given: 103. What is the result? A. 5 4 3 2 B. 5 4 4 3 C. 5 5 4 3 D. 5 5 4 4 E. Compilation fails. 104. 2. Which statements concerning following code are true? (Choose two or three) 105. A. This class is fully encapsulated. B. B. The variables break the encapsulation of class. C. C. The methods break the encapsulation of class D. D. All methods are following the JavaBean standard. E. E. Some methods are not following the JavaBean standard. 106. 3. Which of following methods are valid constructor for class Note? (Choose all that apply) A. public Note() { ... } B. public void Note() { ... } C. private Note() { ... } D. public static Note() { ... } E. Note() { ... } F. final Note() { ... } 107. 4. Given following Java code: 108. What is the result? A. C6 C1 C2 C3 C4 C5 B. C6 C1 C3 C4 C2 C5 C. C6 C1 C3 C4 C5 C2 D. C6 C4 C3 C1 C2 C5 E. C6 C4 C3 C1 C5 C2 109. 5. A JavaBean Class has following field:Which method declaration follows JavaBean standard? (Choose all that apply) A. public void getVisible() B. public boolean getVisible() C. private boolean isVisible() D. public boolean isVisible() E. public boolean canVisible() F. private boolean canVisible() 110. 6. Given:Which four statements are true? (Choose four) A. fun1() can directly modify field i. B. fun1() can directly modify field j. C. fun2() can directly modify field i. D. fun1() can directly call fun2(). E. fun2() can directly call fun1(). F. StaticQuiz.fun1() is a valid invocation outside StaticQuiz class. G. StaticQuiz.fun2() is a valid invocation outside StaticQuiz class. 111. 7. Given: 112. How many objects are created in main()? How many object is available for Garbage Collection at line 13? A. 2 objects are created. B. 4 objects are created. C. 5 objects are created. D. 1 object is avaible for Garbage Collection. E. 2 object is avaible for Garbage Collection. F. 3 object is avaible for Garbage Collection. 113. 8. What is the result of following program: 114. A. B. C. D. E.Counter=2 Compilation fails at line 3. Compilation fails at line 4. Compilation fails at line 9. Compilation fails at line 10. F. Runtime error. 115. 9. Given:What is the result? A. 300 200 B. 200 300 D. 250 300 E. 250 250C. 300 250 116. 10.Given:How many objects are available for Garbage Collection at line 14?A. 0B. 1C. 2D. 3E. 4