
1. Describe the newly added features in Java 8?
Here are the newly added features of Java 8:
| Feature Name | Description |
|---|---|
| Lambda expression | A function that can be shared or referred to as an object. |
| Functional Interfaces | Single abstract method interface. |
| Method References | Uses function as a parameter to invoke a method. |
| Default method | It provides an implementation of methods within interfaces enabling 'Interface evolution' facilities. |
| Stream API | Abstract layer that provides pipeline processing of the data. |
| Date Time API | New improved joda-time inspired APIs to overcome the drawbacks in previous versions |
| Optional | Wrapper class to check the null values and helps in further processing based on the value. |
| Nashorn, JavaScript Engine | An improvised version of JavaScript Engine that enables JavaScript executions in Java, to replace Rhino. |
Q1-a. What New Features Were Added in Java 8?
Java 8 ships with several new features, but the most significant are the following:
- Lambda Expressions − a new language feature allowing us to treat actions as objects
- Method References − enable us to define Lambda Expressions by referring to methods directly using their names
- Optional − special wrapper class used for expressing optionality
- Functional Interface – an interface with maximum one abstract method; implementation can be provided using a Lambda Expression
- Default methods − give us the ability to add full implementations in interfaces besides abstract methods
- Nashorn, JavaScript Engine − Java-based engine for executing and evaluating JavaScript code
- Stream API − a special iterator class that allows us to process collections of objects in a functional manner
- Date API − an improved, immutable JodaTime-inspired Date API
Along with these new features, lots of feature enhancements are done under the hood at both the compiler and JVM level.
- Lambda Expressions − a new language feature allowing us to treat actions as objects
- Method References − enable us to define Lambda Expressions by referring to methods directly using their names
- Optional − special wrapper class used for expressing optionality
- Functional Interface – an interface with maximum one abstract method; implementation can be provided using a Lambda Expression
- Default methods − give us the ability to add full implementations in interfaces besides abstract methods
- Nashorn, JavaScript Engine − Java-based engine for executing and evaluating JavaScript code
- Stream API − a special iterator class that allows us to process collections of objects in a functional manner
- Date API − an improved, immutable JodaTime-inspired Date API
Along with these new features, lots of feature enhancements are done under the hood at both the compiler and JVM level.
2. In which programming paradigm Java 8 falls?
- Object-oriented programming language.
- Functional programming language.
- Procedural programming language.
- Logic programming language
3. What are the significant advantages of Java 8?
- Compact, readable, and reusable code.
- Less boilerplate code.
- Parallel operations and execution.
- Can be ported across operating systems.
- High stability.
- Stable environment.
- Adequate support
4. What is MetaSpace? How does it differ from PermGen?

