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 A(String s); All of these None of these A a = new B(); A a = new B(5); TRUE ANSWER : ? YOUR ANSWER : ?
Which of the following options is the best for generating random integer 0 or 1? (int)(Math.random() + 0.5) (int)Math.random() + 1 (int)Math.random() (int)(Math.random() + 0.2) TRUE ANSWER : ? YOUR ANSWER : ?
Determine output:public class Test{ public static void main(String args[]){ MyClass obj = new MyClass(); obj.val = 1; obj.call(obj); System.out.println(obj.val); }}class MyClass{ public int val; public void call(MyClass ref){ ref.val++; }} Compilation Error 1 None of these 2 3 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()); }} Prints 7 Prints 0 Compilation Fails None of these Prints 10 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 examians() throws IOException{} void examians() throw IOException{} void examians(void) throws IOException{} void examians() throws IOException{} 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 ) ; } } 2.0 None of these Compile time error 0 TRUE ANSWER : ? YOUR ANSWER : ?
public class Test { }What is the prototype of the default constructor? public Test(void) Test(void) Test( ) public Test( ) None of these TRUE ANSWER : ? YOUR ANSWER : ?
What is the output for the below code ?1. public class A{2. int add(int i, int j){3. return i+j;4. }5. }6. public class B extends A{7. public static void main(String argv[]){8. short s = 9;9. System.out.println(add(s,6));10. }11.} Compile fail due to error on line no 2 None of these Compile fail due to error on line no 9 Compile fail due to error on line no 8 15 TRUE ANSWER : ? YOUR ANSWER : ?
In which area of memory, the system stores parameters and local variables whenever a method is invoked? Heap Array Stack Storage Area TRUE ANSWER : ? YOUR ANSWER : ?
The main method should be static for the reason It can be executed without creating any instance of the class. It can be accessed easily by the class loader. It can be accessed by every method or variable without any hindrance. None of these TRUE ANSWER : ? YOUR ANSWER : ?