Computers

University

Image

Java Arrays

483
plays

10 questions

Show Answers
See Preview
  • 1. Multiple Choice
    30 seconds
    1 pt

    Which of the following is FALSE about arrays on Java

    A java array is always an object

    Length of array can be changed after creation of array

    Arrays in Java are always allocated on heap

  • 2. Multiple Choice
    45 seconds
    1 pt

    Predict the output?

    public class Main {

    public static void main(String args[]) {

    int arr[] = {10, 20, 30, 40, 50};

    for(int i=0; i < arr.length; i++)

    {

    System.out.print(" " + arr[i]);

    }

    }

    }

    10 20 30 40 50

    Compiler Error

    10 20 30 40

  • 3. Multiple Choice
    1 minute
    1 pt

    class Test {

    public static void main(String args[]) {

    int arr[2];

    System.out.println(arr[0]);

    System.out.println(arr[1]);

    }

    }

    0

    0

    garbage value

    garbage value

    Compiler Error

    Exception

  • Answer choices
    Tags
    Answer choices
    Tags

    Explore all questions with a free account

    Already have an account?