Module 2 Quiz

¡Supera tus tareas y exámenes ahora con Quizwiz!

By default, Java initializes array elements to

0

Subscripting always starts with ________.

0

It is common practice to use a ________ variable as a size declarator.

final

Each array in Java has a public field named ________ that contains the number of elements in the array.

length

Arrays class is in Java.Util package

True

You can use the ________ method to replace an item at a specific location in an ArrayList.

set

What does the following statement do? double[] array1 = new double[10];

t does all of these.

When an individual element of an array is passed to a method ________.

the method does not have access to the original array

For the following code, what would be the value of str[2]? String[] str = {"abc", "def", "ghi", "jkl"};

a reference to the String object containing "ghi"

What will be the results after the following code is executed? int[] x = { 55, 33, 88, 22, 99, 11, 44, 66, 77 }; int a = 10; if(x[2] > x[5]) a = 5; else a = 8;

a=5

If a and b are both int arrays, then a = b will

create an alias The = is an assignment operator. If the two variables are primitives, than the left-hand variable gets a copy of the right-hand variable. However, since a and b are arrays, the reference variable a is set to the reference variable b, resulting in both a and b referencing the same array in memory, or they are now aliases of each other.

The ArrayList class is in the ________ package.

java.util

Which of the following for loops is valid, given the following declaration? String[] names = {"abc", "def", "ghi", "jkl"};

or (int i = 0; i < names.length; i++) System.out.println(names[i].length());

Which of the following is a correct method header for receiving a one-dimensional array as an argument?

public static void passMyArray(int[] myArray)

The ________ method removes an item from an ArrayList at a specific index.

remove

If any int array, a, is passed as a parameter to a method, which of the following would adequately define the parameter list for the method header?

(int[] a) The parameter is defined much as the variable is originally declared, as type parameter name. Here, the type is int[] and the parameter is a.

Which of the following ArrayList class methods is used to insert an item at a specific location in an ArrayList?

add


Conjuntos de estudio relacionados

Physical Activity and Health Exam 2: Practice Quiz Questions

View Set

Upper Extremity Review Quiz- Muscle Movements

View Set

M11 Chapter 11 Computer Outputs and Networks AUTI 131

View Set

Chapter 23: Audit of Cash Balances

View Set

D4 IS Operations, Maintenance, Svc Mgt. 5/16/2017

View Set

American History 9: The Progressive Presidents and the start of WWI

View Set

Introduction to Sociology Section Quiz CH. 13

View Set