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 one Exception None of these Compilation Error two one one TRUE ANSWER : ? YOUR ANSWER : ?
Which of the modifier can't be used for constructors? private protected public static 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();}} Animal Wild Runtime Exception Compilation Error Wild Animal TRUE ANSWER : ? YOUR ANSWER : ?
The variables declared in a class for the use of all methods of the class are called objects reference variables instance variables None of these TRUE ANSWER : ? YOUR ANSWER : ?
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 accessed easily by the class loader. It can be executed without creating any instance of the class. 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 ) ; } } 2.0 0 Compile time error None of these TRUE ANSWER : ? YOUR ANSWER : ?
The finalize() method is called just prior to Before garbage collection. An object, variable or method goes out of scope. An object or variable goes out of scope. A variable goes out of scope. None of these 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()); }} Compilation Fails None of these Prints 10 Prints 0 Prints 7 TRUE ANSWER : ? YOUR ANSWER : ?
In which area of memory, the system stores parameters and local variables whenever a method is invoked? Storage Area Stack Array Heap 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( ) ) ) ; }} 10.0 0.0 1.0 0.5 TRUE ANSWER : ? YOUR ANSWER : ?