Courseiva
Knowledge + Practice
CertificationsVendorsCareer RoadmapsLabs & ToolsStudy GuidesGlossaryPractice Questions
C
Courseiva

Free IT certification practice questions with explained answers for CCNA, CompTIA, AWS, Azure, Google Cloud, and more.

Certification Practice Questions

CCNA practice questionsSecurity+ SY0-701 practice questionsAWS SAA-C03 practice questionsAZ-104 practice questionsAZ-900 practice questionsCLF-C02 practice questionsA+ Core 1 practice questionsGoogle Cloud ACE practice questionsCySA+ CS0-003 practice questionsNetwork+ N10-009 practice questions
View all certifications →

Product

CertificationsCertification PathsExam TopicsPractice TestsExam Dumps vs Practice TestsStudy HubComparisons

Company

AboutContactEditorial PolicyQuestion Writing PolicyTrust Center

Legal

Privacy PolicyTerms of Service

Courseiva is a free IT certification practice platform offering original exam-style practice questions, detailed explanations, topic-based practice, mock exams, readiness tracking, and study analytics for Cisco, CompTIA, Microsoft, AWS, and other technology certifications.

© 2026 Courseiva. Courseiva is operated by JTNetSolutions Ltd. All rights reserved.

Courseiva is an independent certification practice platform and is not affiliated with, endorsed by, or sponsored by Cisco, Microsoft, AWS, CompTIA, Google, ISC2, ISACA, or any other certification vendor. Vendor names and certification marks are used only to identify the exams learners are preparing for.

← Arrays and Methods practice sets

1Z0-811 Arrays and Methods • Complete Question Bank

1Z0-811 Arrays and Methods — All Questions With Answers

Complete 1Z0-811 Arrays and Methods question bank — all 0 questions with answers and detailed explanations.

72
Questions
Free
No signup
Certifications/1Z0-811/Practice Test/Arrays and Methods/All Questions
Question 1mediummultiple choice
Read the full NAT/PAT explanation →

A developer writes a method that takes an int array and returns the sum of its elements. The method signature is: 'public static int sumArray(int[] arr)'. Which statement correctly calls this method?

Question 2easymultiple choice
Read the full Arrays and Methods explanation →

Given the code snippet: 'int[] nums = {10, 20, 30, 40}; int sum = 0; for (int i = 0; i < nums.length; i++) { sum += nums[i]; }'. What is the value of sum after execution?

Question 3hardmultiple choice
Read the full Arrays and Methods explanation →

A method 'public static void modifyArray(int[] arr) { arr[0] = 99; }' is called with 'int[] myArray = {1,2,3}; modifyArray(myArray); System.out.println(myArray[0]);'. What is the output?

Question 4easymultiple choice
Read the full Arrays and Methods explanation →

Which of the following correctly declares and initializes an array of strings with the elements "A", "B", and "C"?

Question 5mediummultiple choice
Read the full Arrays and Methods explanation →

A method 'public static int findMax(int[] numbers)' returns the maximum value in the array. Which implementation correctly handles an empty array by returning 0?

Question 6hardmultiple choice
Read the full Arrays and Methods explanation →

Given the method: 'public static void swapFirstTwo(int[] arr) { int temp = arr[0]; arr[0] = arr[1]; arr[1] = temp; }'. What is the effect of calling this method with an array of length 1?

Question 7mediummultiple choice
Read the full NAT/PAT explanation →

A developer writes a method that accepts a variable number of int arguments and returns their product. Which method signature correctly implements this?

Question 8easymultiple choice
Read the full Arrays and Methods explanation →

What is the output of the following code? int[] a = {1,2,3}; int[] b = a; b[0] = 99; System.out.println(a[0]);

Question 9hardmultiple choice
Read the full Arrays and Methods explanation →

Which of the following correctly describes the effect of the method call 'Arrays.sort(myArray)' on an array of objects that do not implement Comparable?

Question 10easymulti select
Read the full Arrays and Methods explanation →

Which TWO statements are true about method overloading in Java?

Question 11mediummulti select
Read the full Arrays and Methods explanation →

