Arrays


  1. Which of these method of Array class is used sort an array or its subset?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    sort()


  1. Which of this method is used to make all elements of an equal to specified value?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    fill() method assigns a value to all the elements in an array, in other words, it fills the array with specified value.



  1. Which of these standard collection classes implements all the standard functions on list data structure?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    Array


  1. What is the output of this program?

    public class Result
    {
    public static void main(String[] args)
    {
    int []p[] = {{1,2}, {3,4,5}, {6,7,8,9}};
    int [][]q = p;
    System.out.println("Alligator");
    System.out.println(q[0][0]);
    }
    }












  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: A

    Both p,and q are pointing to the same array.



  1. What is the output of this program?

    public class Result
    {
    public static void main(String args[])
    {
    int array1[] = new int[8];
    int array2[] = {5, 8, 7, 6, 9};
    System.out.println(array1.length + " " + array2.length);
    }
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    Arrays in java are implemented as objects, they contain an attribute that is length which contains the number of elements that can be stored in the array. Hence array1.length gives 8 and array2.length gives 5.
    output: 8 5