programming

Cards (30)

  • The name of the user-defined method seen in the code below is minFunction.
  • The VOID keyword is used in Java user-defined methods to denote that it does not return any value to the main method
  • In Java, parameters are passed to arguments via a function call
  • It is not possible in Java to write code with more than one user-defined method in it false
  • To avoid a syntax or runtime error, change sum to double datatype
  • The code snippet would not produce an error when executed
  • The Java user-defined method shown in the sample code has two arguments
  • It is possible for a Java user-defined method to accept more than a single argument true
  • The name of the Java class seen in the code is udmSample
  • Standard arrays can hold data items of the same data type, so an array is a homogeneous data structure
  • A single-dimensional array (1D array) only has columns of data items true
  • An array is also called an index (a subscript) / subscripted variable
  • The preferred method for creating an array in Java is dataType[] arrayRefVar;
  • A 3x4 2D array has 3 rows and 4 columns, so it can store 12 data items
  • A 2D array (two-dimensional array) has both rows and columns of data true
  • What is the value of arr11[1] after the following code snippet is execute?
    int[] arr11 = {1, 2, 3};
    arr11 = Arrays.copyOf(arr11, arr11.length + 1); arr11[3] = 4;
    2
  • The statement int[] arr4 = new int[10]; creates a new array of integers with 10 elements, all initialized to 0
  • The given code snippet
    int[] arr2 = new int[3];
    arr2[0]
    arr2[1]
    arr2[2]
    creates a new array of integers with 3 elements and assigns values to each element
  • The output of the given code snippet
    int[] arr1 = {1, 2, 3, 4, 5};
    System.out.println(arr1[4]);
    is 5
  • The value of arr8[2] after the given code snippet is executed
    int[] arr8 = {1, 2, 3, 4, 5};
    int[] temp = arr8;
    temp[2] - 10;
    is 3
  • The value stored in the first element of arr2 is 0
  • The given code snippet
    int[] arr9 = (1, 2, 3, 4, 5);
    for (int i = 0; i < arr9.length / 2; i++) {
    int temp arr9[1];
    arr9[i] = arr9[arr9.length-1- i]
    arr9[arr9.length - 1 i]= temp;
    }
    reverses the elements in the array arr9
  • The output of the given code snippet
    int[] arr6 = {1, 2, 3, 4, 5};
    int[] arr7 = new int[arr6.length];
    for (int i = 0; i < arr.length; i++)
    { arr7[i] = arr6[arr6.length-1- i];
    }
    System.out.println(arr7[2]);
    is 3
  • The method Arrays.sort(arr2) sorts the elements of the array arr2 in ascending order
  • The value of arr3.length after the given code snippet is executed
    int[] arr3 (10, 20, 30, 40);
    arr3[2] = 50;
    is 4
  • The length of the array arr1 is arr1.length
  • The output of the given code snippet is 10
    int[] arr10 = {1, 2, 3, 4, 5};
    int sum = 0;
    for (int i = 0; i < arr10.length; i++) { sum += arr10[1];
    }
    System.out.println(sum);
  • Arrays are usually processed in sequential fashion and therefore loops are used to repetitively access its values and perform operations on these values true
  • The preferred method for declaring an array in Java is dataType[] arrayRefVar true
  • In Java, an array with a maximum size of ten (10) data items would have indexes 0-9