JAVA Inheritence The concept of multiple inheritance is implemented in Java byI. Extending two or more classes.II. Extending one class and implementing one or more interfaces.III. Implementing two or more interfaces. (II) and (III) Only (I) (I) and (II) Only (III) Only (II) (II) and (III) Only (I) (I) and (II) Only (III) Only (II) ANSWER DOWNLOAD EXAMIANS APP
JAVA Inheritence Determine output:class A{public void method1(){System.out.print("Class A method1");}}class B extends A{public void method2(){System.out.print("Class B method2");}}class C extends B{public void method2(){System.out.print("Class C method2");}public void method3(){System.out.print("Class C method3");}}public class Test{public static void main(String args[]){A a = new A();C c = new C();c.method2();a = c;a.method3();}} Class B method2 Class C method3 Class C method2 Class C method3 Compilation Error Runtime exception None of these Class B method2 Class C method3 Class C method2 Class C method3 Compilation Error Runtime exception None of these ANSWER DOWNLOAD EXAMIANS APP
JAVA Inheritence What will be the result of compiling and executing the following program code?class Vehicle{ public void printSound(){ System.out.print("vehicle"); }}class Car extends Vehicle{ public void printSound(){ System.out.print("car"); }}class Bike extends Vehicle{ public void printSound(){ System.out.print("bike"); }}public class Test{ public static void main(String[] args){ Vehicle v = new Car(); Bike b = (Bike) v; v.printSound(); b.printSound(); }} "vehiclecar" is printed. "vehiclebike" is printed. Compilation fails. "carcar" is printed. ClassCastException exception is thrown at runtime. "vehiclecar" is printed. "vehiclebike" is printed. Compilation fails. "carcar" is printed. ClassCastException exception is thrown at runtime. ANSWER DOWNLOAD EXAMIANS APP
JAVA Inheritence What will be the output?class One{ final int a = 15;}class Two extends One{ final int a = 20;}public class Test extends Two{ final int a = 30; public static void main(String args[]){ Test t = new One(); System.out.print(t.a); }} None of these Compiler Error 15 30 20 None of these Compiler Error 15 30 20 ANSWER DOWNLOAD EXAMIANS APP
JAVA Inheritence What is the result of compiling and running the following code?class Base{ public Base(){ System.out.print("Base"); }}public class Derived extends Base{ public Derived(){ this("Examveda"); System.out.print("Derived"); } public Derived(String s){ System.out.print(s); } public static void main(String[] args){ new Derived(); }} Compilation Error ExamiansDerived BaseExamiansDerived ExamiansDerivedBase ExamiansBaseDerived Compilation Error ExamiansDerived BaseExamiansDerived ExamiansDerivedBase ExamiansBaseDerived ANSWER DOWNLOAD EXAMIANS APP
JAVA Inheritence Which of the following is true?1. A class can extend more than one class.2. A class can extend only one class but many interfaces.3. An interface can extend many interfaces.4. An interface can implement many interfaces.5. A class can extend one class and implement many interfaces. 3 and 5 1 and 2 2 and 4 3 and 4 2 and 5 3 and 5 1 and 2 2 and 4 3 and 4 2 and 5 ANSWER DOWNLOAD EXAMIANS APP