0% found this document useful (0 votes)
28 views

Course:: Easy-To-Follow Java Programming

This document contains a quiz with questions about Java arrays. The questions cover topics like: - The number of elements, indices, and default values in arrays of different types - How to set the value of a specific element in an array - Which method returns the size of an array - How 2D arrays are structured in Java The questions are followed by the answers in a solutions section.

Uploaded by

Fuad
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views

Course:: Easy-To-Follow Java Programming

This document contains a quiz with questions about Java arrays. The questions cover topics like: - The number of elements, indices, and default values in arrays of different types - How to set the value of a specific element in an array - Which method returns the size of an array - How 2D arrays are structured in Java The questions are followed by the answers in a solutions section.

Uploaded by

Fuad
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Course: Easy-to-follow Java programming

The quiz questions


Answer the questions below to review what you have learned in Video 5. You will
find the right answers after the questions in the solution section.

1. Fill in the gaps in the following paragraph.

If we create an array with the following statement:


double[] arr = new double[10];

then this array will have elements. The type of every element will be ,
the minimal index in the array is , and the maximal is .
The value of the elements in the array is: .

If we create a second array with:


int[] other = {3, 4, 5, 6, 7};

it will have elements. The index of the element valued 3 is . The value of the
element whose index is 3 is . The type of the indices and elements are both .

2. Write a simple piece of code to satisfy the needs.

How can you set the element with index 2 to 6 in the following array?
int[] numbers = new int[4];

Duckademy IT courses – www.duckademy.com


3. Which of the following provides the size of an array?

numbers.length

numbers.size

numbers.num_of_elements()

numbers.length()

numbers.size()

numbers.Length

count(numbers)

4. Which one of the following figures describes Java 2 dimensional arrays


correctly?

Duckademy IT courses – www.duckademy.com


----------------------------------------------------------------------------------------------------------------

The answers

1. Fill in the gaps in the following paragraph.

If we create an array with the following statement:


double[] arr = new double[10];

then this array will have 10 elements. The type of every element will be double ,
the minimal index in the array is 0 , and the maximal is 9 .
The value of the elements in the array is: 0.0 .

If we create a second array with:


int[] other = {3, 4, 5, 6, 7};

it will have 5 elements. The index of the element valued 3 is 0 . The value of the
element whose index is 3 is 6 . The type of the indices and elements are both int .

2. Write a simple piece of code to satisfy the needs.

How can you set the element with index 2 to 6 in the following array?
int[] numbers = new int[4];

numbers[2] = 6;

3. Which of the following provides the size of an array?

X numbers.length

numbers.size

numbers.num_of_elements()

numbers.length()

numbers.size()

numbers.Length

count(numbers)

Duckademy IT courses – www.duckademy.com


4. Which one of the following figures describes Java 2 dimensional arrays
correctly?

Duckademy IT courses – www.duckademy.com

You might also like