1. Home
  2. Training Library
  3. Programming
  4. Programming Courses
  5. Lambda Expressions and Static Imports

Marker and Functional Interfaces

Contents

keyboard_tab
Lambda Expressions and Static Imports
1
Course Overview
PREVIEW27s
4
Predicate
9m 55s

The course is part of this learning path

Marker and Functional Interfaces
Overview
Difficulty
Beginner
Duration
35m
Students
40
Ratings
5/5
starstarstarstarstar
Description

In this lesson, we will learn the Lambda Expressions.

Learning Objectives

  • Marker and Functional Interfaces
  • Lambda Expressions
  • Predicate Interface
  • Static Import

Intended Audience

  • Anyone looking to get Oracle Java Certification
  • Those who want to learn the Java Programming language from scratch
  • Java developers who want to increase their knowledge
  • Beginners with no previous coding experience in Java programming
  • Those who want to learn tips and tricks in Oracle Certified Associate – Java SE 8 Programmer certification exams

Prerequisites

  • No prior knowledge is required about the Java programming language
  • Basic computer knowledge
Transcript

Hi there. In this video, we'll talk about the Marker and Functional Interfaces in Java. If an interface does not contain any methods or a field, it's called a marker interface. There are some interfaces that are ready to find in Java, which we can call marker interfaces. These are the Serializable interface in the java.io package, the quotable interface in the java.lang package, and the remote interface defined in the java.rmi package. For example, on the slide, you can see the Serializable interface. If you notice, it does not contain any methods or fields. So, what is this used for?

For example, the process of making an object ready to be saved in a file, thanks to the Serializable interface, is called serialization. We'll learn about this in the Java IO section. In this case, a class that does not implement the Serializable interface cannot do this. So, rather than using any method or property of these interfaces, we use the interfaces as a marker. That's why such interfaces are called marker interfaces. Now, let's look at the functional interface. An interface which has only one abstract method is called the functional interface. For example, the Runnable interface in the java.lang package can be given as an example. As you can see from the slide, this interface only has an abstract method called run. 

In functional interfaces, there is no need to use the abstract keyword as it's optional to use the abstract keyword. Because by default, the method defined inside the interface is abstract only. As described earlier, functional interfaces can contain only one abstract method. However, they can include any quantity of default and static methods. Functional interface is additionally recognized as Single Abstract Method interfaces. In short, they are also known as SAM interfaces. Functional interfaces in Java are the new feature that provides users with the approach of fundamental programming. Functional interfaces are used and executed by representing the interface with an annotation called @FunctionalInterface. With this annotation, we declare the interface as functional interface. Functional interfaces are included in Java SE 8 with lambda expressions and method references in order to make code more readable, clean, and straightforward. In the next lesson, we'll learn to use the lambda expression. Let's take a short break here. See you in the next lesson.

 

About the Author
Students
458
Courses
47
Learning Paths
3

OAK Academy is made up of tech experts who have been in the sector for years and years and are deeply rooted in the tech world. They specialize in critical areas like cybersecurity, coding, IT, game development, app monetization, and mobile development.

Covered Topics