Flow of Control
Arrays
Inheritance & Abstract Classes
Keywords & Modifiers
Programming
100

How many times does the body of this while loop execute?

int x = 0;

while (x / 3 < 3)
{
   x++;
}

9

100

What code declares a two-dimensional array of doubles named "hours" with 10 rows and 7 columns?

double[][] hours = new double[10][7];

100

The extends keyword applies to...

a class inheriting from another class; defines a child class from its parent.

100

What does the "final" keyword indicate?

This field/class cannot be modified.

100

A class called Quiz has a method with the following signature:

public static void displayStats(int numGrades)

How would you call the displayStats method?

Quiz.displayStats(25);

200

How many iterations does the following loop encounter?

7

200

When referring to arrays, what is an element?

The value at a certain position in the array.

200

How do you instantiate an object from an abstract class?

You can't- at least not directly.

200

To which classes does the protected keyword grant access?

The class itself, any subclasses, and any classes in the same package.

200

We have used the following constant a couple of times in this course:

Integer.MAX_VALUE

What kind of value is this?

class variable; a public constant in the Integer class

300

What output is produced by the following code?

Hello

Hello

300

Given the following two-dimensional array declaration:

double[][] grades = new double[30][10];

What will the following code output?

System.out.println(grades.length);

30

300

What fields and methods are inherited by a subclass?
(Hint: access modifiers?)

Protected and public

300

Which keyword(s) is/are used when a variable belongs to the entire class?

static

300

Given the following code:

How would you call the power method to calculate 3^5 (3 to the 5th power) and set it to an integer variable named 'number'?

int number = Calc.power(3, 5);

400

What output is produced by the following code?

0

count after loop = 1

400

Given the following array, what would the values in numbers be changed to after only one pass of selection sort?

int[] numbers = {6. 3, 4, 7, 9, 2, 5};

{2, 3, 4, 7, 9, 6, 5}

400

In object-oriented programming (OOP), what is the principle of overriding?

A method from a parent class with the same signature (name, parameters, return type) is redefined by a child class.

400

What code would declare and initialize a constant called SIZE to represent the value 30 for the length of an array?

public static final int SIZE = 30;

400

What is the purpose of a parameterized constructor?

To instantiate a new object by initializing its instance variables with the given arguments.

500

What output is produced by the following statements?

Positive

-100

500

What code will declare (and initialize) a two-dimensional array named "settings" with the same layout as the table of data below?

int[][] settings = {  {12, 24, 32, 21}, {14, 67, 87, 65},{19, 1, 24, 12} };

500

Which of the following are properties of an abstract class? 

A) An abstract class cannot have instance variables and methods.
B) An abstract class can have instance variables and methods.
C) An abstract class is used for inheritance purposes
D) An abstract class cannot be instantiated.
E) There is no public constructor provided by an abstract class.
F) The constructor should initialize all instance variables.

B) An abstract class can have instance variables and methods.
C) An abstract class is used for inheritance purposes
D) An abstract class cannot be instantiated.
E) There is no public constructor provided by an abstract class.

500

The extends keyword applies to:

1) a member variable
2) a method of the class
3) an expression
4) a class inheriting from another class
5) the overridden toString method 

4

500

What is the correct implementation of the equals method of the following class?

M
e
n
u