Java MCQ: Which Java 9 feature allows developers to interactively evaluate code snippets?
Answer:
Explanation:
JShell is a feature introduced in Java 9 that allows developers to interactively evaluate code snippets. JShell, also known as the REPL (Read-Eval-Print Loop) tool, provides an environment where developers can type Java code and immediately see the results of its execution.
JShell is particularly useful for learning, prototyping, and testing small pieces of code without the need to write a full Java program or set up an IDE. It supports most Java language features, allowing developers to experiment with code, test APIs, and debug logic in an interactive and incremental way.
For example, you can start JShell by typing jshell
in the command line and then execute Java statements like:
jshell> int x = 5;
jshell> System.out.println(x * 2);
JShell evaluates the code and prints the result immediately, making it a powerful tool for quick code exploration and experimentation in Java 9 and beyond.
Reference links:
https://www.rameshfadatare.com/learn-java-programming/
https://www.javaguides.net/p/java-tutorial-learn-java-programming.html