The main method should be static for the reason It can be accessed easily by the class loader. It can be executed without creating any instance of the class. It can be accessed by every method or variable without any hindrance. None of these TRUE ANSWER : ? YOUR ANSWER : ?
The finalize() method is called just prior to An object, variable or method goes out of scope. An object or variable goes out of scope. A variable goes out of scope. Before garbage collection. None of these TRUE ANSWER : ? YOUR ANSWER : ?
class MyClass{int i;int j;public MyClass(int i, int j){this.i = i;this.j = j;}public void call(){System.out.print("One");}}public class Test{public static void main(String args[]){MyClass m = new MyClass(); //line 1m.call(); //line 2}} One Compilation fails due to an error on line 1 Compilation fails due to an error on line 2 Compilation succeed but no output. 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();}} Compilation Error Animal Wild Runtime Exception Wild Animal TRUE ANSWER : ? YOUR ANSWER : ?
In which area of memory, the system stores parameters and local variables whenever a method is invoked? Stack Array Storage Area Heap TRUE ANSWER : ? YOUR ANSWER : ?
Which of the modifier can't be used for constructors? public private protected static TRUE ANSWER : ? YOUR ANSWER : ?
Determine output of the following program.public class Test{ public static void main(String args[]){ System.out.println( Math.floor( Math.random( ) ) ) ; }} 1.0 10.0 0.0 0.5 TRUE ANSWER : ? YOUR ANSWER : ?
class A{ A(String s){} A(){}}1. class B extends A{2. B(){}3. B(String s){4. super(s);5. }6. void test(){7. // insert code here8. }9. }Which of the below code can be insert at line 7 to make clean compilation ? A a = new B(); A a = new A(String s); All of these A a = new B(5); None of these 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 fails int long None of these Compilation clean but throws RuntimeException 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 5 B 8 A B 8 A B 5 B 8 A 5 TRUE ANSWER : ? YOUR ANSWER : ?