Multiple choice technology

Given: 10. class Line { 11. public static class Point {} 12. } 13. 14. class Triangle { 15. // insert code here 16. } Which code, inserted at line 15, creates an instance of the Point class defined in Line?

  1. Point p = new Point();

  2. Line.Point p = new Line.Point();

  3. The Point class cannot be instatiated at line 15.

  4. Line l = new Line() ; l.Point p = new l.Point();

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

Point is a static nested class inside Line. To instantiate it outside Line, use the fully qualified name Line.Point and call new Line.Point(). Static nested classes don't require an instance of the outer class.