tung's java final

About this set

Created by:

minhtung91  on May 11, 2011

Log in to favorite or report as inappropriate.
Pop out
No Messages

You must log in to discuss this set.

tung's java final

What does a contain after the following loop?

int[] a = {1, 3, 7, 0, 0, 0};
int size = 3, capacity = 6, pos = 0;

for (int i = pos; i < size - 1; i++)
a[i] = a[i + 1];
size--;
{3, 7, 7, 0, 0, 0}
1/17
Preview our new flashcards mode!

Study:

Cards

Speller

Learn

Test

Scatter

Games:

Scatter

Space Race

Tools:

Export

Copy

Combine

Embed

Order by

Terms

Definitions

What does a contain after the following loop?

int[] a = {1, 3, 7, 0, 0, 0};
int size = 3, capacity = 6, pos = 0;

for (int i = pos; i < size - 1; i++)
a[i] = a[i + 1];
size--;
{3, 7, 7, 0, 0, 0}
What does a contain after the following loop?

int[] a = {1, 3, 7, 0, 0, 0};
int size = 3, capacity = 6, pos = 0;

for (int i = pos; i < size - 1; i++)
a[i + 1] = a[i];
size--;
{1, 1, 1, 0, 0, 0}
What does the following loop do?

int[] a = {1, 3, 7, 0, 0, 0};
int size = 3, capacity = 6, pos = 0;

a[pos] = a[size - 1];
size--;
Removes the 1 from the array, replacing it with the 7. Array now unordered.
int[] num = new int[100];

for (int i = 0; i < 50; i++)
num[i] = i;

num[5] = 10;
num[55] = 100;


What is the value at index 10 of the array above?
10
When you write an explicit ____ for a class, you no longer receive the automatically written version. constructor
You are ____ required to write a constructor method for a class. never
Mutator methods typically begin with the word "____". set
You cannot declare the same ____ name more than once within a block, even if a block contains other blocks. variable
A classification hierarchy represents an organization based on _____________ and _____________. generalization and specialization
A ____________ relationship exists between two classes when one class contains fields that are instances of the other class. has-A
When you override a method defined in a superclass, you must do all of these except: Change either the number, type, or order of parameters in the subclass.
To prevent subclasses from overriding an inherited method, the superclass can mark the method as: final
Which of the following lines of code implicitly calls the toString() method, assuming that pete is an initialized Student object variable? String s = "President: " + pete;
To determine the number of valid elements in an ArrayList, use: the size() method
Assume that you have an ArrayList variable named a containing 4 elements, and an object named element that is the correct type to be stored in the ArrayList. Which of these statements assigns the first object in the collection to the variable element? element = a.get(0);
Assume that you have an ArrayList variable named a containing 4 elements, and an object named element that is the correct type to be stored in the ArrayList. Which of these statements replaces the last object in the collection with element? a.set(3, element);
Assume that you have an ArrayList variable named a containing many elements. You can rearrange the elements in random order by writing: Collections.shuffle(a);

First Time Here?

Welcome to Quizlet, a fun, free place to study. Try these flashcards, find others to study, or make your own.

Set Champions

There are no high scores or champions for this set yet. You can sign up or log in to be the first!