Exercises 13.03-06

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

"Jessica" is the 1st name in the array "names" System.out.println(Arrays.binarySearch(names, "Jessica"));

0

What is the first array index?

0

What is the last array index

1 less than the number of elements in the array

Which of these is correct: int grades []; or int[]grades?

Both are correct

Program design includes two related concepts; what are they?

Business of abstraction and utilizing program features

Does the size of the array need to be specified in the previous situation?

No

If you were to add one name to the list2 array, for a total of 7 names, would the 7th name be displayed?

No, because it only displays the first 6

Can the length field be changed?

No, it's a final variable

Is length a method?

No, it's an attribute

Write a java code for an array of 40 strings called "names" in one statement

String names [] = new String[40];

If you were to add one name to the "name" array, for a total of 5 names, would the 5th name be displayed? Why or why not?

Yes, because names.length is used in the for loop and the attribute value will change when you add additional elements

How does the "toString" method display elements of an arrays object?

converts array to a string that can be automatically printed

Write the java code that will allocate memory for 30 ages

int ages [30];

Write the java code to declare an int array called ages

int ages [];

"Diana" is NOT one of the names in the array "names" System.out.println(Arrays.binarySearch(names, "Diana"));

negative number

Method "toString", like all arrays methods, is _____, which means you need to use the arrays identifier.

static

What does length do when used with a java static array?

tells you the number of elements in the array

What method allows you to assign the same value to every element of an arrays object?

the fill method

"Brenda" is one of the names in the array "names" System.out.println(Arrays.binarySearch(names, "Brenda"));

the index of Brenda (an integer)

Why does the program not properly display the index values of the numbers beings searched for?

the list hasn't been sorted

Write the java code necessary to store the age of 18 in the very last element

ages [array.length - 1] = 18;

Write the java code necessary to store the age of 16 in the first element

ages[0] = 16;

In what order does the "arrays" method "sort" arrange the data?

ascending order

Each element of an array has an ______, which is placed between brackets.

Index

What error do you get if you use an index value that is too large?

ArrayIndexOutofBoundsException

Look at how we have calling the "Arrays" methods in this chapter. Are these "class" methods of "object" methods?

The arrays methods are class methods

What if instead of adding a name, you removed a couple names so now there are only 4 left in the array. What will happen when the program is executed?

The program crashes

What is displayed if you put an object, like an array, in a println statement?

You will get memory address

What is sorting important?

because you need to search data

Write java code for initialized array of double values called bob. The initialized values will be 1.1, 2.2, 3.3, 4.4, 5.5

double [] bob = {1.1,2.2,3.3,4.4,5.5};

Array processing includes 4 things. List them.

element display, assigning values, sorting and searching elements

Whether you have an array of integers, an array of real numbers, or an array of strings, what data type will the index always be?

integer

What is the biggest advantage of assigning data to an array using an "initialize list?"

it can assign different values to every array element location


Conjuntos de estudio relacionados

Algebra 2- General Equation of a Line

View Set

Unit 1: Mental/Social/Emotional Health

View Set

Unit 1, Lesson 3-Sociological Theories

View Set

Personal Finance Ch. 8: Vehicle and Other Major Purchases (Study Guide)

View Set

Chapter 29: Management of Patients With Complications From Heart Disease

View Set

Ch. 53: Assessment of Kidney & Urinary Function

View Set

AWS- cloud cert udemy questions study set

View Set

Chapt. 29: Management of pt with complication from heart disease

View Set