Which TWO statements are true about passing arrays to methods in Java?

Question 12hardmulti select
Read the full NAT/PAT explanation →

Which THREE statements are correct about the 'main' method signature in Java?

Question 13mediummultiple choice
Read the full NAT/PAT explanation →

A team is developing a Java application for an online store. The application has a class 'Inventory' that maintains an array of 'Product' objects. The method 'public void addProduct(Product p)' is intended to add a product to the array. The current implementation uses a fixed-size array of length 100. However, the business has grown, and the array may exceed its capacity. The team needs a solution that allows dynamic resizing without changing the method signature. Which approach should the team take?

Question 14hardmultiple choice
Read the full Arrays and Methods explanation →

A developer is working on a Java program that processes sensor data. The data is stored in a 2D array 'double[][] readings', where each row represents a sensor and each column a time interval. The method 'public static double[] averagePerSensor(double[][] data)' should compute the average reading for each sensor (row) and return a 1D array of averages. The developer writes the following implementation: 'double[] result = new double[data.length]; for (int i = 0; i < data.length; i++) { double sum = 0; for (int j = 0; j < data[i].length; j++) { sum += data[i][j]; } result[i] = sum / data[i].length; } return result;'. However, the program sometimes throws a NullPointerException. What is the most likely cause?

Question 15mediumdrag order
Read the full Arrays and Methods explanation →

Arrange the steps to create an object from a class in Java in the correct order.

Drag steps to the numbered slots on the right, or tap a step then tap a slot.

Steps
Order
1Step 1
2Step 2
3Step 3
4Step 4
5Step 5
Question 16mediummatching
Read the full Arrays and Methods explanation →

Match each control flow statement to its purpose.

Drag a concept onto its matching description — or click a concept then click the description.

Concepts
Matches

Executes a block based on a boolean condition

Selects one of many code blocks based on a value

Iterates a fixed number of times

Repeats while a condition is true

Executes at least once then repeats while condition true

Question 17easymultiple choice
Read the full Arrays and Methods explanation →

A banking application stores daily transaction amounts in an array. Which declaration correctly creates an array of 31 double values?

Question 18easymultiple choice
Read the full Arrays and Methods explanation →

A method is designed to compute the average of an array of test scores. What should the method return if the array is empty (length 0)?

Question 19easymultiple choice
Read the full Arrays and Methods explanation →

Given the array declaration: int[] data = new int[5];, what is the value of data[2] after initialization?

Question 20mediummultiple choice
Read the full Arrays and Methods explanation →

Consider a method that takes an int array and modifies it: public static void doubleArray(int[] arr) { for (int i = 0; i < arr.length; i++) { arr[i] *= 2; } }. What is the output of: int[] nums = {1, 2, 3}; doubleArray(nums); System.out.println(nums[1]);

Question 21mediummultiple choice
Read the full Arrays and Methods explanation →

A developer writes two methods: public void process(int a) { ... } and public void process(double a) { ... }. Which method is called by process(10)?

Question 22mediummultiple choice
Read the full Arrays and Methods explanation →

An application requires storing a fixed set of 12 monthly temperatures. Which initialization is most appropriate?

Question 23hardmultiple choice
Read the full Arrays and Methods explanation →

A developer needs to search an unsorted array of 100,000 customer IDs (int) for a specific ID. Which approach is most efficient for a single search?

Question 24hardmultiple choice
Read the full Arrays and Methods explanation →

A method is declared as: public static int[] generateSequence(int n) { ... }. Which return statement is valid inside this method?

Question 25hardmultiple choice
Read the full Arrays and Methods explanation →

A programmer writes code to transpose a 2D array (matrix). Given: int[][] matrix = {{1,2},{3,4}}; int[][] result = new int[2][2]; for (int i=0; i<2; i++) for (int j=0; j<2; j++) result[j][i] = matrix[i][j]; What is the value of result[1][0]?

Question 26easymulti select
Read the full Arrays and Methods explanation →

Which TWO statements are correct about array declaration and initialization in Java?

Question 27mediummulti select
Read the full Arrays and Methods explanation →

Which TWO are valid ways to pass an array to a method in Java?

