SCJP題庫第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.     //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

Comments

Popular posts from this blog

Android+Google Map API v3 Geocoding(地址轉經緯度度