How is class different from an interface?
Classes and interfaces are two different concepts which can be understood by the following points :
- By creating an object a class can be instantiated but the interface cannot be instantiated because all the methods in the interface do not perform any actions and are abstract that is why instantiation is not done in the case of interfaces.
- A class keyword is used to declare a class whereas an interface keyword is used to declare an interface.
- A constructor is defined inside the class to declare the fields inside the class whereas no constructor is defined inside the interface as the fields inside it cannot be initialized.
BY Best Interview Question ON 22 Oct 2019