Abstraction
6.How does abstraction contribute to system security?
-
A. By preventing direct access to implementation details
-
B. By exposing all data to other classes
-
C. By making the code unreadable
-
D. By allowing unrestricted modification of class variables
By preventing direct access to implementation details
By preventing direct access to implementation details
7.How does abstraction contribute to code maintainability?
-
A. By exposing all class details to other classes
-
B. By making it easier to modify the internal logic without affecting external code
-
C. By forcing all methods to be static
-
D. By eliminating the need for constructors
By making it easier to modify the internal logic without affecting external code
By making it easier to modify the internal logic without affecting external code
8.How does abstraction differ from encapsulation?
-
A. Abstraction focuses on hiding implementation, while encapsulation protects data
-
B. Encapsulation involves abstract methods only
-
C. Encapsulation and abstraction are the same concept
-
D. Abstraction forces all classes to be final
Abstraction focuses on hiding implementation, while encapsulation protects data
Abstraction focuses on hiding implementation, while encapsulation protects data
9.Which statement is true regarding interfaces in Java?
-
A. An interface can have a constructor
-
B. An interface allows multiple inheritance through implementation
-
C. An interface cannot have constants
-
D. An interface can be instantiated directly
An interface allows multiple inheritance through implementation
An interface allows multiple inheritance through implementation
10.How does abstraction affect method visibility in Java?
-
A. It ensures all methods are public
-
B. It restricts direct access to method implementations
-
C. It forces all methods to be overridden
-
D. It prevents method overloading
It restricts direct access to method implementations
It restricts direct access to method implementations