JAVA Constructors and Methods public class MyClass{ }For the above class(MyClass) what is the correct way of declaring constructor? MyClass(){} public MyClass(){} MyClass(void) {} public MyClass(void){} 1 and 3 MyClass(){} public MyClass(){} MyClass(void) {} public MyClass(void){} 1 and 3 ANSWER DOWNLOAD EXAMIANS APP
JAVA Constructors and Methods The main method should be static for the reason It can be accessed by every method or variable without any hindrance. None of these It can be executed without creating any instance of the class. It can be accessed easily by the class loader. It can be accessed by every method or variable without any hindrance. None of these It can be executed without creating any instance of the class. It can be accessed easily by the class loader. ANSWER DOWNLOAD EXAMIANS APP
JAVA Constructors and Methods The finalize() method is called just prior to An object, variable or method goes out of scope. A variable goes out of scope. An object or variable goes out of scope. None of these Before garbage collection. An object, variable or method goes out of scope. A variable goes out of scope. An object or variable goes out of scope. None of these Before garbage collection. ANSWER DOWNLOAD EXAMIANS APP
JAVA Constructors and Methods Which of the modifier can't be used for constructors? protected static public private protected static public private 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()); }} Prints 7 Prints 10 Prints 0 None of these Compilation Fails Prints 7 Prints 10 Prints 0 None of these Compilation Fails 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); }} Compilation fails None of these Compilation clean but throws RuntimeException int long Compilation fails None of these Compilation clean but throws RuntimeException int long ANSWER DOWNLOAD EXAMIANS APP