Loading
-
589.
-
590.
-
591.
Consider the following class definitions in a hypothetical Object Oriented language that supports inheritance and uses dynamic binding. The language should not be assumed to be either Java or C++, though the syntax is similar.
Class P {
void f(int i) {
print(i);
}
}Class Q subclass of P {
void f(int i) {
print(2*i);
}
}
Px = new Q()
Qy = new Q();
Pz = new Q();
x.f(1); ((P)y).f(1); z.f(1);
Here ((P)y) denotes a typecast of y to P. The output produced by executing the above program fragment will be [2 marks]
(A) 1 2 1
(B) 2 1 1
(C) 2 1 2
(D) 2 2 2
asked in Computer Science And Engineering, 2003
View Comments [0 Reply]
-
592.
The following program fragment is written in a programming language that allows global variables and does not allow nested declarations of functions.
global int i = 100, j = 5;
void P(x) {
int i = 10;
print(x + 10);
i = 200;
j = 20;
print (x);
}
main() {P(i + j);}[1] If the programming language uses static scoping and call by need parameter passing mechanism, the values printed by the above program are [2 marks]
(A) 115, 220
(B) 25, 220
(C) 25, 15
(D) 115, 105[2] If the programming language uses dynamic scoping and call by name parameter passing mechanism, the values printed by the above program are [2 marks]
(A) 115, 220
(B) 25, 220
(C) 25, 15
(D) 115, 105asked in Computer Science And Engineering, 2003
View Comments [0 Reply]
-
593.
-
594.