JAVA Constructors and Methods 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 ? All of these A a = new B(5); None of these A a = new A(String s); A a = new B(); All of these A a = new B(5); None of these A a = new A(String s); A a = new B(); ANSWER DOWNLOAD EXAMIANS APP
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() (int)(Math.random() + 0.5) (int)Math.random() + 1 (int)(Math.random() + 0.2) (int)Math.random() (int)(Math.random() + 0.5) (int)Math.random() + 1 ANSWER DOWNLOAD EXAMIANS APP
JAVA Constructors and Methods 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(void) throws IOException{} void examians() throws IOException{} examians() throws IOException{} void examians() {} throws IOException void examians() throw IOException{} void examians(void) throws IOException{} void examians() throws IOException{} examians() throws IOException{} void examians() {} throws IOException void examians() throw IOException{} ANSWER DOWNLOAD EXAMIANS APP
JAVA Constructors and Methods 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? 0 0 0 8 5 8 5 0 0 0 0 8 5 8 5 0 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++; }} Compilation Error 2 3 1 None of these Compilation Error 2 3 1 None of these ANSWER DOWNLOAD EXAMIANS APP
JAVA Constructors and Methods Determine Output:class A{public static void method(int i){System.out.print("Method 1");}public static int method(String str){System.out.print("Method 2");return 0;}}public class Test{ public static void main(String args[]){A.method(5);}} Method 2 None of these Compile time error as final method can't be overloaded Method 1 Method 2 None of these Compile time error as final method can't be overloaded Method 1 ANSWER DOWNLOAD EXAMIANS APP