Interview Questions and Answers
Freshers / Beginner level questions & answers
Ques 1. What are new features which got introduced in Java 8?
- Lambda Expression
- Stream API
- Default methods in the interface
- Functional Interface
- Optional
- Method references
- Date API
- Nashorn, JavaScript Engine
Save For Revision
Save For Revision
Bookmark this item, mark it difficult, or place it in a revision set.
Log in to save bookmarks, difficult questions, and revision sets.
Ques 2. Can you explain the syntax of Lambda expression?
- Arguments
- Array Token
- Statements
- Body can have expression or statements.
- If there is only one statement in body, curly brace is not needed and return type of the anonymous function is same as of body expression.
- If there are more than one statements, then it should be in curly braces and return type of anonymous function is same as value return from code block, void if nothing is returned.
Save For Revision
Save For Revision
Bookmark this item, mark it difficult, or place it in a revision set.
Log in to save bookmarks, difficult questions, and revision sets.
Ques 3. What are functional interfaces?
- Functional interfaces are those interfaces which can have only one abstract method. It can have static method, default methods or can override Object’s class methods.
- There are many functional interfaces already present in java such as Comparable, Runnable.
- As we have only one method in Runnable, hence it is considered as functional interface.
Save For Revision
Save For Revision
Bookmark this item, mark it difficult, or place it in a revision set.
Log in to save bookmarks, difficult questions, and revision sets.
Ques 4. What Is a Default Method and When Do We Use It?
Save For Revision
Save For Revision
Bookmark this item, mark it difficult, or place it in a revision set.
Log in to save bookmarks, difficult questions, and revision sets.
Ques 5. What is Optional and how can we use it?
Save For Revision
Save For Revision
Bookmark this item, mark it difficult, or place it in a revision set.
Log in to save bookmarks, difficult questions, and revision sets.
Ques 6. Provide some APIs of Java 8 Date and Time.
LocalDate, LocalTime, and LocalDateTime are the Core API classes for Java 8. As the name suggests, these classes are local to context of observer. It denotes current date and time in context of Observer.
Save For Revision
Save For Revision
Bookmark this item, mark it difficult, or place it in a revision set.
Log in to save bookmarks, difficult questions, and revision sets.
Ques 7. How will you get current date and time using Java 8 Date and TIme API?
Save For Revision
Save For Revision
Bookmark this item, mark it difficult, or place it in a revision set.
Log in to save bookmarks, difficult questions, and revision sets.
Most helpful rated by users:
- What are new features which got introduced in Java 8?
- What are main advantages of using Java 8?
- Can you explain the syntax of Lambda expression?
- What are functional interfaces?
- What Is a Default Method and When Do We Use It?