Question 28hardmulti select
Read the full Arrays and Methods explanation →

Which THREE statements are true about method overloading in Java?

Question 29easymultiple choice
Read the full Arrays and Methods explanation →

What is the output when the main method is executed?

Exhibit

Refer to the exhibit.
public class Calculator {
    public static int add(int a, int b) {
        return a + b;
    }
    public static double add(double a, double b) {
        return a + b;
    }
    public static void main(String[] args) {
        double result = add(5, 10);
        System.out.println(result);
    }
}
Question 30mediummultiple choice
Read the full Arrays and Methods explanation →

What is printed when the main method runs?

Exhibit

Refer to the exhibit.
public class ArrayTest {
    public static void main(String[] args) {
        int[] arr = new int[3];
        arr[0] = 5;
        arr[1] = 10;
        arr[2] = 15;
        modify(arr);
        System.out.println(arr[0]);
    }
    public static void modify(int[] a) {
        a = new int[3];
        a[0] = 100;
    }
}
Question 31easymultiple choice
Read the full NAT/PAT explanation →

A method is needed to return a new array where each element is doubled. Which method signature correctly accomplishes this?

Question 32easymultiple choice
Read the full Arrays and Methods explanation →

Given an array arr of length 5, which code snippet correctly creates a copy using System.arraycopy?

Question 33easymultiple choice
Read the full Arrays and Methods explanation →

A method is declared as 'public void printElements(int... numbers)'. Which invocation will cause a compilation error?

Question 34mediummultiple choice
Read the full Arrays and Methods explanation →

A method 'public static void sort(int[] arr)' sorts the array in place. After calling 'sort(data)', the original array 'data' is changed. Which design issue does this demonstrate?

Question 35mediummultiple choice
Read the full Arrays and Methods explanation →

A method 'public static double average(int[] numbers) { int sum = 0; for (int i = 0; i < numbers.length; i++) sum += numbers[i]; return sum / numbers.length; }' is called with array {10, 20, 30}. What change is needed to return the correct average?

Question 36mediummultiple choice
Read the full Arrays and Methods explanation →

Which method invocation is ambiguous given these overloaded methods? public void process(int[] a) and public void process(int... a)

Question 37hardmultiple choice
Read the full Arrays and Methods explanation →

A method 'public static int[] generate() { int[] result = new int[10]; for (int i = 0; i < result.length; i++) result[i] = i * 2; return result; }' is defined. Which statement correctly calls this method and stores the result?

Question 38hardmultiple choice
Read the full Arrays and Methods explanation →

Given 'int[] source = {1,2,3,4,5};' and 'int[] dest = new int[3];' which code correctly copies the first three elements from source to dest using System.arraycopy?

Question 39hardmultiple choice
Read the full Arrays and Methods explanation →

A method 'public static void modify(int[][] matrix) { matrix[0][0] = 99; }' is called with 'int[][] values = {{1,2},{3,4}}; modify(values);'. What is the value of values[0][0] after the call?

Question 40easymulti select
Read the full Arrays and Methods explanation →

Which TWO are valid ways to declare and initialize an array of Strings?

Question 41mediummulti select
Read the full Arrays and Methods explanation →

Which TWO methods correctly modify the passed array in place?

Question 42hardmulti select
Read the full Arrays and Methods explanation →

Which THREE statements are true about passing arrays to methods in Java?

Question 43easymultiple choice
Read the full Arrays and Methods explanation →

Refer to the exhibit. What is the output?

Exhibit

public class Example {
    public static void main(String[] args) {
        int[] nums = {1, 2, 3};
        int[] result = process(nums);
        System.out.println(result[0]);
    }
    public static int[] process(int[] input) {
        int[] output = new int[input.length];
        for (int i = 0; i < input.length; i++) {
            output[i] = input[i] * 2;
        }
        return output;
    }
}
Question 44mediummultiple choice
Read the full Arrays and Methods explanation →

Refer to the exhibit. Which overloaded methods cause this compilation error?

Exhibit

javac Test.java
Test.java:5: error: reference to print is ambiguous
        print(null);
        ^
  both method print(String[]) in Test and method print(String...) in Test match
