Important Java Mcq 1

Which statement is true for the class First given below?

 package myPackage: 

                     class First 

                   {

                    /* class body */

                   }

a. first class is accessible to all classes defined inside or outside my package.

b. first class is accessible to classes within my package.

c. first class is not accessible to any other class

d. first class is accessible to its subclasses defined inside or outside my package

Answer:

b. first class is accessible to classes within my package.

Explanation:

It is because the access specifiers are not specified. The default access specifier is package-private, which means the class and the member functions are accessible within the specified package. Access specifiers outline how the attributes and methods of a category may be accessed.

Related MCQs
Aniket Malik

Aniket Malik

CERTIFIED TUTOR/TRAINER WITH 300+ REVIEWS

Facing difficulty with

this concept?