JAVA Constructors and Methods public class MyClass{ }For the above class(MyClass) what is the correct way of declaring constructor? MyClass(){} 1 and 3 public MyClass(){} MyClass(void) {} public MyClass(void){} MyClass(){} 1 and 3 public MyClass(){} MyClass(void) {} public MyClass(void){} ANSWER DOWNLOAD EXAMIANS APP
JAVA Constructors and Methods What is the output of the program?class Test{ public int display(int x, int y){ return ("The sum of x and y is " + x + y); } public static void main(String args[]){ Test test = new Test(); System.out.println(test.display(4,5)); } } None of these does not compile The sum of x and y is 45 The sum of x and y is 9 None of these does not compile The sum of x and y is 45 The sum of x and y is 9 ANSWER DOWNLOAD EXAMIANS APP
JAVA Constructors and Methods What will be the return type of a method that not returns any value? None of these int void double None of these int void double ANSWER DOWNLOAD EXAMIANS APP
JAVA Constructors and Methods Which of the modifier can't be used for constructors? private static public protected private static public protected ANSWER DOWNLOAD EXAMIANS APP
JAVA Constructors and Methods The implicit return type of a constructor is void None of these 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. 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++; }} 3 Compilation Error 2 1 None of these 3 Compilation Error 2 1 None of these ANSWER DOWNLOAD EXAMIANS APP