public class MyClass{ }For the above class(MyClass) what is the correct way of declaring constructor? public MyClass(){} MyClass(){} public MyClass(void){} MyClass(void) {} 1 and 3 TRUE ANSWER : ? YOUR ANSWER : ?
The implicit return type of a constructor is None of these void A class object in which it is defined. There is no return type. TRUE ANSWER : ? YOUR ANSWER : ?
Which of the modifier can't be used for constructors? protected private public static TRUE ANSWER : ? YOUR ANSWER : ?
Determine Output:class A{public static void method(int i){System.out.print("Method 1");}public static int method(String str){System.out.print("Method 2");return 0;}}public class Test{ public static void main(String args[]){A.method(5);}} Method 2 Method 1 None of these Compile time error as final method can't be overloaded 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)); } } None of these The sum of x and y is 45 does not compile The sum of x and y is 9 TRUE ANSWER : ? YOUR ANSWER : ?
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(); None of these A a = new A(String s); All of these A a = new B(5); TRUE ANSWER : ? YOUR ANSWER : ?
public class Test { }What is the prototype of the default constructor? Test(void) None of these Test( ) public Test( ) public Test(void) TRUE ANSWER : ? YOUR ANSWER : ?
What is the output for the below code ?1. public class A{2. int add(int i, int j){3. return i+j;4. }5. }6. public class B extends A{7. public static void main(String argv[]){8. short s = 9;9. System.out.println(add(s,6));10. }11.} Compile fail due to error on line no 9 15 None of these Compile fail due to error on line no 2 Compile fail due to error on line no 8 TRUE ANSWER : ? YOUR ANSWER : ?
The finalize() method is called just prior to Before garbage collection. An object or variable goes out of scope. None of these A variable goes out of scope. An object, variable or method goes out of scope. TRUE ANSWER : ? YOUR ANSWER : ?
The variables declared in a class for the use of all methods of the class are called objects instance variables None of these reference variables TRUE ANSWER : ? YOUR ANSWER : ?