JAVA Constructors and Methods Which of the modifier can't be used for constructors? protected private static public protected private static public ANSWER DOWNLOAD EXAMIANS APP
JAVA Constructors and Methods What will be the result of compiling and running the given code?class A{ int b=10; private A(){ this.b=7; } int f(){ return b; }}class B extends A{ int b;}public class Test{ public static void main(String[] args){ A a = new B(); System.out.println(a.f()); }} None of these Prints 0 Prints 7 Compilation Fails Prints 10 None of these Prints 0 Prints 7 Compilation Fails Prints 10 ANSWER DOWNLOAD EXAMIANS APP
JAVA Constructors and Methods Determine Output:class A{public static void method(int i){System.out.print("Method 1");}public static int method(String str){System.out.print("Method 2");return 0;}}public class Test{ public static void main(String args[]){A.method(5);}} Method 1 Method 2 None of these Compile time error as final method can't be overloaded Method 1 Method 2 None of these Compile time error as final method can't be overloaded ANSWER DOWNLOAD EXAMIANS APP
JAVA Constructors and Methods public class MyClass{ }For the above class(MyClass) what is the correct way of declaring constructor? 1 and 3 public MyClass(){} MyClass(){} MyClass(void) {} public MyClass(void){} 1 and 3 public MyClass(){} MyClass(){} MyClass(void) {} public MyClass(void){} ANSWER DOWNLOAD EXAMIANS APP
JAVA Constructors and Methods Which of the following options is the best for generating random integer 0 or 1? (int)(Math.random() + 0.2) (int)Math.random() (int)(Math.random() + 0.5) (int)Math.random() + 1 (int)(Math.random() + 0.2) (int)Math.random() (int)(Math.random() + 0.5) (int)Math.random() + 1 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); }} Won't compile because of line (5), constructor can't be static 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 static Won't compile because of line (1), constructor can't be private 10 50 50 ANSWER DOWNLOAD EXAMIANS APP