TheDeveloperBlog.com

Home | Contact Us

C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML

Difference between object and class

Difference between object and class in java, let's see the object vs class in java with examples, there is given a list of main differences between object and class.

<< Back to DIFFERENCE

Difference between object and class

There are many differences between object and class. A list of differences between object and class are given below:

No.ObjectClass
1)Object is an instance of a class.Class is a blueprint or template from which objects are created.
2)Object is a real world entity such as pen, laptop, mobile, bed, keyboard, mouse, chair etc.Class is a group of similar objects.
3)Object is a physical entity.Class is a logical entity.
4)Object is created through new keyword mainly e.g.
Student s1=new Student();
Class is declared using class keyword e.g.
class Student{}
5)Object is created many times as per requirement.Class is declared once.
6)Object allocates memory when it is created.Class doesn't allocated memory when it is created.
7)There are many ways to create object in java such as new keyword, newInstance() method, clone() method, factory method and deserialization.There is only one way to define class in java using class keyword.

Let's see some real life example of class and object in java to understand the difference well:

Class: Human Object: Man, Woman

Class: Fruit Object: Apple, Banana, Mango, Guava wtc.

Class: Mobile phone Object: iPhone, Samsung, Moto

Class: Food Object: Pizza, Burger, Samosa





Related Links:


Related Links

Adjectives Ado Ai Android Angular Antonyms Apache Articles Asp Autocad Automata Aws Azure Basic Binary Bitcoin Blockchain C Cassandra Change Coa Computer Control Cpp Create Creating C-Sharp Cyber Daa Data Dbms Deletion Devops Difference Discrete Es6 Ethical Examples Features Firebase Flutter Fs Git Go Hbase History Hive Hiveql How Html Idioms Insertion Installing Ios Java Joomla Js Kafka Kali Laravel Logical Machine Matlab Matrix Mongodb Mysql One Opencv Oracle Ordering Os Pandas Php Pig Pl Postgresql Powershell Prepositions Program Python React Ruby Scala Selecting Selenium Sentence Seo Sharepoint Software Spellings Spotting Spring Sql Sqlite Sqoop Svn Swift Synonyms Talend Testng Types Uml Unity Vbnet Verbal Webdriver What Wpf