UBT University of Business and Techno ege of Engineering omputer Programming-2 Q
ID: 3868301 • Letter: U
Question
Explanation / Answer
1) It will print
0
100
200
400
500
600
and the table is as below
2)
a) Here it is calling getArea function with s1 object which will call non parameterized constructor and that constructor is setting dimension = 5 so getArea will return dimension*dimension which will be 5*5 and as its double value so 25.00 will be printed.
b) Here it is calling getArea function with s2 object which will call parameterized constructor of class square and assign dimension value which is passed to this constructor that is dimension = 10 so now getArea will return 10*10 i.e. 100.00
c) Here it is first calling setDimension function on object s2 which will now set the value of dimension to 15 hence getArea will return 15*15 i.e. 225.00
i i<10 i++ if(i==3) print(i*100 +", ") if(i==6) 0 T 1 F 0*100 = 0 F 1 T 2 F 1*100 = 100 F 2 T 3 F 2*100 = 200 F 3 T 4 T (continue and no further line in loop of this iteration will execute and loop will continue for next iteration) 4 T 5 F 4*100=400 F 5 T 6 F 5*100=500 F 6 T 7 F 6*100= 600 T(break from loop and no further iteration will execute)Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.