You are on page 1of 16

Introducing Classes

(Chapter 6 of Schilit)
Object Oriented Programming BS (CS/SE) II
By
Dr. Sher Muhammad Dadupota
Class Fundamentals
• Relation between class and object
• Template and instance
General Form of class
A Simple Class — Code
• Box with only data
A Simple Class — Code
• Two Objects of Box
Declaring Objects
Object Reference Variables and use of null
Introducing Methods
Adding a method to Box
Returning value from method
• Automatic Type Promotion
Method Parameters
Constructors
Parameterized Constructor
Keyword this and variable hiding
A word on Garbage Collection
Code: Stack Class

You might also like