Question 45hardmultiple choice
Read the full Arrays and Methods explanation →

Refer to the exhibit. The code at line 6 of ArrayExample.java is: int[] arr = {10, 20, 30, 40, 50}; int sum = 0; for (int i = 0; i <= arr.length; i++) sum += arr[i]; Which change fixes the exception?

Exhibit

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Index 5 out of bounds for length 5
    at ArrayExample.main(ArrayExample.java:6)
Question 46easymultiple choice
Read the full Arrays and Methods explanation →

Consider the following code that attempts to swap the first two elements of an array using a method:

public static void swap(int[] arr) {
    int temp = arr[0];

arr[0] = arr[1]; arr[1] = temp;

}

public static void main(String[] args) {

int[] values = {1, 2}; swap(values); System.out.println(values[0] + " " + values[1]);

}

What is the output?

Question 47hardmultiple choice
Read the full Arrays and Methods explanation →

A developer implements a method to check if a number exists in an array using binary search. The array is not sorted. What will happen?

Question 48hardmultiple choice
Read the full Arrays and Methods explanation →

Which approach does NOT create a new array that is independent of the original?

Question 49easymultiple choice
Read the full NAT/PAT explanation →

A method is designed to reverse an array of integers. The method signature is: public static void reverse(int[] arr). The method correctly reverses the array. Which statement is true about the method?

Question 50mediummultiple choice
Read the full NAT/PAT explanation →

A developer writes a method that takes a variable number of integer arguments and returns the maximum. Which method signature is correct?

Question 51mediummultiple choice
Read the full Arrays and Methods explanation →

Consider the following code:

int[] arr = new int[5];

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

arr[i] = i;

}

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

What is the result?

Question 52easymultiple choice
Read the full Arrays and Methods explanation →

A method that calculates the average of an array of doubles is defined as:

public static double average(double[] values) {

double sum = 0;

for (double v : values) sum += v;
    return sum / values.length;
}

Which call is valid?

Question 53mediummultiple choice
Read the full Arrays and Methods explanation →

Given the code:

int[] a = {1, 2, 3}; int[] b = {4, 5}; a = b; b[0] = 99; System.out.println(a[0]);

What is the output?

Question 54hardmultiple choice
Read the full Arrays and Methods explanation →

Given the code:

public class Test {
    public static void change(int[] arr) {

arr = new int[]{10, 20};

}
    public static void main(String[] args) {

int[] arr = {1, 2}; change(arr); System.out.println(arr[0]);

}
}

What is the output?

Question 55easymulti select
Read the full Arrays and Methods explanation →

Which two of the following are valid ways to declare and initialize an array of integers? (Select two.)

Question 56mediummulti select
Read the full Arrays and Methods explanation →

Which three statements about method overloading are true? (Select three.)

Question 57hardmulti select
Read the full Arrays and Methods explanation →

Which two statements about passing arrays to methods are correct? (Select two.)

Question 58easymultiple choice
Read the full Arrays and Methods explanation →

Which of the following is not a valid array variable declaration in Java?

Question 59mediummultiple choice
Read the full Arrays and Methods explanation →

Given the method: public static void modify(int[] data) { data = new int[]{10,20}; } What is the output of: int[] vals = {1,2}; modify(vals); System.out.println(vals[0]);

Question 60hardmultiple choice
Read the full Arrays and Methods explanation →

Which statement about method overloading with array parameters is true?

Question 61mediummultiple choice
Read the full Arrays and Methods explanation →

A developer writes a method that accepts an array and returns the sum of all elements. Which implementation is correct if the array might be null?

Question 62easymultiple choice
Read the full Arrays and Methods explanation →

What is the result of the following code? int[] arr = new int[3]; arr[3] = 5; System.out.println(arr[3]);

Question 63hardmultiple choice
Read the full Arrays and Methods explanation →

A developer wants to sort an array of primitive ints in descending order. Which approach will work without using third-party libraries?

Question 64mediummulti select
Read the full Arrays and Methods explanation →

Which two statements about the Arrays class are true? (Choose two.)

