Quiz #4: Java arrays

Array is an important structure in programming language and Java programming language no difference
  1. Is the following array defined as null or with 0 length?

  2. int temp_array[];

    Null
    zero length
  3. What is the correct array initialization from the following?

  4. temp_array[]
    array temp_array[]
    int temp_array[];
    array temp_array[]
  5. Is the following code correct?

  6. Verify the following code and check if there is something wrong
    public class MyClass {
      public static void main(String[] args) {
        int[] myNumbers = {"1", "2", "3", "4"};
        for (int i = 0; i < myNumbers.length; ++i) {
            System.out.println(myNumbers[i]);
        }
      }
    }
    Nothing wrong with the code
    Loop will through an exception
    Array initialization is not correct
    Main method cannot be inside a class
  7. What is the the output of the following code snippet?

  8. public class MyClass {
      public static void main(String[] args) {
        int[] myNumbers = {1, 2, 3, 4};
        System.out.println(myNumbers[1])
      }
    }
    Missing Word


Show Answer without submitting