What is the output of the above program ?class Num { Num(double x ){ System.out.println( x ) ; } }public class Test extends Num { public static void main(String[] args){ Num num = new Num( 2 ) ; } } Compile time error 0 None of these 2.0 TRUE ANSWER : ? YOUR ANSWER : ?
public class Test { }What is the prototype of the default constructor? Test(void) public Test( ) None of these public Test(void) Test( ) TRUE ANSWER : ? YOUR ANSWER : ?
The main method should be static for the reason It can be executed without creating any instance of the class. It can be accessed easily by the class loader. None of these It can be accessed by every method or variable without any hindrance. TRUE ANSWER : ? YOUR ANSWER : ?
The variables declared in a class for the use of all methods of the class are called reference variables None of these objects instance variables TRUE ANSWER : ? YOUR ANSWER : ?
What will be the result of compiling and running the given code?class A{ int b=10; private A(){ this.b=7; } int f(){ return b; }}class B extends A{ int b;}public class Test{ public static void main(String[] args){ A a = new B(); System.out.println(a.f()); }} None of these Prints 10 Prints 7 Prints 0 Compilation Fails TRUE ANSWER : ? YOUR ANSWER : ?
What will be the return type of a method that not returns any value? int None of these void double 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 8 A 5 B 8 None of these A B 5 B 8 A 5 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 one Exception Compilation Error None of these TRUE ANSWER : ? YOUR ANSWER : ?
The finalize() method is called just prior to None of these A variable goes out of scope. An object or variable goes out of scope. Before garbage collection. An object, variable or method goes out of scope. TRUE ANSWER : ? YOUR ANSWER : ?