The main method should be static for the reason It can be accessed by every method or variable without any hindrance. None of these It can be executed without creating any instance of the class. It can be accessed easily by the class loader. 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); }} Compilation clean but throws RuntimeException Compilation fails long None of these int TRUE ANSWER : ? YOUR ANSWER : ?
The variables declared in a class for the use of all methods of the class are called instance variables objects None of these reference variables TRUE ANSWER : ? YOUR ANSWER : ?
public class Test { }What is the prototype of the default constructor? public Test(void) None of these public Test( ) Test( ) Test(void) TRUE ANSWER : ? YOUR ANSWER : ?
In which area of memory, the system stores parameters and local variables whenever a method is invoked? Storage Area Array Heap Stack 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(); }} one one two None of these Compilation Error one Exception two one one TRUE ANSWER : ? YOUR ANSWER : ?
What will be the return type of a method that not returns any value? void None of these int double TRUE ANSWER : ? YOUR ANSWER : ?
The finalize() method is called just prior to Before garbage collection. An object, variable or method goes out of scope. None of these A variable goes out of scope. An object or variable goes out of scope. 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 Animal Wild Compilation Error Runtime Exception TRUE ANSWER : ? YOUR ANSWER : ?
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 ) ; } } 0 Compile time error 2.0 None of these TRUE ANSWER : ? YOUR ANSWER : ?