previous | start | next

Self Check

  1. What elements does the data array contain after the following statements?
    double[] data = new double[10];
    for (int i = 0; i < data.length; i++) data[i] = i * i;
  2. What do the following program segments print? Or, if there is an error, describe the error and specify whether it is detected at compile-time or at run-time.
    1. double[] a = new double[10];
      System.out.println(a[0]);
    2. double[] b = new double[10];
      System.out.println(b[10]);
    3. double[] c;
      System.out.println(c[0]);

previous | start | next