public class Test { }What is the prototype of the default constructor? public Test( ) None of these public Test(void) Test(void) Test( ) TRUE ANSWER : ? YOUR ANSWER : ?
Determine Output:class A{public static void method(int i){System.out.print("Method 1");}public static int method(String str){System.out.print("Method 2");return 0;}}public class Test{ public static void main(String args[]){A.method(5);}} Method 2 Method 1 None of these Compile time error as final method can't be overloaded TRUE ANSWER : ? YOUR ANSWER : ?
Which of the modifier can't be used for constructors? static private public protected 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.} 15 None of these Compile fail due to error on line no 2 Compile fail due to error on line no 9 Compile fail due to error on line no 8 TRUE ANSWER : ? YOUR ANSWER : ?
What is the expected output?public class Profile { private Profile(int w) { // line 1 System.out.print(w); } public static Profile() { // line 5 System.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 static TRUE ANSWER : ? YOUR ANSWER : ?
The variables declared in a class for the use of all methods of the class are called instance variables objects None of these reference variables 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 : ?
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() throws IOException{} examians() throws IOException{} void examians(void) throws IOException{} void examians() throw IOException{} TRUE ANSWER : ? YOUR ANSWER : ?
Which of the following options is the best for generating random integer 0 or 1? (int)(Math.random() + 0.2) (int)(Math.random() + 0.5) (int)Math.random() (int)Math.random() + 1 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(); }} one Exception None of these two one one Compilation Error one one two TRUE ANSWER : ? YOUR ANSWER : ?