Podcast
Questions and Answers
Which of the following is true about interfaces in Java?
Which of the following is true about interfaces in Java?
- They can be instantiated
- They cannot be implemented by a class
- They cannot have static constants
- They provide total abstraction (correct)
What is the purpose of using interfaces in Java?
What is the purpose of using interfaces in Java?
- To achieve encapsulation
- To achieve abstraction and multiple inheritance (correct)
- To provide implementation details of a class
- To restrict access to class members
Which of the following is a new feature introduced in Java 8 for interfaces?
Which of the following is a new feature introduced in Java 8 for interfaces?
- Static constants
- Public variables
- Final methods
- Private methods (correct)
Flashcards are hidden until you start studying
Study Notes
- An interface in Java is a blueprint of a class with static constants and abstract methods.
- It is used to achieve abstraction and multiple inheritance in Java.
- Interfaces cannot be instantiated and represent the IS-A relationship.
- Since Java 8, interfaces can have default and static methods.
- Since Java 9, interfaces can have private methods.
- Interfaces are declared using the interface keyword and provide total abstraction.
- A class that implements an interface must implement all its methods.
- Multiple inheritance is possible through interfaces in Java.
- Java 8 introduced default and static methods in interfaces.
- Serializable, Cloneable, and Remote are examples of marker or tagged interfaces.
Studying That Suits You
Use AI to generate personalized quizzes and flashcards to suit your learning preferences.