Filters
Question type

Study Flashcards

Which of the following println statements will display the last myScores element in an array of 10?


A) System.out.println(vals[0]) ;
B) System.out.println(vals[1]) ;
C) System.out.println(vals[9]) ;
D) System.out.println(vals[10]) ;

E) A) and B)
F) B) and D)

Correct Answer

verifed

verified

The following statement declares an array: int[] scoreArray = {2, 14, 35, 67, 85}; final int INCREASE = 3; Create a loop that will add INCREASE to every array element. Use the length field in the loop that will contain the number of elements in the array.

Correct Answer

verifed

verified

for(sub = 0; sub
 ...

View Answer

When you create an array variable, memory space is automatically reserved.

A) True
B) False

Correct Answer

verifed

verified

When you declare an array name, no computer memory address is assigned to it. Instead, the array variable name has the special value ____, or Unicode value '\u0000'.


A) empty
B) null
C) false
D) zero

E) A) and B)
F) A) and C)

Correct Answer

verifed

verified

Match each term with the correct statement below.

Premises
A nonprimitive object
Hold memory addresses where values are stored
Declared in the same way you declare any simple variable
Numbered beginning with 0
A statement used to return an array from a method
An enhanced for loop
A primitive type
Represent computer memory addresses
An array field
Responses
array variable
int
elements
return
reference types
Java object names
reference type
foreach loop
length

Correct Answer

A nonprimitive object
Hold memory addresses where values are stored
Declared in the same way you declare any simple variable
Numbered beginning with 0
A statement used to return an array from a method
An enhanced for loop
A primitive type
Represent computer memory addresses
An array field

If a class has only a default constructor, you must call the constructor using the keyword ____ for each declared array element.


A) default
B) new
C) first
D) object

E) A) and B)
F) None of the above

Correct Answer

verifed

verified

Individual array elements are ____ by value when a copy of the value is made and used within the receiving method.


A) sorted
B) passed
C) received
D) stored

E) B) and C)
F) A) and B)

Correct Answer

verifed

verified

A(n) ____ loop allows you to cycle through an array without specifying the starting and ending points for the loop control variable.


A) do…while
B) inner
C) enhanced for
D) enhanced while

E) A) and D)
F) A) and C)

Correct Answer

verifed

verified

double[] studentScores; double studentScores[]; Are both of the above statements valid for declaring an array variable? Why or why not?

Correct Answer

verifed

verified

You declare an array variable in the sam...

View Answer

When any ____ type ( boolean , char , byte , short , int , long , float , or double ) is passed to a method, the value is passed.


A) array
B) dummy
C) element
D) primitive

E) A) and B)
F) A) and C)

Correct Answer

verifed

verified

When working with arrays, why is it beneficial to use a loop with a declared constant equal to the size of the array?

Correct Answer

verifed

verified

It is convenient to declare a named cons...

View Answer

When you want to determine whether a variable holds one of many valid values, one option is to use a do…while loop to compare the variable to a series of valid values.

A) True
B) False

Correct Answer

verifed

verified

When populating an array with an initialization list, you do not need to use the new keyword or provide an array size. Explain why this is the case.

Correct Answer

verifed

verified

When you populate an array upon creation...

View Answer

When any primitive type is passed to a method, the ____________________ is passed.

Correct Answer

verifed

verified

A(n) ____ is an integer contained within square brackets that indicates one of an array's variables.


A) postscript
B) subscript
C) variable header
D) indicator

E) A) and B)
F) B) and C)

Correct Answer

verifed

verified

Providing values for all the elements in an array is called ____ the array.


A) populating
B) declaring
C) filling
D) irrigating

E) A) and C)
F) A) and D)

Correct Answer

verifed

verified

String[] countyNames = {"Clark", "Delaware", "Madison"}; Using the above statement, what will be the value of countyNames[0] , countyNames[1] , and countyNames[2] ?

Correct Answer

verifed

verified

countyNames[0] will hold the v...

View Answer

When you create an array of objects, each reference is assigned the value ____.


A) null
B) '\u0000'
C) true
D) false

E) None of the above
F) B) and D)

Correct Answer

verifed

verified

Write the statement to declare an array variable named studentScores with type double . Write a second statement to create an array of 10 objects of type double .

Correct Answer

verifed

verified

double[] studentScor...

View Answer

Many programmers feel that breaking out of a for loop early disrupts the loop flow and makes the code harder to understand.

A) True
B) False

Correct Answer

verifed

verified

Showing 41 - 60 of 66

Related Exams

Show Answer