One of the most important and frequently asked OO interview questions. Not many people can answer this question succinctly and correctly with real-world examples.
An abstract class is a class that is only partially implemented by the programmer. It may contain one or more abstract methods. An abstract method is simply a function definition that serves to tell the programmer that the method must be implemented in a child class.
Whereas an interface is similar to an abstract class so it is a fully abstract class; none of its methods are implemented and instead of a class sub-classing from it, it is said to implement that interface.
none of its methods are implemented
Note that Java 8 Introduces Default method implementation to Interface, which means a method could have default implementation after Java 8.
See this for an example: https://www.tutorialspoint.com/java8/java8_default_methods.htm
I think it is important to say that interface s contract, meaning all declared methods must be implemented by the class which extends it.
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.