PremGen: MetaData information of classes was stored in PremGen (Permanent-Generation) memory type before Java 8. PremGen is fixed in size and cannot be dynamically resized. It was a contiguous Java Heap Memory.
MetaSpace: Java 8 stores the MetaData of classes in native memory called 'MetaSpace'. It is not a contiguous Heap Memory and hence can be grown dynamically which helps to overcome the size constraints. This improves the garbage collection, auto-tuning, and de-allocation of metadata.
Functional Interfaces are an interface with only one abstract method. Due to which it is also known as the Single Abstract Method (SAM) interface. It is known as a functional interface because it wraps a function as an interface or in other words a function is represented by a single abstract method of the interface.
Functional interfaces can have any number of default, static, and overridden methods. For declaring Functional Interfaces @FunctionalInterface annotation is optional to use. If this annotation is used for interfaces with more than one abstract method, it will generate a compiler error.
@FunctionalInterface // Annotation is optional
public interface Foo() {
// Default Method - Optional can be 0 or more
public default String HelloWorld() {
return "Hello World";
}
// Static Method - Optional can be 0 or more
public static String CustomMessage(String msg) {
return msg;
}
// Single Abstract Method
public void bar();
}
public class FooImplementation implements Foo {
// Default Method - Optional to Override
@Override
public default String HelloWorld() {
return "Hello Java 8";
}
// Method Override
@Override
public void bar() {
System.out.println(“Hello World”);
}
}
public static void main(String[] args) {
FooImplementation fi = new FooImplementation();
System.out.println(fi.HelloWorld());
System.out.println(fi.CustomMessage(“Hi”));
fi.bar();
}6. Can a functional interface extend/inherit another interface?
A functional interface cannot extend another interface with abstract methods as it will void the rule of one abstract method per functional interface. E.g:
interface Parent {
public int parentMethod();
}
@FunctionalInterface // This cannot be FunctionalInterface
interface Child extends Parent {
public int childMethod();
// It will also extend the abstract method of the Parent Interface
// Hence it will have more than one abstract method
// And will give a compiler error
}It can extend other interfaces which do not have any abstract method and only have the default, static, another class is overridden, and normal methods. For eg:
interface Parent {
public void parentMethod(){
System.out.println("Hello");
}
}
@FunctionalInterface
interface Child extends Parent {
public int childMethod();
}7. What is the default method, and why is it required?
A method in the interface that has a predefined body is known as the default method. It uses the keyword default. default methods were introduced in Java 8 to have 'Backward Compatibility in case JDK modifies any interfaces. In case a new abstract method is added to the interface, all classes implementing the interface will break and will have to implement the new method. With default methods, there will not be any impact on the interface implementing classes. default methods can be overridden if needed in the implementation. Also, it does not qualify as synchronized or final.
@FunctionalInterface // Annotation is optional
public interface Foo() {
// Default Method - Optional can be 0 or more
public default String HelloWorld() {
return "Hello World";
}
// Single Abstract Method
public void bar();
}8. What are static methods in Interfaces?
Static methods, which contains method implementation is owned by the interface and is invoked using the name of the interface, it is suitable for defining the utility methods and cannot be overridden.
9. What are some standard Java pre-defined functional interfaces?
Some of the famous pre-defined functional interfaces from previous Java versions are Runnable, Callable, Comparator, and Comparable. While Java 8 introduces functional interfaces like Supplier, Consumer, Predicate, etc. Please refer to the java.util.function doc for other predefined functional interfaces and its description introduced in Java 8.
Runnable: use to execute the instances of a class over another thread with no arguments and no return value.
Callable: use to execute the instances of a class over another thread with no arguments and it either returns a value or throws an exception.
Comparator: use to sort different objects in a user-defined order
Comparable: use to sort objects in the natural sort order
10. What are the various categories of pre-defined function interfaces?
Function: To transform arguments in returnable value.
Predicate: To perform a test and return a Boolean value.
Consumer: Accept arguments but do not return any values.
Supplier: Do not accept any arguments but return a value.
Operator: Perform a reduction type operation that accepts the same input types.
here are a lot of functional interfaces in the java.util.function package. The more common ones include, but are not limited to:
- Function – it takes one argument and returns a result
- Consumer – it takes one argument and returns no result (represents a side effect)
- Supplier – it takes no arguments and returns a result
- Predicate – it takes one argument and returns a boolean
- BiFunction – it takes two arguments and returns a result
- BinaryOperator – it is similar to a BiFunction, taking two arguments and returning a result. The two arguments and the result are all of the same types.
- UnaryOperator – it is similar to a Function, taking a single argument and returning a result of the same type
What Is a Functional Interface? What Are the Rules of Defining a Functional Interface?
A functional interface is an interface with one single abstract method (default methods do not count), no more, no less.
Where an instance of such an interface is required, a Lambda Expression can be used instead. More formally put: Functional interfaces provide target types for lambda expressions and method references.
The arguments and return type of such an expression directly match those of the single abstract method.
For instance, the Runnable interface is a functional interface, so instead of:
Thread thread = new Thread(new Runnable() {
public void run() {
System.out.println("Hello World!");
}
});We could simply do:
Thread thread = new Thread(() -> System.out.println("Hello World!"));Functional interfaces are usually annotated with the @FunctionalInterface annotation, which is informative and doesn't affect the semantics.
What Is a Default Method and When Do We Use It?A default method is a method with an implementation, which can be found in an interface.
We can use a default method to add a new functionality to an interface, while maintaining backward compatibility with classes that are already implementing the interface:
public interface Vehicle {
public void move();
default void hoot() {
System.out.println("peep!");
}
}Usually when we add a new abstract method to an interface, all implementing classes will break until they implement the new abstract method. In Java 8, this problem was solved by using the default method.
For example, the Collection interface does not have a forEach method declaration. Thus adding such a method would simply break the whole collections API.
Java 8 introduced the default method so that the Collection interface can have a default implementation of the forEach method without requiring the classes implementing this interface to implement the same.
Will the Following Code Compile?
@FunctonalInterfacepublic interface Function2<T, U, V> {
public V apply(T t, U u);
default void count() {
// increment counter
}
}Yes, the code will compile because it follows the functional interface specification of defining only a single abstract method. The second method, count, is a default method that does not increase the abstract method count
11. What is the lambda expression in Java and How does a lambda expression relate to a functional interface?
Lambda expression is a type of function without a name. It may or may not have results and parameters. It is known as an anonymous function as it does not have type information by itself. It is executed on-demand. It is beneficial in iterating, filtering, and extracting data from a collection.
As lambda expressions are similar to anonymous functions, they can only be applied to the single abstract method of Functional Interface. It will infer the return type, type, and several arguments from the signature of the abstract method of functional interface.
Q12 What Is a Lambda Expression and What Is It Used for?
In very simple terms, a lambda expression is a function that we can reference and pass around as an object.
Moreover, lambda expressions introduce functional style processing in Java, and facilitate the writing of compact and easy-to-read code.
As a result, lambda expressions are a natural replacement for anonymous classes such as method arguments. One of their main uses is to define inline implementations of functional interfaces.
Q12.1 Explain the Syntax and Characteristics of a Lambda Expression
A lambda expression consists of two parts, the parameter part and the expressions part separated by a forward arrow:
params -> expressions
params -> expressionsAny lambda expression has the following characteristics:
- Optional type declaration – when declaring the parameters on the left-hand side of the lambda, we don't need to declare their types as the compiler can infer them from their values. So int param -> … and param ->… are all valid
- Optional parentheses – when only a single parameter is declared, we don't need to place it in parentheses. This means param -> … and (param) -> … are all valid, but when more than one parameter is declared, parentheses are required
- Optional curly braces – when the expressions part only has a single statement, there is no need for curly braces. This means that param – > statement and param – > {statement;} are all valid, but curly braces are required when there is more than one statement
- Optional return statement – when the expression returns a value and it is wrapped inside curly braces, then we don't need a return statement. That means (a, b) – > {return a+b;} and (a, b) – > {a+b;} are both valid
12.2 What is the basic structure/syntax of a lambda expression?
FunctionalInterface fi = (String name) -> {
System.out.println("Hello "+name);
return "Hello "+name;
}Lambda expression can be divided into three distinct parts as below:
1. List of Arguments/Params:
(String name)
A list of params is passed in () round brackets. It can have zero or more params. Declaring the type of parameter is optional and can be inferred for the context.
2. Arrow Token:
->
Arrow token is known as the lambda arrow operator. It is used to separate the parameters from the body, or it points the list of arguments to the body. 3. Expression/Body:
{
System.out.println("Hello "+name);
return "Hello "+name;
}A body can have expressions or statements. {} curly braces are only required when there is more than one line. In one statement, the return type is the same as the return type of the statement. In other cases, the return type is either inferred by the return keyword or void if nothing is returned.
13. What are the features of a lambda expression?
Below are the two significant features of the methods that are defined as the lambda expressions:
- Lambda expressions can be passed as a parameter to another method.
- Lambda expressions can be standalone without belonging to any class.
14. What is a type interface?
Type interface is available even in earlier versions of Java. It is used to infer the type of argument by the compiler at the compile time by looking at method invocation and corresponding declaration.
15. What are the types and common ways to use lambda expressions?
A lambda expression does not have any specific type by itself. A lambda expression receives type once it is assigned to a functional interface. That same lambda expression can be assigned to different functional interface types and can have a different type.
For eg consider expression s -> s.isEmpty() :
Predicate<String> stringPredicate = s -> s.isEmpty(); Predicate<List> listPredicate = s -> s.isEmpty();Function<String, Boolean> func = s -> s.isEmpty();Consumer<String> stringConsumer = s -> s.isEmpty();
Common ways to use the expression
Assignment to a functional Interface —> Predicate<String> stringPredicate = s -> s.isEmpty();
Can be passed as a parameter that has a functional type —> stream.filter(s -> s.isEmpty())
Returning it from a function —> return s -> s.isEmpty()
Casting it to a functional type —> (Predicate<String>) s -> s.isEmpty()
16. In Java 8, what is Method Reference?
Method reference is a compact way of referring to a method of functional interface. It is used to refer to a method without invoking it. :: (double colon) is used for describing the method reference. The syntax is class::methodName
For e.g.:
Integer::parseInt(str) \\ method reference
str -> Integer.ParseInt(str); \\ equivalent lambda
17. What does the String::ValueOf expression mean?
It is a static method reference to method Valueof() of class String. It will return the string representation of the argument passed.
18. What is an Optional class?
Optional is a container type which may or may not contain value i.e. zero(null) or one(not-null) value. It is part of java.util package. There are pre-defined methods like isPresent(), which returns true if the value is present or else false and the method get(), which will return the value if it is present.
static Optional<String> changeCase(String word) {
if (name != null && word.startsWith("A")) {
return Optional.of(word.toUpperCase());
}
else {
return Optional.ofNullable(word); // someString can be null
}
}
19. What are the advantages of using the Optional class?
Below are the main advantage of using the Optional class:
It encapsulates optional values, i.e., null or not-null values, which helps in avoiding null checks, which results in better, readable, and robust code It acts as a wrapper around the object and returns an object instead of a value, which can be used to avoid run-time NullPointerExceptions.
Optional is a new class in Java 8 that encapsulates an optional value, i.e. a value that is either there or not. It's a wrapper around an object, and we can think of it as a container of zero or one element.
Optional has a special Optional.empty() value instead of wrapped null. Thus it can be used instead of a nullable value to get rid of NullPointerException in many cases.
The main purpose of Optional, as designed by its creators, is to be a return type of methods that previously would return null. Such methods would require us to write boilerplate code to check the return value, and we could sometimes forget to do a defensive check. In Java 8, an Optional return type explicitly requires us to handle null or non-null wrapped values differently.
For instance, the Stream.min() method calculates the minimum value in a stream of values. But what if the stream is empty? If it wasn't for Optional, the method would return null or throw an exception.
However, it returns an Optional value, which may be Optional.empty() (the second case). This allows us to easily handle such cases:
int min1 = Arrays.stream(new int[]{1, 2, 3, 4, 5})
.min()
.orElse(0);
assertEquals(1, min1);
int min2 = Arrays.stream(new int[]{})
.min()
.orElse(0);
assertEquals(0, min2);
It's worth noting that Optional is not a general purpose class like Option in Scala. It's not recommended that we use it as a field value in entity classes, which is clearly indicated by it not implementing the Serializable interface.
20. What are Java 8 streams?
A stream is an abstraction to express data processing queries in a declarative way.
A Stream, which represents a sequence of data objects & series of operations on that data is a data pipeline that is not related to Java I/O Streams does not hold any data permanently.
The key interface is java.util.stream.Stream<T>. It accepts Functional Interfaces so that lambdas can be passed. Streams support a fluent interface or chaining. Below is the basic stream timeline marble diagram:

