Java Assessment

Java Assessment

  1. What is the maximum length of a Java identifier?

    a) 32 b) 128 c) No fixed length is specified
  2. What will be the output of the following Java code snippet?

                            int var = 10;
                            System.out.println(var.getClass());
                            var = "hello";
                            System.out.println(var.getClass());
                        
    a) String and int b) int and String c) int and int
  3. Which of the following types of loop are not supported in Java?

    a) for b) while c) do-while
  4. Which of the following blocks will always be executed whether an exception is encountered or not in a Java program?

    a) try b) catch c) finally
  5. What is the keyword used in Java to raise an exception?

    a) throw b) try c) goto
  6. Which of the following packages needs to be imported to handle date-time computations in Java?

    a) java.util.date b) java.util c) java.time
  7. In which language is Java written?

    a) C++ b) Java c) C
  8. What will be the output of the following Java code?

                            int[] a = {1, 2, 3};
                            int[] b = a;
                            b[0] = 5;
                            System.out.println(Arrays.toString(a));
                        
    a) [1, 2, 3] b) [5, 2, 3] c) [1, 2, 3, 5]