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 TRUE ANSWER : ? YOUR ANSWER : ?
What is the output for the below code ?1. public class A{2. int add(int i, int j){3. return i+j;4. }5. }6. public class B extends A{7. public static void main(String argv[]){8. short s = 9;9. System.out.println(add(s,6));10. }11.} None of these Compile fail due to error on line no 8 15 Compile fail due to error on line no 9 Compile fail due to error on line no 2 TRUE ANSWER : ? YOUR ANSWER : ?
In which area of memory, the system stores parameters and local variables whenever a method is invoked? Stack Heap Storage Area Array TRUE ANSWER : ? YOUR ANSWER : ?
The variables declared in a class for the use of all methods of the class are called objects None of these reference variables instance variables 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()); }} None of these Prints 10 Prints 0 Compilation Fails Prints 7 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(); }} None of these Compilation Error two one one one one two one Exception TRUE ANSWER : ? YOUR ANSWER : ?
public class Test { }What is the prototype of the default constructor? Test( ) public Test( ) Test(void) public Test(void) None of these TRUE ANSWER : ? YOUR ANSWER : ?
The finalize() method is called just prior to Before garbage collection. None of these An object, variable or method goes out of scope. A variable goes out of scope. An object or variable goes out of scope. TRUE ANSWER : ? YOUR ANSWER : ?
What is the output of the program?class Test{ public int display(int x, int y){ return ("The sum of x and y is " + x + y); } public static void main(String args[]){ Test test = new Test(); System.out.println(test.display(4,5)); } } The sum of x and y is 45 does not compile The sum of x and y is 9 None of these TRUE ANSWER : ? YOUR ANSWER : ?