Java 8 Interview Questions: Click Here
Java 8 Interview Questions: Click Here
© Copyright by Interviewbit
Contents
Functional
Single abstract method interface.
Interfaces
JVM
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();
}
->
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.
Optional Class
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:
Java 8 Streams
Components of Stream
Terminal Operations:
Kick-starts the Stream pipeline.
used to collect the processed Stream data.
findFirst() findAny()
Collections Streams
External
Internal Iteration
Iteration
Can be
processed any Traversed only once
number of times
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
Conclusion
All in all, Java is a prevalent programming language securing the second rank in
popularity in both TIOBE and PYPL programming language ranking. The world's
leading tech giants like Twitter, LinkedIn, Amazon, PayPal, etc., use Java to build their
web apps and backend web systems. Java is also one of the primary languages used
to develop Android apps; an operating system backed and promoted by Google.
As of today, there are 1,751,661 questions around Java on StackOverflow and 123,776
Java public repositories on GitHub and continuously increasing. Considering Java 8
to be one of the most stable versions, there are immense career opportunities and
scope in the same. Just understand the concepts, implement them and get ready for
the interviews!
Additional Resources
Practice Coding
Java Tutorials
Java Interview Questions
Css Interview Questions Laravel Interview Questions Asp Net Interview Questions