Vidyalelo
Java Programming · all questions

Declaration and Access Control
practice.

Practice every MCQ with options. Use Show answers when you want the correct option and solution.

55

Questions

1/3

Page

Pick an option on a question to see the right answer and solution.

What is the default access modifier for class members in Java if no access modifier is specified?

Select an option to see the answer and solution.

Which access modifier restricts a class member's visibility only to the same class and its subclasses?

Select an option to see the answer and solution.

What keyword is used to declare a constant in Java, which is implicitly final and static?

Select an option to see the answer and solution.

Which of the following access modifiers allows access to a class member from any class in any package?

Select an option to see the answer and solution.

What is the access level of a class member with no access modifier specified in Java?

Select an option to see the answer and solution.

In Java, which access modifier allows a method or variable to be accessed within the same package only?

Select an option to see the answer and solution.

Which keyword is used to explicitly specify that a method cannot be overridden in a subclass?

Select an option to see the answer and solution.

What is the default access modifier for a class in Java if no access modifier is specified?

Select an option to see the answer and solution.

Which access modifier allows a class member to be accessed only within its own class and package?

Select an option to see the answer and solution.

In Java, which access modifier allows a class member to be accessed from anywhere in the code?

Select an option to see the answer and solution.

What keyword is used to declare a method that can be called without creating an instance of the class?

Select an option to see the answer and solution.

Which of the following access modifiers restricts a method or variable's access to the same package only?

Select an option to see the answer and solution.

In Java, what is the purpose of the static keyword when applied to a variable?

Select an option to see the answer and solution.

Which keyword is used to define a superclass's method that is overridden by a subclass method?

Select an option to see the answer and solution.

What is the access level of a class member declared as private in Java?

Select an option to see the answer and solution.

Which access modifier allows a class member to be accessed within the same package and its subclasses?

Select an option to see the answer and solution.

What is the keyword used to declare a class that cannot be instantiated and can only be extended?

Select an option to see the answer and solution.

In Java, what access modifier is used to specify that a class member can be accessed only within its class?

Select an option to see the answer and solution.

Which of the following is not an access modifier in Java?

Select an option to see the answer and solution.

What access modifier allows a class member to be accessed from any class in the same package or any subclass?

Select an option to see the answer and solution.