JAVA CLASSESS
Write the output of the following statement :
class Rectangle{
int length,width,length1;
void insert(int l,int w){
length=1;
width=w;
}
void insert(int 1){
length1=1;
}
void display1()
{
System.out.println(width);
}
void display2()
{
System.out.println(length);
}
void calculateArea()
{
System.out.println(length*width);
} void calculateArea3()
{
System.out.println(length1);
}
void calculateArea2()
{
System.out.println(length width 2);
}
}
class Test Rectangle2{ public static void main(String args[]){
Rectangle r1-new Rectangle();
Rectangle r2-new Rectangle(); Rectangle r3-new Rectangle();
r1.insert(10,5); r2.insert(3,5);
r3.insert(2);
r1.display1();
r1.display2();
r1.calculateArea();
r2.calculateArea2();
r2.display1();
r2.display2();
r2.calculateArea();
r2.calculateArea2();
r3.calculateArea3();
r3.display1();
}
}
31-34 Answer the ff.
a.) 5 b.) 10 c.) 30 d.) 50
31. What is the output of line 40?
32. What is the output of line 41?
33. What is the output of line 42?
34. What is the output of line 43?
35-38 Answer the ff.
a.) 3 b.) 5 c.)15 d.) 30
35. What is the output of line 44?
36. What is the output of line 45?
37. What is the output of line 46?
38. What is the output of line 47?
39-40 Answer the ff.
a.) 0 b.) 2 c.)3 d.) 5
39. What is the output of line 48?
40. What is the output of line 49?
Extracted text: Line, 32 class Test Rectangle2{ public static void main (String args[]){ Rectangle r1=new Rectangle(); Rectangle r2=new Rectangle(); Rectangle r3-new Rectangle(); r1.insert(10,5); r2.insert(3,5); r3.insert(2); r1.display1(); r1.display2(%3; r1.calculateArea(); r2.calculateArea2()3; 33 34 35 36 37 38 39 40 41 42 43 44 r2.display1(); r2.display2(); r2.calculateArea(); r2.calculateArea2(); r3.calculateArea3(); 45 46 47 48 r3.display1()3; 50 } 51 } 49 31. What is the output of line 40? a) 5 b) 10 c) 30 d) 50 32. What is the output of line 41? a) 5 b) 10 c) 30 d) 50 33. What is the output of line 42? a) 5 34. What is the output of line 43? a) 5 35. What is the output of line 44? a) 3 b) 5 c) 15 d) 30 36. What is the output of line 45? a) 3 b) 5 c) 15 d) 30 37. What is the output of line 46? a) 3 b) 5 c) 15 d) 30 38. What is the output of line 47? a) 3 b) 5 c) 15 d) 30 39. What is the output of line 48? a) 0 b) 2 c) 3 d) 5 40. What is the output of line 49? a) 0 b) 2 c) 3 d) 5 b) 10 c) 30 d) 50 b) 10 c) 30 d) 50
Extracted text: TEST II. PROGRAM TRACING Line class Rectangle{ int length,width,length%3B void insert(int I,int w){ length=l3B width=Dw3; } void insert(int I){ length1=l; } void display1() { System.out.println(width)3; 2. 4 6. 9. 10 11 12 13 14 void display2() 15 { System.out.printIn(length)3B } void calculateArea() 16 17 18 19 20 System.out.printIn(length*width)3B 21 22 23 void calculateArea3() 24 { System.out.printIn(length1); 26 25 27 void calculateArea2() 28 { 29 System.out.println(length*width*2); 30 } 31