Java Abstraction MCQ - Multiple Choice Questions And Answers
Q. What is the purpose of abstraction in Java?
A. To produce resultsB. To consume values
C. To filter elements based on a condition
D. To hide implementation details and provide a simplified interface
Q. Select the correct statement about abstraction in Java.
A. Abstraction is only applicable to classes, not interfacesB. Abstraction is only useful in large-scale applications
C. Abstraction allows for code reuse and modularity
D. Abstraction is not supported in Java
Q. Which keyword is used to implement abstraction in Java?
A. abstractB. implements
C. extends
D. class
Q. Which statement is true about abstract classes in Java?
A. An abstract class can be instantiated directlyB. An abstract class can have both abstract and non-abstract methods
C. An abstract class must implement all methods declared as abstract in its superclasses
D. An abstract class cannot have any constructors
Q. Which statement is true about interfaces in Java?
A. An interface can be instantiated directlyB. An interface can have instance variables
C. An interface can implement other interfaces
D. An interface can have both abstract and non-abstract methods
Q. Which of the following is an example of abstraction in Java?
A. ArrayList classB. Scanner class
C. Math class
D. String class
Q. Which of the following statements is true about method overriding in Java?
A. In method overriding, the method names must be different in the superclass and the subclassB. Method overriding can only be applied to abstract methods
C. Method overriding is not related to abstraction in Java
D. In method overriding, the method signature must be the same in the superclass and the subclass
Q. What is the purpose of an abstract method in Java?
A. To provide a default implementationB. To define a method that must be implemented by any concrete subclass
C. To hide implementation details
D. To define a method that cannot be overridden
Q. What is the purpose of the Predicate functional interface in Java 8?
A. To produce resultsB. To consume values
C. To filter elements based on a condition
D. To transform values
Q. What is the difference between abstract classes and interfaces in Java?
A. Abstract classes can have static methods, while interfaces cannotB. Interfaces cannot have instance variables, while abstract classes can
C. Abstract classes can be inherited by multiple classes, while interfaces cannot
D. Interfaces can have default method implementations, while abstract classes cannot