public class Test { }What is the prototype of the default constructor? public Test(void) Test(void) None of these public Test( ) Test( ) TRUE ANSWER : ? YOUR ANSWER : ?
class MyClass{int i;int j;public MyClass(int i, int j){this.i = i;this.j = j;}public void call(){System.out.print("One");}}public class Test{public static void main(String args[]){MyClass m = new MyClass(); //line 1m.call(); //line 2}} Compilation fails due to an error on line 2 One Compilation fails due to an error on line 1 Compilation succeed but no output. TRUE ANSWER : ? YOUR ANSWER : ?
Which of these is a legal definition of a method named examveda assuming it throws IOException, and returns void. Also assume that the method does not take any arguments. Select the one correct answer. void examians() throws IOException{} void examians(void) throws IOException{} examians() throws IOException{} void examians() {} throws IOException void examians() throw IOException{} TRUE ANSWER : ? YOUR ANSWER : ?
Which of the modifier can't be used for constructors? protected public private static 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 An object or variable goes out of scope. Before garbage collection. 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 2, constructor call At line 3, compilation error, ambiguity problem, compiler can't determine whether a constructor At line 1, constructor Tester must be marked public like its class At line 4 TRUE ANSWER : ? YOUR ANSWER : ?
The main method should be static for the reason 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. It can be accessed easily by the class loader. TRUE ANSWER : ? YOUR ANSWER : ?
The variables declared in a class for the use of all methods of the class are called instance variables None of these objects reference variables 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.} None of these Compile fail due to error on line no 8 Compile fail due to error on line no 2 Compile fail due to error on line no 9 15 TRUE ANSWER : ? YOUR ANSWER : ?
public class MyClass{ }For the above class(MyClass) what is the correct way of declaring constructor? public MyClass(){} MyClass(void) {} public MyClass(void){} 1 and 3 MyClass(){} TRUE ANSWER : ? YOUR ANSWER : ?