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)); } } The sum of x and y is 45 None of these The sum of x and y is 9 does not compile 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); }} A B 5 A B 8 B 8 A 5 None of these A 5 B 8 TRUE ANSWER : ? YOUR ANSWER : ?
The finalize() method is called just prior to An object or variable goes out of scope. A variable goes out of scope. An object, variable or method goes out of scope. None of these Before garbage collection. 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);}} None of these Method 1 Compile time error as final method can't be overloaded Method 2 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 one Exception one one two two one one None of these 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(void) throws IOException{} void examians() throws IOException{} void examians() throw IOException{} void examians() {} throws IOException examians() throws IOException{} TRUE ANSWER : ? YOUR ANSWER : ?
The variables declared in a class for the use of all methods of the class are called objects None of these instance variables reference variables TRUE ANSWER : ? YOUR ANSWER : ?
What is the expected output?class Animal {Animal() {System.out.println("Animal");}}class Wild extends Animal{Wild() {System.out.println("Wild");super();}}public class Test {public static void main(String args[]) {Wild wild = new Wild();}} Wild Animal Runtime Exception Compilation Error Animal Wild TRUE ANSWER : ? YOUR ANSWER : ?
Which of the following options is the best for generating random integer 0 or 1? (int)(Math.random() + 0.2) (int)(Math.random() + 0.5) (int)Math.random() (int)Math.random() + 1 TRUE ANSWER : ? YOUR ANSWER : ?