CIS Chapter 7

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

Which method is used to determine the number of items stored in an ArrayList object?

size

What will be the result after the following code is executed? final int ARRAY_SIZE = 5; float[ ] x = float[ARRAY_SIZE]; for (I = 1; i <= ARRAY_SIZE; i++) { x[i] = 10.0;}

The code contains a syntax error and will not compile

Which would be the result after the following code is executed? int [ ] numbers = {40, 3, 5, 7, 12, 10}; int value = numbers[0]; for (int i = 1; i < numbers.length; i++) { if (numbers[i] < value) value = numbers [i];}

The value variable will contain the lowest value in the numbers array

What would be the result after the following code is executed? int [ ] numbers = {50, 10, 15, 20, 25, 100, 30}; int value = 0; for (int i = 1; i < numbers.length; i++); value += numbers [i];

The value variable will contain the sum of all the values in the numbers array.

T/F: An ArrayList object automatically expands in size to accommodate the items stored in it.

True

T/F: Objects in an array are assessed with subscripts, just like any other data type in an array

True

Which of the following import statements is required in order to use the Array List class?

import.java.util.ArrayList;

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

It does all of these

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

add

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

remove

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

set

Which of the following methods returns a string representing all of the items stored in an ArrayList object?

toString

What does <String> specify in the following statement? ArrayList<String> nameList = new ArrayList<String>( );

It specifies that only String objects may be stored in the ArrayList object

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"

Which of the following statements are true about this code? final int ARRAY_SIZE = 10; long[ ] array1 = new long[ARRAY_SIZE];

All of these are true

What would be the result of executing the following code? int[ ] = {0, 1, 2, 3, 4, 5};

An array of 6 values, ranging from 0 through 5 and referenced by the variable x will be created


Set pelajaran terkait

Insurance exam: Missed questions

View Set

Ch.7: Love and Romantic Relationships

View Set

The Basic Problems in Economics.

View Set

Chapter 73- Care of the School-Age Child or Adolescent.rtf

View Set

Mental Health Test 4 [Monday 4/27/17] 60 questions total

View Set