JAVA Constructors and Methods In which area of memory, the system stores parameters and local variables whenever a method is invoked? Stack Array Heap Storage Area Stack Array Heap Storage Area 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 ? A a = new B(5); None of these All of these A a = new A(String s); A a = new B(); A a = new B(5); None of these All of these A a = new A(String s); A a = new B(); ANSWER DOWNLOAD EXAMIANS APP
JAVA Constructors and Methods The following code contains one compilation error, find it?public class Test {Test() { } // line 1static void Test() { this(); } // line 2 public static void main(String[] args) { // line 3Test(); // line 4}} At line 4 At line 2, constructor call At line 1, constructor Tester must be marked public like its class At line 3, compilation error, ambiguity problem, compiler can't determine whether a constructor At line 4 At line 2, constructor call At line 1, constructor Tester must be marked public like its class At line 3, compilation error, ambiguity problem, compiler can't determine whether a constructor 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 None of these Prints 10 Prints 0 Compilation Fails Prints 7 None of these Prints 10 Prints 0 Compilation Fails ANSWER DOWNLOAD EXAMIANS APP
JAVA Constructors and Methods public class Test { }What is the prototype of the default constructor? public Test(void) public Test( ) Test( ) None of these Test(void) public Test(void) public Test( ) Test( ) None of these Test(void) ANSWER DOWNLOAD EXAMIANS APP
JAVA Constructors and Methods Determine output:public class Test{ public static void main(String args[]){ MyClass obj = new MyClass(); obj.val = 1; obj.call(obj); System.out.println(obj.val); }}class MyClass{ public int val; public void call(MyClass ref){ ref.val++; }} None of these 2 3 1 Compilation Error None of these 2 3 1 Compilation Error ANSWER DOWNLOAD EXAMIANS APP