JAVA Constructors and Methods The implicit return type of a constructor is There is no return type. void A class object in which it is defined. None of these There is no return type. void A class object in which it is defined. None of these 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 None of these A B 5 A B 8 B 8 A 5 A 5 B 8 None of these A B 5 A B 8 B 8 A 5 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 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(); }} None of these two one one Compilation Error one Exception one one two None of these two one one Compilation Error one Exception one one two 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 None of these Prints 7 Prints 0 Prints 10 Compilation Fails None of these Prints 7 Prints 0 Prints 10 ANSWER DOWNLOAD EXAMIANS APP
JAVA Constructors and Methods Given the following piece of code:class Person{ public int number;}public class Test{ public void doIt(int i , Person p){ i = 5; p.number = 8; } public static void main(String args[]){ int x = 0; Person p = new Person(); new Test().doIt(x, p); System.out.println(x + " " + p.number); }}What is the result? 0 8 5 8 0 0 5 0 0 8 5 8 0 0 5 0 ANSWER DOWNLOAD EXAMIANS APP