Question: class Box { int width, height; Box ( int w , int h ) { width = w; height = h; } } public class

class Box { int width, height; Box(int w, int h){ width = w; height = h; }} public class Test { public static void main(String[] args){ Box box1= new Box(10,20); Box box2= box1; box2.width =30; System.out.println("Width of box1: "+ box1.width); }}
Question 18 options:
Runtime error
Width of box1: 30
Compile-time error
Width of box1: 10

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!