The implicit return type of a constructor is None of these A class object in which it is defined. There is no return type. void 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(5); None of these A a = new B(); A a = new A(String s); All of these TRUE ANSWER : ? YOUR ANSWER : ?
public class MyClass{ }For the above class(MyClass) what is the correct way of declaring constructor? public MyClass(void){} MyClass(void) {} MyClass(){} public MyClass(){} 1 and 3 TRUE ANSWER : ? YOUR ANSWER : ?
The finalize() method is called just prior to Before garbage collection. A variable goes out of scope. An object, variable or method goes out of scope. None of these An object or variable goes out of scope. TRUE ANSWER : ? YOUR ANSWER : ?
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(); }} Compilation Error None of these one Exception one one two two one one 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.} 15 Compile fail due to error on line no 2 Compile fail due to error on line no 8 None of these Compile fail due to error on line no 9 TRUE ANSWER : ? YOUR ANSWER : ?
What is the expected output?public class Profile {private Profile(int w) { // line 1System.out.print(w);}public final Profile() { // line 5System.out.print(10);}public static void main(String args[]) {Profile obj = new Profile(50);}} 50 Won't compile because of line (1); constructor can't be private Won't compile because of line (5); constructor can't be final 10 50 TRUE ANSWER : ? YOUR ANSWER : ?
The variables declared in a class for the use of all methods of the class are called None of these objects reference variables instance variables TRUE ANSWER : ? YOUR ANSWER : ?
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 3, compilation error, ambiguity problem, compiler can't determine whether a constructor At line 2, constructor call At line 1, constructor Tester must be marked public like its class 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++; }} 3 Compilation Error 2 None of these 1 TRUE ANSWER : ? YOUR ANSWER : ?