1 / 117100%
1
1
CSE 205 QUIZZES 1, 2 AND 3-JAVA PROGRAMMING FUNDAMENTALS:
COMPREHENSIVE QUIZ SET ON CORE CONCEPTS, DATA TYPES, AND
DECISION STRUCTURES
QUIZ 1: INTRODUCTION
MULTIPLE-CHOICE QUESTIONS
Q1. What is the core definition of a computer program as established in the chapter?
A. A machine that stores data and interacts with devices.
B. A sequence of instructions and decisions that directs a computer to perform a specific task.
C. The physical components of a computing system, collectively called hardware.
D. A high-level language used to simplify the process of providing instructions to the CPU.
Bloom’s Level: Remember
Concept Tested: Computer program definition
Correct Answer: A sequence of instructions and decisions that directs a computer to perform a
specific task.
Explanation: The text defines a computer program as a sequence of instructions and decisions
needed to fulfill a task, directing the computer's operations.
Q2. In the context of programming, what is the act of "designing and implementing computer
programs" called?
A. Compilation
B. Execution
C. Programming
D. Algorithm design
Bloom’s Level: Remember
Concept Tested: Programming definition
Correct Answer: Programming
2
2
Explanation: The chapter explicitly states that the act of designing and implementing computer
programs is called programming.
Q3. Which term collectively refers to "the physical computer and peripheral devices"?
A. Software
B. The Central Processing Unit
C. Hardware
D. Firmware
Bloom’s Level: Remember
Concept Tested: Hardware definition
Correct Answer: Hardware
Explanation: The text defines the physical computer and peripheral devices as the hardware of
the system.
Q4. What are the programs that a computer executes collectively known as?
A. Hardware
B. The CPU
C. Firmware
D. Software
Bloom’s Level: Remember
Concept Tested: Software definition
Correct Answer: Software
Explanation: The programs executed by the computer are defined as software, in contrast to the
physical hardware.
Q5. Which component, described as being at the heart of the computer, performs program
control and data processing?
A. Hard Disk
B. Central Processing Unit (CPU)
C. Random Access Memory (RAM)
D. Graphics Card
3
3
Bloom’s Level: Remember
Concept Tested: Central Processing Unit (CPU)
Correct Answer: Central Processing Unit (CPU)
Explanation: The chapter identifies the CPU as lying at the heart of the computer and
performing program control and data processing.
Q6. According to the schematic of a personal computer, which two main functions does the CPU
perform?
A. Data input and output
B. Program control and data processing
C. Network transmission and sound processing
D. Primary and secondary storage management
Bloom’s Level: Understand
Concept Tested: CPU functions (control & processing)
Correct Answer: Program control and data processing
Explanation: The text specifies that the CPU locates/executes program instructions (control)
and carries out arithmetic operations (data processing).
Q7. What type of storage is made from memory chips that require continuous electric power to
retain data?
A. Secondary Storage
B. Network Storage
C. Primary Storage
D. Read-Only Storage
Bloom’s Level: Remember
Concept Tested: Primary storage (memory)
Correct Answer: Primary Storage
Explanation: Primary storage (memory) is defined as being made from chips that store data only
when supplied with power.
4
4
Q8. A hard disk, which provides persistent storage without electricity, is an example of what
category of storage?
A. Virtual Storage
B. Primary Storage
C. Volatile Storage
D. Secondary Storage
Bloom’s Level: Understand
Concept Tested: Secondary storage (hard disk)
Correct Answer: Secondary Storage
Explanation: The chapter classifies hard disks as secondary storage, which is slower, less
expensive, and persistent.
Q9. Keyboards, mice, monitors, and printers are all examples of what category of computer
components?
A. Processing Units
B. Storage Devices
C. Network Devices
D. Peripheral Devices
Bloom’s Level: Remember
Concept Tested: Peripheral devices
Correct Answer: Peripheral Devices
Explanation: Devices used to interact with a human user, such as for input and output, are
defined as peripheral devices.
Q10. When a user enters information for the computer using a keyboard, what is this action
formally called?
A. Processing
B. Output
C. Storage
D. Input
5
5
Bloom’s Level: Remember
Concept Tested: Computer input
Correct Answer: Input
Explanation: Information entered by the user for the computer, such as via a keyboard, is
defined as input.
Q11. Information that the computer transmits to the user, for example through a display screen,
is known as what?
A. Input
B. A command
C. Output
D. A process
Bloom’s Level: Remember
Concept Tested: Computer output
Correct Answer: Output
Explanation: The text defines information the computer sends to the user (e.g., to a screen or
printer) as output.
Q12. What allows computers to read data and programs from central storage locations or send
data to other computers?
A. Peripheral Devices
B. The Operating System
C. Networks
D. The Compiler
Bloom’s Level: Understand
Concept Tested: Networks
Correct Answer: Networks
Explanation: The chapter explains that computers interconnected through networks can share
data and programs.
6
6
Q13. Languages like Java, which allow programmers to specify actions at a conceptual level
rather than detailed CPU instructions, are known as what?
A. Assembly Languages
B. Machine Languages
C. Low-level Programming Languages
D. High-level Programming Languages
Bloom’s Level: Remember
Concept Tested: High-level programming languages
Correct Answer: High-level Programming Languages
Explanation: The text introduces high-level languages as creations that let programmers specify
desired actions, which are then translated for the CPU.
Q14. What is the role of a compiler in the context of a high-level programming language like
Java?
A. It executes the program instructions on the CPU.
B. It translates high-level instructions into detailed CPU instructions.
C. It helps the programmer debug logic errors in the code.
D. It organizes the source code files into folders.
Bloom’s Level: Understand
Concept Tested: Compiler function
Correct Answer: It translates high-level instructions into detailed CPU instructions.
Explanation: The compiler's function is defined as translating high-level language instructions
into the more detailed instructions the CPU requires.
Q15. According to the chapter, what were the original design goals for the Java language at Sun
Microsystems?
A. To be complex and powerful for enterprise servers only.
B. To be simple, secure, and usable for many different processor types.
C. To directly compete with and mimic the syntax of the C++ language.
D. To be optimized solely for graphical user interface programming.
7
7
Bloom’s Level: Remember
Concept Tested: Java design goals (1991)
Correct Answer: To be simple, secure, and usable for many different processor types.
Explanation: The text states Java was designed to be simple, secure, and usable for many
different processor types for consumer devices.
Q16. For what kind of devices was the Java language originally designed?
A. Internet servers
B. Industrial supercomputers
C. Consumer devices, like intelligent TV set-top boxes
D. Scientific workstations for numerical analysis
Bloom’s Level: Remember
Concept Tested: Java's original purpose (consumer devices)
Correct Answer: Consumer devices, like intelligent TV set-top boxes
Explanation: Java was originally designed for programming consumer devices, such as
intelligent television "set-top" boxes.
Q17. Who was a leader of the group at Sun Microsystems that designed the Java programming
language?
A. John Mauchly
B. J. Presper Eckert
C. Patrick Naughton
D. James Gosling
Bloom’s Level: Remember
Concept Tested: James Gosling
Correct Answer: James Gosling
Explanation: James Gosling is identified as leading the group (with Patrick Naughton) that
designed Java.
Q18. Alongside James Gosling, who else is credited as a leader of the team at Sun Microsystems
that designed Java?
8
8
A. John Mauchly
B. Patrick Naughton
C. J. Presper Eckert
D. Bill Gates
Bloom’s Level: Remember
Concept Tested: Patrick Naughton
Correct Answer: Patrick Naughton
Explanation: The chapter states Java was designed by a group led by James Gosling and Patrick
Naughton.
Q19. At which company was the Java programming language originally developed?
A. Microsoft
B. IBM
C. Sun Microsystems
D. Oracle
Bloom’s Level: Remember
Concept Tested: Sun Microsystems
Correct Answer: Sun Microsystems
Explanation: Java was designed by a group at Sun Microsystems.
Q20. What were the small Java programs called that could be located anywhere on the Internet
and run in a browser, leading to Java's initial popularity?
A. Servlets
B. Applets
C. Scripts
D. JAR files
Bloom’s Level: Remember
Concept Tested: Internet applets
Correct Answer: Applets
9
9
Explanation: Java was introduced with a browser that ran appletsJava code located on the
Internet.
Q21. Compiled Java programs contain instructions for a simulated CPU called the what?
A. Java Compiler
B. Java Runtime Environment
C. Java Virtual Machine
D. Java Development Kit
Bloom’s Level: Remember
Concept Tested: Java Virtual Machine (JVM)
Correct Answer: Java Virtual Machine
Explanation: The text explains that compiled Java programs contain instructions for the Java
virtual machine, a program that simulates a CPU.
Q22. The ability for the same Java program to run unchanged on Windows, Linux, or macOS is
a key benefit of Java's what?
A. Security
B. Portability
C. Syntax
D. Library size
Bloom’s Level: Understand
Concept Tested: Platform independence
Correct Answer: Portability
Explanation: Platform independence, achieved via the JVM, allows a Java program to run on
different operating systems without change.
Q23. Which attribute of Java, achieved through the use of the Java Virtual Machine, ensures that
a program will run the same way on different computer systems?
A. Safety
B. Complexity
10
10
C. Portability
D. Speed
Bloom’s Level: Understand
Concept Tested: Java portability
Correct Answer: Portability
Explanation: Portability is named as a key benefit of Java, meaning the same program runs
without change on various platforms.
Q24. Java's safety features, which allow applets to run in a browser without attacking the
computer, also help beginners by doing what?
A. Making programs run faster.
B. Providing accurate error reports for unsafe behavior.
C. Reducing the number of lines of code needed.
D. Automatically fixing syntax errors.
Bloom’s Level: Analyze
Concept Tested: Java safety/security
Correct Answer: Providing accurate error reports for unsafe behavior.
Explanation: The text states Java's safety features help learners by providing accurate error
reports when code results in unsafe behavior.
Q25. What does the Java compiler translate source code into?
A. Machine code for a specific CPU
B. Executable (.exe) files
C. Class files containing JVM instructions
D. Assembly language files
Bloom’s Level: Remember
Concept Tested: Java class files
Correct Answer: Class files containing JVM instructions
Explanation: The compiler translates source code into class files, which contain instructions for
the Java Virtual Machine.
11
11
Q26. Why is it unrealistic for a programmer, even an expert, to learn the entire Java library?
A. Because the Java language syntax changes every year.
B. Because it is vast and contains packages for many specialized purposes.
C. Because the library documentation is poorly written.
D. Because most of the library is obsolete and unused.
Bloom’s Level: Understand
Concept Tested: Java library size
Correct Answer: Because it is vast and contains packages for many specialized purposes.
Explanation: The chapter notes Java has a vast set of library packages for graphics, networking,
etc., and experts only use those needed for specific projects.
Q27. Which Java version first introduced generic classes, the enhanced for loop, and auto-
boxing?
A. Version 1.2
B. Version 1.4
C. Version 5
D. Version 7
Bloom’s Level: Remember
Concept Tested: Java versions history
Correct Answer: Version 5
Explanation: Table 1 in the chapter lists generic classes, enhanced for loop, and auto-boxing as
new features in Java version 5.
Q28. What is the term for a programming environment that often integrates an editor, compiler,
and debugger into a single application?
A. Virtual Machine
B. Command Console
C. Integrated Development Environment (IDE)
D. Source Code Manager
12
12
Bloom’s Level: Remember
Concept Tested: Integrated Development Environment (IDE)
Correct Answer: Integrated Development Environment (IDE)
Explanation: The text mentions that many computers have an integrated development
environment for writing and testing programs.
Q29. Which program is used for entering and modifying text, such as the instructions of a Java
program?
A. Compiler
B. Virtual Machine
C. Browser
D. Editor
Bloom’s Level: Remember
Concept Tested: Editor program
Correct Answer: Editor
Explanation: An editor is defined as a program for entering and modifying text, like a Java
program.
Q30. What is the text that a programmer writes in a high-level language (like Java) called before
it is compiled?
A. Class Files
B. Bytecode
C. Machine Code
D. Source Code
Bloom’s Level: Remember
Concept Tested: Source code
Correct Answer: Source Code
Explanation: The statements written by the programmer are referred to as the source code.
Q31. In Java, the words main, Main, and MAIN are considered to be different. This property is
known as what?
13
13
A. Portability
B. Case sensitivity
C. Syntax flexibility
D. Dynamic typing
Bloom’s Level: Remember
Concept Tested: Case sensitivity in Java
Correct Answer: Case sensitivity
Explanation: Java is described as case-sensitive, meaning it distinguishes between uppercase
and lowercase letters.
Q32. What is the multi-step process that transforms Java source code into a running program?
A. The editing process
B. The compilation process
C. The debugging process
D. The documentation process
Bloom’s Level: Understand
Concept Tested: Compilation process
Correct Answer: The compilation process
Explanation: Figure 8 illustrates the process from source code to running program, central to
which is compilation by the Java compiler.
Q33. What is the recommended strategy for organizing programming work, involving a
hierarchy of containers for files?
A. Using a single desktop folder for all projects.
B. Creating separate folders for your class and for each program.
C. Relying on the IDE's default location for all files.
D. Storing all files on a network drive only.
Bloom’s Level: Apply
Concept Tested: Organizing files/folders
Correct Answer: Creating separate folders for your class and for each program.
14
14
Explanation: The chapter advises making a separate folder for your programming class and,
inside that, a folder for each program.
Q34. Why is developing a strategy for backup copies crucial for a programmer?
A. To make the code compile faster.
B. To prevent the frustration of retyping lost code due to accidents or malfunctions.
C. To meet the requirements of the Java compiler.
D. To reduce the size of the source code files.
Bloom’s Level: Evaluate
Concept Tested: Backup strategy importance
Correct Answer: To prevent the frustration of retyping lost code due to accidents or
malfunctions.
Explanation: The text emphasizes backing up work to avoid the frustrating and time-consuming
task of recreating lost files.
Q35. According to the chapter, what are the fundamental building blocks of Java programs?
A. Methods
B. Statements
C. Classes
D. Variables
Bloom’s Level: Remember
Concept Tested: Class as fundamental building block
Correct Answer: Classes
Explanation: The text explicitly states: "Classes are the fundamental building blocks of Java
programs."
Q36. Which method must every Java application contain, as it is the starting point for execution?
A. The start() method
B. The init() method
C. The run() method
D. The main method
15
15
Bloom’s Level: Remember
Concept Tested: Main method requirement
Correct Answer: The main method
Explanation: The chapter states that every Java application must have a main method, where
execution begins.
Q37. In Java, what is a named collection of programming instructions that describes how to
carry out a particular task?
A. A Class
B. A Method
C. A Statement
D. A Variable
Bloom’s Level: Remember
Concept Tested: Method definition
Correct Answer: A Method
Explanation: A method is defined as a collection of instructions that describe how to carry out a
task.
Q38. What is each individual instruction inside a method, which ends with a semicolon, called?
A. A Class
B. A Method
C. A Statement
D. An Argument
Bloom’s Level: Remember
Concept Tested: Statement definition
Correct Answer: A Statement
Explanation: Instructions inside a method are called statements, and each ends in a semicolon.
Q39. What character in Java must terminate every statement, serving as a crucial delimiter for
the compiler?
A. A period (.)
16
16
B. A colon (:)
C. A semicolon (;)
D. A comma (,)
Bloom’s Level: Remember
Concept Tested: Semicolon as statement terminator
Correct Answer: A semicolon (;)
Explanation: The text specifies that each statement ends in a semicolon.
Q40. What is the full name of the method used in the introductory example to print "Hello,
World!" and then move to a new line?
A. System.out.print
B. System.out.println
C. System.print.line
D. Console.writeLine
Bloom’s Level: Remember
Concept Tested: System.out.println method
Correct Answer: System.out.println
Explanation: The example program uses System.out.println to print the greeting.
Q41. In the statement System.out.println("Hello, World!"), what is the term for the value "Hello,
World!" that the method needs to carry out its task?
A. A Statement
B. A Method
C. An Argument (or Parameter)
D. A Class
Bloom’s Level: Understand
Concept Tested: Method arguments/parameters
Correct Answer: An Argument (or Parameter)
Explanation: The chapter defines a value that a method needs as an argument (e.g., the string
in println).
17
17
Q42. What is a sequence of characters enclosed in quotation marks, such as "Hello", formally
called in Java?
A. A Number
B. A Keyword
C. A String
D. A Comment
Bloom’s Level: Remember
Concept Tested: String definition
Correct Answer: A String
Explanation: A sequence of characters in quotation marks is defined as a string.
Q43. Why must text like "Hello" be enclosed in double quotation marks in Java source code?
A. To make the text bold in the output.
B. To indicate it is a comment for the programmer.
C. To tell the compiler it is a string literal, not a program instruction.
D. To mark it as the name of a variable.
Bloom’s Level: Analyze
Concept Tested: String literal syntax (quotes)
Correct Answer: To tell the compiler it is a string literal, not a program instruction.
Explanation: Quotation marks tell the compiler the contents are plain text, so it doesn't try to
interpret words like "main" as code.
Q44. Which method prints an item but does NOT start a new line afterward, allowing subsequent
output to appear on the same line?
A. System.out.println
B. System.out.newline
C. System.out.print
D. System.out.write
Bloom’s Level: Remember
Concept Tested: System.out.print method
18
18
Correct Answer: System.out.print
Explanation: The System.out.print method is introduced for printing without starting a new line.
Q45. An error where the programmer writes System.ou.println (missing a 't') is caught by the
compiler. What is this type of error called?
A. Run-time error
B. Logic error
C. Compile-time error
D. Virtual machine exception
Bloom’s Level: Understand
Concept Tested: Compile-time error (syntax error)
Correct Answer: Compile-time error
Explanation: Violations of language rules detected by the compiler, like a misspelled method
name, are compile-time errors.
Q46. A program compiles successfully but prints "Hello, Word!" instead of "Hello, World!".
What is this type of error called?
A. Compile-time error
B. Syntax error
C. Run-time error (Logic error)
D. Linker error
Bloom’s Level: Understand
Concept Tested: Run-time error (logic error)
Correct Answer: Run-time error (Logic error)
Explanation: An error where the program runs but produces incorrect results is a run-time or
logic error.
Q47. If a Java program executes the statement System.out.println(1 / 0);, the virtual machine will
stop and issue a message like "Division by zero". What is this type of error message called?
A. A compiler warning
B. A syntax error
19
19
C. An exception
D. A linker error
Bloom’s Level: Remember
Concept Tested: Exception (JVM error message)
Correct Answer: An exception
Explanation: Severe run-time errors that generate an error message from the JVM are called
exceptions.
Q48. The process of finding and fixing errors in a program, which includes addressing both
compile-time and run-time issues, is known as what?
A. Compiling
B. Executing
C. Debugging
D. Documenting
Bloom’s Level: Remember
Concept Tested: Debugging process
Correct Answer: Debugging
Explanation: The chapter discusses the need to diagnose and fix programming errors, which is
the debugging process.
Q49. What is a step-by-step description of how to solve a problem, which serves as a recipe
before programming begins?
A. A Program
B. Pseudocode
C. Source Code
D. An Algorithm
Bloom’s Level: Remember
Concept Tested: Algorithm definition
Correct Answer: An Algorithm
Explanation: An algorithm is defined as a step-by-step description of how to solve a problem.
20
20
Q50. For a sequence of steps to be considered a valid algorithm, it must be unambiguous,
executable, and what else?
A. Complex
B. Written in Java
C. Terminating
D. Approved by the compiler
Bloom’s Level: Understand
Concept Tested: Algorithm requirements (unambiguous, executable, terminating)
Correct Answer: Terminating
Explanation: The text lists the three requirements for an algorithm: unambiguous, executable,
and terminating.
Q51. What is the term for an informal, English-like description of an algorithm that is used for
human understanding before coding?
A. Machine Code
B. Java
C. Pseudocode
D. Syntax
Bloom’s Level: Remember
Concept Tested: Pseudocode definition
Correct Answer: Pseudocode
Explanation: Pseudocode is defined as an informal description of steps for solving a problem,
read by humans.
Q52. According to the software development process diagram (Figure 10), what should you do
immediately after developing and describing an algorithm?
A. Compile the Java program.
B. Test the algorithm with simple inputs.
C. Start translating the entire program into Java.
D. Document the code with comments.
21
21
Bloom’s Level: Understand
Concept Tested: Problem-solving process steps
Correct Answer: Test the algorithm with simple inputs.
Explanation: The diagram shows the step after describing an algorithm is to test it with simple
inputs.
Q53. The overall sequence depicted in Figure 10, from understanding the problem to compiling
and testing the final program, represents what?
A. The hardware lifecycle.
B. The software development process.
C. The Java compilation process.
D. The debugging workflow.
Bloom’s Level: Understand
Concept Tested: Software development process
Correct Answer: The software development process
Explanation: Figure 10 is labeled "the software development process."
Q54. Which machine, completed in 1946, is identified in the chapter as the first usable electronic
computer?
A. The IBM PC
B. The ENIAC
C. The Transistor Computer
D. The Sun Workstation
Bloom’s Level: Remember
Concept Tested: ENIAC (first electronic computer)
Correct Answer: The ENIAC
Explanation: Random Fact 1.1 titles the section "the ENIAC and the dawn of Computing" and
states it was the first usable electronic computer.
Q55. For what primary military purpose was the ENIAC originally designed and used?
A. Decrypting enemy communications.
22
22
B. Simulating nuclear reactions.
C. Computing ballistic tables for projectile trajectories.
D. Managing payroll for the U.S. Navy.
Bloom’s Level: Remember
Concept Tested: ENIAC purpose (ballistic tables)
Correct Answer: Computing ballistic tables for projectile trajectories.
Explanation: Its work was supported by the U.S. Navy to compute ballistic tables giving
projectile trajectories.
Q56. In what year was the ENIAC computer completed?
A. 1939
B. 1946
C. 1948
D. 1951
Bloom’s Level: Remember
Concept Tested: ENIAC completion year (1946)
Correct Answer: 1946
Explanation: The text states the ENIAC was completed in 1946.
Q57. Who was one of the two designers of the ENIAC computer at the University of
Pennsylvania?
A. James Gosling
B. J. Presper Eckert
C. Patrick Naughton
D. John von Neumann
Bloom’s Level: Remember
Concept Tested: J. Presper Eckert
Correct Answer: J. Presper Eckert
Explanation: The ENIAC was designed by J. Presper Eckert and John Mauchly.
23
23
Q58. Along with J. Presper Eckert, who is credited as the co-designer of the ENIAC?
A. John Mauchly
B. James Gosling
C. John von Neumann
D. Alan Turing
Bloom’s Level: Remember
Concept Tested: John Mauchly
Correct Answer: John Mauchly
Explanation: John Mauchly is named as Eckert's co-designer of the ENIAC.
Q59. The ENIAC was built using approximately 18,000 of which now-obsolete electronic
component?
A. Transistors
B. Integrated Circuits
C. Vacuum Tubes
D. Magnetic Cores
Bloom’s Level: Remember
Concept Tested: Vacuum tubes
Correct Answer: Vacuum Tubes
Explanation: The ENIAC consisted of cabinets containing about 18,000 vacuum tubes.
Q60. The ENIAC was completed two years before which fundamental electronic component was
invented?
A. The Integrated Circuit
B. The Microprocessor
C. The Vacuum Tube
D. The Transistor
Bloom’s Level: Remember
Concept Tested: Transistor invention (1948)
24
24
Correct Answer: The Transistor
Explanation: It was completed in 1946, two years before transistors were invented (1948).
Q61. Which of the following is given in the chapter as an example of a primitive instruction a
CPU can execute?
A. "Find the most attractive photo in a sequence."
B. "Put a red dot at a given screen position."
C. "Compute the monthly charge for a cell phone plan."
D. "Balance my checkbook."
Bloom’s Level: Remember
Concept Tested: Program instruction examples (primitive)
Correct Answer: "Put a red dot at a given screen position."
Explanation: The text lists very basic instructions like putting a red dot, adding numbers, or
making a conditional jump.
Q62. Where does the computer store both data and programs when they are not currently in use?
A. In the Central Processing Unit (CPU)
B. In primary storage (memory)
C. In secondary storage (e.g., hard disk)
D. In the graphics card's buffer
Bloom’s Level: Understand
Concept Tested: Storing data vs. programs
Correct Answer: In secondary storage (e.g., hard disk)
Explanation: Both data and programs are located in secondary storage and loaded into memory
when needed.
Q63. When a program is running, what does the CPU do with the program instructions it has
loaded into memory?
A. Stores them permanently back to the hard disk.
B. Reads and executes them one at a time.
25
25
C. Displays them on the screen for the user.
D. Transmits them over the network to other computers.
Bloom’s Level: Understand
Concept Tested: Fetching and executing instructions
Correct Answer: Reads and executes them one at a time.
Explanation: The CPU reads the program one instruction at a time from memory and executes
it.
Q64. Why does a computer user perceive smooth interaction from a program composed of
primitive instructions?
A. Because each instruction is very complex and high-level.
B. Because the program contains a huge number of instructions executed at great speed.
C. Because modern CPUs execute only one instruction per second.
D. Because the instructions are written in pseudocode first.
Bloom’s Level: Analyze
Concept Tested: User illusion of smooth interaction
Correct Answer: Because the program contains a huge number of instructions executed at great
speed.
Explanation: The illusion of smoothness comes from the vast number of simple instructions and
the CPU's high speed.
Q65. The chapter suggests that creating a complex software product like a modern word
processor requires what?
A. A single highly-skilled programmer.
B. A team of many highly-skilled programmers.
C. An extremely powerful supercomputer.
D. Writing the program in machine code for efficiency.
Bloom’s Level: Remember
Concept Tested: Programmer team necessity for complex software
Correct Answer: A team of many highly-skilled programmers.
26
26
Explanation: It states that writing a sophisticated word processor is a complex task requiring a
team.
Q66. According to the author, what can be a thrilling experience even in simple programming
tasks?
A. Memorizing the entire Java library.
B. Seeing the computer quickly carry out a tedious task.
C. Getting a program to compile without any errors on the first try.
D. Writing pseudocode that is perfectly formatted.
Bloom’s Level: Evaluate
Concept Tested: Thrill of simple programming
Correct Answer: Seeing the computer quickly carry out a tedious task.
Explanation: The text describes the thrill of seeing the computer precisely and quickly complete
a task that would be human drudgery.
Q67. In the pseudocode example for choosing a car, what are the two main cost components that
are summed to find the "total cost"?
A. Fuel cost and insurance cost.
B. Purchase price and operating cost.
C. Annual miles and price per gallon.
D. Fuel efficiency and maintenance cost.
Bloom’s Level: Apply
Concept Tested: Example: Comparing can pack vs. bottle (adapted to car example)
Correct Answer: Purchase price and operating cost.
Explanation: The algorithm defines total cost = purchase price + operating cost.
Q68. The chapter advises that well-chosen variable names can serve as documentation. What is
this practice often called?
A. Writing comments
B. Creating self-documenting code
27
27
C. Using magic numbers
D. Compiling source code
Bloom’s Level: Remember
Concept Tested: Self-documenting code
Correct Answer: Creating self-documenting code
Explanation: While not a major focus, the idea that good names reduce the need for separate
comments relates to self-documenting code, a key programming practice hinted at in problem-
solving.
Q69. In programming, what is the term for an unexplained numeric constant (like 0.05 for 5%
interest) that should ideally be avoided?
A. A variable
B. A string literal
C. A magic number
D. An operator
Bloom’s Level: Remember
Concept Tested: Magic number (avoidance)
Correct Answer: A magic number
Explanation: This is a standard term in programming for hard-coded numbers without clear
meaning, which the text implies is bad practice by using named constants in examples.
Q70. What backup strategy involves using multiple directories and cycling through them, so you
always have several recent versions?
A. Single backup
B. Network backup
C. Rotating backups
D. Incremental backup
Bloom’s Level: Understand
Concept Tested: Rotating backups
28
28
Correct Answer: Rotating backups
Explanation: Programming Tip 1.1 recommends rotating backups across multiple directories.
Q71. Why is it important to "check your backups once in a while"?
A. To ensure they are not taking up too much disk space.
B. To double-check that the backups are where you think they are.
C. To compile the Java programs stored in the backup.
D. To delete old backups automatically.
Bloom’s Level: Apply
Concept Tested: Checking backup integrity
Correct Answer: To double-check that the backups are where you think they are.
Explanation: The tip explicitly states to check that backups exist in the expected location.
Q72. When restoring a lost file from a backup, what does the chapter recommend you do first to
avoid making a mistake?
A. Immediately copy the newest backup file.
B. Take a deep breath and think through the recovery process.
C. Delete the corrupted original file to make space.
D. Run a virus scan on the backup file.
Bloom’s Level: Apply
Concept Tested: Restoring from backups
Correct Answer: Take a deep breath and think through the recovery process.
Explanation: The text advises relaxing and thinking first to avoid accidentally overwriting
backups.
Q73. In Figure 6, the "Hello, World!" output is shown in a simple text-based window. What is
this type of window commonly called?
A. An editor window
B. A browser window
C. A console window
D. A dialog box
29
29
Bloom’s Level: Remember
Concept Tested: Console window output
Correct Answer: A console window
Explanation: The figure caption describes it as a "Console Window".
Q74. In Java, the convention for writing multi-word variable or method names
(like annualFuelCost) is called what?
A. PascalCase
B. snake_case
C. camelCase
D. kebab-case
Bloom’s Level: Remember
Concept Tested: Naming conventions (camelCase)
Correct Answer: camelCase
Explanation: Java uses camelCase for method and variable names (e.g., annualFuelCost), as
shown in examples.
Q75. The first line of the HelloPrinter program is public class HelloPrinter. What does the
keyword public signify here?
A. The class is very simple.
B. The class can be used by any other part of the program.
C. The class contains the main method.
D. The class is located in a public folder.
Bloom’s Level: Understand
Concept Tested: Public class declaration
Correct Answer: The class can be used by any other part of the program.
Explanation: The text explains public denotes the class is usable by the "public" or other code.
Q76. For a Java source file containing a public class named HelloPrinter, what must the file be
named?
A. Main.java
30
30
B. HelloPrinter.java
C. Hello.java
D. Printer.java
Bloom’s Level: Remember
Concept Tested: Class name matching file name
Correct Answer: HelloPrinter.java
Explanation: The rule is the public class name must match the file name, so HelloPrinter.java.
Q77. In the declaration public static void main(String[] args), what does the
keyword void indicate?
A. The method accepts no arguments.
B. The method returns no value.
C. The method is empty.
D. The method can be called multiple times.
Bloom’s Level: Understand
Concept Tested: Void keyword in main method
Correct Answer: The method returns no value.
Explanation: void is a Java keyword meaning the method does not return any value.
Q78. The chapter mentions that the term static in the main method header will be explained in
detail later. At this point, how does it suggest beginners treat it?
A. As a critical part of the algorithm.
B. As a required part of the "plumbing" for a Java program.
C. As an optional keyword that can be omitted.
D. As a variable name.
Bloom’s Level: Remember
Concept Tested: Static keyword (preliminary)
Correct Answer: As a required part of the "plumbing" for a Java program.
Explanation: The text advises considering public static void main(...) as part of the required
"plumbing" for now.
31
31
Q79. What is the purpose of the (String[] args) parameter in the main method header?
A. It holds the command-line arguments passed to the program.
B. It defines a string variable named "args".
C. It tells the compiler to print arguments.
D. It is a placeholder with no purpose in simple programs.
Bloom’s Level: Understand
Concept Tested: String[] args parameter
Correct Answer: It holds the command-line arguments passed to the program.
Explanation: While details are in Chapter 7, the parameter is for command-line arguments.
Q80. What is the action of asking a method to perform its task, such as
writing System.out.println("Hello"), called?
A. Defining a method
B. Declaring a method
C. Calling (or invoking) a method
D. Compiling a method
Bloom’s Level: Remember
Concept Tested: Invoking/calling a method
Correct Answer: Calling (or invoking) a method
Explanation: The text uses the phrase "call a method" when describing System.out.println.
Q81. What will the statement System.out.println(3 + 4); output?
A. "3 + 4"
B. 7
C. "7"
D. It will cause an error because numbers can't be printed.
Bloom’s Level: Apply
Concept Tested: Printing numerical values
Correct Answer: 7
Explanation: The chapter states it evaluates the expression 3 + 4 and displays the number 7.
32
32
Q82. What common error occurs if a programmer writes System.out.println("Hello") without the
semicolon?
A. A run-time logic error.
B. A compile-time (syntax) error.
C. No error; the program will run fine.
D. A virtual machine exception.
Bloom’s Level: Understand
Concept Tested: Omitting semicolon error
Correct Answer: A compile-time (syntax) error.
Explanation: Omitting a semicolon is a syntax violation that the compiler will catch.
Q83. What error occurs if a programmer writes System.out.println(Hello); without quotes
around Hello?
A. The program will print the value of a variable named Hello.
B. It is a run-time error "Cannot find symbol Hello".
C. It is a compile-time error "Cannot find symbol Hello".
D. The program will print the word "Hello" correctly.
Bloom’s Level: Analyze
Concept Tested: Omitting quotation marks error
Correct Answer: It is a compile-time error "Cannot find symbol Hello".
Explanation: Without quotes, the compiler thinks Hello is a variable name. When it can't find it,
it reports a compile-time error.
Q84. Writing Main instead of main for the method name results in the program compiling but
failing to run. Why?
A. Because Main is a reserved keyword.
B. Because the Java Virtual Machine is case-sensitive and looks for a main method specifically.
C. Because the compiler changes Main to main automatically.
D. Because Main is the name of the required class.
33
33
Bloom’s Level: Analyze
Concept Tested: Misspelling words/case error
Correct Answer: Because the Java Virtual Machine is case-sensitive and looks for
a main method specifically.
Explanation: Common Error 1.2 explains the JVM looks for main, and Main is considered a
different, unrelated method.
Q85. The chapter uses the example of a computerized dating service to illustrate what key
limitation of computers in problem-solving?
A. Computers are too slow for such tasks.
B. Computers cannot execute instructions rapidly.
C. Computers can only solve problems for which an objective, unambiguous algorithm exists.
D. Computers require the internet to solve any problem.
Bloom’s Level: Evaluate
Concept Tested: Limitations of computer problem-solving
Correct Answer: Computers can only solve problems for which an objective, unambiguous
algorithm exists.
Explanation: It explains a computer cannot find the "best-looking" partner because there's no
objective standard/algorithm for that.
Q86. In the dating service example, why is "Find the best-looking person" not a solvable
computer problem?
A. Because it requires too much memory.
B. Because "good looks" is a subjective criterion, not an objective one.
C. Because computers cannot process images.
D. Because it would take too long to compute.
Bloom’s Level: Analyze
Concept Tested: Objective vs. subjective criteria
Correct Answer: Because "good looks" is a subjective criterion, not an objective one.
Explanation: The text contrasts subjective opinions with the objective, unambiguous
instructions a computer needs.
34
34
Q87. The step-by-step process used to determine how many years it takes for a $10,000
investment at 5% to double is an example of what?
A. A compiler error.
B. A pseudocode description.
C. An algorithm for solving an investment doubling problem.
D. A Java program.
Bloom’s Level: Understand
Concept Tested: Investment doubling problem
Correct Answer: An algorithm for solving an investment doubling problem.
Explanation: The manual calculation and subsequent pseudocode describe an algorithm for this
specific problem.
Q88. Manually calculating the balance year by year until it reaches $20,000 is described in the
chapter as what kind of computation?
A. A thrilling computation.
B. A stepwise computation.
C. A compiled computation.
D. An erroneous computation.
Bloom’s Level: Remember
Concept Tested: Stepwise computation
Correct Answer: A stepwise computation.
Explanation: The text describes carrying out the computation "stepwise" until the condition is
met.
Q89. What is the control structure used in the pseudocode for the investment problem to repeat
steps while the balance is less than $20,000?
A. An If statement
B. A For loop
C. A While loop
D. A Switch statement
35
35
Bloom’s Level: Apply
Concept Tested: Pseudocode for investment doubling
Correct Answer: A While loop
Explanation: The pseudocode says: "Repeat the following steps while the balance is less than
$20,000".
Q90. In pseudocode, which of the following is an example of a statement that describes how a
value is set or changed?
A. If total cost1 < total cost2
B. While the balance is less than $20,000
C. total cost = purchase price + operating cost
D. Report the final year value as the answer.
Bloom’s Level: Apply
Concept Tested: Pseudocode statements for setting values
Correct Answer: total cost = purchase price + operating cost
Explanation: The chapter lists "total cost = purchase price + operating cost" as an example of
setting a value.
Q91. Which of the following is a pseudocode statement for describing a decision?
A. For each car
B. Remove the first and last character from the word.
C. If total cost1 < total cost2
D. Add 1 to the year value.
Bloom’s Level: Apply
Concept Tested: Pseudocode for decisions/repetitions
Correct Answer: If total cost1 < total cost2
Explanation: The text gives "If total cost1 < total cost2" as an example for describing decisions.
Q92. In the chapter's pseudocode examples, what is used to visually indicate which statements
are part of a loop or decision block?
A. Semicolons
36
36
B. Quotation Marks
C. Indentation
D. Curly Braces {}
Bloom’s Level: Remember
Concept Tested: Indentation in pseudocode
Correct Answer: Indentation
Explanation: It states "Use indentation to indicate which statements should be selected or
repeated".
Q93. In the Java HelloPrinter program, the opening brace { after public class HelloPrinter must
have a corresponding closing brace }. What is this requirement called?
A. Indentation
B. Case matching
C. Statement termination
D. Matching braces
Bloom’s Level: Remember
Concept Tested: Matching braces {}
Correct Answer: Matching braces
Explanation: Syntax 1.1 advises to "match the opening and closing braces".
Q94. In the expression balance * 0.05 within the investment algorithm, what does the * symbol
represent?
A. The addition operator.
B. The multiplication operator.
C. The exponentiation operator.
D. A wildcard character.
Bloom’s Level: Remember
Concept Tested: Arithmetic operators (+, -, *, /)
Correct Answer: The multiplication operator.
Explanation: * is the operator for multiplication in Java and the pseudocode.
37
37
Q95. In the statement System.out.println("My lucky number is" + 12);, the + operator is used to
concatenate a string and a number. What is its primary arithmetic purpose?
A. String concatenation
B. Multiplication
C. Division
D. Addition
Bloom’s Level: Understand
Concept Tested: Operator precedence (implied through use)
Correct Answer: Addition
Explanation: While + can concatenate, its fundamental arithmetic purpose is addition, as shown
in 3 + 4.
Q96. In Java, text that begins with // on a line is ignored by the compiler. What is this text
called?
A. A string
B. A method
C. A comment
D. A command
Bloom’s Level: Remember
Concept Tested: Comments syntax (// and /* */)
Correct Answer: A comment
Explanation: While not heavily used in Chapter 1, // is the standard syntax for a single-line
comment, a fundamental concept.
Q97. What is the name for the special multi-line comment format /** ... */ that is used to
generate documentation automatically?
A. A block comment
B. A Javadoc comment
C. A string literal
D. A compiler directive
38
38
Bloom’s Level: Remember
Concept Tested: Javadoc comments (/** */)
Correct Answer: A Javadoc comment
Explanation: /** */ is the syntax for Javadoc comments, used for formal API documentation.
Q98. What is the primary purpose of the documentation generated from Javadoc comments?
A. To make the code run faster.
B. To serve as a reference for other programmers using the code's classes and methods.
C. To hide code from the compiler.
D. To create backup copies of source files.
Bloom’s Level: Understand
Concept Tested: API Documentation purpose
Correct Answer: To serve as a reference for other programmers using the code's classes and
methods.
Explanation: API (Application Programming Interface) documentation describes how to use
code components.
Q99. What is the purpose of the "Review Exercises" (R1.1, etc.) found at the end of the chapter?
A. To provide more complex programming projects.
B. To allow students to practice and test their understanding of the chapter concepts.
C. To list all the keywords in Java.
D. To serve as the only graded assignment.
Bloom’s Level: Understand
Concept Tested: Review exercises for practice
Correct Answer: To allow students to practice and test their understanding of the chapter
concepts.
Explanation: Review exercises are for practice and self-assessment of conceptual
understanding.
Q100. How do the "Programming Exercises" (P1.1, etc.) differ from the "Review Exercises"?
A. They are easier and shorter.
39
39
B. They require writing actual Java programs to solve problems.
C. They focus only on multiple-choice questions.
D. They are optional and not related to the chapter.
Bloom’s Level: Understand
Concept Tested: Programming exercises for practice
Correct Answer: They require writing actual Java programs to solve problems.
Explanation: Programming exercises are hands-on tasks that involve implementing code,
applying the chapter's concepts.
TRUE/FALSE QUESTIONS
Q1. In Java, System.out.print("Hello"); and System.out.println("Hello"); produce identical
output, including a trailing newline character.
Answer: False
Bloom’s Level: Remember
Concept Tested: Print vs. Println difference
Justification: println appends a newline, print does not. This distinction is crucial for formatting
algorithm output and logs.
Q2. The Java statement int result = 1 / 0; will cause a compile-time error.
Answer: False
Bloom’s Level: Apply
Concept Tested: Dividing by zero run-time error
Justification: This is a run-time ArithmeticException. The compiler only checks syntax; the
error occurs during program execution.
Q3. You can effectively test a program for run-time errors while it still has unresolved compile-
time (syntax) errors.
Answer: False
Bloom’s Level: Analyze
40
40
Concept Tested: Testing for run-time errors
Justification: Compile-time errors prevent the creation of an executable class file, so the
program cannot run and thus cannot be tested for run-time errors.
Q4. When a program "crashes" (terminates unexpectedly) or "hangs" (stops responding), it is
experiencing a compile-time syntax error.
Answer: False
Bloom’s Level: Understand
Concept Tested: Program crashing/hanging
Justification: Crashing or hanging are behaviors that occur during program execution, indicating
run-time errors like infinite loops or uncaught exceptions.
Q5. The relationship between CPU instructions and perceived speed is that a single, highly
complex instruction makes a computer fast.
Answer: False
Bloom’s Level: Analyze
Concept Tested: Relationship between instructions and speed
Justification: Speed comes from executing an enormous sequence of very simple instructions at
an extremely high frequency (billions per second).
Q6. The primary reason computers are more flexible than single-use machines (like a toaster) is
their superior processing speed.
Answer: False
Bloom’s Level: Evaluate
Concept Tested: Flexibility of computers vs. single-use machines
Justification: Flexibility stems from being programmableable to execute different software
for different tasks. Speed is a secondary characteristic.
Q7. The "balance checkbook" example in the chapter is used to illustrate a task that is too
complex and subjective for a computer to handle.
41
41
Answer: False
Bloom’s Level: Remember
Concept Tested: Balance checkbook example
Justification: It illustrates a repetitive, tedious task that a computer handles perfectly, showing
automation's value for objective, algorithmic work.
Q8. The chapter uses the example of a modern word processor to demonstrate a program a
beginner could easily write as a first project.
Answer: False
Bloom’s Level: Remember
Concept Tested: Word processor example
Justification: A word processor is cited as an example of complex software requiring a large
team of skilled programmers, far beyond beginner scope.
Q9. The first programs students write in this course are expected to be as sophisticated and
feature-rich as commercial applications.
Answer: False
Bloom’s Level: Understand
Concept Tested: Initial program simplicity
Justification: Early programs are intentionally simple, focusing on core concepts like variables
and I/O, not on building complex, polished applications.
Q10. The central goal of learning foundational programming concepts is to memorize the syntax
and names of every method in the Java standard library.
Answer: False
Bloom’s Level: Evaluate
Concept Tested: Learning foundational concepts
Justification: The goal is to learn problem-solving and algorithmic thinking. The vast library is
a tool to be referenced, not memorized.
42
42
Q11. Setting up your programming environment (editor, compiler, etc.) is an optional, advanced
step that can be deferred until later in the course.
Answer: False
Bloom’s Level: Apply
Concept Tested: Programming environment setup
Justification: It is a necessary first step. You cannot write, compile, or run programs without a
properly configured development environment.
Q12. To run your first Java program, you simply type the source code into a text editor and
double-click the file.
Answer: False
Bloom’s Level: Apply
Concept Tested: Running a first program
Justification: Java source code must be explicitly compiled (javac) into bytecode, which is then
executed by the Java Virtual Machine (java).
Q13. Diagnosing programming errors refers only to the process of fixing mistakes that cause the
program to fail compilation.
Answer: False
Bloom’s Level: Analyze
Concept Tested: Diagnosing programming errors
Justification: It encompasses fixing both compile-time (syntax) errors and run-time (logic)
errors, which may produce incorrect output without crashing.
Q14. Describing an algorithm with pseudocode is the final, executable form of a computer
program.
Answer: False
Bloom’s Level: Understand
Concept Tested: Describing algorithms
43
43
Justification: Pseudocode is an informal, human-readable planning tool. It must be translated
into a formal programming language like Java to be executed.
Q15. Planning computer programs by first designing an algorithm is an outdated practice that
modern programmers skip to code faster.
Answer: False
Bloom’s Level: Evaluate
Concept Tested: Planning computer programs
Justification: Algorithm design is a critical, foundational step in software development. It
ensures a clear, correct, and efficient solution strategy.
Q16. In the schematic anatomy of a personal computer, the Central Processing Unit (CPU)
fetches instructions directly from the hard disk.
Answer: False
Bloom’s Level: Analyze
Concept Tested: Anatomy of a personal computer schematic
Justification: The CPU fetches instructions from main memory (RAM). Programs are loaded
from the hard disk into memory before execution.
Q17. When a program starts, the operating system loads the entire program from secondary
storage (e.g., SSD) directly into the CPU's registers.
Answer: False
Bloom’s Level: Understand
Concept Tested: Loading programs into memory
Justification: Programs are loaded into the main memory (RAM). The CPU then fetches
instructions from memory into its registers for execution.
Q18. The CPU reads and executes program instructions strictly in the sequential order they
appear in memory, with no exceptions.
Answer: False
Bloom’s Level: Analyze
44
44
Concept Tested: CPU reading instructions sequentially
Justification: While execution is generally sequential, control flow instructions (like jumps for
loops/conditionals) and modern techniques (pipelines, speculation) change the order.
Q19. A key function of the CPU is to read data from input devices, modify it through arithmetic
operations, and write the results back to an output device.
Answer: True
Bloom’s Level: Remember
Concept Tested: Modifying and writing data
Justification: This describes the core "process" in the input-process-output cycle. The CPU
performs calculations and coordinates data movement.
Q20. A computer generates smooth video and audio by sending a single, complex "play movie"
instruction to the graphics and sound cards.
Answer: False
Bloom’s Level: Analyze
Concept Tested: Displaying images and sound
Justification: Smooth output results from the rapid execution of thousands of simple instructions
per frame (e.g., calculating pixels, audio samples).
Q21. Reading user input from a keyboard involves the program directly polling the keyboard's
hardware port for key presses.
Answer: False
Bloom’s Level: Understand
Concept Tested: Reading user input (keyboard/mouse)
Justification: Input is handled by the operating system and device drivers. Programs receive
input through high-level APIs (like Scanner), not direct hardware access.
Q22. After a program reads user input, it must analyze that input to determine the next block of
code to execute, enabling interactive behavior.
45
45
Answer: True
Bloom’s Level: Apply
Concept Tested: Analyzing user input
Justification: This decision-making, often using if or switch statements, is fundamental to
creating programs that respond differently to different inputs.
Q23. The sequence of Java bytecode instructions executed by the JVM is fixed at compile time
and cannot be altered based on data values during runtime.
Answer: False
Bloom’s Level: Analyze
Concept Tested: Choosing which instructions to execute
Justification: Conditional and iterative statements compile into bytecode that can change the
execution path at runtime, which is essential for all non-trivial algorithms.
Q24. The ENIAC, often cited as the dawn of practical computing, was built using transistors,
which made it more reliable than earlier mechanical computers.
Answer: False
Bloom’s Level: Remember
Concept Tested: Random Fact: ENIAC and computing dawn
Justification: ENIAC used about 18,000 vacuum tubes, not transistors (invented later). Tubes
were less reliable and generated significant heat.
Q25. The worked example for writing a tiling algorithm primarily focuses on optimizing
memory usage and cache performance for large tile sets.
Answer: False
Bloom’s Level: Remember
Concept Tested: Worked Example: Writing a tiling algorithm
Justification: The example focuses on designing the step-by-step logic (algorithm) for placing
tiles in a pattern, not on low-level performance optimization.
46
46
QUIZ 2: FUNDAMENTAL DATA TYPES
MULTIPLE-CHOICE QUESTIONS
Q1. In Java, which of the following correctly declares and initializes an integer variable
named count with the value 10?
A. int count = 10;
B. count int = 10;
C. integer count = 10;
D. count = 10;
Bloom’s Level: Remember
Concept Tested: Variable declaration
Correct Answer: int count = 10;
Explanation: A variable declaration specifies the type (int), the variable name (count), and
optionally an initial value (10). The syntax requires the type before the name.
Q2. Which of the following best defines a variable in a computer program?
A. A fixed value that cannot be changed during program execution.
B. A named storage location that holds a value, which can be modified.
C. A sequence of instructions that performs a specific task.
D. A method that returns a computed result.
Bloom’s Level: Understand
Concept Tested: Variable as named storage location
Correct Answer: A named storage location that holds a value, which can be modified.
Explanation: A variable is a storage location with a name. It holds data that can be read and
updated, analogous to a labeled box holding an item.
Q3. What is the term for providing an initial value to a variable at the time of its declaration?
A. Casting
B. Initializing
47
47
C. Concatenating
D. Formatting
Bloom’s Level: Remember
Concept Tested: Initializing a variable
Correct Answer: Initializing
Explanation: Initializing a variable means assigning it a value when it is declared. This is done
using the = operator.
Q4. In the variable declaration double price = 19.99;, what does the word double specify?
A. The name of the variable.
B. The initial value of the variable.
C. The type of data the variable can hold.
D. The memory address of the variable.
Bloom’s Level: Understand
Concept Tested: Specifying variable type
Correct Answer: The type of data the variable can hold.
Explanation: The double keyword specifies the data type, indicating that the variable price can
store floating-point numbers.
Q5. Which Java data type is most appropriate for storing a whole number, such as the count of
items in a shopping cart?
A. double
B. String
C. int
D. float
Bloom’s Level: Apply
Concept Tested: int data type (integer)
Correct Answer: int
Explanation: The int type is used for integers (whole numbers) without fractional parts. It is
suitable for counts, indices, and other discrete quantities.
48
48
Q6. You need to store a value representing the average temperature (like 98.6°F). Which Java
primitive type is most suitable?
A. int
B. char
C. double
D. boolean
Bloom’s Level: Apply
Concept Tested: double data type (floating-point)
Correct Answer: double
Explanation: The double type represents double-precision floating-point numbers, which can
store fractional values like temperatures or measurements.
Q7. In Java, what is the term for a fixed numeric value written directly in the source code, such
as 3.14159 or 42?
A. Variable
B. Constant
C. Number literal
D. Expression
Bloom’s Level: Remember
Concept Tested: Number literals
Correct Answer: Number literal
Explanation: A number literal is a fixed numeric value (like 5 or 2.0) that appears directly in the
code. It is not stored in a variable.
Q8. The variable naming style where multiple words are joined, and each word after the first
begins with a capital letter (e.g., cansPerPack), is known as:
A. Snake case
B. Pascal case
C. Camel case
D. Kebab case
49
49
Bloom’s Level: Remember
Concept Tested: Camel case naming convention
Correct Answer: Camel case
Explanation: Camel case is a naming convention where the first word is lowercase and
subsequent words start with an uppercase letter, producing a shape resembling camel humps.
Q9. Which of the following is a valid Java variable name according to the rules presented in
Chapter 2?
A. 2ndPlace
B. my-variable
C. _score
D. final
Bloom’s Level: Apply
Concept Tested: Variable name rules (letters, digits, underscore)
Correct Answer: _score
Explanation: Variable names can start with a letter or underscore, and contain letters, digits, or
underscores. _score is valid; names cannot start with a digit or contain hyphens.
Q10. Which of the following is a Java reserved word (keyword) and therefore cannot be used as
a variable name?
A. value
B. number
C. double
D. data
Bloom’s Level: Remember
Concept Tested: Reserved words (keywords)
Correct Answer: double
Explanation: double is a Java keyword used to declare a floating-point type. Keywords have
special meanings and cannot be used as identifiers like variable names.
50
50
Q11. In Java, are the variable names totalVolume and TotalVolume considered the same?
A. Yes, because they represent the same concept.
B. No, because Java is case-sensitive, so they are different identifiers.
C. Only if they are declared in the same scope.
D. Yes, because uppercase and lowercase letters are interchangeable in variable names.
Bloom’s Level: Understand
Concept Tested: Case sensitivity of names
Correct Answer: No, because Java is case-sensitive, so they are different identifiers.
Explanation: Java is case-sensitive, meaning totalVolume and TotalVolume are distinct variable
names. This applies to all identifiers.
Q12. What is the purpose of the assignment operator (=) in Java?
A. To compare two values for equality.
B. To store a value into a variable.
C. To declare a new variable.
D. To perform arithmetic addition.
Bloom’s Level: Understand
Concept Tested: Assignment statement (=)
Correct Answer: To store a value into a variable.
Explanation: The assignment operator (=) assigns the value on its right-hand side to the variable
on its left-hand side. It does not denote mathematical equality.
Q13. How does the assignment operator (=) in Java fundamentally differ from the mathematical
equality symbol?
A. In Java, = checks if two values are equal, while in mathematics it assigns a value.
B. In Java, = assigns a value to a variable, while in mathematics it states that two expressions are
equal.
C. There is no difference; they both denote equality.
D. In Java, = can only be used with numbers, while in mathematics it can be used with any
expression.
51
51
Bloom’s Level: Analyze
Concept Tested: Assignment vs. mathematical equality
Correct Answer: In Java, = assigns a value to a variable, while in mathematics it states that two
expressions are equal.
Explanation: In programming, = is an instruction to store a value. In mathematics, = asserts a
relationship between two expressions. They are conceptually different.
Q14. After the execution of the statement x = x + 1; in Java, what happens to the value stored in
variable x?
A. It remains unchanged.
B. It is incremented by 1, replacing the previous value.
C. It is compared to the value x + 1.
D. It causes a compile-time error because x cannot equal x + 1.
Bloom’s Level: Apply
Concept Tested: Replacing variable values
Correct Answer: It is incremented by 1, replacing the previous value.
Explanation: The assignment evaluates the expression x + 1 and stores the result back into x,
overwriting the old value. This is a common pattern for incrementing.
Q15. Which keyword is used in Java to declare a constant variable whose value cannot be
changed after initialization?
A. static
B. final
C. constant
D. fixed
Bloom’s Level: Remember
Concept Tested: final keyword (constants)
Correct Answer: final
Explanation: The final keyword indicates that a variable is a constant; once assigned, its value
cannot be modified. It must be initialized when declared.
52
52
Q16. According to Java naming conventions, how should constants (final variables) typically be
named?
A. Using camel case starting with a lowercase letter (e.g., maxSize).
B. Using all uppercase letters with underscores separating words (e.g., MAX_SIZE).
C. Using Pascal case starting with an uppercase letter (e.g., MaxSize).
D. Using any style as long as the final keyword is used.
Bloom’s Level: Remember
Concept Tested: Constant naming convention (UPPER_CASE)
Correct Answer: Using all uppercase letters with underscores separating words
(e.g., MAX_SIZE).
Explanation: By convention, constants are named in all capital letters with underscores to
distinguish them from regular variables and improve readability.
Q17. What is the primary purpose of adding comments to a Java program?
A. To make the code execute faster.
B. To provide explanations for human readers, making the code easier to understand.
C. To reduce the size of the compiled bytecode.
D. To hide parts of the code from the compiler.
Bloom’s Level: Understand
Concept Tested: Comments for human readers
Correct Answer: To provide explanations for human readers, making the code easier to
understand.
Explanation: Comments are non-executable notes intended for programmers. They clarify
intent, describe algorithms, or document assumptions.
Q18. Which symbol sequence is used in Java to begin a single-line comment?
A. /*
B. //
C. <!--
D. #
53
53
Bloom’s Level: Remember
Concept Tested: // single-line comment delimiter
Correct Answer: //
Explanation: A double slash (//) starts a single-line comment. Everything from // to the end of
the line is ignored by the compiler.
Q19. How do you enclose a multi-line comment (a comment spanning several lines) in Java?
A. Between // and the end of each line.
B. Between /* and */.
C. Between /** and */.
D. Between # and a newline.
Bloom’s Level: Remember
Concept Tested: /* */ multi-line comment delimiter
Correct Answer: Between /* and */.
Explanation: Multi-line comments start with /* and end with */. Everything between is ignored
by the compiler, regardless of line breaks.
Q20. Which comment format is specifically used for documentation comments that can be
processed by tools like Javadoc to generate API documentation?
A. //
B. /* */
C. /** */
D. #
Bloom’s Level: Remember
Concept Tested: /** */ documentation comment delimiter
Correct Answer: /** */
Explanation: Documentation comments begin with /** and end with */. They describe classes,
methods, and fields for automatic documentation generation.
Q21. How does the Java compiler treat comments in the source code?
A. It compiles them into bytecode for runtime display.
54
54
B. It completely ignores them; they are only for human readers.
C. It uses them to optimize the generated machine code.
D. It checks them for syntax errors.
Bloom’s Level: Remember
Concept Tested: Compiler ignoring comments
Correct Answer: It completely ignores them; they are only for human readers.
Explanation: The compiler skips over comments. They have no effect on the program's
execution or size; they are purely for documentation.
Q22. What is a "magic number" in the context of programming, as described in Chapter 2?
A. A number that causes a program to crash.
B. A numeric constant that appears in code without an explanatory name.
C. A number that is the result of a complex calculation.
D. A number that is used in cryptographic algorithms.
Bloom’s Level: Understand
Concept Tested: Magic number (bad practice)
Correct Answer: A numeric constant that appears in code without an explanatory name.
Explanation: Magic numbers are unnamed numeric literals that make code hard to understand
and maintain. They should be replaced with named constants.
Q23. What occurs when a computation produces a value that exceeds the range of the int type
(about ±2.14 billion)?
A. The program terminates with an error.
B. The value is converted to a double automatically.
C. Overflow: the value wraps around to a seemingly arbitrary number.
D. The value is truncated to the maximum int value.
Bloom’s Level: Understand
Concept Tested: Overflow error
Correct Answer: Overflow: the value wraps around to a seemingly arbitrary number.
55
55
Explanation: Integer overflow occurs when a value exceeds the storage capacity of its type. The
result is truncated, yielding an incorrect value without an explicit error.
Q24. Why might the calculation double total = 4.35 * 100; print as 434.99999999999994 instead
of 435.0?
A. Because of an overflow error in floating-point representation.
B. Because of a roundoff error due to the binary representation of numbers.
C. Because the * operator is not precise for double values.
D. Because 4.35 is a magic number.
Bloom’s Level: Analyze
Concept Tested: Roundoff error
Correct Answer: Because of a roundoff error due to the binary representation of numbers.
Explanation: Floating-point numbers are represented in binary, and some decimal fractions (like
0.35) cannot be represented exactly, leading to small precision errors.
Q25. Computers internally represent numbers using which number system?
A. Decimal (base 10)
B. Binary (base 2)
C. Hexadecimal (base 16)
D. Octal (base 8)
Bloom’s Level: Remember
Concept Tested: Binary number system basis
Correct Answer: Binary (base 2)
Explanation: All data in a computer, including numbers, are ultimately stored as sequences of
binary digits (bits), i.e., 0s and 1s.
Q26. In Java, values of which category are considered "primitive types"?
A. Objects of classes like String and Scanner.
B. Basic data types like int, double, and char.
C. Arrays and collections.
D. Any value that can be stored in a variable.
56
56
Bloom’s Level: Remember
Concept Tested: Primitive types vs. objects
Correct Answer: Basic data types like int, double, and char.
Explanation: Primitive types are built-in, non-object types that store simple values. They
include byte, short, int, long, float, double, char, and boolean.
Q27. Which Java data type is a single-precision 32-bit floating-point number, as opposed
to double which is double-precision?
A. float
B. short
C. decimal
D. single
Bloom’s Level: Remember
Concept Tested: float data type (single-precision)
Correct Answer: float
Explanation: The float type uses 32 bits and offers about 7 decimal digits of precision. It is less
precise and has a smaller range than double.
Q28. Which integer type in Java uses exactly 1 byte (8 bits) of storage and has a range from -128
to 127?
A. short
B. byte
C. tiny
D. int8
Bloom’s Level: Remember
Concept Tested: byte data type
Correct Answer: byte
Explanation: The byte type is an 8-bit signed integer. It is often used for raw binary data or to
save memory in large arrays.
57
57
Q29. The short data type in Java is a 16-bit signed integer. What is its approximate range?
A. -32,768 to 32,767
B. -2,147,483,648 to 2,147,483,647
C. -128 to 127
D. -9.22×10¹⁸ to 9.22×10¹⁸
Bloom’s Level: Remember
Concept Tested: short data type
Correct Answer: -32,768 to 32,767
Explanation: short is a 16-bit signed two's complement integer. Its minimum value is -2¹⁵ and
maximum is 2¹⁵ - 1.
Q30. When an integer value might exceed the range of int (about 2 billion), which data type can
store integers up to about 9×10¹⁸?
A. long
B. bigInt
C. double
D. BigInteger
Bloom’s Level: Remember
Concept Tested: long data type
Correct Answer: long
Explanation: The long type is a 64-bit signed integer with a range of about -9.22×10¹⁸ to
9.22×10¹⁸. It is used for very large whole numbers.
Q31. In Java, the char type represents a single character using which encoding scheme?
A. ASCII
B. EBCDIC
C. UTF-8
D. Unicode
Bloom’s Level: Remember
Concept Tested: char data type (Unicode)
58
58
Correct Answer: Unicode
Explanation: Java uses Unicode to represent characters. The char type is a 16-bit Unicode code
unit, allowing for a wide range of international characters.
Q32. Which Java class is designed to represent integers of arbitrary precision, effectively
without a fixed limit on size?
A. BigDecimal
B. BigInteger
C. LargeInteger
D. HugeInt
Bloom’s Level: Remember
Concept Tested: BigInteger class (large integers)
Correct Answer: BigInteger
Explanation: BigInteger (in package java.math) can represent integers of any size, limited only
by available memory. It is used for cryptographic and mathematical computations.
Q33. For financial calculations that require exact decimal representation without roundoff errors,
which Java class is most appropriate?
A. double
B. float
C. BigInteger
D. BigDecimal
Bloom’s Level: Apply
Concept Tested: BigDecimal class (exact decimals)
Correct Answer: BigDecimal
Explanation: BigDecimal provides arbitrary-precision signed decimal numbers. It avoids the
rounding errors inherent in binary floating-point types like double.
Q34. In Java, which operator is used for integer division that truncates any fractional part?
A. %
B. /
59
59
C. \
D. //
Bloom’s Level: Remember
Concept Tested: Arithmetic operators (+, -, *, /)
Correct Answer: /
Explanation: The / operator performs division. When both operands are integers, it performs
integer division, discarding the remainder.
Q35. What is the result of the expression 5 + 2.0 in Java?
A. 7
B. 7.0
C. 52.0
D. Compilation error because types don't match.
Bloom’s Level: Apply
Concept Tested: Mixing int and double in expressions
Correct Answer: 7.0
Explanation: When an int and a double are mixed in an arithmetic operation, the int is promoted
to double, and the result is a double value.
Q36. In the expression a + b * c, which operation is performed first due to operator precedence?
A. Addition (+)
B. Multiplication (*)
C. Left to right, so a + b first.
D. It depends on the values of a, b, and c.
Bloom’s Level: Understand
Concept Tested: Operator precedence
Correct Answer: Multiplication (*)
Explanation: Multiplication has higher precedence than addition, so b * c is computed first, then
added to a. Parentheses can override precedence.
60
60
Q37. What is the effect of the increment operator (++) when placed after a variable, as in x++?
A. It adds 1 to x and returns the new value.
B. It adds 1 to x and returns the old value.
C. It adds 2 to x.
D. It multiplies x by itself.
Bloom’s Level: Understand
Concept Tested: Increment operator (++)
Correct Answer: It adds 1 to x and returns the old value.
Explanation: The postfix increment (x++) increments the variable but evaluates to its original
value. The prefix form (++x) increments and returns the new value.
Q38. Which operator decreases the value of a variable by 1?
A. --
B. -1
C. -=
D. dec
Bloom’s Level: Remember
Concept Tested: Decrement operator (--)
Correct Answer: --
Explanation: The decrement operator (--) subtracts 1 from a variable. It has both prefix (--x) and
postfix (x--) forms, similar to increment.
Q39. Given int a = 7; int b = 4;, what is the value of a / b?
A. 1.75
B. 1
C. 2
D. 3
Bloom’s Level: Apply
Concept Tested: Integer division (truncation)
Correct Answer: 1
61
61
Explanation: Integer division discards the fractional part (remainder). 7 / 4 is 1 with a remainder
of 3, so the result is 1.
Q40. The modulus operator (%) in Java gives:
A. The quotient of integer division.
B. The remainder of integer division.
C. The floating-point division result.
D. The square root of a number.
Bloom’s Level: Remember
Concept Tested: Modulus/remainder operator (%)
Correct Answer: The remainder of integer division.
Explanation: The % operator yields the remainder after division. For example, 7 % 4 is 3
because 7 divided by 4 leaves a remainder of 3.
Q41. To compute the square root of a variable x of type double, which method call should you
use?
A. Math.squareRoot(x)
B. Math.sqrt(x)
C. sqrt(x)
D. x.sqrt()
Bloom’s Level: Apply
Concept Tested: Math.sqrt method (square root)
Correct Answer: Math.sqrt(x)
Explanation: The Math.sqrt static method returns the square root of its argument. It is part of
the Math class and requires the class name as a prefix.
Q42. How do you compute x raised to the power y (xʸ) in Java?
A. x ^ y
B. Math.power(x, y)
C. Math.pow(x, y)
D. x ** y
62
62
Bloom’s Level: Apply
Concept Tested: Math.pow method (exponentiation)
Correct Answer: Math.pow(x, y)
Explanation: The Math.pow method takes two double arguments and returns the first raised to
the power of the second as a double.
Q43. Which Math class method would you use to compute the trigonometric sine of an angle
given in radians?
A. Math.sine(angle)
B. Math.sin(angle)
C. Math.trigSin(angle)
D. Math.Trig.sin(angle)
Bloom’s Level: Remember
Concept Tested: Math.sin/cos/tan methods
Correct Answer: Math.sin(angle)
Explanation: Math.sin, Math.cos, and Math.tan are static methods for trigonometric functions.
The angle must be in radians.
Q44. To compute the natural logarithm (base e) of a number x, which method is used?
A. Math.log10(x)
B. Math.ln(x)
C. Math.log(x)
D. Math.naturalLog(x)
Bloom’s Level: Remember
Concept Tested: Math.log method (natural logarithm)
Correct Answer: Math.log(x)
Explanation: Math.log returns the natural logarithm (base e). For base 10 logarithm,
use Math.log10.
Q45. Which method computes the base-10 logarithm of a number?
A. Math.log10(x)
63
63
B. Math.log(10, x)
C. Math.log(x, 10)
D. Math.log(x) / Math.log(10)
Bloom’s Level: Remember
Concept Tested: Math.log10 method
Correct Answer: Math.log10(x)
Explanation: Math.log10 directly computes the logarithm base 10. It is more efficient and
accurate than computing Math.log(x) / Math.log(10).
Q46. How can you round a floating-point value x to the nearest integer, storing the result as
a long?
A. long rounded = (long) x;
B. long rounded = Math.round(x);
C. long rounded = Math.floor(x);
D. long rounded = Math.rint(x);
Bloom’s Level: Apply
Concept Tested: Math.round method
Correct Answer: long rounded = Math.round(x);
Explanation: Math.round returns the closest long to the argument. For a double, it returns long;
for a float, it returns int.
Q47. What does the method call Math.abs(-5) return?
A. -5
B. 5
C. 0
D. 5.0
Bloom’s Level: Apply
Concept Tested: Math.abs method (absolute value)
Correct Answer: 5
64
64
Explanation: Math.abs returns the absolute value of its argument. For an int, it returns an int; for
a double, a double.
Q48. Which Math method returns the larger of two values a and b?
A. Math.max(a, b)
B. Math.larger(a, b)
C. Math.greater(a, b)
D. Math.peak(a, b)
Bloom’s Level: Remember
Concept Tested: Math.max/min methods
Correct Answer: Math.max(a, b)
Explanation: Math.max returns the greater of two values; Math.min returns the lesser. They are
overloaded for int, long, float, and double.
Q49. Which of the following is a constant defined in the Math class representing the ratio of a
circle's circumference to its diameter?
A. Math.PI
B. Math.E
C. Math.CIRCLE
D. Math.PI_RATIO
Bloom’s Level: Remember
Concept Tested: Math.PI constant
Correct Answer: Math.PI
Explanation: Math.PI is a double constant representing π (approximately 3.141592653589793).
It is useful for geometry and trigonometry.
Q50. Which operator is used to explicitly convert a value from one type to another, such as
from double to int?
A. Conversion operator ::
B. Cast operator (type)
65
65
C. Assignment operator =
D. Dot operator .
Bloom’s Level: Remember
Concept Tested: Cast operator (typeName)
Correct Answer: Cast operator (type)
Explanation: A cast is written as the target type in parentheses before the expression, e.g., (int)
3.7. It converts the value to the specified type.
Q51. What is the result of the cast (int) 9.75?
A. 10
B. 9.75
C. 9
D. Compilation error because you cannot cast a double to int.
Bloom’s Level: Apply
Concept Tested: Converting double to int (truncation)
Correct Answer: 9
Explanation: Casting a double to int truncates the fractional part (rounds toward zero). It does
not round to the nearest integer.
Q52. To round a double value x to the nearest integer and store it as an int, which of the
following is correct?
A. int n = (int) x;
B. int n = Math.round(x);
C. int n = (int) Math.round(x);
D. int n = Math.ceil(x);
Bloom’s Level: Apply
Concept Tested: Using Math.round for rounding
Correct Answer: int n = (int) Math.round(x);
Explanation: Math.round(x) returns a long. To store as an int, you must cast the result to int,
provided it fits within the int range.
66
66
Q53. What error occurs if you write double average = (score1 + score2 + score3) / 3; when all
scores are int variables?
A. Overflow error
B. Roundoff error
C. Unintended integer division
D. Syntax error
Bloom’s Level: Analyze
Concept Tested: Unintended integer division error
Correct Answer: Unintended integer division
Explanation: Because all operands are integers, the division is integer division, discarding the
remainder. This likely gives an incorrect average.
Q54. In the expression ((a + b) * t / 2 * (1 - t), what is the problem?
A. Missing operator between 2 and (1 - t).
B. Unbalanced parentheses: three ( but only two ).
C. The variable t is used twice.
D. It should use * instead of x for multiplication.
Bloom’s Level: Analyze
Concept Tested: Unbalanced parentheses error
Correct Answer: Unbalanced parentheses: three ( but only two ).
Explanation: Every opening parenthesis must have a matching closing parenthesis. Here, there
is an extra (.
Q55. Which of the following is a recommended style for writing arithmetic expressions to
improve readability?
A. Write everything on one line without spaces.
B. Put spaces around binary operators like + and *.
C. Never use parentheses because they confuse readers.
D. Use commas to separate terms.
67
67
Bloom’s Level: Understand
Concept Tested: Spaces in expressions (style)
Correct Answer: Put spaces around binary operators like + and *.
Explanation: Spaces around operators make expressions easier to read. However, do not put a
space after a unary minus or before a parenthesis.
Q56. The statement total += cans; is equivalent to:
A. total = cans;
B. total = total + cans;
C. cans = total + cans;
D. total = cans + 1;
Bloom’s Level: Understand
Concept Tested: Combined assignment operators (+=, *=)
Correct Answer: total = total + cans;
Explanation: The += operator adds the right operand to the left variable and stores the result
back in the left variable. Similar operators exist for -=, *=, etc.
Q57. The Pentium floating-point bug (1994) was an example of:
A. A compiler error in Java.
B. A hardware flaw causing incorrect floating-point division in rare cases.
C. An overflow error in integer arithmetic.
D. A roundoff error due to using float instead of double.
Bloom’s Level: Remember
Concept Tested: Pentium floating-point bug (1994)
Correct Answer: A hardware flaw causing incorrect floating-point division in rare cases.
Explanation: The Pentium FDIV bug caused some floating-point division operations to produce
slightly inaccurate results due to an error in a lookup table.
Q58. Which method in Java allows you to print formatted output, similar to printf in C?
A. System.out.print
B. System.out.println
68
68
C. System.out.printf
D. System.out.format
Bloom’s Level: Remember
Concept Tested: Formatted output with printf
Correct Answer: System.out.printf
Explanation: System.out.printf takes a format string and arguments, and prints formatted text. It
does not automatically add a newline.
Q59. In a printf format string, what character introduces a format specifier?
A. \
B. %
C. $
D. #
Bloom’s Level: Remember
Concept Tested: Format specifier syntax (%)
Correct Answer: %
Explanation: Format specifiers start with a % and end with a conversion character, e.g., %d for
integer, %f for floating-point.
Q60. Which format specifier should be used to print an integer value?
A. %f
B. %d
C. %s
D. %i
Bloom’s Level: Remember
Concept Tested: Format specifier types (%d, %f, %s)
Correct Answer: %d
Explanation: %d formats an integer as a decimal number. %f is for floating-point, %s for
strings. Java does not use %i.
69
69
Q61. In the format specifier %10d, what does the number 10 specify?
A. The number of decimal places.
B. The minimum field width; the output is padded with spaces if necessary.
C. The maximum number of digits to print.
D. The base of the number (e.g., base 10).
Bloom’s Level: Understand
Concept Tested: Field width in format specifiers
Correct Answer: The minimum field width; the output is padded with spaces if necessary.
Explanation: The field width indicates the minimum number of characters to output. If the
number has fewer digits, spaces are added (by default, right-aligned).
Q62. To print a floating-point number with exactly two digits after the decimal point, which
format specifier should you use?
A. %2f
B. %.2f
C. %2.0f
D. %f.2
Bloom’s Level: Apply
Concept Tested: Precision in format specifiers (%.2f)
Correct Answer: %.2f
Explanation: The precision is specified after a dot. %.2f means two digits after the decimal
point. The number is rounded if necessary.
Q63. How can you ensure that printf outputs a newline after printing the formatted text?
A. Use println instead of printf.
B. Include \n at the end of the format string.
C. Call System.out.println() after printf.
D. Both B and C are valid.
Bloom’s Level: Apply
Concept Tested: Newline character (\n) in printf
70
70
Correct Answer: Both B and C are valid.
Explanation: You can embed \n in the format string, or call println after printf. The escape
sequence \n moves to the next line.
Q64. Which class is commonly used to read input from the keyboard in a console Java
application?
A. Reader
B. System.in
C. Scanner
D. InputStream
Bloom’s Level: Remember
Concept Tested: Scanner class for input
Correct Answer: Scanner
Explanation: The Scanner class (in java.util) provides convenient methods for reading typed
input from various sources, including System.in.
Q65. What statement must you include at the top of your Java file to use the Scanner class?
A. #include java.util.Scanner
B. import java.util.Scanner;
C. using java.util.Scanner;
D. require java.util.Scanner;
Bloom’s Level: Remember
Concept Tested: import statement
Correct Answer: import java.util.Scanner;
Explanation: The import statement makes a class from a package available. For Scanner, you
import java.util.Scanner.
Q66. To which package does the Scanner class belong?
A. java.lang
B. java.io
71
71
C. java.util
D. java.text
Bloom’s Level: Remember
Concept Tested: java.util package
Correct Answer: java.util
Explanation: Scanner is part of the java.util package, which contains utility classes like
collections, date/time, and random number generation.
Q67. How do you create a Scanner object to read from the standard input (keyboard)?
A. Scanner in = new Scanner();
B. Scanner in = new Scanner(System.in);
C. Scanner in = Scanner.create(System.in);
D. Scanner in = System.in.scanner();
Bloom’s Level: Apply
Concept Tested: Creating a Scanner object
Correct Answer: Scanner in = new Scanner(System.in);
Explanation: The constructor Scanner(InputStream source) is used. System.in is
an InputStream representing the keyboard.
Q68. Before reading input, it is good practice to display a ________ to tell the user what to enter.
A. comment
B. prompt
C. format specifier
D. newline
Bloom’s Level: Remember
Concept Tested: Prompting the user
Correct Answer: prompt
Explanation: A prompt is a message (like "Enter your age:") displayed to the user before
reading input. It makes the program more user-friendly.
72
72
Q69. Which Scanner method reads the next token of input as an int?
A. next()
B. nextInt()
C. readInt()
D. getInt()
Bloom’s Level: Remember
Concept Tested: nextInt method
Correct Answer: nextInt()
Explanation: nextInt() reads the next integer token and returns it as an int. It skips any leading
whitespace.
Q70. To read a floating-point number from the keyboard, which method of Scanner should you
use?
A. nextFloat()
B. nextDouble()
C. nextDecimal()
D. Either A or B, depending on the desired precision.
Bloom’s Level: Remember
Concept Tested: nextDouble method
Correct Answer: Either A or B, depending on the desired precision.
Explanation: nextFloat() returns a float, nextDouble() returns a double. Both read a floating-
point token. double is more commonly used.
Q71. Which Scanner method reads the next word (a sequence of characters without whitespace)
as a String?
A. nextLine()
B. nextString()
C. next()
D. nextWord()
73
73
Bloom’s Level: Remember
Concept Tested: next method (for strings)
Correct Answer: next()
Explanation: next() reads the next token (by default delimited by whitespace) as
a String. nextLine() reads an entire line including spaces.
Q72. What is the primary purpose of the API documentation for Java?
A. To provide tutorials for beginners.
B. To list all classes and methods in the Java library, with descriptions.
C. To debug your programs.
D. To compile Java source code.
Bloom’s Level: Understand
Concept Tested: API Documentation use
Correct Answer: To list all classes and methods in the Java library, with descriptions.
Explanation: The API (Application Programming Interface) documentation is a reference for
programmers, detailing packages, classes, methods, and their usage.
Q73. What does API stand for in the context of Java programming?
A. Application Program Interface
B. Applied Programming Instructions
C. Application Programming Interface
D. Advanced Programming Interface
Bloom’s Level: Remember
Concept Tested: Application Programming Interface (API)
Correct Answer: Application Programming Interface
Explanation: API stands for Application Programming Interface. It defines how software
components interact, including libraries' classes and methods.
Q74. Before writing a Java program, it is often helpful to first write __________, which is an
informal description of the steps.
A. pseudocode
74
74
B. source code
C. machine code
D. bytecode
Bloom’s Level: Remember
Concept Tested: Pseudocode for computations
Correct Answer: pseudocode
Explanation: Pseudocode is a plain-language description of an algorithm. It helps plan the logic
without worrying about syntax.
Q75. Why is it important to carry out hand calculations with concrete values before coding an
algorithm?
A. To ensure the algorithm works correctly for specific cases.
B. To make the code run faster.
C. To avoid using variables in the program.
D. To reduce the number of comments needed.
Bloom’s Level: Evaluate
Concept Tested: Hand calculation before coding
Correct Answer: To ensure the algorithm works correctly for specific cases.
Explanation: Working through examples by hand helps you understand the problem and verify
that your algorithm produces the expected results.
Q76. In the car purchase comparison algorithm from How To 2.1, what are the two main costs
considered?
A. Fuel cost and insurance cost.
B. Purchase price and operating cost.
C. Tax and registration fees.
D. Down payment and monthly loan payments.
Bloom’s Level: Remember
Concept Tested: Car purchase comparison algorithm
Correct Answer: Purchase price and operating cost.
75
75
Explanation: The algorithm compares total cost = purchase price + operating cost (fuel,
maintenance over a period). This helps decide which car is cheaper overall.
Q77. In the vending machine change algorithm, if a customer inserts a $5 bill for an item costing
$2.25, how many dollar coins and quarters should be returned?
A. 2 dollars, 3 quarters
B. 2 dollars, 2 quarters
C. 3 dollars, 0 quarters
D. 2 dollars, 4 quarters
Bloom’s Level: Apply
Concept Tested: Vending machine change algorithm
Correct Answer: 2 dollars, 3 quarters
Explanation: Change due is $2.75. Dollar coins = 2 (from 275/100), remainder 75 cents.
Quarters = 75/25 = 3. So 2 dollars and 3 quarters.
Q78. In the tiling floor algorithm (Section 2.4), if total width is 100 inches and tile width is 5
inches, how many tiles are needed if the first and last tiles must be black?
A. 20
B. 19
C. 18
D. 21
Bloom’s Level: Apply
Concept Tested: Tiling floor algorithm (hand calculation)
Correct Answer: 19
Explanation: One black tile plus pairs of white/black. Pairs = (100-5)/(2*5) = 9.5 → 9 pairs (18
tiles). Total tiles = 1 + 18 = 19.
Q79. When translating pseudocode into Java, which of the following steps is typically done last?
A. Declaring variables and constants.
B. Writing the class and main method.
76
76
C. Translating pseudocode statements into Java statements.
D. Testing the program with sample inputs.
Bloom’s Level: Understand
Concept Tested: Pseudocode to Java translation steps
Correct Answer: Testing the program with sample inputs.
Explanation: After writing the code, you must compile and test it. Testing ensures the program
works as intended and catches logic errors.
Q80. In Java, a string is defined as:
A. A sequence of bytes.
B. A sequence of characters.
C. A single character.
D. An array of integers.
Bloom’s Level: Remember
Concept Tested: String as character sequence
Correct Answer: A sequence of characters.
Explanation: A String object represents a sequence of Unicode characters. For
example, "Hello" is a string of 5 characters.
Q81. What is the difference between a string literal and a string variable?
A. A string literal is a value, while a string variable is a storage location that can hold a string.
B. A string literal can change, while a string variable cannot.
C. A string variable must be declared with String, but a string literal does not need to be.
D. There is no difference; they are interchangeable.
Bloom’s Level: Understand
Concept Tested: String literal vs. variable
Correct Answer: A string literal is a value, while a string variable is a storage location that can
hold a string.
Explanation: A string literal (e.g., "cat") is a fixed sequence of characters. A string variable
(e.g., String s;) can hold different string values.
77
77
Q82. Which method returns the number of characters in a string str?
A. str.size()
B. str.length()
C. str.count()
D. str.charCount()
Bloom’s Level: Remember
Concept Tested: length() method
Correct Answer: str.length()
Explanation: The length() method returns an int representing the number of characters in the
string. Note parentheses: it's a method, not a field.
Q83. What is the value of the expression "" (two double quotes with nothing between)?
A. A string containing a space.
B. A string containing a null character.
C. The empty string, with length 0.
D. An invalid string literal.
Bloom’s Level: Remember
Concept Tested: Empty string ("")
Correct Answer: The empty string, with length 0.
Explanation: The empty string has no characters. It is a valid string object and its length is 0. It
is often used as a default or placeholder.
Q84. Which operator is used to concatenate (join) two strings?
A. &
B. +
C. concat
D. append
Bloom’s Level: Remember
Concept Tested: Concatenation operator (+)
Correct Answer: +
78
78
Explanation: The + operator concatenates strings. If one operand is a string and the other is not,
the non-string is converted to a string.
Q85. What happens when you use the + operator with a string and a number, e.g., "Number " +
5?
A. A compilation error occurs because types are incompatible.
B. The number is converted to a string and concatenated.
C. The string is converted to a number and added.
D. The expression yields the number 5.
Bloom’s Level: Understand
Concept Tested: Automatic conversion to string in +
Correct Answer: The number is converted to a string and concatenated.
Explanation: When one operand of + is a String, the other is automatically converted to
a String, and then concatenation occurs.
Q86. If the user types "Hello World" in response to in.next(), what is stored in the variable?
A. "Hello World"
B. "Hello"
C. "World"
D. "H"
Bloom’s Level: Apply
Concept Tested: Reading string input with next()
Correct Answer: "Hello"
Explanation: next() reads the next token, which is a sequence of characters up to whitespace. So
it reads only the first word.
Q87. What are escape sequences used for in Java strings?
A. To exit the program.
B. To represent characters that are hard to type directly, like newline or quote.
C. To skip part of the string during printing.
D. To encrypt the string.
79
79
Bloom’s Level: Understand
Concept Tested: Escape sequences
Correct Answer: To represent characters that are hard to type directly, like newline or quote.
Explanation: Escape sequences begin with a backslash and represent special characters,
e.g., \n for newline, \" for a double quote inside a string literal.
Q88. How do you include a double quote character inside a string literal?
A. """
B. \"
C. \\"
D. "\"
Bloom’s Level: Apply
Concept Tested: Escape sequence " (quotation mark)
Correct Answer: \"
Explanation: The escape sequence \" inserts a double quote without terminating the string. For
example, "He said \"Hello\"".
Q89. To include a backslash character in a string literal, you must write:
A. \
B. \\
C. \backslash
D. /\
Bloom’s Level: Apply
Concept Tested: Escape sequence \ (backslash)
Correct Answer: \\
Explanation: A single backslash starts an escape sequence, so to represent a literal backslash,
you need two: \\. Example: "C:\\Temp".
Q90. Which escape sequence represents a newline character, causing subsequent output to start
on a new line?
A. \new
80
80
B. \n
C. \r
D. \t
Bloom’s Level: Remember
Concept Tested: Escape sequence \n (newline)
Correct Answer: \n
Explanation: \n is the newline character. When printed, it moves the cursor to the beginning of
the next line. It is often used in formatted output.
Q91. In Java, which data type represents a single character, such as 'A' or '7'?
A. String
B. char
C. Character
D. letter
Bloom’s Level: Remember
Concept Tested: char data type (single character)
Correct Answer: char
Explanation: char is a primitive type that holds a single Unicode character. Literals are enclosed
in single quotes, e.g., 'A'.
Q92. How do you denote a character literal in Java?
A. With double quotes, e.g., "A".
B. With single quotes, e.g., 'A'.
C. With backticks, e.g., A.
D. With parentheses, e.g., (A).
Bloom’s Level: Remember
Concept Tested: Character literals (single quotes)
Correct Answer: With single quotes, e.g., 'A'.
Explanation: Character literals use single quotes. "A" is a string containing one character,
while 'A' is a char value.
81
81
Q93. In a string, positions are indexed starting at:
A. 1
B. 0
C. -1
D. It depends on the string length.
Bloom’s Level: Remember
Concept Tested: String indexing (starting at 0)
Correct Answer: 0
Explanation: Like arrays, string positions are zero-based. The first character is at index 0, the
second at index 1, and so on.
Q94. Given String s = "Java";, what does s.charAt(2) return?
A. 'J'
B. 'a'
C. 'v'
D. 'a' (the last 'a')
Bloom’s Level: Apply
Concept Tested: charAt(int index) method
Correct Answer: 'v'
Explanation: Indices: 0='J', 1='a', 2='v', 3='a'. charAt(2) returns the character at index 2, which
is 'v'.
Q95. If str = "Hello", what is the result of str.substring(1, 4)?
A. "Hel"
B. "ell"
C. "ello"
D. "lo"
Bloom’s Level: Apply
Concept Tested: substring(int begin, int end) method
Correct Answer: "ell"
82
82
Explanation: The substring starts at index 1 ('e') and goes up to but not including index 4 ('o'),
so characters at indices 1,2,3: "ell".
Q96. What does str.substring(3) return if str = "Hello"?
A. "lo"
B. "llo"
C. "Hel"
D. "Hello"
Bloom’s Level: Apply
Concept Tested: substring(int begin) method
Correct Answer: "lo"
Explanation: With one argument, substring returns from that index to the end. Index 3 is 'l', so
from 3 to end: "lo".
Q97. A method that is invoked on an object (like str.length()) is called:
A. A static method.
B. An instance method.
C. A class method.
D. A constructor.
Bloom’s Level: Remember
Concept Tested: Instance methods (invoked on objects)
Correct Answer: An instance method.
Explanation: Instance methods are called on objects and operate on that object's data. They use
the dot notation: object.method().
Q98. A method that is invoked using the class name (like Math.sqrt) is called:
A. An instance method.
B. A static method.
C. An object method.
D. A variable method.
83
83
Bloom’s Level: Remember
Concept Tested: Static methods (invoked on class)
Correct Answer: A static method.
Explanation: Static methods belong to the class, not to individual objects. They are called
as ClassName.methodName().
Q99. Which class provides dialog boxes for simple graphical input and output?
A. Scanner
B. JOptionPane
C. System
D. Dialog
Bloom’s Level: Remember
Concept Tested: JOptionPane for dialog boxes
Correct Answer: JOptionPane
Explanation: JOptionPane (in javax.swing) has static methods
like showInputDialog and showMessageDialog for pop-up dialogs.
Q100. Which method displays a dialog box that prompts the user for input and returns the input
as a string?
A. JOptionPane.showMessageDialog
B. JOptionPane.showInputDialog
C. JOptionPane.askForInput
D. JOptionPane.prompt
Bloom’s Level: Remember
Concept Tested: showInputDialog method
Correct Answer: JOptionPane.showInputDialog
Explanation: showInputDialog displays a dialog with a prompt and a text field. The user's input
is returned as a String.
84
84
Fill-in-the-Blank Questions
Q101. The __________ method of the JOptionPane class is used to display a message to the user
in a dialog box.
Answer: showMessageDialog
Bloom’s Level: Remember
Concept Tested: Graphical Output for User Interaction
Explanation: In biophysical simulations, this method can be used to display calculated results,
such as protein concentration or reaction rates, to the user.
Q102. To convert a String input from a dialog box into a numeric value for calculation, such as a
ligand concentration, you would use the __________ or __________ methods.
Answer: parseDouble, parseInt
Bloom’s Level: Apply
Concept Tested: Converting String Input to Numeric Data
Explanation: This is essential for processing user-entered experimental parameters (e.g.,
temperature, pH) from a graphical interface into computable double or int variables.
Q103. The __________ standard provides a unique numeric code for every character used in the
world's major writing systems.
Answer: Unicode
Bloom’s Level: Remember
Concept Tested: Character Encoding for International Text
Explanation: Understanding encoding is relevant for handling genetic sequence data (e.g.,
FASTA files) or metadata in international collaborations, ensuring accurate text representation.
Q104. Java's support for __________ allows programs to process biochemical terms or
researcher names that use non-Latin scripts.
Answer: international alphabets
Bloom’s Level: Understand
Concept Tested: Software Internationalization
Explanation: This capability ensures software tools in biophysical chemistry can correctly
display and manipulate text data from global sources without corruption.
85
85
Q105. In writing systems like Chinese, each __________ represents a concept or object rather
than a sound.
Answer: ideographic character
Bloom’s Level: Remember
Concept Tested: Ideographic vs. Phonetic Writing Systems
Explanation: This contrasts with alphabetic systems and is a consideration in computational
linguistics when analyzing textual scientific data from different regions.
Q106. When an arithmetic expression involves both int and double values, Java uses
__________ to produce a double result.
Answer: mixed-type evaluation (or floating-point promotion)
Bloom’s Level: Understand
Concept Tested: Type Promotion in Expressions
Explanation: This automatic conversion is crucial in biophysical calculations, like converting an
integer count of molecules to a molar concentration (a double).
Q107. A combination of variables, literals, operators, and method calls that yields a single value
is called a(n) __________.
Answer: expression
Bloom’s Level: Remember
Concept Tested: Definition of an Expression
Explanation: In biophysical chemistry, complex formulas for Gibbs free energy or ligand
binding affinity are implemented as expressions in code.
Q108. To force a specific order of operations in a complex formula, such as the Henderson-
Hasselbalch equation, you must use __________.
Answer: parentheses
Bloom’s Level: Apply
Concept Tested: Controlling Operator Precedence
Explanation: Correct use of parentheses is critical to accurately compute layered biophysical
expressions like pH = pKa + log10([A-]/[HA]).
86
86
Q109. A calculation that attempts __________ with integer or floating-point numbers will cause
a program to terminate with an ArithmeticException.
Answer: division by zero
Bloom’s Level: Analyze
Concept Tested: Runtime Error from Invalid Operation
Explanation: This error must be guarded against in calculations like scaling data by a difference
that could theoretically be zero (e.g., a denominator in a rate equation).
Q110. The volume of a spherical molecule or vesicle can be computed using the formula V =
(4/3) * Math.PI * __________.
Answer: Math.pow(radius, 3)
Bloom’s Level: Apply
Concept Tested: Applying Mathematical Functions (pow)
Explanation: This expression directly implements the geometric formula for volume, a common
calculation in structural biology and nanoparticle characterization.
Q111. You can isolate the last digit of an integer representing a sample ID or a residual number
using the __________ operator.
Answer: modulus (%)
Bloom’s Level: Apply
Concept Tested: Using Integer Division and Modulus
Explanation: The % 10 operation is a standard technique for digit manipulation, useful in
parsing encoded sample identifiers or data fields.
Q112. To create a monogram from a researcher's full name stored in String variables, you would
extract the first character of each name using the __________ method and concatenate them.
Answer: substring(0, 1)
Bloom’s Level: Apply
Concept Tested: String Manipulation for Data Formatting
Explanation: This is a simple example of parsing and reformatting text data, a common task in
generating labels or keys from database entries.
87
87
Q113. A program that converts a measurement from feet to meters must __________ the input
value by 0.3048.
Answer: multiply
Bloom’s Level: Apply
Concept Tested: Unit Conversion Calculation
Explanation: This represents a fundamental step in scientific computing: applying a conversion
factor to translate empirical data into consistent SI units.
Q114. To find the distance between two points in a 2D plot of experimental data (e.g., on a
scatter plot), you can apply the __________.
Answer: Pythagorean theorem
Bloom’s Level: Apply
Concept Tested: Applying Geometric Principles
Explanation: The formula Math.sqrt(dx*dx + dy*dy) calculates Euclidean distance, useful in
analyzing spatial data or clustering results.
Q115. __________ states that the voltage (V) across a resistor in an electrophysiology circuit is
the product of the current (I) and the resistance (R): V = I * R.
Answer: Ohm's law
Bloom’s Level: Remember
Concept Tested: Fundamental Circuit Law
Explanation: This law is the basis for analyzing simple equivalent circuits used to model cell
membranes or instrumentation in biophysical experiments.
Q116. The __________ approximates the temperature at which dew forms, using air temperature
and relative humidity in a logarithmic formula.
Answer: dew point calculation
Bloom’s Level: Understand
Concept Tested: Implementing Empirical Formulas
Explanation: This is an example of translating a complex, multi-step environmental science
formula into a sequence of Java expressions, relevant for lab condition monitoring.
88
88
Q117. The resistance R of a __________, a temperature-sensitive semiconductor, changes
predictably with temperature according to an exponential relationship.
Answer: thermistor
Bloom’s Level: Remember
Concept Tested: Model for Sensor Behavior
Explanation: This formula (R = R0 * exp(beta*(1/T - 1/T0))) is key for writing code that
interprets raw sensor resistance from a temperature probe into degrees Celsius.
Q118. __________ describes the electrostatic force between two charged particles, such as ions
in solution, and is implemented as F = (k * Q1 * Q2) / (r*r).
Answer: Coulomb's law
Bloom’s Level: Remember
Concept Tested: Fundamental Force Law
Explanation: Implementing this law allows for the computational modeling of intermolecular
forces, a core aspect of molecular dynamics simulations.
Q119. Gauss's algorithm for calculating the date of __________ is a historical example of a
complex, multi-step computational procedure defined entirely with integer arithmetic.
Answer: Easter Sunday
Bloom’s Level: Remember
Concept Tested: Complex Algorithm Implementation
Explanation: While not biochemical, it serves as an archetype for translating a verbose, step-by-
step published algorithm into precise sequential Java statements.
Q120. To reformat a ten-digit String of numbers into a standard phone number pattern "(###)
###-####", you would use the __________ method to extract specific digit groups.
Answer: substring
Bloom’s Level: Apply
Concept Tested: Data Formatting with String Methods
Explanation: This is analogous to reformatting data identifiers (like sample codes or accession
numbers) into a standardized, human-readable layout.
89
89
Q121. To separate the dollar and cent components of a price stored as a double, you can cast the
value to an int for dollars, and calculate cents from the __________.
Answer: fractional part (or (price - dollars) * 100)
Bloom’s Level: Analyze
Concept Tested: Isating Integer and Fractional Parts
Explanation: This technique is useful for any calculation requiring discrete units, such as
converting a continuous energy value into whole and fractional quanta.
Q122. __________ growth, such as the monthly accrual in a bank account or the growth of a
bacterial colony under ideal conditions, can be calculated iteratively with balance = balance * (1
+ rate).
Answer: Compound interest (or exponential)
Bloom’s Level: Understand
Concept Tested: Modeling Exponential Processes
Explanation: The mathematical pattern is identical to that of first-order growth or decay
processes common in biochemistry, like radioactive decay or enzyme kinetics.
Q123. A __________ uses a thermistor as part of a voltage divider circuit to produce a signal
that can be converted into a temperature reading.
Answer: temperature sensor circuit
Bloom’s Level: Remember
Concept Tested: Instrumentation Circuit Design
Explanation: Writing code to interpret the voltage from such a circuit requires understanding
both the physics of the sensor and the programming for analog-to-digital conversion.
Q124. The resonant frequency of a simple __________ composed of an inductor (L) and a
capacitor (C) is given by f = 1 / (2 * PI * sqrt(L * C)).
Answer: tuning circuit (or LC circuit)
Bloom’s Level: Remember
Concept Tested: Physics of Resonant Circuits
Explanation: This formula is essential for designing or analyzing circuits used in
instrumentation like NMR spectrometers, which rely on precise resonant frequencies.
90
90
Q125. In an AC circuit model for power delivery, the __________ is a ratio (between 0 and 1)
that affects the voltage required from the source to deliver a certain amount of real power to a
load.
Answer: power factor (pf)
Bloom’s Level: Remember
Concept Tested: AC Circuit Analysis Parameter
Explanation: This concept highlights how computational models in biophysics must account for
real-world electrical engineering constraints when simulating laboratory equipment.
91
91
QUIZ 3: DECISIONS
TRUE/FALSE QUESTIONS
Q1. The if statement in Java executes a block of code only when its Boolean condition evaluates
to true.
Answer: True
Bloom’s Level: Remembering
Concept Tested: if statement
Justification: The if statement is a control flow construct that runs code conditionally based on a
true/false test.
Q2. Decision making in programs allows the flow of execution to change based on input values
or conditions.
Answer: True
Bloom’s Level: Understanding
Concept Tested: Decision making in programs
Justification: Programs alter their behavior via decision structures like if, switch, and
conditional operators.
Q3. Conditional execution refers to running different blocks of code depending on runtime
conditions.
Answer: True
Bloom’s Level: Remembering
Concept Tested: Conditional execution
Justification: Conditional execution is implemented using if-else, switch, and ternary operators
to branch program flow.
Q4. In Java, the condition in an if statement must be a Boolean expression it cannot be an
integer.
Answer: True
Bloom’s Level: Remembering
Concept Tested: Boolean condition
92
92
Justification: Java requires a boolean expression (true/false); integers or other types cause
compilation errors.
Q5. Relational operators in Java include =, ==, !=, <, >, <=, and >=.
Answer: False
Bloom’s Level: Remembering
Concept Tested: Relational operators
Justification: = is the assignment operator, not a relational operator. Relational operators
are ==, !=, <, >, <=, >=.
Q6. An else clause must always follow an if statement in Java.
Answer: False
Bloom’s Level: Remembering
Concept Tested: else clause
Justification: The else clause is optional; an if statement can stand alone without an else.
Q7. In flowcharts, a decision is represented by a diamond shape.
Answer: True
Bloom’s Level: Remembering
Concept Tested: Flowchart representation
Justification: Diamonds denote decision points; rectangles denote processes; parallelograms
denote input/output.
Q8. Branching behavior means a program can take different execution paths based on
conditions.
Answer: True
Bloom’s Level: Understanding
Concept Tested: Branching behavior
Justification: Branching is achieved through conditionals, enabling multiple possible execution
flows.
Q9. In the elevator simulation, the desired floor entered by the user always equals the actual
elevator floor.
93
93
Answer: False
Bloom’s Level: Applying
Concept Tested: Actual vs. desired floor
Justification: For floors above 13, the actual floor is one less than the entered floor to skip the
13th floor.
Q10. The elevator simulation program adjusts floor numbers above 13 to account for the missing
13th floor.
Answer: True
Bloom’s Level: Applying
Concept Tested: Elevator simulation
Justification: The program subtracts 1 from input floors >13 to simulate skipping the 13th floor.
Q11. Floor number adjustment in the elevator example is performed by adding 1 to floors above
13.
Answer: False
Bloom’s Level: Applying
Concept Tested: Floor number adjustment
Justification: Adjustment is done by subtracting 1, not adding, for floors above 13.
Q12. The Java compiler enforces a specific brace layout style for if statements.
Answer: False
Bloom’s Level: Remembering
Concept Tested: Brace layout style
Justification: Brace placement is a style choice; the compiler only cares about syntax, not
formatting.
Q13. Always using braces with if statements, even for single-line bodies, prevents dangling-else
errors.
Answer: True
Bloom’s Level: Applying
Concept Tested: Always use braces
94
94
Justification: Braces explicitly define block boundaries, reducing errors and improving
readability.
Q14. A semicolon immediately after an if condition is a syntax error in Java.
Answer: False
Bloom’s Level: Applying
Concept Tested: Semicolon after if error
Justification: It is legal but causes a logic errorthe if body becomes empty, and the next block
always runs.
Q15. Using spaces instead of tabs for indentation guarantees consistent formatting across all
editors.
Answer: True
Bloom’s Level: Evaluating
Concept Tested: Tab vs. space indentation
Justification: Spaces are displayed uniformly; tab widths vary, leading to misaligned code in
different editors.
Q16. The conditional operator ?: can be used anywhere an expression is expected, not just in
assignments.
Answer: True
Bloom’s Level: Applying
Concept Tested: Conditional operator (?:)
Justification: ?: is an expression that returns a value, usable in prints, returns, and assignments.
Q17. Moving duplicated code out of both branches of an if-else simplifies maintenance.
Answer: True
Bloom’s Level: Applying
Concept Tested: Avoid code duplication
Justification: Reducing duplication minimizes errors and eases updates, as changes need only be
made once.
95
95
Q18. The == operator compares the contents of String objects in Java.
Answer: False
Bloom’s Level: Remembering
Concept Tested: Equality operator (==)
Justification: == compares references (memory addresses); equals() compares content.
Q19. Using = instead of == in a condition causes a compilation error.
Answer: False
Bloom’s Level: Applying
Concept Tested: Assignment vs. equality
Justification: It compiles but assigns a value; the condition becomes the assigned value (likely a
type mismatch error for non-boolean).
Q20. string1.equals(string2) returns true if both strings contain the same characters.
Answer: True
Bloom’s Level: Remembering
Concept Tested: String comparison with equals
Justification: equals() performs a character-by-character comparison, returning true for identical
content.
Q21. Comparing two double values with == is safe if they result from the same calculation.
Answer: False
Bloom’s Level: Understanding
Concept Tested: Floating-point comparison error
Justification: Floating-point rounding errors can cause seemingly equal values to differ slightly.
Q22. Using an epsilon tolerance (e.g., 1E-14) is a reliable way to compare floating-point
numbers for “near equality.”
Answer: True
Bloom’s Level: Applying
Concept Tested: Epsilon tolerance
Justification: Checking Math.abs(a - b) < EPSILON accounts for minor rounding differences.
96
96
Q23. Lexicographic ordering in Java is identical to alphabetical ordering in an English
dictionary.
Answer: False
Bloom’s Level: Understanding
Concept Tested: Lexicographic string ordering
Justification: Java uses Unicode order: uppercase before lowercase, digits before letters, spaces
before printable chars.
Q24. str1.compareTo(str2) returns a positive number if str1 comes after str2 in dictionary order.
Answer: True
Bloom’s Level: Remembering
Concept Tested: compareTo method
Justification: compareTo() returns >0 if str1 is lexicographically greater, <0 if less, 0 if equal.
Q25. In Java lexicographic order, lowercase letters come before uppercase letters.
Answer: False
Bloom’s Level: Remembering
Concept Tested: Dictionary order rules
Justification: Uppercase letters (e.g., ‘A’) have lower Unicode values than lowercase (e.g., ‘a’),
so they come first.
Q26. The string "Zebra" comes before "apple" in lexicographic order.
Answer: True
Bloom’s Level: Applying
Concept Tested: Uppercase before lowercase
Justification: ‘Z’ (uppercase) has a lower Unicode value than ‘a’, so "Zebra" is considered
smaller.
Q27. Multiple alternatives can be implemented using a sequence of if-else if statements.
Answer: True
Bloom’s Level: Applying
Concept Tested: Multiple alternatives
Justification: if-else if chains allow handling several exclusive cases in a clear, structured way.
97
97
Q28. In an if-else if ladder, all conditions are evaluated even after one matches.
Answer: False
Bloom’s Level: Understanding
Concept Tested: else if ladder
Justification: Evaluation stops at the first true condition; subsequent else if branches are
skipped.
Q29. The Richter scale example uses independent if statements to print exactly one description.
Answer: False
Bloom’s Level: Applying
Concept Tested: Richter scale categories
Justification: It uses if-else if to ensure exclusivity; independent ifs could print multiple
descriptions.
Q30. In exclusive conditions, only one condition can be true at any time.
Answer: True
Bloom’s Level: Understanding
Concept Tested: Exclusive conditions
Justification: Exclusive conditions are mutually exclusive; exactly one will be true for any
given input.
Q31. When testing multiple conditions, the most general condition should be placed first.
Answer: False
Bloom’s Level: Applying
Concept Tested: Order of condition testing
Justification: Specific conditions should come first to avoid being overshadowed by a broader
matching condition.
Q32. If a general condition is tested before a specific one, the specific condition may never be
reached.
Answer: True
Bloom’s Level: Analyzing
Concept Tested: General vs. specific conditions
98
98
Justification: A general condition (e.g., x > 0) will capture values also satisfying a later specific
one (e.g., x > 10).
Q33. Using independent if statements for multiple alternatives guarantees that only one block
executes.
Answer: False
Bloom’s Level: Applying
Concept Tested: Independent if statements
Justification: Independent ifs are not exclusive; multiple blocks can execute if several
conditions are true.
Q34. A switch statement can be used with any primitive data type in Java.
Answer: False
Bloom’s Level: Remembering
Concept Tested: switch statement
Justification: switch works with byte, short, char, int, String, and enums not float, double,
or boolean.
Q35. case labels in a switch must be compile-time constants.
Answer: True
Bloom’s Level: Remembering
Concept Tested: case labels
Justification: case values must be literals, final constants, or enum constants not variables.
Q36. Every case in a switch must end with a break statement.
Answer: False
Bloom’s Level: Understanding
Concept Tested: break statement necessity
Justification: break is optional; omitting it causes fall-through to the next case.
Q37. Fall-through behavior in switch always indicates a logic error.
Answer: False
Bloom’s Level: Understanding
99
99
Concept Tested: Fall-through behavior
Justification: Fall-through is intentional in some designs (e.g., multiple cases sharing code), but
often error-prone.
Q38. Enumeration types in Java are defined with the enum keyword and represent a fixed set of
constants.
Answer: True
Bloom’s Level: Remembering
Concept Tested: Enumeration types
Justification: Enums define a type with predefined instances, improving type safety over strings
or integers.
Q39. An enum can be declared only as a top-level type, not inside a class.
Answer: False
Bloom’s Level: Remembering
Concept Tested: enum declaration
Justification: Enums can be declared as nested types inside a class or as separate files.
Q40. Nested if statements are if statements placed inside another if or else block.
Answer: True
Bloom’s Level: Remembering
Concept Tested: Nested if statements
Justification: Nesting allows multi-level decision making, where an inner if depends on an outer
condition.
Q41. Two-level decision making can be implemented only with nested if statements.
Answer: False
Bloom’s Level: Understanding
Concept Tested: Two-level decision making
Justification: It can also be done with logical operators combining conditions, though nesting is
common.
100
100
Q42. The tax calculation example applies a single tax rate to the entire income.
Answer: False
Bloom’s Level: Applying
Concept Tested: Tax bracket calculation
Justification: It uses progressive taxation: one rate for the first bracket, a higher rate for amounts
above it.
Q43. In the tax program, marital status determines which set of income brackets to use.
Answer: True
Bloom’s Level: Applying
Concept Tested: Marital status logic
Justification: Different bracket limits
(RATE1_SINGLE_LIMIT vs RATE1_MARRIED_LIMIT) are used based on status.
Q44. Hand-tracing involves simulating code execution on paper to verify logic and variable
changes.
Answer: True
Bloom’s Level: Applying
Concept Tested: Hand-tracing technique
Justification: It manually steps through code, tracking variable values to understand or debug
flow.
Q45. When hand-tracing, you should record a variable’s value only when it changes.
Answer: False
Bloom’s Level: Applying
Concept Tested: Variable value tracking
Justification: Important values should be tracked at each step, even if unchanged, to confirm
expectations.
Q46. The dangling-else problem occurs when an else pairs with the wrong if due to missing
braces.
Answer: True
Bloom’s Level: Understanding
101
101
Concept Tested: Dangling else problem
Justification: Without braces, else binds to the nearest if, which may not be the intended one.
Q47. Java resolves ambiguous else bindings by pairing the else with the outermost if.
Answer: False
Bloom’s Level: Remembering
Concept Tested: Ambiguous else binding
Justification: else binds to the closest preceding if that doesn’t already have an else.
Q48. In flowcharts, a rectangle represents a decision point.
Answer: False
Bloom’s Level: Remembering
Concept Tested: Flowchart elements
Justification: Rectangles are process boxes; diamonds are decision points.
Q49. A task in a flowchart is shown as a parallelogram.
Answer: False
Bloom’s Level: Remembering
Concept Tested: Task box
Justification: Tasks are rectangles; parallelograms denote input/output.
Q50. A decision diamond has two outgoing arrows: one for true, one for false.
Answer: True
Bloom’s Level: Remembering
Concept Tested: Decision diamond
Justification: The diamond evaluates a condition; arrows labeled “True” and “False” indicate
the two paths.
Q51. Input/output operations in flowcharts are represented by a diamond shape.
Answer: False
Bloom’s Level: Remembering
Concept Tested: Input/output parallelogram
Justification: I/O uses a parallelogram; diamonds are for decisions.
102
102
Q52. In flowchart design, arrows may point into other branches to reuse common tasks.
Answer: False
Bloom’s Level: Applying
Concept Tested: Arrow direction rule
Justification: Arrows should not cross into other branches; this creates spaghetti code and
unclear logic.
Q53. Spaghetti code in flowcharts results from excessive use of decision diamonds.
Answer: False
Bloom’s Level: Understanding
Concept Tested: Spaghetti code avoidance
Justification: Spaghetti code comes from unstructured, crossing arrows, not from the number of
diamonds.
Q54. Designing test cases before coding helps clarify requirements and catch errors early.
Answer: True
Bloom’s Level: Evaluating
Concept Tested: Test case design
Justification: Pre-coding tests improve understanding of specifications and reveal edge cases
sooner.
Q55. Boundary testing involves checking values at the edges of valid input ranges.
Answer: True
Bloom’s Level: Applying
Concept Tested: Boundary condition testing
Justification: Testing minimum, maximum, and off-by-one values catches common off-by-one
and overflow errors.
Q56. Complete branch coverage requires that every possible path through the code is tested.
Answer: False
Bloom’s Level: Remembering
Concept Tested: Complete branch coverage
103
103
Justification: Branch coverage tests each decision outcome, not all paths (which is path
coverage).
Q57. Invalid input handling ensures a program only processes data that meets predefined criteria.
Answer: True
Bloom’s Level: Understanding
Concept Tested: Invalid input handling
Justification: Validation checks (range, type, format) prevent crashes and incorrect outputs from
bad data.
Q58. A good error-checking strategy assumes user input is usually correct to keep code simple.
Answer: False
Bloom’s Level: Evaluating
Concept Tested: Error checking strategy
Justification: Defensive programming validates all input; assuming correctness leads to
vulnerabilities and bugs.
Q59. When estimating coding time, doubling the initial estimate accounts for unexpected
problems.
Answer: True
Bloom’s Level: Evaluating
Concept Tested: Time estimation for coding
Justification: Unforeseen issues (debugging, research) often arise; a buffer reduces schedule
risk.
Q60. Experienced programmers don’t need to include buffer time in project schedules.
Answer: False
Bloom’s Level: Evaluating
Concept Tested: Schedule buffer time
Justification: Even experts encounter unexpected challenges; buffers are a prudent planning
practice.
104
104
Q61. The Logger class allows temporary deactivation of debug messages without removing print
statements.
Answer: True
Bloom’s Level: Applying
Concept Tested: Logging with Logger
Justification: Logger provides configurable logging levels (INFO, OFF) to enable/disable
output dynamically.
Q62. Trace messages are used to log execution flow and variable states for debugging.
Answer: True
Bloom’s Level: Remembering
Concept Tested: Trace messages
Justification: Strategic print/log statements help developers follow program behavior and
identify bugs.
Q63. Setting log level to Level.OFF disables all logging, including SEVERE messages.
Answer: True
Bloom’s Level: Applying
Concept Tested: Level.OFF deactivation
Justification: OFF is a level that suppresses all log messages regardless of severity.
Q64. The boolean data type in Java can store three values: true, false, and null.
Answer: False
Bloom’s Level: Remembering
Concept Tested: Boolean data type
Justification: boolean is a primitive; only true and false. null is for object references, not
primitives.
Q65. Boolean literals in Java are written in uppercase: TRUE and FALSE.
Answer: False
Bloom’s Level: Remembering
Concept Tested: true and false literals
105
105
Justification: Java requires lowercase true and false; uppercase identifiers would be treated as
variables.
Q66. A boolean variable used to indicate a condition’s state is often called a flag.
Answer: True
Bloom’s Level: Understanding
Concept Tested: Boolean variable as flag
Justification: Flags store binary states (e.g., isFound, isValid) to control program logic.
Q67. The boolean type is named after George Boole, who developed Boolean algebra.
Answer: True
Bloom’s Level: Remembering
Concept Tested: George Boole
Justification: Boolean algebra underpins digital logic; the boolean type honors George Boole’s
work.
Q68. The && operator returns true if either operand is true.
Answer: False
Bloom’s Level: Remembering
Concept Tested: Logical AND (&&)
Justification: && requires both operands to be true; || returns true if at least one is true.
Q69. The || operator returns false only when both operands are false.
Answer: True
Bloom’s Level: Remembering
Concept Tested: Logical OR (||)
Justification: || is inclusive OR: true if any operand is true, false only if both are false.
Q70. Short-circuit evaluation means both operands of && or || are always evaluated.
Answer: False
Bloom’s Level: Understanding
Concept Tested: Short-circuit evaluation
106
106
Justification: Short-circuit skips the right operand if the result is already known from the left
operand.
Q71. Short-circuit evaluation can prevent division-by-zero errors in conditions like denom != 0
&& num / denom > 1.
Answer: True
Bloom’s Level: Applying
Concept Tested: Division-by-zero protection
Justification: If denom != 0 is false, the division is skipped, avoiding an arithmetic exception.
Q72. The ! operator inverts a boolean value: !true is false and !false is true.
Answer: True
Bloom’s Level: Remembering
Concept Tested: Logical NOT (!)
Justification: ! is the unary negation operator, flipping true to false and vice versa.
Q73. A truth table shows output values of a logical operation for all possible input combinations.
Answer: True
Bloom’s Level: Remembering
Concept Tested: Truth tables
Justification: Truth tables systematically define Boolean functions for inputs true/false.
Q74. Java allows chained relational operators like 0 < x < 100.
Answer: False
Bloom’s Level: Applying
Concept Tested: Combining relational operators
Justification: Chaining is illegal; must use 0 < x && x < 100.
Q75. The expression 0 <= x && x <= 100 correctly tests whether x is between 0 and 100
inclusive.
Answer: True
Bloom’s Level: Applying
Concept Tested: Chained comparison error
107
107
Justification: Logical && combines two relational checks, mimicking mathematical interval
notation.
Q76. To test if x equals 1, 2, or 3, you can write x == 1 || 2 || 3.
Answer: False
Bloom’s Level: Applying
Concept Tested: Multiple equality tests
Justification: Each comparison must be explicit: x == 1 || x == 2 || x == 3.
Q77. De Morgan’s Law states that !(A && B) is equivalent to !A && !B.
Answer: False
Bloom’s Level: Understanding
Concept Tested: De Morgan’s Law
Justification: De Morgan’s: !(A && B) ≡ !A || !B and !(A || B) ≡ !A && !B.
Q78. Negating (country.equals("USA") && !state.equals("AK")) gives !country.equals("USA")
|| state.equals("AK").
Answer: True
Bloom’s Level: Applying
Concept Tested: Negating compound conditions
Justification: Applying De Morgan’s: !(A && B) ≡ !A || !B, and !!C ≡ C.
Q79. De Morgan’s laws are named after the mathematician Augustus De Morgan.
Answer: True
Bloom’s Level: Remembering
Concept Tested: Augustus De Morgan
Justification: Augustus De Morgan formulated these logical transformation rules in the 19th
century.
Q80. Input validation checks user input for correctness before processing it.
Answer: True
Bloom’s Level: Understanding
Concept Tested: Input validation
108
108
Justification: Validation prevents errors, security issues, and crashes by ensuring input meets
expectations.
Q81. Scanner.hasNextInt() returns true if the next input token can be parsed as an integer.
Answer: True
Bloom’s Level: Remembering
Concept Tested: hasNextInt method
Justification: hasNextInt() checks the token without consuming it, allowing safe input
validation.
Q82. hasNextDouble() checks if the next token is a valid floating-point number.
Answer: True
Bloom’s Level: Remembering
Concept Tested: hasNextDouble method
Justification: Similar to hasNextInt(), it validates that the next token matches a double format.
Q83. Using hasNextInt() before nextInt() can prevent InputMismatchException.
Answer: True
Bloom’s Level: Applying
Concept Tested: Runtime exception prevention
Justification: If hasNextInt() returns false, you can handle the error instead of
calling nextInt() and crashing.
Q84. If the user enters "five" when nextInt() is called, a runtime exception occurs.
Answer: True
Bloom’s Level: Understanding
Concept Tested: Invalid integer input
Justification: InputMismatchException is thrown when the input doesn’t match the expected
type.
Q85. Range checking ensures a numeric input falls within minimum and maximum allowed
values.
Answer: True
109
109
Bloom’s Level: Understanding
Concept Tested: Range checking
Justification: Range validation rejects inputs outside specified bounds (e.g., floor between 1 and
20).
Q86. The elevator simulation skips floor 13 because it is considered unlucky in some cultures.
Answer: True
Bloom’s Level: Remembering
Concept Tested: Unlucky number 13
Justification: The example adjusts floor numbers to account for superstition about the 13th
floor.
Q87. Some buildings skip both the 13th and 14th floors due to cultural superstitions.
Answer: True
Bloom’s Level: Remembering
Concept Tested: Unlucky number 14
Justification: In some Asian countries, 14 is also unlucky, leading to double-floor skipping.
Q88. In the discount pricing example, an 8% discount is applied for prices of $128 or more.
Answer: False
Bloom’s Level: Applying
Concept Tested: Discount pricing logic
Justification: 8% discount for price < $128; 16% discount for price ≥ $128.
Q89. The fuel indicator example prints "red" when fuel is less than 10% of capacity.
Answer: True
Bloom’s Level: Applying
Concept Tested: Fuel level indicator
Justification: Condition: fuelAmount < 0.10 * fuelCapacity triggers the red warning.
Q90. The status light logic uses a single boolean condition to choose between two outputs.
Answer: True
Bloom’s Level: Applying
110
110
Concept Tested: Status light logic
Justification: The if-else branches on one boolean condition to print either "red" or "green".
Q91. The opposite of floor > 13 is floor <= 13.
Answer: True
Bloom’s Level: Applying
Concept Tested: Opposite condition formulation
Justification: Negating > gives <=; negating < gives >=.
Q92. To check if a string str is empty, str == "" is the recommended approach.
Answer: False
Bloom’s Level: Applying
Concept Tested: String empty check
Justification: Use str.equals("") or str.isEmpty(); == compares references, not content.
Q93. "Tomato".substring(0, 3) returns the string "Tom".
Answer: True
Bloom’s Level: Applying
Concept Tested: Substring extraction logic
Justification: substring(0,3) extracts characters at indexes 0,1,2 the first three characters.
Q94. The Denver airport’s automated luggage system succeeded and is still in use today.
Answer: False
Bloom’s Level: Understanding
Concept Tested: Denver airport luggage system
Justification: The system failed due to software and mechanical issues and was replaced with
manual handling.
Q95. Robotic carts in the Denver system sometimes accumulated unnecessarily due to software
glitches.
Answer: True
Bloom’s Level: Understanding
Concept Tested: Robotic cart failure
111
111
Justification: Software routing errors caused carts to cluster instead of moving to needed
locations.
Q96. The Denver luggage system failure resulted in significant financial losses and delays.
Answer: True
Bloom’s Level: Understanding
Concept Tested: Software glitch consequences
Justification: The project’s failure delayed the airport opening and cost nearly $1 billion.
Q97. Incremental deployment is recommended over big-bang launches for complex systems.
Answer: True
Bloom’s Level: Evaluating
Concept Tested: Incremental system deployment
Justification: Gradual rollout allows testing and adjustment, reducing risk of catastrophic
failure.
Q98. The tax calculation example uses the actual current-year federal tax brackets.
Answer: False
Bloom’s Level: Remembering
Concept Tested: Federal tax schedule
Justification: The example uses a simplified 2008 tax schedule for illustration, not current law.
Q99. Tax brackets apply different rates to different portions of income (progressive taxation).
Answer: True
Bloom’s Level: Understanding
Concept Tested: Rate thresholds
Justification: Progressive systems tax higher income at higher rates, using brackets.
Q100. In the tax example, a single taxpayer pays 10% on the first $32,000 and 25% on the
remainder.
Answer: True
Bloom’s Level: Applying
112
112
Concept Tested: Taxable income brackets
Justification: Constants RATE1_SINGLE_LIMIT = 32000, RATE1 = 0.10, RATE2 = 0.25.
Q101. The marriage penalty refers to a tax situation where married couples pay less than two
singles.
Answer: False
Bloom’s Level: Understanding
Concept Tested: Marriage penalty concept
Justification: Marriage penalty is when a couple pays more tax married than they would as two
singles.
Q102. Getting a raise can never reduce net take-home pay due to tax bracket progression.
Answer: False
Bloom’s Level: Evaluating
Concept Tested: Raise and tax misconception
Justification: In progressive systems, only income within a bracket is taxed at that rate; raises
always increase net.
Q103. The shipping cost example uses nested if statements to determine rates based on location.
Answer: True
Bloom’s Level: Applying
Concept Tested: Shipping cost logic
Justification: Outer if checks country; inner checks state for Alaska/Hawaii vs. continental US.
Q104. The continental United States includes Alaska and Hawaii.
Answer: False
Bloom’s Level: Remembering
Concept Tested: Continental U.S. definition
Justification: Continental US refers to the 48 contiguous states, excluding Alaska and Hawaii.
Q105. Alaska and Hawaii are charged a higher shipping rate in the example.
Answer: True
Bloom’s Level: Remembering
113
113
Concept Tested: Alaska/Hawaii surcharge
Justification: The logic charges $10 for AK/HI vs. $5 for continental US.
Q106. Water is liquid if its temperature is strictly between 0°C and 100°C at sea level.
Answer: True
Bloom’s Level: Applying
Concept Tested: Water phase determination
Justification: Condition: temp > 0 && temp < 100 for liquid water (exclusive of
freezing/boiling points).
Q107. At sea level, water freezes at 0°C and boils at 100°C.
Answer: True
Bloom’s Level: Remembering
Concept Tested: Freezing/boiling points
Justification: These are standard physical constants for pure water at standard atmospheric
pressure.
Q108. The condition temp >= 0 && temp <= 100 correctly identifies liquid water.
Answer: False
Bloom’s Level: Applying
Concept Tested: Liquid water range
Justification: At exactly 0°C or 100°C, water is not liquid; must be > and <, not >= and <=.
Q109. The condition for water not being liquid is temp <= 0 || temp >= 100.
Answer: True
Bloom’s Level: Applying
Concept Tested: Not liquid condition
Justification: This includes solid (<=0) and gaseous (>=100) states; liquid is the complement.
Q110. On a chessboard, a square’s color depends only on its row number.
Answer: False
Bloom’s Level: Applying
114
114
Concept Tested: Chessboard square color
Justification: Color depends on both row and column parity (e.g., (row + col) % 2).
Q111. Two appointments overlap if the later start time is less than the earlier end time.
Answer: True
Bloom’s Level: Applying
Concept Tested: Appointment overlap logic
Justification: Overlap occurs when the intervals intersect: max(start1, start2) < min(end1, end2).
Q112. Military time uses a 24-hour clock, where 13:00 corresponds to 1:00 PM.
Answer: True
Bloom’s Level: Remembering
Concept Tested: Military time comparison
Justification: 24-hour time avoids AM/PM; 13:00 is 1 PM, 00:00 is midnight.
Q113. The holiday matching program uses a series of if statements to compare dates.
Answer: True
Bloom’s Level: Applying
Concept Tested: Holiday date matching
Justification: It checks month and day against fixed holiday dates using if or switch.
Q114. A score of 90 or above is always an ‘A’ in typical letter grade assignments.
Answer: True
Bloom’s Level: Applying
Concept Tested: Letter grade assignment
Justification: Common grading scales define A as 90100%, inclusive.
Q115. If the grade cutoff for a B is 80, then a score of 80 is a B and 79 is a C.
Answer: True
Bloom’s Level: Applying
Concept Tested: Grade cutoff boundaries
Justification: Typically, B = 8089, C = 7079; boundaries are inclusive at the top.
115
115
Q116. Converting a numeric grade to a letter grade requires an if-else if chain or switch.
Answer: True
Bloom’s Level: Applying
Concept Tested: Number-to-letter grade
Justification: Multiple exclusive ranges are naturally expressed with if-else if or switch.
Q117. The card notation program decodes "QS" as "Queen of Spades".
Answer: True
Bloom’s Level: Applying
Concept Tested: Card notation decoding
Justification: ‘Q’ → Queen, ‘S’ → Spades; uses substring and equals or switch to map symbols.
Q118. Finding the largest of three numbers requires nested if statements.
Answer: False
Bloom’s Level: Applying
Concept Tested: Three-number comparison
Justification: Can be done with chained if-else if or using Math.max, not strictly nested ifs.
Q119. Lexicographic sorting of three strings can be done using compareTo in if statements.
Answer: True
Bloom’s Level: Applying
Concept Tested: Lexicographic sort
Justification: compareTo determines order; if swaps or arranges strings accordingly.
Q120. The season algorithm uses month and day to determine season, adjusting for equinox
dates.
Answer: True
Bloom’s Level: Applying
Concept Tested: Season determination algorithm
Justification: It first assigns season by month, then adjusts if day ≥21 and month divisible by 3.
Q121. The season algorithm changes season if month % 3 == 0 and day >= 21.
Answer: True
116
116
Bloom’s Level: Applying
Concept Tested: Equinox date adjustment
Justification: This approximates the equinoxes (March, June, September, December ~21st).
Q122. To compare two doubles for equality up to two decimal places, use == after rounding.
Answer: False
Bloom’s Level: Applying
Concept Tested: Two-decimal-place equality
Justification: Better to check Math.abs(a - b) < 0.005; rounding can still have floating-point
issues.
Q123. A horoscope program typically uses a switch on birth month to print fortunes.
Answer: True
Bloom’s Level: Applying
Concept Tested: Horoscope fortune logic
Justification: switch is concise for mapping discrete months (or zodiac signs) to messages.
Q124. A leap year is any year divisible by 4.
Answer: False
Bloom’s Level: Applying
Concept Tested: Leap year rules
Justification: Exception: years divisible by 100 are not leap unless also divisible by 400.
Q125. The Gregorian calendar correction accounts for the Earth’s orbit being slightly less than
365.25 days.
Answer: True
Bloom’s Level: Remembering
Concept Tested: Gregorian calendar correction
Justification: The Gregorian calendar omits some leap years to better match the solar year
(~365.2425 days).
117
117
Reference
Horstmann, C. S. (2017). Big Java: Early objects (6th ed.). Wiley.
Students also viewed