मराठी

How does an Object differ from a Class?

Advertisements

प्रश्न

How does an Object differ from a Class?

फरक स्पष्ट करा
Advertisements

उत्तर

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
  या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
पाठ 4: Objects - EXERCISE [पृष्ठ १०६]

APPEARS IN

धीरज मेहरोत्रा Computer Science [English] Class 12
पाठ 4 Objects
EXERCISE | Q 1. (ii) | पृष्ठ १०६
Advertisements
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×