JAVA Constructors and Methods Which of the following options is the best for generating random integer 0 or 1? (int)(Math.random() + 0.2) (int)(Math.random() + 0.5) (int)Math.random() (int)Math.random() + 1 (int)(Math.random() + 0.2) (int)(Math.random() + 0.5) (int)Math.random() (int)Math.random() + 1 ANSWER DOWNLOAD EXAMIANS APP
JAVA Constructors and Methods 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 8 Compile fail due to error on line no 9 None of these Compile fail due to error on line no 2 15 Compile fail due to error on line no 8 Compile fail due to error on line no 9 None of these Compile fail due to error on line no 2 15 ANSWER DOWNLOAD EXAMIANS APP
JAVA Constructors and Methods What will be the return type of a method that not returns any value? double void None of these int double void None of these int ANSWER DOWNLOAD EXAMIANS APP
JAVA Constructors and Methods 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 5 B 8 None of these A B 8 B 8 A 5 A B 5 A 5 B 8 None of these A B 8 B 8 A 5 A B 5 ANSWER DOWNLOAD EXAMIANS APP
JAVA Constructors and Methods 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++; }} None of these 3 Compilation Error 2 1 None of these 3 Compilation Error 2 1 ANSWER DOWNLOAD EXAMIANS APP
JAVA Constructors and Methods The finalize() method is called just prior to Before garbage collection. None of these An object or variable goes out of scope. An object, variable or method goes out of scope. A variable goes out of scope. Before garbage collection. None of these An object or variable goes out of scope. An object, variable or method goes out of scope. A variable goes out of scope. ANSWER DOWNLOAD EXAMIANS APP