GATE Computer Science Engineering(CSE) 2027 Test: Arrays Free Online Test


MCQ Practice Test & Solutions: Test: Arrays (10 Questions)

You can prepare effectively for Computer Science Engineering (CSE) GATE Computer Science Engineering(CSE) 2027 Mock Test Series with this dedicated MCQ Practice Test (available with solutions) on the important topic of "Test: Arrays". These 10 questions have been designed by the experts with the latest curriculum of Computer Science Engineering (CSE) 2026, to help you master the concept.

Test Highlights:

  • - Format: Multiple Choice Questions (MCQ)
  • - Duration: 30 minutes
  • - Number of Questions: 10

Sign up on EduRev for free to attempt this test and track your preparation progress.

Test: Arrays - Question 1

Which of these best describes an array?

Detailed Solution: Question 1

Array contains elements only of the same type.

Test: Arrays - Question 2

How do you instantiate an array in Java?

Detailed Solution: Question 2

Note that int arr[]; is declaration whereas int arr[] = new int[3]; is to instantiate an array.

Test: Arrays - Question 3

What is the output of the following Java code?

public class array

{

  public static void main(String args[])

  {

    int []arr = {1,2,3,4,5};

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

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

  }

}

Detailed Solution: Question 3

Correct option: A

In Java, array indexing starts from 0, so the first element has index 0, the second has index 1, and so on.

Thus, arr[2] refers to the third element of the array, which is 3.

Similarly, arr[4] refers to the fifth element of the array, which is 5.

Each System.out.println prints its value on a new line. Therefore the program prints:

3

5

Test: Arrays - Question 4

When does the ArrayIndexOutOfBoundsException occur?

Detailed Solution: Question 4

ArrayIndexOutOfBoundsException is a run-time exception and the compilation is error-free.

Test: Arrays - Question 5

What are the advantages of arrays?

Detailed Solution: Question 5

Arrays store elements of the same data type and present in continuous memory locations.

Test: Arrays - Question 6

Assuming int is of 4bytes, what is the size of int arr[15];?

Detailed Solution: Question 6

Since there are 15 int elements and each int is of 4bytes, we get 15*4 = 60bytes.

Test: Arrays - Question 7

Elements in an array are accessed _____________

Detailed Solution: Question 7

Elements in an array are accessed randomly. In Linked lists, elements are accessed sequentially.

Test: Arrays - Question 8

How do you initialize an array in C?

Detailed Solution: Question 8

This is the syntax to initialize an array in C.

Test: Arrays - Question 9

Which of the following is the correct way to declare a multidimensional array in Java?

Detailed Solution: Question 9

The syntax to declare multidimensional array in java is either int[][] arr; or int arr[][];

Test: Arrays - Question 10

What is the output of the following Java code?

public class array
{
    public static void main(String args[])
    {
        int []arr = {1,2,3,4,5};
        System.out.println(arr[5]);
    }
}

Detailed Solution: Question 10

Trying to access an element beyond the limits of an array gives ArrayIndexOutOfBoundsException.

56 docs|215 tests
Information about Test: Arrays Page
In this test you can find the Exam questions for Test: Arrays solved & explained in the simplest way possible. Besides giving Questions and answers for Test: Arrays, EduRev gives you an ample number of Online tests for practice
Download as PDF