JAVA Constructors and Methods The implicit return type of a constructor is There is no return type. A class object in which it is defined. void None of these There is no return type. A class object in which it is defined. void None of these ANSWER DOWNLOAD EXAMIANS APP
JAVA Constructors and Methods class MyClass{int i;int j;public MyClass(int i, int j){this.i = i;this.j = j;}public void call(){System.out.print("One");}}public class Test{public static void main(String args[]){MyClass m = new MyClass(); //line 1m.call(); //line 2}} Compilation fails due to an error on line 2 Compilation succeed but no output. One Compilation fails due to an error on line 1 Compilation fails due to an error on line 2 Compilation succeed but no output. One Compilation fails due to an error on line 1 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++; }} 2 1 Compilation Error 3 None of these 2 1 Compilation Error 3 None of these ANSWER DOWNLOAD EXAMIANS APP
JAVA Constructors and Methods public class MyClass{ }For the above class(MyClass) what is the correct way of declaring constructor? public MyClass(void){} 1 and 3 public MyClass(){} MyClass(void) {} MyClass(){} public MyClass(void){} 1 and 3 public MyClass(){} MyClass(void) {} MyClass(){} ANSWER DOWNLOAD EXAMIANS APP
JAVA Constructors and Methods The following code contains one compilation error, find it?public class Test {Test() { } // line 1static void Test() { this(); } // line 2 public static void main(String[] args) { // line 3Test(); // line 4}} At line 2, constructor call At line 1, constructor Tester must be marked public like its class At line 3, compilation error, ambiguity problem, compiler can't determine whether a constructor At line 4 At line 2, constructor call At line 1, constructor Tester must be marked public like its class At line 3, compilation error, ambiguity problem, compiler can't determine whether a constructor At line 4 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 9 None of these Compile fail due to error on line no 8 Compile fail due to error on line no 2 15 Compile fail due to error on line no 9 None of these Compile fail due to error on line no 8 Compile fail due to error on line no 2 15 ANSWER DOWNLOAD EXAMIANS APP