
AP CSA - Unit 6 - Arrays
Authored by Arasaka Teacher
English
9th - 12th Grade
Used 8+ times

AI Actions
Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...
Content View
Student View
17 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
3 mins • 1 pt
Arrays are immutable. Immutable means:
dynamic
Answer explanation
In computer science, "immutable" means something that can't be changed after it's made. Once created, its value or state stays the same always. For example, in Java, a String is immutable. If you make a String with certain text, you can't change that text later. You need to make a new String for a different text.
2.
MULTIPLE CHOICE QUESTION
3 mins • 1 pt
Which of the following is the correct way to initialize an array in Java?
I. int[] num = new int[3];
II. int[] num = new array [1,2,3];
III. int[] num = {1,2,3};
I only
II only
III only
I and II
I and III
3.
MULTIPLE CHOICE QUESTION
3 mins • 1 pt
Which of the following is the correct way to initialize an array in Java?
I. String [] str = new String[3];
II. String str [ ] = {"hi","hello"};
III. String [] str = {'1','2','3'};
I only
II only
III only
I and II
I and III
Answer explanation
Though the syntax looks a little strange, the code in line II still works correctly.
4.
MULTIPLE CHOICE QUESTION
3 mins • 1 pt
Consider the following code segment:
int[] num = new int[5];
System.out.println(num[3]);
What is the output of the above code?
3
ArrayIndexOutOfBounds
Compile-time Error
Answer explanation
When an array is created, but is not assigned any values, it is automatically filled with zeroes.
Therefore,
int[] num = new int[5];
Will look like this:
{0, 0, 0, 0, 0}
5.
MULTIPLE CHOICE QUESTION
3 mins • 1 pt
Consider the following code segment:
double[] num = new double[5];
System.out.println(num[3]);
What is the output of the above code?
3.0
null
ArrayIndexOutOfBounds
0.0
Compile-time Error
Answer explanation
When an array is created, but is not assigned any values, it is automatically filled with zeroes.
Therefore,
int[] num = new int[5];
Will look like this:
{0, 0, 0, 0, 0}
6.
MULTIPLE CHOICE QUESTION
3 mins • 1 pt
Consider the following code segment:
String[] str= new String[5];
System.out.println(str[3]);
What is the output of the above code?
3
ArrayIndexOutOfBounds
Compile-time Error
Answer explanation
When an int array is declared but not initialized it is automatically filled with zeroes. However, when a string array is declared but not initialized, it is automatically filled with null values.
Therefore,
String[] str= new str[5];
Will look like this:
{null, null, null, null, null}
7.
FILL IN THE BLANK QUESTION
3 mins • 1 pt
int number = 13;
int[] values = {0, 1, 2, 3, 4, 5};
for (int i = 0; i < values.length; i++)
{
number += values[i];
}
System.out.println(number);
What number is printed as a result of executing the code above?
Access all questions and much more by creating a free account
Create resources
Host any resource
Get auto-graded reports

Continue with Google

Continue with Email

Continue with Classlink

Continue with Clever
or continue with

Microsoft
%20(1).png)
Apple
Others
Already have an account?
Similar Resources on Wayground
20 questions
Bài tập Wordform
Quiz
•
9th Grade
20 questions
Past Simple (milán)
Quiz
•
9th Grade
20 questions
An Inspector Calls Context Quiz
Quiz
•
9th - 10th Grade
15 questions
E3 UNIT 3 Should, could, would QUIZ
Quiz
•
12th Grade - Professi...
20 questions
REPORT TEXT X MIPA 2
Quiz
•
10th Grade
20 questions
ÔN BÁN KỲ 2
Quiz
•
11th Grade
18 questions
Legend XI.1
Quiz
•
10th - 12th Grade
19 questions
The European Union
Quiz
•
8th - 10th Grade
Popular Resources on Wayground
15 questions
Fractions on a Number Line
Quiz
•
3rd Grade
20 questions
Equivalent Fractions
Quiz
•
3rd Grade
25 questions
Multiplication Facts
Quiz
•
5th Grade
29 questions
Alg. 1 Section 5.1 Coordinate Plane
Quiz
•
9th Grade
22 questions
fractions
Quiz
•
3rd Grade
11 questions
FOREST Effective communication
Lesson
•
KG
20 questions
Main Idea and Details
Quiz
•
5th Grade
20 questions
Context Clues
Quiz
•
6th Grade
Discover more resources for English
20 questions
Combining Sentences
Lesson
•
9th Grade
15 questions
ACT Reading Practice
Quiz
•
11th Grade
10 questions
Test Taking Strategies for State Reading Assessments
Interactive video
•
6th - 10th Grade
25 questions
Name that Logo
Quiz
•
10th Grade
10 questions
The Landlady
Quiz
•
9th Grade
30 questions
Vocabulary Review Practice – Set A & B
Quiz
•
10th Grade
10 questions
Multisyllabic Words 1
Quiz
•
4th - 9th Grade
12 questions
IREAD Week 4 - Review
Quiz
•
3rd Grade - University