public class MyClass{ }For the above class(MyClass) what is the correct way of declaring constructor? public MyClass(){} MyClass(){} public MyClass(void){} 1 and 3 MyClass(void) {} TRUE ANSWER : ? YOUR ANSWER : ?
In which area of memory, the system stores parameters and local variables whenever a method is invoked? Array Stack Storage Area Heap TRUE ANSWER : ? YOUR ANSWER : ?
What is the expected output?public class Profile { private Profile(int w) { // line 1 System.out.print(w); } public static Profile() { // line 5 System.out.print (10); } public static void main(String args[]) { Profile obj = new Profile(50); }} Won't compile because of line (1), constructor can't be private 10 50 50 Won't compile because of line (5), constructor can't be static TRUE ANSWER : ? YOUR ANSWER : ?
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++; }} Compilation Error None of these 2 3 1 TRUE ANSWER : ? YOUR ANSWER : ?
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 The sum of x and y is 9 The sum of x and y is 45 None of these TRUE ANSWER : ? YOUR ANSWER : ?
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 ) ; } } 0 2.0 None of these Compile time error TRUE ANSWER : ? YOUR ANSWER : ?
The finalize() method is called just prior to An object, variable or method goes out of scope. A variable goes out of scope. None of these Before garbage collection. An object or variable goes out of scope. TRUE ANSWER : ? YOUR ANSWER : ?
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 Prints 10 Prints 0 Compilation Fails None of these TRUE ANSWER : ? YOUR ANSWER : ?
The main method should be static for the reason It can be accessed easily by the class loader. It can be accessed by every method or variable without any hindrance. None of these It can be executed without creating any instance of the class. TRUE ANSWER : ? YOUR ANSWER : ?
Which of the modifier can't be used for constructors? static protected public private TRUE ANSWER : ? YOUR ANSWER : ?