Which two import statements can make the a.b.parent class compliable?

Given two classes in separate files:

package a.b;

/ / import statement

public class parent

child c = new child();

package a.b.c;

public class child{

}

Which two import statements can make the a.b.parent class compliable?

Given two classes in separate files:

package a.b;

/ / import statement

public class parent

child c = new child();

package a.b.c;

public class child{

}

Which two import statements can make the a.b.parent class compliable?

A.
import a.b.c.Parent;

B.
import a.b.c.Child;

C.
import a.b.c.*;

D.
import a.b.*;

E.
import a.*;

Explanation:
B:To import a specific member into the current file, put an import statement at the beginning of the file before any type definitions but after the package statement, if there is one.

C:To import all the types contained in a particular package, use the import statement with the asterisk (*) wildcard character.

Reference: The Java Tutorials,Using Package Members



Leave a Reply 2

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


B

B

B if it was child instead of Child & C