JAVA Constructors and Methods Which of the following options is the best for generating random integer 0 or 1? (int)(Math.random() + 0.5) (int)Math.random() + 1 (int)Math.random() (int)(Math.random() + 0.2) (int)(Math.random() + 0.5) (int)Math.random() + 1 (int)Math.random() (int)(Math.random() + 0.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 3, compilation error, ambiguity problem, compiler can't determine whether a constructor At line 2, constructor call At 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 2, constructor call At line 4 At line 1, constructor Tester must be marked public like its class ANSWER DOWNLOAD EXAMIANS APP
JAVA Constructors and Methods The main method should be static for the reason It can be executed without creating any instance of the class. None of these It can be accessed by every method or variable without any hindrance. It can be accessed easily by the class loader. It can be executed without creating any instance of the class. None of these It can be accessed by every method or variable without any hindrance. It can be accessed easily by the class loader. ANSWER DOWNLOAD EXAMIANS APP
JAVA Constructors and Methods Which of the modifier can't be used for constructors? public protected private static public protected private static ANSWER DOWNLOAD EXAMIANS APP
JAVA Constructors and Methods What is Math.floor(3.6)? 4.0 3.0 3 4 4.0 3.0 3 4 ANSWER DOWNLOAD EXAMIANS APP
JAVA Constructors and Methods class MyClass{ MyClass(){ System.out.print("one"); } public void myMethod(){ this(); System.out.print("two"); }} public class TestClass{ public static void main(String args[]){ MyClass obj = new MyClass(); obj.myMethod(); }} two one one one Exception None of these one one two Compilation Error two one one one Exception None of these one one two Compilation Error ANSWER DOWNLOAD EXAMIANS APP