Sessions-7 Call by ValueReference
Sessions-7 Call by ValueReference
Sessions-7 Call by ValueReference
sessions-7
Call Class
by value,and
call by reference
Object
Introduction to call by value
SESSION
All data types can be passed 5
Array can also be passed
Class and Object
An object of a class can also be passed (call by reference)
1. Calling statement
SESSION 5
2. Called function
3. Return types
Class and Object
4. Parameters
A) actual parameters
B) formal parameters
model programs
SESSION 5
What is a reference
SESSION 5
Eg: Box b1=new Box(10,20,30);
Box b2;
Class and Object
b2=b1
This means,
All the data and methods of b1 are now shared with b2
Let us see call by reference
This is similar to call by value, in the place of
ordinary variable we use object reference.
SESSION 5
Eg. Box b1= new Box(10,20,30)
Class
Calling statement: andb1)
volume( Object
Called method:
Void volume( Box b2){
System.out.println( b2.w*b2.h*.b2.);
}
Exercise programs