Skip to main content

Difference between Class and Interface

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

RAW_BOY said…
nice way to explane
Abhishek said…
Thank you for your feedback

Popular posts from this blog

DBMS LEARNING SHEET

                                                            Types of DATA Structured data are facts concerning objects and events. The most important structured data are numeric, character, and dates. Structured data are stored in tabular form. Unstructured data are multimedia data such as documents, photographs, maps, images, sound, and video clips. Unstructured data are most commonly found on Web servers and Web-enabled databases. Database A database is a collection of data that is organised in such a way that it provides efficient retrieval of desired information. This collected data could be in any format like printed, audio, electronic and graphic. Consider an example of an address book, it is also a database that provides information of personal contacts of persons. DBMS A Database Mana...
Java Programming

Concept of OOPS

Java Programming This are the basic concept of OOPS. 1. Object 2. Class 3. Data abstraction 4. Data encapsulation 5. Inheritance 6. Polymorphism 7. Dynamic binding Java Classes/Objects Java is an object-oriented programming language. Everything in Java is associated with classes and objects, along with its attributes and methods. For example: in real life, a car is an object. The car has  attributes , such as weight and color, and  methods , such as drive and brake. A Class is like an object constructor, or a "blueprint" for creating objects. Create a Class To create a class, use the keyword  Myclass.java Create an Object In Java, an object is created from a class. We have already created the class named  MyClass , so now we can use this to create objects. To create an object of  MyClass , specify the class name, followed by the object name, and use the keyword  new : Example=> public class Myclass{ int x=10;...