Lect 6 - Closer Look To Classes and Method
Lect 6 - Closer Look To Classes and Method
(Chapter 7 of Schilit)
Object Oriented Programming BS (CS/SE) II
By
Dr. Sher Muhammad Dadupota
Overloading Methods
• Concept
• Type or number of argument determine the method to be called
• Return type alone is not sufficient
Overloading Methods
• Type promotion in overloading
• Example of abs() method
Overloading Constructors
Using Object as Parameters
A closer look at Argument passing
• Pass by value
• Pass by reference
Returning objects from a method as return
type
Recursion
• The factorial example
Access Controls in Java
• public
• private
• protected
• default
• Stack example
Understanding static member variables
• static member variable of class
• Associated with class
• One copy for all objects
• Example
Understanding static member methods
• Can only call other static methods
• Can access only static member variables of class
• Can be called on class name as well as object reference
• Can’t refer this and super keywords
• Example
Understanding static code block
• Gets executed exactly once