class A{ A(String s){} A(){}}1. class B extends A{2. B(){}3. B(String s){4. super(s);5. }6. void test(){7. // insert code here8. }9. }Which of the below code can be insert at line 7 to make clean compilation ? A a = new B(); None of these A a = new B(5); All of these A a = new A(String s); TRUE ANSWER : ? YOUR ANSWER : ?
Determine output of the following program.public class Test{ public static void main(String args[]){ System.out.println( Math.floor( Math.random( ) ) ) ; }} 10.0 0.0 1.0 0.5 TRUE ANSWER : ? YOUR ANSWER : ?
The finalize() method is called just prior to An object, variable or method goes out of scope. A variable goes out of scope. None of these Before garbage collection. An object or variable goes out of scope. TRUE ANSWER : ? YOUR ANSWER : ?
Given the following piece of code:class Person{ public int number;}public class Test{ public void doIt(int i , Person p){ i = 5; p.number = 8; } public static void main(String args[]){ int x = 0; Person p = new Person(); new Test().doIt(x, p); System.out.println(x + " " + p.number); }}What is the result? 5 0 0 0 5 8 0 8 TRUE ANSWER : ? YOUR ANSWER : ?
Which of these is a legal definition of a method named examveda assuming it throws IOException, and returns void. Also assume that the method does not take any arguments. Select the one correct answer. void examians() throws IOException{} void examians(void) throws IOException{} void examians() throw IOException{} void examians() {} throws IOException examians() throws IOException{} TRUE ANSWER : ? YOUR ANSWER : ?
What will be the result of compiling and running the given code?class A{ int b=10; private A(){ this.b=7; } int f(){ return b; }}class B extends A{ int b;}public class Test{ public static void main(String[] args){ A a = new B(); System.out.println(a.f()); }} Compilation Fails None of these Prints 0 Prints 10 Prints 7 TRUE ANSWER : ? YOUR ANSWER : ?
What is the output for the below code ?class A{ public A(){ System.out.println("A"); } public A(int i){ this(); System.out.println(i); }}class B extends A{ public B(){ System.out.println("B"); } public B(int i){ this(); System.out.println(i+3); }}public class Test{ public static void main (String[] args){ new B(5); }} A B 5 None of these A B 8 A 5 B 8 B 8 A 5 TRUE ANSWER : ? YOUR ANSWER : ?
The main method should be static for the reason It can be accessed by every method or variable without any hindrance. It can be executed without creating any instance of the class. None of these It can be accessed easily by the class loader. TRUE ANSWER : ? YOUR ANSWER : ?
What will be the return type of a method that not returns any value? None of these int void double TRUE ANSWER : ? YOUR ANSWER : ?
What is the output of the above program ?class Num { Num(double x ){ System.out.println( x ) ; } }public class Test extends Num { public static void main(String[] args){ Num num = new Num( 2 ) ; } } Compile time error 2.0 0 None of these TRUE ANSWER : ? YOUR ANSWER : ?