Java Programming
*Difference between Class and Interface
Class
1. The members of a class can be constant or variables.
2. The class definition can contain code for each of its methods. That is, the methods can be abstract or non-abstract.
3. It can be instantiated by declaring objects.
4. It can use various access specifier like public,private or protected.
Interface
1. The members of an interface are always declared as constant, i.e. their values are final.
2. The methods in an interface are abstract in nature, i.e., there is no code associated with them. It is later defined by the class that implements the interface.
3. It cannot be used to declare objects. It can only be inherited by a class.
4. It can only use the public access specifier.
Comments