0% found this document useful (0 votes)
14 views15 pages

5.1 Oop

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views15 pages

5.1 Oop

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 15

Elementary Concepts

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

Create a Box class.


depth
Compute and output
height the volume of the box
in main() method.

width Create another box


and do the same.
Box mybox; // declare reference to object
mybox = new Box(); // allocate a Box object

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!

You might also like