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;
Related study packs and tools
1. Computing, Culture, and Society
A progressive guide to how computing reshapes culture, economic life, public institutions, and individual opportunities, with frameworks for evaluating digital equity, bias, cybersecurity, encryption, and collective participation.
3. Risks and Unintended Consequences
A 14-question quiz on the social, economic, privacy, informational, health, and environmental risks of computing innovations, including strategies for responsible design and oversight.
6. Cybersecurity and Digital Safety
A practical guide to recognizing cybersecurity threats, protecting accounts and devices, and responding safely when information or systems may be compromised.
7. Encryption, Privacy, and Trust
A guided introduction to how encryption, authentication, hashing, secure protocols, and key management establish confidentiality, integrity, privacy, and trust while creating practical and legal trade-offs.
08 — Discrete Mathematics for Computer Science
A focused review of propositional logic, quantifiers, sets, relations, functions, and foundational proof methods in discrete mathematics for computer science.
9. Evaluating the Social Impact of Computing
A practical guide to evaluating computing innovations by examining their benefits, risks, equity, security, participation, and long-term effects on people and communities.
12 — Foundations Capstone
A medium-difficulty quiz on integrating problem definition, representation, algorithms, complexity analysis, testing, correctness, ethical evaluation, and documentation in a computer science capstone.
Fault Tolerance and Redundant Systems
A progressive guide to designing, operating, and testing systems that continue useful service despite component faults, overload, data loss, and recovery challenges.
How the Internet Works
A medium-difficulty quiz on how independently operated networks, protocols, addresses, naming systems, transport services, and routing mechanisms work together to form the Internet.
IP Addressing and Internetworking
A progressive guide to how IP addressing, local delivery, routing, forwarding, translation, and DNS work together to connect independent networks and locate services.
Packets, Links, and Network Performance
A progressive guide to how packet-switched networks encapsulate data, move it across links, and manage delay, throughput, queues, and congestion.
Parallel and Distributed Computing
A structured guide to designing parallel and distributed systems through decomposition, communication, coordination, state management, scalability, and fault tolerance.