+ 2
What is the use of interface concept in oops ,what are the differences among interface,inheritance and abstract class in Java ?
2 ответов
+ 1
did you read the section "more about classes"?
in Java, abstraction is achieved using abstract classes and interfaces.
An abstract class is defined using the abstract keyword.
- If a class is declared abstract it cannot be instantiated (you cannot create objects of that type).
- To use an abstract class, you have to inherit it from another class.
- Any class that contains an abstract method should be defined as abstract.
interface is a completely abstract class that contains only abstract methods.
Some specifications for interfaces:
- Defined using the interface keyword.
- May contain only static final variables.
- Cannot contain a constructor because interfaces cannot be instantiated.
- Interfaces can extend other interfaces.
- A class can implement any number of interfaces.
you can extend a abstract class, and you have to implement an interface.
-- copied text from sololearn course
+ 1
Thank you @Gunther Strauss