5.1 Oop
5.1 Oop
of
Objects & Classes
By Upekha Vandebona
A class is a blueprint
for an object. It tells
the virtual machine
how to make an object
of that particular type.
Designing Classes
Instance variables represent an object’s state and can have
unique values for each object of that type.
Exercise
Television
Class Vs Objects
Creating Objects
Class is a template for an
object, and an object is an
instance of a class.
Think of instance as another
way of saying object.
Because an object is an
instance of a class, you will
often see the two words,
object and instance, used
interchangeably.
Exercise
Exercise
new
allocates
memory
for an
object
during run
Assigning object reference
variables
When you assign
one object
Box b1 = new Box();
reference variable Box b2 = b1;
to another object’s
reference variable,
you are not
creating a copy of
the object, you are
only making a
copy of the
reference.
Thank You!