16
Loading subject content…
Loading subject content…
Loading practice questions…
What is the output of the following program?
class A { static String s() { return "A"; } }
class B extends A { static String s() { return "B"; } }
class Main {
public static void main(String[] args) {
A obj = new B();
System.out.println(obj.s());
}
}What is the output of the following program?
public class Main {
public static void main(String[] args) {
System.out.println(new B().info());
}
}
class A { String info() { return "A"; } }
class B extends A { String info() { return super.info() + "B"; } }What is the output of the following program?
class A { String hi() { return "A"; } }
class B extends A { String hi() { return super.hi() + "B"; } }
class Main { public static void main(String[] args) { System.out.println(new B().hi()); } }What is the output of the following program?
public class Main {
public static void main(String[] args) {
A a = new B();
System.out.println(a.x);
}
}
class A { int x = 1; }
class B extends A { int x = 2; }