Somu
September 28th, 1999, 06:11 AM
Hi.....
I have a question & its answer but i am confuse about it.
If any one clear about thsi question explain me.
Question is
class class1{}
class class2 extends class1{}
class class3 extends class3{}
When is the following method valid?
public class1 castMe(class3 ref){
return (class1)ref;
}
A. Always
B. Never
C. If and only if ref references an class3 object
D. If and only if ref references an class2 object
Answer : A
I have a question & its answer but i am confuse about it.
If any one clear about thsi question explain me.
Question is
class class1{}
class class2 extends class1{}
class class3 extends class3{}
When is the following method valid?
public class1 castMe(class3 ref){
return (class1)ref;
}
A. Always
B. Never
C. If and only if ref references an class3 object
D. If and only if ref references an class2 object
Answer : A