JAVA Constructors and Methods public class Test { }What is the prototype of the default constructor? Test( ) Test(void) None of these public Test(void) public Test( ) Test( ) Test(void) None of these public Test(void) public Test( ) ANSWER DOWNLOAD EXAMIANS APP
JAVA Constructors and Methods What is the output for the below code ?1. public class A{2. int add(int i, int j){3. return i+j;4. }5. }6. public class B extends A{7. public static void main(String argv[]){8. short s = 9;9. System.out.println(add(s,6));10. }11.} 15 Compile fail due to error on line no 8 None of these Compile fail due to error on line no 9 Compile fail due to error on line no 2 15 Compile fail due to error on line no 8 None of these Compile fail due to error on line no 9 Compile fail due to error on line no 2 ANSWER DOWNLOAD EXAMIANS APP
JAVA Constructors and Methods The implicit return type of a constructor is 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 void A class object in which it is defined. 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()); }} Compilation Fails Prints 0 Prints 10 None of these Prints 7 Compilation Fails Prints 0 Prints 10 None of these Prints 7 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(); }} one Exception Compilation Error one one two None of these two one one one Exception Compilation Error one one two None of these two one one ANSWER DOWNLOAD EXAMIANS APP
JAVA Constructors and Methods What will be the return type of a method that not returns any value? void double None of these int void double None of these int ANSWER DOWNLOAD EXAMIANS APP