In a simple Java application, where does execution begin when the program runs?
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.
A program contains public class Greeting. What should the source file normally be named?
- A
Greeting.java
- B
Main.java
- C
Greeting.class
- D
Java.java
Which two Java types below are primitive types commonly used for whole-number and logical values? Select all correct choices.
- A
int
- B
String
- C
boolean
- D
ArrayList
Which descriptions correctly identify stages of the beginner input–process–output pattern? Select all correct choices.
- A
Read data from an input source.
- B
Process the data using expressions, calculations, or assignments.
- C
Display the resulting value or output.
- D
Use inheritance as a required step before displaying the result.
True or false: If a Java source file declares public class Greeting, the file should normally be named Greeting.java.
- A
True
- B
False
True or false: If a Java program compiles, it must produce the intended result for every valid input.
- A
True
- B
False
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.
The % operator is called the operator.
In a Scanner object named input, the method used to read one integer token is input..
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.
What does System.out.println(...) do that System.out.print(...) does not automatically do?
- A
It displays the value and then moves to a new line.
- B
It reads a line from standard input.
- C
It formats every number to two decimal places.
- D
It writes only to the standard error stream.
A Java application contains several methods in a class. Which method is the program's entry point when the application runs?
- A
The constructor of the class
- B
The main method
- C
The first import statement
- D
The first variable declaration
Which declaration pair correctly stores the text "Java" in label and the single character J in initial?
- A
char for both variables
- B
int for both variables
- C
String for label and char for initial
- D
String for both variables
True or false: The statement int age = "sixteen"; produces a compile-time error.
- A
True
- B
False
What value is stored in x after these statements execute?
int x = 4;
x = 10;
- A
10
- B
4
- C
14
- D
The program cannot determine x
Which Java keyword should be placed before a variable declaration when the variable represents a value that should not change?
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?
- A
nextLine()
- B
nextDouble()
- C
next()
- D
nextBoolean()
What value is assigned to result?
int result = 7 / 2;
- A
3.5
- B
3
- C
4
- D
A compile-time error
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.
What value is stored in wholePart after this code executes?
double price = 9.99;
int wholePart = (int) price;