Chapter 8 quiz

Ace your homework & exams now with Quizwiz!

Suppose you have declared an array as follows: int[] creditScores = {670, 720, 815}; What is the value of creditScores.length?

3

If you declare an integer array as follows, what is the value of num[2]? int[] num = {101, 202, 303, 404, 505, 606};

303

For how many integers does the following statement reserve room? int[] value = new int[34];

34

If a class named Student contains a method setID() that takes an int argument and you write an application in which you create an array of 20 Student objects named scholar, which of the following statements correctly assigns an ID number to the first Studentscholar? a. Student[0].setID(1234); b. scholar[0].setID(1234); c. Student.setID[0](1234); d. scholar.setID[0](1234);

Student.setID[0](1234);

In which of the following situations would setting up parallel arrays be most useful? a.You need to look up an employee's ID number to find the employee's last name. b.You need to calculate interest earned on a savings account balance. c.You need to store a list of 20 commonly misspelled words. d.You need to determine the shortest distance between two points on a map.

You need to look up an employee's ID number to find the employee's last name.

When you pass an array element to a method, the method receives _____________.

a copy of the value in the element

An array is a list of data items that _____________.

all have the same type

In Java, you can declare an array of 12 elements and initialize _____. a. only the first one b. all of them c. Both of these are true. d. Neither of these is true.

b. all of them

Assume an array is declared as follows. Which of the following statements correctly assigns the value 100 to each of the array elements? int[] num = new int[4]; a. for(x = 0; x < 3; ++x) num[x] = 100; b. for(x = 0; x <4; ++x) num[x] = 100; c. for(x = 1; x < 4; ++x) num[x] = 100; d. for(x = 1; x < 5; ++x) num[x] = 100;

b. for(x = 0; x <4; ++x) num[x] = 100;

When you initialize an array by giving it values upon creation, you _____________.

do not explicitly give the array a size

A parallel array is one that _____.

holds values that correspond to those in another array

Which of the following can be used as an array subscript?

int

Unicode value '\u0000' is also known as _____________.

null

If you declare an array as follows, how do you indicate the final element of the array? int[] num = new int[6];

num[5]

Array names represent _____________.

references

When you pass an array to a method, the method receives _____________.

the address of the array

f a method should return an array to its calling method _____.

the return type in the method header is followed by square brackets

You reserve memory locations for an array when you _____________.

use the keyword new

A single array element of a primitive type is passed to a method by _____.

value

When you declare an array, _____________.

you might reserve memory for it in the same statement


Related study sets

Week 6-7 Cranial Nerves - Lecture

View Set

Course 1 Week 2 - All About Analytical Thinking

View Set

Sociology Exam 1 chapter 1,2 & 3

View Set

Lecture 3 (Financial Performance Measures - Chapter 10) Textbook Notes

View Set