English

How does an Object differ from a Class?

Advertisements

Question

How does an Object differ from a Class?

Distinguish Between
Advertisements

Solution

Object

Class

1. An object is an instance of a class that represents a real-world entity.

1. A class is a blueprint or template that is used to create objects.

2. An object is a physical entity that exists in memory during program execution.

2. A class is a logical entity that defines the structure and behaviour of objects.

3. An object occupies memory when it is created during the execution of a program.

3. A class definition does not allocate memory for the instance variables of its objects.

4. An object contains data members that represent its state and uses methods to perform specific operations.

4. A class defines the data members and methods that are shared in structure by its objects.

5. An object is created from a class, generally by using the new keyword in Java.

5. A class is declared by using the class keyword followed by the name of the class.

6. Multiple objects can be created from a single class, and each object can have its own data values.

6. A single class can be used to create multiple objects having similar properties and behaviours.

7. Example: Car c = new Car(); is a statement that creates an object of the Car class.

7. Example: class Car { } is a declaration that defines a class named Car.

shaalaa.com
  Is there an error in this question or solution?
Chapter 4: Objects - EXERCISE [Page 106]

APPEARS IN

Dheeraj Mehrotra Computer Science [English] Class 12
Chapter 4 Objects
EXERCISE | Q 1. (ii) | Page 106
Advertisements
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×