Difference between Class and Interface





Class Interface
The keyword used to create a class is "class". The keyword used to create a interface is "interface".
A class can be instantiated i.e, objects of a class can be created. An Interface cannot be instantiated i.e, objects cannot be created.
Classes does not support multiple inheritance. Interface supports multiple inheritance.
It can be inherit another class. It cannot inherit a class.
It can be inherited by another class using the keyword ‘extends’. It can be inherited by a class by using the keyword ‘implements’ and it can be inherited by an interface using the keyword ‘extends’.
It cannot contain abstract methods. It contains abstract methods only.
Variables in a class can be static, final or neither. All variables are static and final.
It can contain constructors. It cannot contain constructors.
Variables and methods in a class can be declared using any access specifier(public, private, default, protected) All variables and methods in a interface are declared as public.
AJ Blogs

Hello everyone, My name Arth and I like to write about what I learn. Follow My Website - https://sites.google.com/view/aj-blogs/home

Post a Comment

Previous Post Next Post
Best Programming Books

Facebook

AJ Facebook
Checkout Our Facebook Page
AJ Blogs
Checkout Our Instagram Page