What Is a Stream? How Does It Differ From a Collection?
In simple terms, a stream is an iterator whose role is to accept a set of actions to apply on each of the elements it contains.
The stream represents a sequence of objects from a source such as a collection, which supports aggregate operations. They were designed to make collection processing simple and concise. Contrary to the collections, the logic of iteration is implemented inside the stream, so we can use methods like map and flatMap for performing a declarative processing.
Additionally, the Stream API is fluent and allows pipelining:
int sum = Arrays.stream(new int[]{1, 2, 3})
.filter(i -> i >= 2)
.map(i -> i * 3)
.sum();Another important distinction from collections is that streams are inherently lazily loaded and processed.
21. What are the main components of a Stream?
Components of the stream are:
- A data source
- Set of Intermediate Operations to process the data source
- Single Terminal Operation that produces the result

22. What are the sources of data objects a Stream can process?
A Stream can process the following data:
- A collection of an Array.
- An I/O channel or an input device.
- A reactive source (e.g., comments in social media or tweets/re-tweets)
- A stream generator function or a static factory.
23. What are Intermediate and Terminal operations?
Intermediate Operations:
- Process the stream elements.
- Typically transforms a stream into another stream.
- Are lazy, i.e., not executed till a terminal operation is invoked.
- Does internal iteration of all source elements.
- Any number of operations can be chained in the processing pipeline.
- Operations are applied as per the defined order.
- Intermediate operations are mostly lambda functions.
Terminal Operations:
- Kick-starts the Stream pipeline.
- used to collect the processed Stream data.
int count = Stream.of(1, 2, 3, 4, 5)
.filter(i -> i <4) // Intermediate Operation filter
.count(); // Terminal Operation count24. What are the most commonly used Intermediate operations?
Filter(Predicate<T>) - Allows selective processing of Stream elements. It returns elements that are satisfying the supplied condition by the predicate.
map(Funtion<T, R>) - Returns a new Stream, transforming each of the elements by applying the supplied mapper function.= sorted() - Sorts the input elements and then passes them to the next stage.
distinct() - Only pass on elements to the next stage, not passed yet.
limit(long maxsize) - Limit the stream size to maxsize.
skip(long start) - Skip the initial elements till the start.
peek(Consumer) - Apply a consumer without modification to the stream.
flatMap(mapper) - Transform each element to a stream of its constituent elements and flatten all the streams into a single stream.
25. What is the stateful intermediate operation? Give some examples of stateful intermediate operations.
To complete some of the intermediate operations, some state is to be maintained, and such intermediate operations are called stateful intermediate operations. Parallel execution of these types of operations is complex.
For Eg: sorted() , distinct() , limit() , skip() etc.
Sending data elements to further steps in the pipeline stops till all the data is sorted for sorted() and stream data elements are stored in temporary data structures.
26. What is the most common type of Terminal operations?
- collect() - Collects single result from all elements of the stream sequence.
- reduce() - Produces a single result from all elements of the stream sequence
- count() - Returns the number of elements on the stream.
- min() - Returns the min element from the stream.
- max() - Returns the max element from the stream.
- Search/Query operations
- anyMatch() , noneMatch() , allMatch() , ... - Short-circuiting operations.
- Takes a Predicate as input for the match condition.
- Stream processing will be stopped, as and when the result can be determined.
- Iterative operations
- forEach() - Useful to do something with each of the Stream elements. It accepts a consumer.
- forEachOrdered() - It is helpful to maintain order in parallel streams.
27. What is the difference between findFirst() and findAny()?
| findFirst() | findAny() |
|---|---|
| Returns the first element in the Stream | Return any element from the Stream |
| Deterministic in nature | Non-deterministic in nature |
What Is the Difference Between Intermediate and Terminal Operations?
We combine stream operations into pipelines to process streams. All operations are either intermediate or terminal.
Intermediate operations are those operations that return Stream itself, allowing for further operations on a stream.
These operations are always lazy, i.e. they do not process the stream at the call site. An intermediate operation can only process data when there is a terminal operation. Some of the intermediate operations are filter, map and flatMap.
In contrast, terminal operations terminate the pipeline and initiate stream processing. The stream is passed through all intermediate operations during terminal operation call. Terminal operations include forEach, reduce, Collect and sum.
To drive this point home, let's look at an example with side effects:
public static void main(String[] args) {
System.out.println("Stream without terminal operation");
Arrays.stream(new int[] { 1, 2, 3 }).map(i -> {
System.out.println("doubling " + i);
return i * 2;
});
System.out.println("Stream with terminal operation");
Arrays.stream(new int[] { 1, 2, 3 }).map(i -> {
System.out.println("doubling " + i);
return i * 2;
}).sum();
}The output will be as follows:
StreaIntermediate operations are those operations that return Stream itself, allowing for further operations on a stream.These operations are always lazy, i.e. they do not process the stream at the call site. An intermediate operation can only process data when there is a terminal operation. Some of the intermediate operations are filter, map and flatMap.
In contrast, terminal operations terminate the pipeline and initiate stream processing. The stream is passed through all intermediate operations during terminal operation call. Terminal operations include forEach, reduce, Collect and sum.
To drive this point home, let's look at an example with side effects:
public static void main(String[] args) {
System.out.println("Stream without terminal operation");
Arrays.stream(new int[] { 1, 2, 3 }).map(i -> {
System.out.println("doubling " + i);
return i * 2;
});
System.out.println("Stream with terminal operation");
Arrays.stream(new int[] { 1, 2, 3 }).map(i -> {
System.out.println("doubling " + i);
return i * 2;
}).sum();
}
The output will be as follows:
Stream without terminal operation
Stream with terminal operation
doubling 1
doubling 2
doubling 3
As we can see, the intermediate operations are only triggered when a terminal operation exists.
m without terminal operation
Stream with terminal operation
doubling 1
doubling 2
doubling 3As we can see, the intermediate operations are only triggered when a terminal operation exists.
What Is the Difference Between Map and flatMap Stream Operation?
There is a difference in signature between map and flatMap. Generally speaking, a map operation wraps its return value inside its ordinal type, while flatMap does not.
For example, in Optional, a map operation would return Optional<String> type, while flatMap would return String type.
So after mapping, we need to unwrap (read “flatten”) the object to retrieve the value, whereas after flat mapping, there is no such need as the object is already flattened. We apply the same concept to mapping and flat mapping in Stream.
Both map and flatMap are intermediate stream operations that receive a function and apply this function to all the elements of a stream.
The difference is that for the map, this function returns a value, but for flatMap, this function returns a stream. The flatMap operation “flattens” the streams into one.
Here's an example where we take a map of users' names and lists of phones and “flatten” it down to a list of phones of all the users using flatMap:
Map<String, List<String>> people = new HashMap<>();
people.put("John", Arrays.asList("555-1123", "555-3389"));
people.put("Mary", Arrays.asList("555-2243", "555-5264"));
people.put("Steve", Arrays.asList("555-6654", "555-3242"));
List<String> phones = people.values().stream()
.flatMap(Collection::stream)
.collect(Collectors.toList());What Is Stream Pipelining in Java 8?
Stream pipelining is the concept of chaining operations together. We do this by splitting the operations that can happen on a stream into two categories: intermediate operations and terminal operations.
Each intermediate operation returns an instance of Stream itself when it runs. Therefore, we can set up an arbitrary number of intermediate operations to process data, forming a processing pipeline.
There must then be a terminal operation which returns a final value and terminates the pipeline.
28. How are Collections different from Stream?
Collections are the source for the Stream. Java 8 collection API is enhanced with the default methods returning Stream<T> from the collections.
| Collections | Streams |
|---|---|
| Data structure holds all the data elements | No data is stored. Have the capacity to process an infinite number of elements on demand |
| External Iteration | Internal Iteration |
| Can be processed any number of times | Traversed only once |
| Elements are easy to access | No direct way of accessing specific elements |
| Is a data store | Is an API to process the data |
29. What is the feature of the new Date and Time API in Java 8?
- Immutable classes and Thread-safe
- Timezone support
- Fluent methods for object creation and arithmetic
- Addresses I18N issue for earlier APIs
- Influenced by popular joda-time package
- All packages are based on the ISO-8601 calendar system
30. What are the important packages for the new Data and Time API?
- java.time
- dates
- times
- Instants
- durations
- time-zones
- periods
- Java.time.format
- Java.time.temporal
- java.time.zone
31. Explain with example, LocalDate, LocalTime, and LocalDateTime APIs.
LocalDate
- Date with no time component
- Default format - yyyy-MM-dd (2020-02-20)
- LocalDate today = LocalDate.now(); // gives today’s date
- LocalDate aDate = LocalDate.of(2011, 12, 30); //(year, month, date)
LocalTime
- Time with no date with nanosecond precision
- Default format - hh:mm:ss:zzz (12:06:03.015) nanosecond is optional
- LocalTime now = LocalTime.now(); // gives time now
- LocalTime aTime2 = LocalTime.of(18, 20, 30); // (hours, min, sec)
LocalDateTime
- Holds both Date and Time
- Default format - yyyy-MM-dd-HH-mm-ss.zzz (2020-02-20T12:06:03.015)
- LocalDateTime timestamp = LocalDateTime.now(); // gives timestamp now
- //(year, month, date, hours, min, sec)
- LocalDateTime dt1 = LocalDateTime.of(2011, 12, 30, 18, 20, 30);
A long-standing problem for Java developers has been the inadequate support for the date and time manipulations required by ordinary developers.
The existing classes such as java.util.Date and SimpleDateFormatter aren’t thread-safe, leading to potential concurrency issues for users.
Poor API design is also a reality in the old Java Data API. Here's just a quick example: years in java.util.Date start at 1900, months start at 1, and days start at 0, which is not very intuitive.
These issues and several others have led to the popularity of third-party date and time libraries, such as Joda-Time.
In order to address these problems and provide better support in JDK, a new date and time API, which is free of these problems, has been designed for Java SE 8 under the package java.time.
32. Define Nashorn in Java 8
Nashorn is a JavaScript processing engine that is bundled with Java 8. It provides better compliance with ECMA (European Computer Manufacturers Association) normalized JavaScript specifications and better performance at run-time than older versions.
33. What is the use of JJS in Java 8?
As part of Java 8, JJS is a command-line tool that helps to execute the JavaScript code in the console. Below is the example of CLI commands:
JAVA>jjsjjs> print("Hello, Java 8 - I am the new JJS!")Hello, Java 8 - I am the new JJS!jjs> quit()>>

