-
What is the output of this program?
class box_Shape
{
int width;
int height;
int length;
}
public class mainclass
{
public static void main(String args[])
{
box_Shape obj1 = new box_Shape();
box_Shape obj2 = new box_Shape();
obj1.height = 3;
obj1.length = 4;
obj1.width = 6;
obj2 = obj1;
System.out.println(obj2.height);
}
}
-
- 3
- 2
- 1
- Runtime error
- Garbage value
Correct Option: A
When we assign an object to another object of same type, all the elements of right side object gets copied to object on left side of equal to, =, operator.
output: 3