Encapsulation in Java MCQs Exercise I
Ques 1
Encapsulation
What is encapsulation in Java?
A A method of creating objects from classes
B A technique for hiding an object's internal state and requiring controlled access through methods
C A way to perform mathematical operations on objects
D A process of inheritance in object-oriented programming
Ques 2
Encapsulation
What is the main benefit of encapsulation?
A To make methods and variables available to any class
B To restrict access to certain methods and variables for better control and security
C To make code execution faster
D To create a new instance of a class
Ques 3
Encapsulation
Which Java access modifier is used to make a class or member accessible only within the same package?
A private
B protected
C package-private (default)
D public
Ques 4
Encapsulation
In Java, which keyword is used to declare a private instance variable?
A var
B int
C private
D final