Exam 1z0-819 All QuestionsBrowse all questions from this exam
Question 141

Given:

and

    Correct Answer: A

    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.

Discussion
ASPushkinOption: A

A class may be declared with the modifier public or default. If it is default it is visible only within its own package.

Ashan_OzlovOption: D

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

StavokOption: A

A is correct

d7bb0b2Option: A

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

RoxyFoxyOption: A

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.

Ashan_OzlovOption: E

E is the best answer

KiraguJohn

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:

KiraguJohnOption: A

A. default class can only be accessed within the same package