1. ► Select the true statement about given code ?
1 2 3 4 5 6
class Solution { public static void main(String[]args) { for (int i = 0; i < args.length; i++) System.out.print(i == 0 ? args[i] : " " + args[i]); System.out.println(); }}
2. ► Selects correct declaration of array variable?
3. ► What would be output of following program
1 2 3 4 5 6 7 8 9 10 11
public class SolArray { public static void main(String[]args) { int array1[] = { 1, 2 }; int array2[] = array1; System.out.print((array1 == array2) + " "); array1[1]++; System.out.println(array2[1]); } }
4. ► Which statement(s) are true about following program?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
class MyException extends Exception { MyException() { } MyException(String s) { super(s); } } public class FunDo { static void throwException() throws MyException { throw new MyException(); } public static void main(String[]args) { try { throwException(); } catch(RuntimeException r) { System.out.println("RuntimeException:" + r); } catch(MyException exp) { System.out.println("MyException"); } } }
5. ► Which of following can be represented as literal in java?
6. ► Which statement(s) is true about java?
7. ► What would be output of following program?
1 2 3 4 5 6 7 8 9 10
public class SolArray { public static void main(String[]args) { int array1[] = { 1, 2 }; int array2[] = array1; System.out.println(array1[0] == array2[0] && array1[1] == array2[1]); } }
8. ► Which statements are true about following code?
1 2 3 4 5
Class A { int x; } class B extends A { int y; }
9. ► What would be output of following program?
1 2 3 4 5 6 7
public class FunOp { public static void main(String[]args) { int x = 3, y = 5; int a = x + y - x / y + 2; int b = (x + y) - x / (y + 2); System.out.println("a=" + a + " " + "b=" + b); }}
10. ► Select declaration where array objects are created?
11. ► What would be output of following program?
public class FunOp { public static void main(String[]args) { int x = 3, y = 5; int a = x + y - x / y + 2; int b = (x + y) - x / (y + 2); System.out.println(a + b); }}
12. ► Which statement is/are true about object?
13. ► What is the command to check version of installed java?
14. ► What would be output of following program?
class Solution { public static void main(String[]args) { int[] array = new int[101]; for (int i = 0; i < array.length; i++) array[i] = i; int sum = 0; for (int x:array) sum += x; System.out.println(sum); }}
15. ► You are writing a java class HelloWorld which prints "HelloWorld", what will be the file name of your program?
16. ► Which of following is not of integer types?
17. ► What would be output of following program?
1 2 3 4 5 6 7 8 9
public class SolArray { public static void main(String[]args) { int array[][] = { {1, 2}, null }; for (int[]arr:array) for (int x:arr) System.out.println(x); } }
18. ► Which statement is true? Select one correct answer.
19. ► What would be output of following program?
public class FunDo { public static void main(String[]args) { int x = 9; x += (x = 3); System.out.print(x); int y = 9; y = y + (y = 3); System.out.print(" "); System.out.println(y); }}
20. ► Choose correct option about Arrays in java?