Java Basics
Classes & Methods
control statements
Random
Arrays/Array Lists
100

True or False: A benefit of using an IDE is your code complies and runs faster.

false

100

What does the following statement do in a Java application?

import java.util.Scanner;

It makes the Scanner class available to the application without qualification.

100

In a while loop, the Boolean expression is tested when?

before the loop is executed

100

To join (or concatenate) one string with another string or another data type, you can use the ________________ operator.

+

100

The array that follows is an array of

double[] grades = new double[3];

double values

200

Java's syntax is similar to the syntax of what language(s)?

C++ and C#

200

You can use the nextLine method of the Scanner object to do what?

return all text on the current line as a String object

200

You can use a logical operator to do what?

combine two Boolean expressions

determine if two expressions are equal

200

To append a string or another data type to a string, you can use the ________________ operator.

+=

200

What is the value of names[4] in the following array?

String[] names = {"Jeff", "Dan", "Sally", "Jill", "Allie"};

Allie

300
The source files for a project can be organized into one or more _____.

Packages

300

A Boolean expression is an expression that returns a ________________ value.

True or False

300

The difference between a if/else and a switch statements is what? 

It can’t perform an operation based on the result of a Boolean expression

300

    You can use the final keyword to do what?

to prevent a class from being inherited

to prevent a method from being overridden

to prevent a method from assigning a new value to a parameter

300

To refer to an element in an array you use a/an ____________.

index

400

One of the primary benefits of a typical IDE for Java is that it checks the ________________ of your code as you enter it so you make fewer entry errors.

Syntax

400

When you use a constructor to create an object from a Java class, you are creating a/an ________________ of the class.

instance
400

How many lines are printed on the console when the following for loop is executed?

for (int i = 2; i < 10; i++) {

    System.out.println(i);

}

8

400

What keyword do you use in a class declaration to create a subclass?

extends

400

Which of the following is a difference between arrays and collections?

Collections can grow in size, but arrays can’t.

Arrays can store unwrapped primitive types, but collections can’t.

Collections are created from classes, but arrays aren’t.

500

The Java compiler takes the source code for an application and translates it into ______.

bytecodes

500

You call a/an ________________ from an object.

method

500

What is the value of x after the following statements are executed?

int x = 5;

switch(x) {

    case 5: 

        x += 2;

        break;

    case 6:

        x++;

        break;

    default:

        x *= 2;

        break;

}

7

500

What class or classes is a variable available to if it is declared without an access modifier?

All classes in the same package

500

What is the value of m after the code that follows is executed?

ArrayList<Double> miles = new ArrayList<>();

miles.add(37.5);

miles.add(26.2);

miles.add(54.7);

double m = miles.remove(0);

37.5