Computer Applications
Which of the following access specifiers will make a member accessible only within its own class?
- public
- private
- protected
- default
Encapsulation & Inheritance in Java
5 Likes
Answer
private
Reason — In Java, the private access specifier restricts a member’s visibility so it can be accessed only within the same class where it is declared.
Answered By
2 Likes
Related Questions
What is the output of the code snippet given below?
int lives = 5; System.out.print(lives--); System.out.print(lives);- 4 3
- 5 4
- 5 3
- 4 4
What will be the output of the following statement?
String s = "JavaProgramming"; System.out.println(s.substring(4, 11).toUpperCase());- Programm
- PROGRAMM
- PROGRAM
- program
What will be the output of the following Java method?
Character.isLetterOrDigit('\n')- 1
- 0
- true
- false
Which of the following is not a type of token in Java?
1. Method 3. Literal 2. Identifier 4. Keyword - only 1
- 1 and 3
- only 2
- only 4