Q10
What is the output of the following program ?
class Question
{
String s="Outer";
public static void main(String args[])
{
S2 s2 = new S2();
s2.display();
}
}
class S1
{
String s="s1";
void display()
{
System.out.println(s);
}
}
class S2 extends S1
{
String s="s2";
}
(a)S1
(b)S2
(c)null
(d)S1S2
The answer mentioned is (a),but should'nt it be (b) because we are using an object of class S2 to invoke a method which it has inherited.Pls give ur opinion.