Java MCQ: How do you start a JShell session from the command line?
java -jshell
jshell
java -jar jshell.jar
shelljava
Answer:
jshell
Explanation:
To start a JShell session from the command line, you run the command jshell
. JShell is a REPL (Read-Eval-Print Loop) tool introduced in Java 9 that allows developers to interactively write and execute Java code snippets. By typing jshell
in the command line, you enter an interactive environment where you can experiment with Java code, test new APIs, and debug logic on the fly.
JShell is particularly useful for quick prototyping, learning, and exploring Java language features without needing to write a full Java program or set up an IDE. Once in JShell, you can type Java expressions, statements, and methods, and see the results immediately.
Reference links:
https://www.rameshfadatare.com/learn-java-programming/
https://www.javaguides.net/p/java-tutorial-learn-java-programming.html