JAVA Constructors and Methods The main method should be static for the reason It can be accessed by every method or variable without any hindrance. It can be accessed easily by the class loader. It can be executed without creating any instance of the class. None of these It can be accessed by every method or variable without any hindrance. It can be accessed easily by the class loader. It can be executed without creating any instance of the class. None of these ANSWER DOWNLOAD EXAMIANS APP
JAVA Constructors and Methods The finalize() method is called just prior to An object or variable goes out of scope. A variable goes out of scope. None of these 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 Before garbage collection. An object, variable or method goes out of scope. ANSWER DOWNLOAD EXAMIANS APP
JAVA Constructors and Methods 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 ) ; } } None of these 0 Compile time error 2.0 None of these 0 Compile time error 2.0 ANSWER DOWNLOAD EXAMIANS APP
JAVA Constructors and Methods Given the following piece of code:class Person{ public int number;}public class Test{ public void doIt(int i , Person p){ i = 5; p.number = 8; } public static void main(String args[]){ int x = 0; Person p = new Person(); new Test().doIt(x, p); System.out.println(x + " " + p.number); }}What is the result? 5 8 0 0 5 0 0 8 5 8 0 0 5 0 0 8 ANSWER DOWNLOAD EXAMIANS APP
JAVA Constructors and Methods 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(); }} Compilation Error two one one one one two None of these one Exception Compilation Error two one one one one two None of these one Exception ANSWER DOWNLOAD EXAMIANS APP
JAVA Constructors and Methods 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}} Compilation fails due to an error on line 2 One Compilation succeed but no output. Compilation fails due to an error on line 1 Compilation fails due to an error on line 2 One Compilation succeed but no output. Compilation fails due to an error on line 1 ANSWER DOWNLOAD EXAMIANS APP