11.) Which modifier restricts access to class members within the same class?
A) public
B) protected
C) private
D) static
12.) What does an abstract method lack?
A) Implementation
B) Access modifier
C) Return type
D) Parameter
13.) What is the main difference between encapsulation and abstraction in Java?
A) Encapsulation focuses on hiding data, while abstraction focuses on hiding implementation details.
B) Encapsulation focuses on hiding implementation details, while abstraction focuses on hiding data.
C) Encapsulation and abstraction are the same concepts.
D) Encapsulation and abstraction are unrelated concepts.
14.) Can an abstract class have non-abstract (concrete) methods in Java?
A) No, an abstract class can only have abstract methods.
B) Yes, but only if the non-abstract methods are marked as “final.”
C) Yes, an abstract class can have both abstract and non-abstract methods.
D) Yes, but only if the non-abstract methods have private access.
15.) What is the purpose of an abstract method in an abstract class?
A) To prevent subclassing.
B) To provide a concrete implementation in the abstract class.
C) To serve as a placeholder that must be overridden by subclasses.
D) To make the class inaccessible.
16.) How does encapsulation contribute to data protection and security in Java?
A) By making all class members public.
B) By allowing unrestricted access to all data.
C) By restricting direct access to internal data and providing controlled access through methods.
D) By using the “protected” access modifier for all attributes.
17.) What does encapsulation ensure in Java?
A) Access to all class members from any package
B) Hiding implementation details and restricting access to class members
C) Accessibility of only private methods within the class
D) Automatic instantiation of objects
18.) Which access modifier provides the most open visibility for class members in Java?
A) private
B) protected
C) default (package-private)
D) public
19.) Which Java keyword is used to declare a method as abstract within an abstract class?
A) abstract
B) method
C) void
D) override
20.) How does abstraction contribute to reducing software complexity and improving maintenance?
A) By exposing all implementation details
B) By making all methods public
C) By hiding data attributes
D) By presenting a high-level view and hiding low-level details