why does java have both abstract class as well as interface? what is the need or importance of having both?
They both have some unique features.
An interface is used in situations when a class needs to extend an other class apart from the abstract class. In such situations it is not possible to have multiple inheritance of classes. An interface on the other hand can be used when it is required to implement one or more interfaces. Abstract class does not support Multiple Inheritance whereas an Interface supports multiple Inheritance.
Abstract classes are used when you do intend to create a concrete class, but want to make sure that there is some common state in all the subclasses or a possible common implementation for some operations. Interfaces cannot contain either.
we use interface in case of multiple inheritance. if an interface contains 100 methods and we want to implements its only two or three methods at that time we make an abstract class and implements that interface in that class and we are able to use only required methods or our needs