Which code, inserted at line 15, creates an instance of the Point class defined in Line?

Given:

09. class Line {
10. public static class Point {}
11. }
12.
13. class Triangle {
14. public Triangle(){
15. // insert code here
16. }
17. }

Which code, inserted at line 15, creates an instance of the Point class defined in Line?

Given:

09. class Line {
10. public static class Point {}
11. }
12.
13. class Triangle {
14. public Triangle(){
15. // insert code here
16. }
17. }

Which code, inserted at line 15, creates an instance of the Point class defined in Line?

A.
Point p = new Point();

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

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

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

Explanation:
A:
Main.java:15: cannot find symbol
symbol : class Point
location: class Triangle
Point p = new Point();
^
Main.java:15: cannot find symbol
symbol : class Point
location: class Triangle
Point p = new Point();
^
2 errors

B:
compiled successfully

C:
false

D:
Main.java:15: package l does not exist
Line l = new Line() ; l.Point p = new l.Point();
^
Main.java:15: package l does not exist
Line l = new Line() ; l.Point p = new l.Point();
^
2 errors



Leave a Reply 0

Your email address will not be published. Required fields are marked *