Given:
and
Given:
and
A class declared with default access (no access modifier) is only accessible within its own package. As the class X in package p1 does not have the public modifier, it cannot be accessed from package p2, even if it is imported. Therefore, the statement that the class X is not accessible in p2 is correct.
A class may be declared with the modifier public or default. If it is default it is visible only within its own package.
The answer here is D since the method in D is public. A is wrong, we imported the class E is wrong, ran on compiler
A is correct
A is correct, so X is default access, cannot be accessed outside package. protected contructor, instance variable and method can access because has protected acces
X is not public and cannot be accessed from outside package (even if we use import statement). X is in p1 and Y is in p2. X has default access = package private. Regarding E , X(list) and Y() are two different things. Y is the subclass and X(list) must not match the constructor of its subclass. X(list) is the constructor with one parameter that overloads X()...nothing to do with Y(). Y () depends on X(list) but not viceversa. So I think E is not correct.
E is the best answer
Default. When we don't use any keyword explicitly, Java will set a default access to a given class, method or property. The default access modifier is also called package-private, which means that all members are visible within the same package but aren't accessible from other packages:
A. default class can only be accessed within the same package