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 45 The sum of x and y is 9 None of these 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 An object, variable or method goes out of scope. A variable goes out of scope. TRUE ANSWER : ? YOUR ANSWER : ?
Which of the following options is the best for generating random integer 0 or 1? (int)Math.random() (int)(Math.random() + 0.2) (int)(Math.random() + 0.5) (int)Math.random() + 1 TRUE ANSWER : ? YOUR ANSWER : ?
The implicit return type of a constructor is There is no return type. None of these A class object in which it is defined. void TRUE ANSWER : ? YOUR ANSWER : ?
What is the output for the below code?public class Test{ public static void printValue(int i, int j, int k){ System.out.println("int"); } public static void printValue(byte...b){ System.out.println("long"); } public static void main(String... args){ byte b = 9; printValue(b,b,b); }} long Compilation fails None of these int Compilation clean but throws RuntimeException TRUE ANSWER : ? YOUR ANSWER : ?
In which area of memory, the system stores parameters and local variables whenever a method is invoked? Heap Storage Area Array Stack TRUE ANSWER : ? YOUR ANSWER : ?
What is the output for the below code ?class A{ public A(){ System.out.println("A"); } public A(int i){ this(); System.out.println(i); }}class B extends A{ public B(){ System.out.println("B"); } public B(int i){ this(); System.out.println(i+3); }}public class Test{ public static void main (String[] args){ new B(5); }} None of these A B 8 B 8 A 5 A B 5 A 5 B 8 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(); }} two one one one one two Compilation Error one Exception 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 : ?