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.
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
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
- Not categorized 0%
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- Current
- Review / Skip
- Answered
- Correct
- Incorrect
-
Question 1 of 15
1. Question
Which of the following is not a syntax of a Single dimensional Array?
CorrectIncorrect -
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]);
}
}
}
CorrectIncorrect -
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]);
}
}
}
CorrectIncorrect -
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]+” “);
}
}
}
}
CorrectIncorrect -
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]);
}
}
}
CorrectIncorrect -
Question 6 of 15
6. Question
Which loop / statement in Java is used to display elements in an array ?
CorrectIncorrect -
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);
}
CorrectIncorrect -
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?
CorrectIncorrect -
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]);
}
}
}
CorrectIncorrect -
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]);
}
}
CorrectIncorrect -
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] );
}
}
}
}
CorrectIncorrect -
Question 12 of 15
12. Question
int size[] = { };
CorrectIncorrect -
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]);
}
}
CorrectIncorrect -
Question 14 of 15
14. Question
What is the name of the method where an array is declared without mentioning size of the array ?
CorrectIncorrect -
Question 15 of 15
15. Question
class ArraySize {
public static void main ( String args [ ] )
{
int marks[ ] , a ;
a = 5;
marks = new marks[a];
}
}
CorrectIncorrect
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!
