Java Encapsulation MCQ - Multiple Choice Questions And Answers
Q. What is encapsulation in Java?
A. It is a process of wrapping data and methods in a single unitB. It is a process of defining multiple interfaces
C. It is a process of creating objects from classes
D. It is a process of establishing relationships between classes
Q. Which access modifier is used to restrict the access of a member to the same package?
A. privateB. protected
C. public
D. default
Q. Which keyword is used to create a constant variable?
A. staticB. final
C. abstract
D. constant
Q. Which access modifier is used to allow a member to be accessed from any class in any package?
A. privateB. protected
C. public
D. default
Q. Which keyword is used to inherit a class in Java?
A. newB. create
C. extends
D. implement
Q. Which keyword is used to access the superclass members in a subclass?
A. superB. parent
C. this
D. extends
Q. Which access modifier is most restrictive in Java?
A. privateB. protected
C. public
D. default
Q. What is abstraction in Java?
A. It is a process of hiding data and methods in a single unitB. It is a process of defining multiple interfaces
C. It is a process of creating objects from classes
D. It is a process of establishing relationships between classes
Q. What is the purpose of encapsulation in Java?
A. To produce resultsB. To consume values
C. To hide data and implementation details
D. To transform values
Q. Which access modifier is used by default for class members in Java?
A. privateB. protected
C. public
D. default