Lesson 2
Lesson 2
new keyword- is used to allocate space in the dynamic memory for the
storage of data and functions belonging to an object
Instance means member
What is instantiation?
The process by which a class blueprint is used to create a specific object
with its own distinct set of attributes and behaviors
// Define the class
public class Student
{
// Attributes /data members/characteristics(properties)
int age;
int rollno;
string name;
//methods
Attend class();
Write exam();
• Class car
//attributes/data members are
Make;
Model;
Color;
//method
Start
Accelerate
Stop
For different car data members will be different but method will be same.
• Object is the real thing you create using the blueprint. It follows the
description and instructions from the class.
Objects classified into two
Real world objects
Software objects
Real world objects are physical objects that exists in the world around us.
You can touch ,have a physical presence , see,or interact with them directly.
It exists independently of computers or software
Eg: car
Whereas software objects are the virtual versions of real world objects
created inside a computer program .
they don’t have physical presence they exist inside the computers memory
Or it represent things or ideas that the program needs to work with.
Eg mycar1,mycar2
Message passing
• It is the mechanism through which objects invoke methods on each
other to request action or retrieve information.
• Think of objects in a program like characters in a story
• They talk to each other by calling each others names(objects)and
asking for things or telling each other what to do