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 ) ; } } 2.0 Compile time error 0 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() throw IOException{} void examians() {} throws IOException void examians() throws IOException{} examians() throws IOException{} 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()); }} Prints 10 Compilation Fails Prints 0 None of these Prints 7 TRUE ANSWER : ? YOUR ANSWER : ?
What is the expected output?public class Profile {private Profile(int w) { // line 1System.out.print(w);}public final Profile() { // line 5System.out.print(10);}public static void main(String args[]) {Profile obj = new Profile(50);}} Won't compile because of line (5); constructor can't be final 10 50 50 Won't compile because of line (1); constructor can't be private TRUE ANSWER : ? YOUR ANSWER : ?
What will be the return type of a method that not returns any value? None of these double int void 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. None of these 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); }} int None of these Compilation fails Compilation clean but throws RuntimeException long TRUE ANSWER : ? YOUR ANSWER : ?
The finalize() method is called just prior to 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. Before garbage collection. 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); }} 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 50 TRUE ANSWER : ? YOUR ANSWER : ?