1. Consider the following program: import java.util.*; public class ListColl { public static void main(String str[]) { List l = new ArrayList(); l.add('1'); l.add('2'); l.add(1,'3'); List l2 = new LinkedList(l); l.addAll(l2); System.out.println(l); } } Which of the following sequences will be printed when the above program is run?
2. What will be the output when the following code is compiled and run? class Equates { Equates() { int a,b,c; a = b = c = 20; System.out.println(a); } public static void main(String str[]) { new Equates(); } }
3. What will be the output of the following program? public class Prnt { public static void main(String args[]) { System.out.println(11 ^ 2); } }
4. You have defined a static method to divide two integers: 1 public static int divide(int a,int b) throws Exception 2 { 3 if(b==0) 4 throw new Exception('Invalid Value for denominator'); 5 else 6 return (a/b); 7 } Which of the following statements is correct?
5. What will be the output when the following code is compiled and run?abstract class Search { public Search() { } public abstract void Result(); }public class SearchMain extends Search { public SearchMain() { } public int Result() { System.out.println('I am Result()'); return 1; } public static void main(String str[]) { new SearchMain().Result(); } }
6. What will happen on compiling and running the code?
7. You have created the following class to print some numbers:public class PrintNumber { int a; int b; public void basefunt() { a = 0; b = 0; int[] c = { 0 }; modify(b, c); System.out.println( '' '' + a + b + c[0]); } public void modify(int b, int[] c) { a = 1; b = 1; c[0] = 1; } public static void main(String args[]) { PrintNumber p = new PrintNumber(); p.basefunt(); } }What will be the output?
8. Consider the following class: public class Intro { static int a; int b; public Intro() { int c; c = a; a++; b += c; } public void Intro() { int c; c = a; a++; b += c; } public static void main(String args[]) { new Intro(); } } What will happen on compiling and running this class?
9. You have defined the following methods in one of the java classes: 1 void setId(int newId) 2 private void manageRecord(int RecordNo) 3 protected void delete(int recordNo) 4 boolean isValidRecord(int recordNo) Which of the following methods is incorrect for a class that extends above class?
10. What will be the result obtained on compiling and running the viewer on .net command prompt?
11. Which one is a valid way to name the '.java' file containing the above classes?
12. What will happen on compiling and running the code?
13. You want a component to resize vertically, but not horizontally. How should it be placed?
14. Which one is not a correct way of getting 'sin' value?
15. What will be the output when myMethod() is executed?
16. A class named MyLoop is defined as follows: public class MyLoop { public static void main(String args[]) { int counter = 0; lbl1: for (int i=10; i<0; i--) { int j = 0; lbl2: while (j < 10) { if (j > i) break lbl2; if (i == j) { counter++; continue lbl1; } } counter--; } System.out.println(counter); } } What will happen when you try to compile and run the program?
17. Two functions are defined with the same name in a class: public boolean isGreater(int no1, int no2) public boolean isGreater(String st1, String st2) Which of the following concept does this definition represent?