"SCJP 1.6版考題 114" 修訂間的差異
出自 陳富國維基館
(新頁面: Given: 10. class line{ 11. public class Point{public int x, y;} 12. public Point getPoint(){return new Point();} 13. } 14. class Triangle{ 15. public Triangle(){ 16. ...) |
(無差異)
|
於 2013年3月30日 (六) 04:20 的最新修訂
Given:
10. class line{
11. public class Point{public int x, y;}
12. public Point getPoint(){return new Point();}
13. }
14. class Triangle{
15. public Triangle(){
16. //insert code here
17. }
18. }
Which code, inserted at line 16, correctly retrieves a local instance of a Point object?
A. Point p = Line.getPoint();
B. Line.Point p = Line.getPoint();
C. Point p = (new Line()).getPoint();
D. Line.Point p = (new Line()).getPoint();
解答
Ans: D
解說:
getPoint是物件成員,要存取這個物件成員要先建立Line物件 Point是在Line中定義,要存取須用Line.Point
| ||||||||||||||||||||