Java OOPs Program Test-4

What will be the output of the following java code?

class Hello {

public void check() {

System.out.println("Hello");

}

}

public class Test extends Hello {

public void check() {

System.out.println("Test");

}

public static void main(String[] args) {

Hello h=((Hello) new Test());

h.check();

}

}

What will be the output of the following java code?

class Hello {

public void check() throws Exception {

throw new Exception();

}

}

class Test extends Hello {

public void check() { System.out.println("Test");}

}

public static void main(String[] args) {

new Test().check();

}

}

What will be the output of the following java code?

class Hello {

public final void check() {

System.out.println("Hello");

}

}

public class Test extends Hello {

public void check() {

System.out.println("Test");

super.check();

}

public static void main(String[] args) {

new Test().check();

}

}

What will be the output of the following java code?

public class Test extends String {

Test() {

super();

}

}

What will be the output of the following java code?

class Hello {

int check(int a, int b) {

if (b > a) {

return a;

} else {

return b;

}

}

}

class Demo extends Hello {

int check(int a, int b) {

return 2 * super.check(a, b);

}

}

class Data extends Demo {

int max(int a, int b) {

return super.check(2 * a, 2 * b);

}

}

public class Test {

public static void main(String args[]) {

Demo c = new Data();

System.out.println(c.check(50, 40));

}

}