JAVA Constructors and Methods public class MyClass{ }For the above class(MyClass) what is the correct way of declaring constructor? public MyClass(){} 1 and 3 MyClass(void) {} MyClass(){} public MyClass(void){} public MyClass(){} 1 and 3 MyClass(void) {} MyClass(){} public MyClass(void){} ANSWER DOWNLOAD EXAMIANS APP
JAVA Constructors and Methods The implicit return type of a constructor is void A class object in which it is defined. There is no return type. None of these void A class object in which it is defined. There is no return type. None of these ANSWER DOWNLOAD EXAMIANS APP
JAVA Constructors and Methods public class Test { }What is the prototype of the default constructor? Test( ) Test(void) public Test(void) public Test( ) None of these Test( ) Test(void) public Test(void) public Test( ) None of these ANSWER DOWNLOAD EXAMIANS APP
JAVA Constructors and Methods Which of the modifier can't be used for constructors? public static protected private public static protected private ANSWER DOWNLOAD EXAMIANS APP
JAVA Constructors and Methods What is the output for the below code ?class A{ public A(){ System.out.println("A"); } public A(int i){ this(); System.out.println(i); }}class B extends A{ public B(){ System.out.println("B"); } public B(int i){ this(); System.out.println(i+3); }}public class Test{ public static void main (String[] args){ new B(5); }} A 5 B 8 A B 5 B 8 A 5 None of these A B 8 A 5 B 8 A B 5 B 8 A 5 None of these A B 8 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 7 Prints 0 Compilation Fails Prints 10 None of these Prints 7 Prints 0 Compilation Fails Prints 10 ANSWER DOWNLOAD EXAMIANS APP