017-006-006

Functional Interface Basics

Easy

Problem Description

Functional Interface Basics

Learning Objective: Understand the definition and basic usage of functional interfaces

Overview

Create a functional interface Calculator with a single abstract method and implement it with a lambda expression.

Specifications

  • Calculator interface: has int calculate(int a, int b) method
  • Annotate with @FunctionalInterface
  • In main, create an addition implementation using lambda expression
  • Pass 5 and 3 as arguments and output the result

Output Format

Result: 8

Ready to Try Running Code?

Log in to access the code editor and execute your solutions for this problem.

Don't have an account?