JAVA Constructors and Methods public class MyClass{ }For the above class(MyClass) what is the correct way of declaring constructor? public MyClass(void){} MyClass(){} 1 and 3 MyClass(void) {} public MyClass(){} public MyClass(void){} MyClass(){} 1 and 3 MyClass(void) {} public MyClass(){} 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 reference variables instance variables objects None of these reference variables instance variables objects None of these ANSWER DOWNLOAD EXAMIANS APP
JAVA Constructors and Methods class A{ A(String s){} A(){}}1. class B extends A{2. B(){}3. B(String s){4. super(s);5. }6. void test(){7. // insert code here8. }9. }Which of the below code can be insert at line 7 to make clean compilation ? None of these All of these A a = new B(); A a = new A(String s); A a = new B(5); None of these All of these A a = new B(); A a = new A(String s); A a = new B(5); 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 0 None of these Prints 10 Compilation Fails Prints 7 Prints 0 None of these Prints 10 Compilation Fails ANSWER DOWNLOAD EXAMIANS APP
JAVA Constructors and Methods The implicit return type of a constructor is There is no return type. None of these A class object in which it is defined. void There is no return type. None of these A class object in which it is defined. void ANSWER DOWNLOAD EXAMIANS APP
JAVA Constructors and Methods class MyClass{int i;int j;public MyClass(int i, int j){this.i = i;this.j = j;}public void call(){System.out.print("One");}}public class Test{public static void main(String args[]){MyClass m = new MyClass(); //line 1m.call(); //line 2}} Compilation fails due to an error on line 1 One Compilation fails due to an error on line 2 Compilation succeed but no output. Compilation fails due to an error on line 1 One Compilation fails due to an error on line 2 Compilation succeed but no output. ANSWER DOWNLOAD EXAMIANS APP