Java Programming Questions & Answers: part8



Software Programming : Java Programming QUESTIONS AND ANSWERS :: part8 : 11 to 15

Following Software Programming language Entrance Multiple choice objective type questions and answers will help you in Software Programming 2024 examinations :

11.Which of the following language is Architecture-Neutral?

Java
C++
C
Ada
Pascal.

12.Given the following definitions and reference declarations, which one of the following assignments is legal? //Definitions: interface I1{} interface I2{} class C1 implements I1 {} class C2 implements I2 {} class C3 extends C1 implements I2 {} //Reference declarations: //. . . . C1 obj1; C2 obj2; C3 obj3; //. . . .

obj2 = obj1;
obj3 = obj1;
obj3 = obj2;
I1 a = obj2;
I1 b = obj3;

13.Which of the following statements is true? #110. Which of the following statements is true?

The subclass of a non-abstract class can be declared abstract
All the members of the superclass are inherited by the subclass
A final class can be abstract
A class in which all the members are declared private, cannot be declared public
In Java the extends clause is used to specify interface.

14.What will be the result of attempting to compile and run the following program? public class Polymorphism { public static void main(String[] args) { A ref1 = new C(); B ref2 = (B) ref1; System.out.println(ref2.f()); } } class A { int f() { return 0; } } class B extends A { int f() { return 1; } } class C extends B { int f() { return 2; } }

The program will fail to compile
The program will compile without error, but will throw a ClassCastException when run
The program will compile without error and print 0 when run
The program will compile without error and print 1 when run
The program will compile without error and print 2 when run.

More Java Programming QUESTIONS AND ANSWERS available in next pages

    Health is the greatest gift, contentment is the greatest wealth -Buddha
The only place where success comes before work is in the dictionary.- Vidal Sassoon