Q. 22 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++, thought the syntax is similar
that supports inheritance and uses dynamic binding. The language should not be
assumed to be either Java or C++, thought the syntax is similar
Now consider the following program fragment:
P x =new Q(); Q y =new Q(); P z =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
above program fragment will be
(A) 1 2 1
(B) 2 1 1
(C) 2 1 2
(D) 2 2 2