11.) Can an interface have a private method?
A) Yes, but it can only be accessed within the interface.
B) No, interfaces cannot have private methods.
C) Yes, and it can be accessed by classes that implement the interface.
D) Yes, but it can only be accessed within the same package.
12.) Which access modifier is appropriate for a method that should be accessible only within the same package and not be overridden by subclasses?
A) public
B) protected
C) default (package-private)
D) final
13) If a subclass is in a different package, which access modifiers of the superclass are accessible?
A) public and protected
B) protected and default (package-private)
C) public only
D) default (package-private) only
14.) Which access modifier allows a subclass to increase the visibility of a method while overriding it?
A) private
B) default (package-private)
C) protected
D) public
15.) Can a class be marked as both abstract and final simultaneously?
A) Yes, as long as it has abstract methods.
B) No, abstract and final are conflicting modifiers and cannot be used together.
C) Yes, but it can’t have any methods.
D) Yes, but only if it’s in a different package.
16.) Which access modifier is used for interface methods by default?
A) public
B) protected
C) default (package-private)
D) private
17.) In which case would you use the “protected” access modifier for a class member?
A) When you want it to be accessible globally.
B) When you want it to be accessible only within the same package.2
C) When you want it to be accessible within the same package and its subclasses.
D) When you want it to be accessible only within the same class.
18.) Which access modifier would you use for a class member that needs to be accessed by any class, even those in different packages?
A) public
B) protected
C) default (package-private)
D) private