JAVA Constructors and Methods Which of the modifier can't be used for constructors? static private public protected static private public protected ANSWER DOWNLOAD EXAMIANS APP
JAVA Constructors and Methods What is the output for the below code?public class Test{ public static void printValue(int i, int j, int k){ System.out.println("int"); } public static void printValue(byte...b){ System.out.println("long"); } public static void main(String... args){ byte b = 9; printValue(b,b,b); }} None of these long Compilation clean but throws RuntimeException int Compilation fails None of these long Compilation clean but throws RuntimeException int Compilation fails ANSWER DOWNLOAD EXAMIANS APP
JAVA Constructors and Methods What is the expected output?public class Profile {private Profile(int w) { // line 1System.out.print(w);}public final Profile() { // line 5System.out.print(10);}public static void main(String args[]) {Profile obj = new Profile(50);}} Won't compile because of line (1); constructor can't be private 10 50 50 Won't compile because of line (5); constructor can't be final Won't compile because of line (1); constructor can't be private 10 50 50 Won't compile because of line (5); constructor can't be final 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 The sum of x and y is 45 The sum of x and y is 9 does not compile None of these The sum of x and y is 45 The sum of x and y is 9 does not compile ANSWER DOWNLOAD EXAMIANS APP
JAVA Constructors and Methods The implicit return type of a constructor is void There is no return type. None of these A class object in which it is defined. void There is no return type. None of these 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 2 One Compilation succeed but no output. Compilation fails due to an error on line 1 Compilation fails due to an error on line 2 One Compilation succeed but no output. Compilation fails due to an error on line 1 ANSWER DOWNLOAD EXAMIANS APP