Chapter 7 Quiz + bit of Ch. 8

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

An array reference variable is used for what?

To access the elements in an array using an index

An anonymous array is what?

When a statement to create an array has no reference variable, such as new elementType[]{1, 2, 3, 4};

Are arrays objects in java?

Yes. Stored in heap

in double[] myList, what is the array?

myList. or, it is a variable referencing to an array.

How to obtain size of an array? the array is myList

myList.length

How to call the tenth index in myList with 10 elements?

myList[9] (from 0 to length - 1)

If an array is sorted, which is more efficient of a search? Binary or linear?

Binary

Which style works to declare array variables? elementType arrayRefVar[] elementType[] arrayRefVar

Both works. elementType[] arrayRefVar is preferred

Can you use the 'new' operator in an array-initializer?

No, syntax error.

What is an array?

Stores a fixed-size sequential collection of elements of the same type

How would one print an array? use myList[i]

System.out.println(myList[i] + " ");

Java treats a variable-length parameter as an array. T/F?

T

Once an array is created, its size is fixed. T/F?

T

When an array is passed to a method, a new array is created and passed to the method. T/F?

T

How would one print an array of the char[] type?

char[] city = {'N', 'a', 'b', 'i', 'l'}; System.out.println(city);

What would be the syntax for declaring an array variable? the element type is double and the array reference variable is called myList with 10 elements

double[] myList = new double[10];

What would the syntax of an array-initializer look like? array is myList and type is double. there are four elements.

double[] myList = {1, 2, 3, 4};

When a method returns an array, what is returned?

the reference of the array


Set pelajaran terkait

Chapter 1: Introduction to Computers and Programming

View Set

PEDO (L'examen en dentisterie pédiatrique)

View Set

Geography 332 - Study Guide for Megalopolis

View Set

Thirteenth, Fourteenth, & Fifteenth Amendments

View Set

Environmental Science Chapter 5: Species Interactions, Ecological Succession, and Population Control

View Set

Biology Unit 12 (mosses & ferns)

View Set