-1

First of all! Iam new to programming, In a blog i saw this two definitions . but iam confused . It says

Class is a instance of an object

and another says

Class is a collection of objecs

Which definition is correct? How? If both definitions are true? How? Thank you

Muhammed Anas U
  • 305
  • 1
  • 4
  • 15

3 Answers3

5

Generally speaking, a class is the mold with which you can create an objet. With one class, you create many objects of the same type.

An object is thus an instance of a class (but not the other way around).

Hope it helps

MusicAndCode
  • 870
  • 8
  • 22
1

An object is an instance of a class. An object can be instantiated in other classes. A class is definitely not a collection of objects. However, other objects can be created or instantiated inside of a class.

Lupus Nox
  • 138
  • 8
0

A class is a blueprint to build a specific type of object. Every object is built from a class.

An instance is a specific object built from a specific class. It is assigned to a reference variable that is used to access the instance's properties and methods. The process of making a new instance is called instantiation and is typically done using the new keyword.

A collection of objects is just that, a collection. There are many data structures designed to hold a collection of object, such as arrays, lists, etc.