Site icon DataFlair

Quiz on Java Array

quiz on java array

Get Job-ready: Java Course with 45+ Real-time Projects! - Learn Java

Arrays are the building blocks of data storage in Java. They allow you to efficiently group and manage collections of elements that all share the same data type.

Whether you’re a seasoned Java developer or a complete programming novice, testing your knowledge of arrays is a fantastic way to solidify your understanding of this core concept.

This comprehensive Java array quiz is specifically designed to assess your grasp of single-dimensional array syntax, making it the perfect tool to sharpen your programming skills.

Dive right in, challenge yourself with the questions, and identify areas where you can further strengthen your knowledge! By tackling these challenges, you’ll gain valuable insights into how effectively you can work with single-dimensional arrays in Java. Let’s test your knowledge.

Time limit: 0

Quiz Summary

0 of 15 Questions completed

Questions:

Information

You have already completed the quiz before. Hence you can not start it again.

Quiz is loading…

You must sign in or sign up to start the quiz.

You must first complete the following:

Results

Quiz complete. Results are being recorded.

Results

0 of 15 Questions answered correctly

Your time:

Time has elapsed

You have reached 0 of 0 point(s), (0)

Earned Point(s): 0 of 0, (0)
0 Essay(s) Pending (Possible Point(s): 0)

Categories

  1. Not categorized 0%
  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  1. Current
  2. Review / Skip
  3. Answered
  4. Correct
  5. Incorrect
  1. Question 1 of 15
    1. Question

    Which of the following is not a syntax of a Single dimensional Array?

    Correct
    Incorrect
  2. Question 2 of 15
    2. Question

     class ArraySample {

    Public static void main ( String args [ ] )

    {

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

    for( i = 0; i < a.length; i++ )

    {

    system.out.println(rollno[i]);

    }

    }

    }

    Correct
    Incorrect
  3. Question 3 of 15
    3. Question

    class ArrayInitialization {

    public static void main ( String args [ ] )

    {

    int marks[ ] = new int [4];

    marks[0] = 65;

    marks[1] = 70;

    marks[2] = 74;

    marks[3] = 90;

    marks[4] = 87;

    for(i=0; i<marks.length ; i++)

    {

    system.out.println(marks[i]);

    }

    }

    }

    Correct
    Incorrect
  4. Question 4 of 15
    4. Question

     class JaggedArray {

    public static void main ( String args [ ] )

    {

     int arr[][] = new int[3][];  

         arr[0] = new int[1];  

    arr[1] = new int[2];  

                arr[2] = new int[3];  

    int number = 0;

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

                for(int y=0; y<arr[x].length; j++)  

                arr[x][y] = number++;

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

    {  

                for (int j=0; y<arr[x].length; y++)

    {  

                System.out.print(arr[x][y]+” “);  

                }

    }

    }

    }

    Correct
    Incorrect
  5. Question 5 of 15
    5. Question

    class Exception {   

    public static void main ( String args [ ] )

    {

    int arr[ ] = new int[-2];

    arr[0] = 1;

    arr[1] = 2;

    arr[2] = 3;

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

    {

    system.out.println(arr[i]);

    }

    }

    }

    Correct
    Incorrect
  6. Question 6 of 15
    6. Question

    Which loop / statement in Java is used to display elements in an array ?

    Correct
    Incorrect
  7. Question 7 of 15
    7. Question

    class ArrayMethod {

        void get() {

    int disp=arr[0];  

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

     if(disp>arr[i])  

     disp=arr[i];   

    System.out.println(disp);  

    }

    public static void main ( String args [ ] )

    {

    int a[]={ ‘a’ , ‘b’ , ‘c’ , ‘d’ };

    disp(a);

    }

    Correct
    Incorrect
  8. Question 8 of 15
    8. Question

    Which of the following is the syntax to get the length of an array for a single dimensional array?

    Correct
    Incorrect
  9. Question 9 of 15
    9. Question

    class  ArrayElements {

    public static void main ( String args [ ] )

    {

    String coding[ ] = { “C” , “C++” , “Java”};

    coding[0] = “Python”;

    for( i = 0 ; i <coding.length; i++)

    {

    system.out.println(coding[i]);

    }

    }

    }

    Correct
    Incorrect
  10. Question 10 of 15
    10. Question

     class Traversal {

    public static void main ( String args [ ] )

    {

    String names [ ] = { “DataFlair” , “Godaddy” , “Grandma’s Kitchen” , “Infogates” };

    system.out.println(names[0]);

    }

    }

    Correct
    Incorrect
  11. Question 11 of 15
    11. Question

     class Multidimensional {

    public static void main ( String args [ ] )

    {

    int array[] [] = { {100,200} , {300,400} };

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

    {

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

    {

    system.out.println( arr [i] [j] );

    }

    }

    }

    }

    Correct
    Incorrect
  12. Question 12 of 15
    12. Question

    int size[] = {  };

    Correct
    Incorrect
  13. Question 13 of 15
    13. Question

    class Exception {

    public static void main ( String args [ ] )

    {

    char arr[5] = { ‘a’ , ‘b’ , ‘c’ , ‘d’ , ‘e’ }

    system.out.println(arr[3]);

    }

    }

    Correct
    Incorrect
  14. Question 14 of 15
    14. Question

    What is the name of the method where an array is declared without mentioning size of the array ?

    Correct
    Incorrect
  15. Question 15 of 15
    15. Question

    class ArraySize {

    public static void main ( String args [ ] )

    {

    int marks[ ] , a ;

    a = 5;

    marks = new marks[a];

    }

    }

    Correct
    Incorrect

Summary:

This Java array quiz tested your grasp of single-dimensional array syntax, a fundamental concept in Java programming. It’s designed to be a springboard for further learning, regardless of your experience level.

By tackling the questions, you gained valuable insights into your strengths and weaknesses. Even if you encounter challenges, that’s a great opportunity to grow! Explore the provided resources, delve deeper into arrays through online courses and tutorials, and consider practising with problem sets.

Remember, consistent learning is key to mastering Java arrays and becoming a proficient programmer. This quiz is just the beginning of your exciting Java adventure!

 

Exit mobile version