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 Compile fail due to error on line no 2 Compile fail due to error on line no 8 None of these TRUE ANSWER : ? YOUR ANSWER : ?
Determine output of the following program.public class Test{ public static void main(String args[]){ System.out.println( Math.floor( Math.random( ) ) ) ; }} 0.0 1.0 10.0 0.5 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); }} 50 Won't compile because of line (1), constructor can't be private Won't compile because of line (5), constructor can't be static 10 50 TRUE ANSWER : ? YOUR ANSWER : ?
Which of the following statements regarding static methods are correct?1. Static methods are difficult to maintain, because you can not change their implementation.2. Static methods can be called using an object reference to an object of the class in which this method is defined.3. Static methods are always public, because they are defined at class-level.4. Static methods do not have direct access to non-static methods which are defined inside the same class. 3 and 4 1 and 3 2 and 4 1 and 2 TRUE ANSWER : ? YOUR ANSWER : ?
The implicit return type of a constructor is A class object in which it is defined. There is no return type. void None of these 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 None of these Method 1 Compile time error as final method can't be overloaded 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 succeed but no output. Compilation fails due to an error on line 1 Compilation fails due to an error on line 2 One TRUE ANSWER : ? YOUR ANSWER : ?
What will be the return type of a method that not returns any value? int double None of these void 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. An object or variable goes out of scope. None of these Before garbage collection. TRUE ANSWER : ? YOUR ANSWER : ?