What is the use of interface concept in oops ,what are the differences among interface,inheritance and abstract class in Java ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

What is the use of interface concept in oops ,what are the differences among interface,inheritance and abstract class in Java ?

25th Aug 2017, 6:18 PM
Sowmya Reddy
Sowmya Reddy - avatar
2 Answers
+ 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
25th Aug 2017, 7:07 PM
Gunther Strauss
Gunther Strauss - avatar
+ 1
Thank you @Gunther Strauss
1st Sep 2017, 1:34 PM
Sowmya Reddy
Sowmya Reddy - avatar