Given below the sample code :
class SuperClass {
String s = "Outer";
public static void main(String[] args) {
M2 m2 = new M2();
m2.display();
}
}
class M1 {
String s = "M1";
void display() {
System.out.println(s);
}
}
class M2 extends M1 {
String s = "M2";
}
What will be the output of the following code ?
1. Compile error
2. M1
3 M2
4. M1 M2.
(2)
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.