DUET PG Score Card 2021
NHAI Recruitment 2021
Bihar Board 12th Dummy Admit Card 2022
RBI Assistant Notification 2021
Jee Advanced 2021 Result
NIACL Assistant Recruitment 2021
SBI PO Online Form 2021

lambda expressions can be used to represent the instance of a functional interface( lambda expressions are supported java 8 onwards).

Functional Interfaces:

Key points:

  1. Functional interface contains only one abstract method. 
  2. Functional interface can have only one functionality to exhibit. 
  3. Functional interface can have any number of default methods. 

Note: lambda expressions can be used to represent the instance of a functional interface( lambda expressions are supported java 8 onwards).

Some of the examples of functional interfaces are:

Runnable

ActionListener

Comparable 

Before Java 8 Java Code for creating functional interface implementation is given below:

import java.util.*;
import java.lang.*;
import java.io.*;

class FunctionalInterface {
    public static void main(String args[]) {
          new Thread(new Runnable(){  //Anonymous inner class object
         	 @Override
        	  public void run() {
         		System.out.println("Creation of new thread");
        	 }
         }).start();
    }
}
Creation of new thread
import java.util.*;

import java.lang.*;

import java.io.*;

class FunctionalInterface {

    public static void main(String args[]) {

        new Thread(new Runnable() {

            @Override

            public void run() {

                System.out.println("Creation of new thread");

            }

        }).start();

    }

}

Leave a Comment