What is the output of following code snippet ?
public class TestOverriding { public static void main(String aga[]){ Test t =new Fest(); t.tests(); } } class Test{ void tests(){ System.out.println("Test class : tests"); } } class Fest extends Test{ static void tests(){ System.out.println("Fest class : tests"); } }
What will be the output the following method Java code
public class TestOverriding { public static void main(String aga[]){ Test t =new Fest(); t.tests(); } } class Test{ private void tests(){ System.out.println("Test class : tests"); } } class Fest extends Test{ public void tests(){ System.out.println("Fest class : fests"); } }
What is the output of the following code snippet ?
public class TestOverriding { public static void main(String aga[]){ Super superRef =new Sub(); Sub subRef = new Sub(); Super suRef=new Super(); superRef.tests(); subRef.tests(); suRef.tests(); } } class Super{ public static void tests(){ System.out.println("Super static"); } } class Sub extends Super{ public static void tests(){ System.out.println("Sub static"); } }
public class TestOverriding { public static void main(String aga[]){ Parrot bird=new Parrot(); bird.fly(); } } class Bird{ private void fly(){ System.out.println("Bird is flying"); } } class Parrot extends Bird{ public void doStuff(){ System.out.println("I am parrot , and I am doing stuff"); } }
whether the following will compile
import java.io.IOException class Animal { public void eat() throws IOException { } } class Dog extends Animal { public void eat() throws IOException { } }
Is the following code is a valid override ?
class MyClass { void add(int i, int ti) { // I will do later } } class MySubclass extends MyClass { public void add(int i, int ti) { // Will do now } }