Skip to main content

Array — Part 1 MCQs with Explanations

Practice high-yield Programming & Software Development MCQs on Array — Part 1 with worked academic solutions for FPSC, PPSC, NTS, NITB, PTS.

Questions
40
Difficulty Level
Exam-Level
Target Exams
FPSC, PPSC, NTS...
Estimated Time
48 mins
Exam-Level FPSC PPSC NTS NITB PTS
Verified for Commission Syllabus • Oct 14, 2026
40

Verified Practice Questions

Interactive test mode with detailed academic worked solutions

Live Progress | 0/40 answered
✓ 0 correct ✗ 0 wrong 0% score
Question 1 of 40
★ FPSC ★ PPSC

How do you declare a one-dimensional array in Java?

Question 2 of 40
★ FPSC ★ PPSC

Which of the following is a valid declaration and initialization of a String array in Java?

Question 3 of 40
★ FPSC ★ PPSC

Which of the following statements is true about arrays in Java?

Question 4 of 40
★ FPSC ★ PPSC

In Java arrays are

Question 5 of 40
★ FPSC ★ PPSC

Which one of the following is a valid statement?

Question 6 of 40
★ FPSC ★ PPSC

What is the result of compiling and running the following code? public class Test{ public static void main(String[] args){ int[] a = new int[0]; System.out.print(a.length); } }

Question 7 of 40
★ FPSC ★ PPSC

What will be the output? public class Test{ public static void main(String[] args){ int[] x = new int[3]; System.out.println("x[0] is " + x[0]); } }

Question 8 of 40
★ FPSC ★ PPSC

What is the output of the following code? public class Test{ public static void main(String args[]){ double[] myList = {1, 5, 5, 5, 5, 1}; double max = myList[0]; int indexOfMax = 0; for(int i = 1; i < myList.length; i++){ if(myList[i] > max){ max = myList[i]; indexOfMax = i; } } System.out.println(indexOfMax); } }

Question 9 of 40
★ FPSC ★ PPSC

What is output of the following code: public class Test{ public static void main(String[] args){ int[] x = {120, 200, 016 }; for(int i = 0; i < x.length; i++) System.out.print(x[i] + " "); } }

Question 10 of 40
★ FPSC ★ PPSC

What will be the output? public class Test{ public static void main(String[] args){ int[] a = new int[4]; a[1] = 1; a = new int[2]; System.out.println("a[1] is " + a[1]); } }

Question 11 of 40
★ FPSC ★ PPSC

What would be the result of attempting to compile and run the following code? public class HelloWorld{ public static void main(String[] args){ double[] x = new double[]{1, 2, 3}; System.out.println("Value is " + x[1]); } }

Question 12 of 40
★ FPSC ★ PPSC

Which will legally declare, construct, and initialize an array?

Question 13 of 40
★ FPSC ★ PPSC

What will be the output of the program? public class Test{ public static void main(String [] args){ String s1 = args[1]; String s2 = args[2]; String s3 = args[3]; String s4 = args[4]; System.out.print(" args[2] = " + s2); } } and the command-line invocation is C:Java> java Test 1 2 3 4

Question 14 of 40
★ FPSC ★ PPSC

What is the value of a[1] after the following code is executed? int[] a = {0, 2, 4, 1, 3}; for(int i = 0; i < a.length; i++) a[i] = a[(a[i] + 3) % a.length];

Question 15 of 40
★ FPSC ★ PPSC

Predict the output: public class Test{ public static void main(String... args){ int[] index = new int[5]; System.out.println(index instanceof Object); } }

Question 16 of 40
★ FPSC ★ PPSC

In Java, arrays are objects of which class?

Question 17 of 40
★ FPSC ★ PPSC

What is the default initial value of numeric elements in an array of type int in Java?

Question 18 of 40
★ FPSC ★ PPSC

What is the correct way to initialize a two-dimensional array in Java?

Question 19 of 40
★ FPSC ★ PPSC

What does the length attribute of an array in Java represent?

Question 20 of 40
★ FPSC ★ PPSC

How do you access an element in a one-dimensional array named myArray at index 3 in Java?

Question 21 of 40
★ FPSC ★ PPSC

What happens if you try to access an array element at an index that is out of bounds in Java?

Question 22 of 40
★ FPSC ★ PPSC

Which method is used to find the length of an array in Java?

Question 23 of 40
★ FPSC ★ PPSC

What is the highest index of an array with 10 elements in Java?

Question 24 of 40
★ FPSC ★ PPSC

How do you find the number of rows in a two-dimensional array named matrix in Java?

Question 25 of 40
★ FPSC ★ PPSC

What is the default initial value of elements in an array of type boolean in Java?

Question 26 of 40
★ FPSC ★ PPSC

What is the correct way to copy the elements of one array to another in Java?

Question 27 of 40
★ FPSC ★ PPSC

How do you declare and initialize an array of integers with 5 elements in Java?

Question 28 of 40
★ FPSC ★ PPSC

How do you declare a dynamic array (ArrayList) of integers in Java?

Question 29 of 40
★ FPSC ★ PPSC

What is the purpose of the System.arraycopy() method in Java?

Question 30 of 40
★ FPSC ★ PPSC

Which of the following is true about the size of an ArrayList in Java?

Question 31 of 40
★ FPSC ★ PPSC

In Java, how do you remove an element at a specific index from an ArrayList named list?

Question 32 of 40
★ FPSC ★ PPSC

How do you check if an element exists in an array or ArrayList in Java?

Question 33 of 40
★ FPSC ★ PPSC

What is the purpose of the Arrays.sort() method in Java?

Question 34 of 40
★ FPSC ★ PPSC

How do you find the index of an element in an ArrayList named list in Java?

Question 35 of 40
★ FPSC ★ PPSC

Which method is used to add an element to the end of an ArrayList in Java?

Question 36 of 40
★ FPSC ★ PPSC

What happens when you try to access an element at an index that is out of bounds in an ArrayList in Java?

Question 37 of 40
★ FPSC ★ PPSC

Which method is used to remove all elements from an ArrayList in Java?

Question 38 of 40
★ FPSC ★ PPSC

In Java, how do you find the maximum element in an array?

Question 39 of 40
★ FPSC ★ PPSC

Which of the following statements is true about ArrayLists in Java?

Question 40 of 40
★ FPSC ★ PPSC

How do you declare a multi-dimensional array in Java?

✓ Link copied to clipboard
Continue Your Practice

Advance Html — Part 1

Master the next curriculum module with 40 exam-standard MCQs.

Next Practice Set →

💡 Examiner's Advisory for Programming & Software Development

In competitive commission exams (FPSC, PPSC, KPPSC, SPSC, CSS, PMS), questions are frequently phrased with distractor options designed to catch rote learners. Whenever you answer an MCQ, read the Detailed Academic Explanation and Conceptual Anchor to understand why the remaining options are incorrect.

More Modules in Programming & Software Development

View All →
📚

Study Guides

Topic summaries and syllabus breakdown

Explore Guides →
🎯

Complete Library

Search through 78,000+ verified MCQs

Browse Library →
📱

Mobile App

Offline mock tests and instant bookmarks

Get Mobile App →