21 Unique MCQ Questions on JAVA/COMPUTER APPLICATIONS ICSE X LEVEL: EASY

 Unique MCQ Questions on ARRAYS CHAPTER FROM JAVA/COMPUTER APPLICATIONS ICSE X, LEVEL: EASY 


1.  What is an array in Java? 

     A. Collection of characters

     B. Collection of variables of the same type

     C. Collection of integers and characters

     D. Collection of different data types


2.  In Java, the index of the first element in an array is: 

     A. 1

     B. 0

     C.  1

     D. 10


3.  Which of the following is the correct way to declare an array in Java? 

     A.  int[] array = new int[5]; 

     B.  array int[] = new int[5]; 

     C.  int[] array = {1, 2, 3, 4, 5}; 

     D.  array = {1, 2, 3, 4, 5}; 


4.  What is the size of the array declared as  int[] numbers = new int[8]; ? 

     A. 8

     B. 16

     C. 32

     D. 64


5.  How do you access the third element of an array in Java? 

     A.  array[2] 

     B.  array(3) 

     C.  array.3 

     D.  array.get(2) 



6.  What is the purpose of the length of an array in Java? 

     A. To specify the data type

     B. To allocate memory

     C. To determine the length of the array

     D. To declare the array


7.  Which of the following loops is commonly used for traversing an array in Java? 

     A.  for 

     B.  while 

     C.  do while 

     D.  if 


8.  What will be the output of the following Java code snippet? 


   int[] values = {3, 7, 2, 8, 5};

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

      

     A. 3

     B. 7

     C. 2

     D. 8


9.  In Java, how do you find the number of elements in an array? 

     A.  array.size() 

     B.  array.length 

     C.  array.size 

     D.  array.length() 


10.  What is the correct syntax to initialize an array with values in Java? 

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

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

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

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



11.  Which of the following class is used to input elements into an array in Java? 

      A.  input 

      B.  Scanner 

      C.  get 

      D.  scanf 


12.  What will be the output of the following Java code snippet? 


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

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

       

      A. 1

      B. 2

      C. 3

      D. Error


13.  What is the correct way to declare a 2D array in Java? 

      A.  int[][] array2D; 

      B.  array2D(3, 3); 

      C.  int[3][3] array2D; 

      D.  array2D{3, 3}; 


14.  In a 2D array, how do you access the element in the second row and third column in Java? 

      A.  array[2][3] 

      B.  array(2, 3) 

      C.  array[1][2] 

      D.  array(1, 2) 


15.  What is the maximum number of dimensions an array can have in Java? 

      A. 1

      B. 2

      C. 3

      D. There is no limit


16.  Which of the following is true regarding the deletion of an array in Java? 

      A. Arrays cannot be deleted

      B. Use the  delete  keyword

      C. Use the  free()  function

      D. Arrays are automatically deleted


17.  What is the output of the following Java code snippet? 


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

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

       

      A. 1

      B. 2

      C. 3

      D. Error



18.  Which library is used in Java for dynamic memory allocation functions like  new  and  delete ? 

      A.  java.util 

      B.  java.memory 

      C.  java.malloc 

      D. No specific library


19.  What is the purpose of the  length  property in Java arrays? 

      A. Returns the size of an array

      B. Returns the size of a variable

      C. Returns the size of the array in bytes

      D. Returns the size of the array in elements


20.  What does the following Java code do? 

       java

    int[] arr = new int[5];

       

      A. Declares an array

      B. Allocates memory for an array

      C. Deallocates memory for an array

      D. Copies elements to another array




21.  What will be the output of the following Java code snippet? 


    int[] arr = {5, 10, 15, 20, 25};

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

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

    }

       

      A. 5 10 15 20 25

      B. 25 20 15 10 5

      C. 5 6 7 8 9

      D. 0 0 0 0 0












 Answers: 

1. B, 2. B, 3. A, 4. A, 5. A, 6. C, 7. A, 8. C, 9. B, 10. A, 11. B, 12. D, 13. A, 14. A, 15. D, 16. A, 17. B, 18. D, 19. D, 20. B,  21. A, 

Comments