Multiple choice technology programming languages

class Line { Line 1. public class Point { public int x,y; } Line 2. public Point getPoint() { return new Point(); } Line 3. } Line 4. class Triangle { Line 5. public Triangle() { Line 6. // insert code here Line 7. } 18. } Which code, inserted at line Line 6, 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();

  1. A

  2. B

  3. C

  4. D

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

Point is a static nested class inside Line. To call getPoint() (an instance method), you need a Line instance: (new Line()).getPoint(). Since Point is defined inside Line, the full type is Line.Point. Option D correctly combines both: Line.Point p = (new Line()).getPoint(). Options A and C miss the Line. prefix for the nested class type. Option B is missing the Line instance.