What is the output of the following program?
public class Main { String s = "Outer"; public static void main(String[] args) { S2 s2 = new S2(); s2.display();//from ww w . j a v a 2 s . c o m } } class S1 { String s = "S1"; void display() { System.out.println(s); } } class S2 extends S1 { String s = "S2"; }
A
The display()
method displays the s variable of the S1 class.