Given the following classes, which of the following snippets can be inserted in place of INSERT IMPORTS HERE and have the code compile? (Choose all that apply)
//Shape.java package com.java2s; public class Shape { boolean printable = false; } //Shape.java package com.java2s.beans; public class Shape { boolean printable = true; } //ShapeFiller.java package filter; INSERT IMPORTS HERE public class ShapeFiller { Shape water; }
A, B, C.
A is correct because it imports all the classes in the com.java2s package including com.java2s.Shape.
B and C are correct because they import Shape by classname.
Since importing by classname takes precedence over wildcards, these compile.
D is incorrect because Java doesn't know which of the two wildcard Shape classes to use. They both have the Shape class.
E is incorrect because you cannot specify the same classname in two imports, which result in name confliction.