The difference between Classes Objects and Instances

0 votes
As the title says, what is the difference among them in Java?
Jun 6, 2022 in Java by rajiv
• 1,620 points
6,710 views

1 answer to this question.

0 votes

A class is a type of blueprint that you can use to make objects. A concrete 'thing' that you constructed using a certain class is an object, which is an instance of a class. So, while the terms 'object' and 'instance' are interchangeable, the term 'instance' refers to an object's relationship to its class.

If you look at an example, you'll see what I mean. Let's say you have a class called House. This is an object that belongs to the House class. Another object is your sister's residence (another instance of class House).

// Class House describes what a house is
class House {
    // ...
}

// You can use class House to create objects (instances of class House)
House myHouse = new House();
House sistersresidence = new House();

The class House defines what a house is, and there are specific, concrete houses that are objects and instances of this class.

answered Jun 7, 2022 by pranav
• 2,590 points

Related Questions In Java

0 votes
2 answers

What is the difference between implements and extends?

Extends : This is used to get attributes ...READ MORE

answered Aug 3, 2018 in Java by samarth295
• 2,220 points
15,153 views
0 votes
1 answer

What is the difference between jdk and jre?

JRE: It stands for Java Runtime Environment. ...READ MORE

answered Apr 20, 2018 in Java by Akrati
• 3,190 points
1,638 views
0 votes
2 answers

What is the difference between = and equals()?

The equals() method compares the "value" inside String instances ...READ MORE

answered Aug 13, 2018 in Java by Daisy
• 8,120 points
1,068 views
0 votes
2 answers

What is the difference between Set and List in java?

List is an ordered sequence of elements. ...READ MORE

answered Apr 26, 2018 in Java by Akrati
• 3,190 points
62,638 views
0 votes
1 answer

What is the difference between Runnable and extends Thread

Runnable is the preferred way to create ...READ MORE

answered May 1, 2018 in Java by sharth
• 3,370 points
893 views
0 votes
1 answer

How to calculate the difference between two date instances in Java?

You can use Joda Time Library. Interval i ...READ MORE

answered May 4, 2018 in Java by Parth
• 4,630 points
750 views
0 votes
1 answer

C++ "Object" class

No, there is no generic base class&nb ...READ MORE

answered Jun 2, 2022 in C++ by Damon
• 4,960 points
289 views
0 votes
1 answer

Python class inherits object

Python 3.x: class MyClass(object): = new-style class class MyClass: = new-style ...READ MORE

answered Aug 30, 2018 in Python by Priyaj
• 58,090 points
577 views
0 votes
1 answer

How can we compare objects by multiple fields in Java?

You can implement a Comparator which compares two Person objects, and ...READ MORE

answered Jan 9, 2019 in Java by Daisy
• 8,120 points
3,594 views
0 votes
1 answer

Should a class file always be inside package for importing it in jsp page?

Hey there! It is not necessary for the ...READ MORE

answered May 24, 2019 in Java by Karan
1,933 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP