JAVA Constructors and Methods What is the output of the above program ?class Num { Num(double x ){ System.out.println( x ) ; } }public class Test extends Num { public static void main(String[] args){ Num num = new Num( 2 ) ; } } 2.0 0 Compile time error None of these 2.0 0 Compile time error None of these 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 one one two two one one Compilation Error None of these one Exception one one two two one one Compilation Error None of these ANSWER DOWNLOAD EXAMIANS APP
JAVA Constructors and Methods What will be the return type of a method that not returns any value? None of these int double void None of these int double void 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 0 0 8 5 0 5 8 0 0 0 8 5 0 5 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 10 Prints 0 Prints 7 Compilation Fails None of these Prints 10 Prints 0 Prints 7 Compilation Fails ANSWER DOWNLOAD EXAMIANS APP
JAVA Constructors and Methods Which of the modifier can't be used for constructors? private protected public static private protected public static ANSWER DOWNLOAD EXAMIANS APP