Java 8 Features - TOP8

Java 8 features is very frequenctly asked question in advance java iterviews.
  • Lambda expression − Adds functional processing capability to Java.

  • Method references − Referencing functions by their names instead of invoking them directly. Using functions as parameter.

  • Default method − Interface to have default method implementation.

  • New tools − New compiler tools and utilities are added like ‘jdeps’ to figure out dependencies.

  • Stream API − New stream API to facilitate pipeline processing.

  • Date Time API − Improved date time API.

  • Optional − Emphasis on best practices to handle null values properly.

  • Nashorn, JavaScript Engine − A Java-based engine to execute JavaScript code.


1) Interface Static method:


Interfaces can now define static methods. This is example for natural order static method in Comparator interface

public static >
    Comparator naturalOrder() { 
   return (Comparator)       
 Comparators.NaturalOrderComparator.INSTANCE;
}


2) Functional interfaces


This enhancement is core of Java 8 changes. An interface is a functional interface if it defines exactly one abstract method. For instance, 
java.lang.Runnable is a functional interface because it only defines one abstract method:

public abstract void run();



3 ) Lambda expressions

A lambda expression is characterized by the following syntax.

parameter -> expression body

Following are the important characteristics of a lambda expression.

  • Optional type declaration − No need to declare the type of a parameter. The compiler can inference the same from the value of the parameter.

  • Optional parenthesis around parameter − No need to declare a single parameter in parenthesis. For multiple parameters, parentheses are required.

  • Optional curly braces − No need to use curly braces in expression body if the body contains a single statement.

  • Optional return keyword − The compiler automatically returns the value if the body has a single expression to return the value. Curly braces are required to indicate that expression returns a value.


4) Method references
   Java 8 Method reference is used to refer method of functional interface . It is compact and easy form of lambda expression. Each time when you are using lambda expression to just referring a method, you can replace your lambda expression with method reference.

5) Stream API,

Java 8 java.util.stream package consists of classes, interfaces and an enum to allow functional-style operations on the elements. It performs lazy computation. So, it executes only when it requires.

6) Default methods,

Java provides a facility to create default methods inside the interface. Methods which are defined inside the interface and tagged with default keyword are known as default methods. These methods are non-abstract methods and can have method body.

7)Base64 Encode Decode,

Java provides a class Base64 to deal with encryption and decryption. You need to import java.util.Base64 class in your source file to use its methods.

This class provides three different encoders and decoders to encrypt information at each level.


8) Optional class,
introduced a new class Optional in Java 8. It is a public final class which is used to deal with NullPointerException in Java application. We must import java.util package to use this class. It provides methods to check the presence of value for particular variable.

Java 8 Security Enhancements

1) The Java Secure Socket Extension(JSSE) provider enables the protocols Transport Layer Security (TLS) 1.1 and TLS 1.2 by default on the client side.

2) A improved method AccessController.doPrivileged has been added which enables code to assert a subset of its privileges, without preventing the full traversal of the stack to check for other permissions.

3) Advanced Encryption Standard (AES) and Password-Based Encryption (PBE) algorithms, such as PBEWithSHA256AndAES_128 and PBEWithSHA512AndAES_256 has been added to the SunJCE provider.





7 comments:

  1. This site helps to clear your all query. mgsu bsc 3rd year result
    Hpu ba 3rd Year Result This is really worth reading. nice informative article.

    ReplyDelete
  2. This is great stuff!! need to share lots of articles for the reader who like your blog and thanks for sharing your ideas and tips
    1Z0-900: Java EE 7 Application Developer
    1Z0-819: Oracle Java SE 11 Developer

    ReplyDelete
  3. xcellent information provided by you through this post. I follow all the mentioned information.If you are looking for Interview Questions and answers website then you can visit Just Crack Interview, here you will find interview questions and answers for developer, software engineer, bankers etc.

    ReplyDelete
  4. Impressive writing. You have the power to keep the reader occupied with your quality content and style of writing. I encourage you to write more.

    BSc 1st Year Hall Ticket 2022
    BSc 2nd Year Hall Ticket 2022
    BSc 3rd Year Hall Ticket 2022

    ReplyDelete
  5. Sarswatienterprises is a trusted Die Set Manufacturers, Power Press Manufacturer, and Flip off Seals Machinery in Delhi, India. For more information visit our website.
    Air Blower Machine Manufacturer in Delhi

    ReplyDelete
  6. Get the best deals on honda acura engines for sale, toyota transmission for sale and jdm lexus engines online at JDM of Washington. For more information in detail visit our website.
    Honda Acura Engines for Sale

    ReplyDelete