Java OCA OCP Practice Question 1712

Question

Which statements about the use of modifiers are true?.

Select the two correct answers.

  • (a) If no accessibility modifier (public, protected, or private) is specified for a member declaration, the member is only accessible by classes in the package of its class and by subclasses of its class in any package.
  • (b) You cannot specify accessibility of local variables. They are only accessible within the block in which they are declared.
  • (c) Subclasses of a class must reside in the same package as the class they extend.
  • (d) Local variables can be declared static.
  • (e) The objects themselves do not have any accessibility modifiers, only the object references do.


(b) and (e)

Note

You cannot specify accessibility of local variables.

They are accessible only within the block in which they are declared.

Objects themselves do not have any accessibility, only references to objects do.

If no accessibility modifier (public, protected, or private) is given in the member declaration of a class, the member is only accessible by classes in the same package.

A subclass does not have access to members with default accessibility declared in a superclass, unless both classes are in the same package.

Local variables cannot be declared static or have an accessibility modifier.




PreviousNext

Related