Free Practice Quiz Question List

Foundations of Java Program Design Online Quiz Questions

Use this free practice quiz with 20 questions to review Foundations of Java Program Design, test your knowledge, and prepare for your next test or exam.

20 questions
01
Choose one
1 point

In a simple Java application, where does execution begin when the program runs?

  1. A

    The constructor

  2. B

    The main method

  3. C

    The import statement

  4. D

    The class declaration

02
Choose one
1 point

A program contains public class Greeting. What should the source file normally be named?

  1. A

    Greeting.java

  2. B

    Main.java

  3. C

    Greeting.class

  4. D

    Java.java

03
Choose all
1 point

Which two Java types below are primitive types commonly used for whole-number and logical values? Select all correct choices.

  1. A

    int

  2. B

    String

  3. C

    boolean

  4. D

    ArrayList

04
Choose all
1 point

Which descriptions correctly identify stages of the beginner input–process–output pattern? Select all correct choices.

  1. A

    Read data from an input source.

  2. B

    Process the data using expressions, calculations, or assignments.

  3. C

    Display the resulting value or output.

  4. D

    Use inheritance as a required step before displaying the result.

05
True or false
1 point

True or false: If a Java source file declares public class Greeting, the file should normally be named Greeting.java.

  1. A

    True

  2. B

    False

06
True or false
1 point

True or false: If a Java program compiles, it must produce the intended result for every valid input.

  1. A

    True

  2. B

    False

07
Written response
1 point

A time-conversion program computes minutes = totalMinutes % 60. For an input of 135 total minutes, what value does minutes contain? Enter the number of remaining minutes as a whole-number value.

08
Fill in the blank
1 point

The % operator is called the operator.

09
Fill in the blank
1 point

In a Scanner object named input, the method used to read one integer token is input..

10
Open ended
1 point

Explain how the input–process–output pattern and boundary-case testing work together in a beginner Java program. Use the minutes-conversion problem as an example and identify at least two useful test cases.

11
Choose one
1 point

What does System.out.println(...) do that System.out.print(...) does not automatically do?

  1. A

    It displays the value and then moves to a new line.

  2. B

    It reads a line from standard input.

  3. C

    It formats every number to two decimal places.

  4. D

    It writes only to the standard error stream.

12
Choose one
1 point

A Java application contains several methods in a class. Which method is the program's entry point when the application runs?

  1. A

    The constructor of the class

  2. B

    The main method

  3. C

    The first import statement

  4. D

    The first variable declaration

13
Choose one
1 point

Which declaration pair correctly stores the text "Java" in label and the single character J in initial?

  1. A

    char for both variables

  2. B

    int for both variables

  3. C

    String for label and char for initial

  4. D

    String for both variables

14
True or false
1 point

True or false: The statement int age = "sixteen"; produces a compile-time error.

  1. A

    True

  2. B

    False

15
Choose one
1 point

What value is stored in x after these statements execute?

int x = 4;
x = 10;

  1. A

    10

  2. B

    4

  3. C

    14

  4. D

    The program cannot determine x

16
Written response
1 point

Which Java keyword should be placed before a variable declaration when the variable represents a value that should not change?

17
Choose one
1 point

A program needs to read one whitespace-delimited word from the user, such as a surname with no spaces. Which Scanner method should it call?

  1. A

    nextLine()

  2. B

    nextDouble()

  3. C

    next()

  4. D

    nextBoolean()

18
Choose one
1 point

What value is assigned to result?

int result = 7 / 2;

  1. A

    3.5

  2. B

    3

  3. C

    4

  4. D

    A compile-time error

19
Written response
1 point

A time-conversion algorithm receives totalMinutes = 135. What is the value of minutes = totalMinutes % 60? Enter the number of remaining whole minutes; no tolerance is allowed.

20
Written response
1 point

What value is stored in wholePart after this code executes?

double price = 9.99;

int wholePart = (int) price;