Short answerEasy2 marks
Name any two types of access specifiers.
Topic: Access specifiers
Previous-year question practice database
Answer
Exam answer
public and private. (protected and default are equally acceptable.)
Explanation
Java has exactly four levels of access, and naming any two earns the marks — but knowing all four is safer: public - accessible from anywhere protected - accessible within the class, its subclasses and its package default - accessible only within the same package (written by giving no specifier at all) private - accessible only within the same class Adding one word of meaning beside each name costs nothing and protects you if the examiner wants more.
More from Encapsulation
Which of the following is NOT an access specifier?2026Post office is an example for __________ access specifier.2025The access specifier that gives least accessibility is __________.2024Assertion (A): Static method can access static and instance variables.
Reason (R): Static variables can be accessed only by static method.2024A mechanism where one class acquires the properties of another class:2023A method which is a part of a class rather than an instance of the class is termed as:2023