The main method should be static for the reason It can be executed without creating any instance of the class. It can be accessed easily by the class loader. None of these It can be accessed by every method or variable without any hindrance. TRUE ANSWER : ? YOUR ANSWER : ?
What is the expected output?public class Profile {private Profile(int w) { // line 1System.out.print(w);}public final Profile() { // line 5System.out.print(10);}public static void main(String args[]) {Profile obj = new Profile(50);}} 50 10 50 Won't compile because of line (1); constructor can't be private Won't compile because of line (5); constructor can't be final 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 one Exception Compilation Error two one one one one two TRUE ANSWER : ? YOUR ANSWER : ?
Which of these is a legal definition of a method named examveda assuming it throws IOException, and returns void. Also assume that the method does not take any arguments. Select the one correct answer. void examians() throws IOException{} void examians() throw IOException{} void examians() {} throws IOException examians() throws IOException{} void examians(void) throws IOException{} TRUE ANSWER : ? YOUR ANSWER : ?
The finalize() method is called just prior to None of these Before garbage collection. An object or variable goes out of scope. A variable goes out of scope. An object, variable or method 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 9 None of these does not compile The sum of x and y is 45 TRUE ANSWER : ? YOUR ANSWER : ?
Determine output:public class Test{ public static void main(String args[]){ MyClass obj = new MyClass(); obj.val = 1; obj.call(obj); System.out.println(obj.val); }}class MyClass{ public int val; public void call(MyClass ref){ ref.val++; }} 3 1 Compilation Error 2 None of these 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 : ?
In which area of memory, the system stores parameters and local variables whenever a method is invoked? Array Storage Area Stack Heap TRUE ANSWER : ? YOUR ANSWER : ?