Question 65hardmulti select
Read the full Arrays and Methods explanation →

Which two statements about method parameter passing in Java are true? (Choose two.)

Question 66easymulti select
Read the full Arrays and Methods explanation →

Which three statements about arrays are correct? (Choose three.)

Question 67mediummultiple choice
Read the full Arrays and Methods explanation →

A company manages employee data stored in an array of Employee objects. The HR application frequently needs to find an employee by ID. The current implementation uses a linear search through the array each time. Performance reports indicate that this search is becoming a bottleneck as the company grows. The array is not sorted, and the company does not want to sort it because the order is meaningful for display. The array is large and frequently updated. The development team considers several options to improve the search performance without changing the array order. Which approach should they implement?

Question 68hardmultiple choice
Read the full Arrays and Methods explanation →

A team is developing a financial application that processes large arrays of market data. They have a method that calculates moving averages by copying a subarray for each window. The current implementation creates a new array for each window using System.arraycopy. The application is running slowly in production. The team identifies that the method is called millions of times per minute. The array is large and the window size is small. The garbage collector overhead is high due to many short-lived arrays. Which optimization should they apply to reduce object creation and improve performance?

Question 69easymultiple choice
Read the full Arrays and Methods explanation →

A developer is writing a method to compute the average of an array of scores. The method should handle edge cases gracefully. The scores array may be empty or contain null values if the collection was interrupted. The scores are stored as primitive doubles. Which implementation is safest and follows best practices?

Question 70mediummultiple choice
Read the full Arrays and Methods explanation →

In a login system, the authentication method receives an array of user roles as a String[] and checks if a specific role is present. The array may be large (thousands of roles), and the method is called frequently for each user request. Performance is critical. The array is static and does not change after initialization. Which approach is most efficient for repeated checks?

Question 71hardmultiple choice
Read the full Arrays and Methods explanation →

A company's legacy code has a method that takes an array of integers and returns a new array containing only the positive numbers. The current implementation uses a fixed-size array equal to the input size and counts positive numbers, then copies them, but if many negatives exist, the result array has trailing zeros (which are removed by copying again). This wastes memory and time. The array can be large (up to 1 million elements). The developer wants to improve memory efficiency and runtime without using external libraries. Which approach should they implement?

Question 72easymultiple choice
Read the full Arrays and Methods explanation →

A new developer writes a method that accepts an array and intends to swap the first and last elements. The code is: public static void swapEnds(int[] arr) { int temp = arr[0]; arr[0] = arr[arr.length-1]; arr[arr.length-1] = temp; } What is a potential issue with this method if the array is empty?

Practice tests

Scored 10-question sessions with instant feedback and explanations.

1Z0-811 Practice Test 1 — 10 Questions→1Z0-811 Practice Test 2 — 10 Questions→1Z0-811 Practice Test 3 — 10 Questions→1Z0-811 Practice Test 4 — 10 Questions→1Z0-811 Practice Test 5 — 10 Questions→1Z0-811 Practice Exam 1 — 20 Questions→1Z0-811 Practice Exam 2 — 20 Questions→1Z0-811 Practice Exam 3 — 20 Questions→1Z0-811 Practice Exam 4 — 20 Questions→Free 1Z0-811 Practice Test 1 — 30 Questions→Free 1Z0-811 Practice Test 2 — 30 Questions→Free 1Z0-811 Practice Test 3 — 30 Questions→1Z0-811 Practice Questions 1 — 50 Questions→1Z0-811 Practice Questions 2 — 50 Questions→1Z0-811 Exam Simulation 1 — 100 Questions→

Practice by domain

Each domain maps to a weighted exam section. Focus on the domain where you are weakest.

What is JavaJava Basics and SyntaxPrimitives, Strings and OperatorsControl Flow and LoopsArrays and MethodsObject-Oriented ProgrammingException Handling and Development Tools

Practice by scenario

Filter questions by type — troubleshooting, exhibit, drag-and-drop, PBQ, ACLs, OSPF, and more.

Browse scenarios→

Continue studying

All Arrays and Methods setsAll Arrays and Methods questions1Z0-811 Practice Hub