JAVA Constructors and Methods Which of the following options is the best for generating random integer 0 or 1? (int)Math.random() + 1 (int)(Math.random() + 0.5) (int)Math.random() (int)(Math.random() + 0.2) (int)Math.random() + 1 (int)(Math.random() + 0.5) (int)Math.random() (int)(Math.random() + 0.2) 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 Compilation clean but throws RuntimeException long Compilation fails int None of these Compilation clean but throws RuntimeException long Compilation fails int 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 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 At line 2, constructor call 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 (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 Won't compile because of line (1); constructor can't be private 10 50 50 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)); } } 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 None of these ANSWER DOWNLOAD EXAMIANS APP
JAVA Constructors and Methods The variables declared in a class for the use of all methods of the class are called None of these objects instance variables reference variables None of these objects instance variables reference variables ANSWER DOWNLOAD EXAMIANS APP