JAVA Constructors and Methods The implicit return type of a constructor is There is no return type. None of these void A class object in which it is defined. There is no return type. None of these void A class object in which it is defined. 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 1 Compilation succeed but no output. One Compilation fails due to an error on line 2 Compilation fails due to an error on line 1 Compilation succeed but no output. One Compilation fails due to an error on line 2 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 4 At line 3, compilation error, ambiguity problem, compiler can't determine whether a constructor At line 1, constructor Tester must be marked public like its class At line 2, constructor call At line 4 At line 3, compilation error, ambiguity problem, compiler can't determine whether a constructor At line 1, constructor Tester must be marked public like its class At line 2, constructor call ANSWER DOWNLOAD EXAMIANS APP
JAVA Constructors and Methods public class Test { }What is the prototype of the default constructor? Test( ) public Test( ) Test(void) public Test(void) None of these Test( ) public Test( ) Test(void) public Test(void) 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){} MyClass(){} 1 and 3 MyClass(void) {} public MyClass(){} public MyClass(void){} MyClass(){} 1 and 3 MyClass(void) {} public MyClass(){} ANSWER DOWNLOAD EXAMIANS APP
JAVA Constructors and Methods What is the expected output?public class Profile { private Profile(int w) { // line 1 System.out.print(w); } public static Profile() { // line 5 System.out.print (10); } public static void main(String args[]) { Profile obj = new Profile(50); }} 50 Won't compile because of line (1), constructor can't be private Won't compile because of line (5), constructor can't be static 10 50 50 Won't compile because of line (1), constructor can't be private Won't compile because of line (5), constructor can't be static 10 50 ANSWER DOWNLOAD EXAMIANS APP