JAVA Constructors and Methods public class MyClass{ }For the above class(MyClass) what is the correct way of declaring constructor? MyClass(void) {} public MyClass(void){} 1 and 3 MyClass(){} public MyClass(){} MyClass(void) {} public MyClass(void){} 1 and 3 MyClass(){} public MyClass(){} ANSWER DOWNLOAD EXAMIANS APP
JAVA Constructors and Methods What is the output of the program?class Test{ public int display(int x, int y){ return ("The sum of x and y is " + x + y); } public static void main(String args[]){ Test test = new Test(); System.out.println(test.display(4,5)); } } does not compile None of these The sum of x and y is 45 The sum of x and y is 9 does not compile None of these The sum of x and y is 45 The sum of x and y is 9 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 one two one Exception two one one None of these Compilation Error one one two one Exception two one one None of these Compilation Error ANSWER DOWNLOAD EXAMIANS APP
JAVA Constructors and Methods What is the output for the below code?public class Test{ public static void printValue(int i, int j, int k){ System.out.println("int"); } public static void printValue(byte...b){ System.out.println("long"); } public static void main(String... args){ byte b = 9; printValue(b,b,b); }} Compilation clean but throws RuntimeException long Compilation fails None of these int Compilation clean but throws RuntimeException long Compilation fails None of these int ANSWER DOWNLOAD EXAMIANS APP
JAVA Constructors and Methods In which area of memory, the system stores parameters and local variables whenever a method is invoked? Storage Area Stack Array Heap Storage Area Stack Array Heap 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 10 Prints 0 None of these Prints 7 Compilation Fails Prints 10 Prints 0 None of these Prints 7 Compilation Fails ANSWER DOWNLOAD EXAMIANS APP