Appendix A Introduction to JShell: Java's
REPL for Interactive Java
A.1 Introduction
A.1.1 What does REPL stand for in the context of JShell?
a) Read-Evaluate-Print-Loop
b) Rapid-Execution-Programming-Language
c) Real-Environment-Processing-Library
d) Runtime-Error-Prevention-Logic
Answer: a
A.1.2 Which of the following best describes JShell's primary purpose?
a) To replace traditional Java IDEs completely
b) To provide a fast and friendly environment for exploring, discovering, and experimenting
with Java
c) To compile complete Java applications faster
d) To debug existing Java programs
Answer: b
A.1.3 JShell eliminates the need for which of the following when testing code snippets?
a) Variable declarations
b) Method calls
c) Creating a class containing a main method
d) Import statements
Answer: c
A.1.4 What is auto-completion in JShell?
a) A feature that automatically finishes writing your code based on machine learning
predictions
b) A feature that completes names of classes, methods, and variables after you enter a
portion of them
c) A feature that automatically creates documentation for your code
d) A feature that automatically creates variable names for you
Answer: b
A.2 Introduction to JShell
A.2.1 What command is used to start a JShell session?
a) java
© Copyright 1992-2025
,Java How to Program, 12/e—Appendix A Test-Item File 2
b) javac
c) jshell
d) jdk
Answer: c
A.2.2 What does JShell display when you start a new session?
a) Only the jshell> prompt
b) A welcome message, version information, and the jshell> prompt
c) The Java classpath information
d) A list of available commands
Answer: b
A.2.3 What are the two input types that JShell accepts?
a) Java code snippets and compilation commands
b) Java code snippets and JShell commands
c) Java source files and class files
d) Expressions and statements only
Answer: b
A.2.4 When entering a standalone statement in JShell, semicolons are:
a) Always required
b) Never allowed
c) Optional - JShell adds them automatically
d) Required only for method declarations
Answer: c
A.2.5 What is the di]erence between using System.out.println() and
System.out.print() in JShell?
a) println() displays text, while print() only displays numbers
b) println() adds a newline character after the output, while print() does not
c) print() adds a newline character after the output, while println() does not
d) There is no di]erence between these methods in JShell
Answer: b
A.2.6 When you declare an int variable without initialization in JShell, what value does it
receive?
a) null
b) 0
c) undefined
d) 1
Answer: b
A.2.7 What happens when you declare a new variable with the same name as an existing
variable in JShell?
© Copyright 1992-2025
,Java How to Program, 12/e—Appendix A Test-Item File 3
a) JShell reports a compilation error
b) The new declaration is ignored
c) JShell replaces the first declaration with the new one
d) Both variables coexist with di]erent scope
Answer: c
A.2.8 When JShell displays a variable assignment, what does the notation "==>" mean?
a) Comparison operator
b) Assignment operator
c) "Has the value"
d) Error indicator
Answer: c
A.2.9 What does the /list command do in JShell?
a) Lists all Java packages available in the current session
b) Lists the valid snippets entered in the current session
c) Lists all the errors encountered in the current session
d) Lists all files in the current directory
Answer: b
A.2.10 How do you execute a specific snippet by its ID number in JShell?
a) /run id
b) /exec id
c) /id
d) /execute id
Answer: c
A.2.11 Which command re-executes the previous snippet in JShell?
a) /last
b) /previous
c) /!
d) /back
Answer: c
A.2.12 When you enter an expression in JShell, it creates an implicit variable named:
a) $temp
b) $var
c) $# (where # is the snippet ID)
d) $result
Answer: c
A.2.13 What type does JShell infer for the expression "11 + 5"?
a) String
b) double
© Copyright 1992-2025
, Java How to Program, 12/e—Appendix A Test-Item File 4
c) int
d) Object
Answer: c
A.2.14 Can you use implicitly declared variables (like $10) in subsequent expressions?
a) No, they are read-only
b) Yes, they can be used like any other variable
c) Only in the same line where they were created
d) Only after explicitly declaring them
Answer: b
A.2.15 How do you view a variable's current value in JShell?
a) Use the /value command
b) Enter the variable name and press Enter
c) Use System.out.println() only
d) Use the /show command
Answer: b
A.2.16 Which command removes all prior code from a JShell session?
a) /clear
b) /delete
c) /reset
d) /restart
Answer: c
A.2.17 What happens when you begin entering a multi-line statement like an if statement in
JShell?
a) JShell displays an error message because multi-line statements are not supported
b) JShell waits until the entire statement is completed before processing it
c) JShell displays a continuation prompt (...>) and indents the next line
d) JShell processes each line separately as it's entered
Answer: c
A.2.18 What prompt does JShell display when you enter an incomplete multiline statement?
a) jshell>
b) ...>
c) >>
d) >>>
Answer: b
A.2.19 In a multiline if statement body, are semicolons required?
a) No, JShell adds them automatically
b) Yes, they are required
© Copyright 1992-2025