0% found this document useful (0 votes)
2 views8 pages

Interfaces in Java Notes

Interfaces in Java define a contract for behavior, supporting abstraction and polymorphism without providing implementation. They allow multiple inheritance and can be reused across unrelated classes, with all implementing classes required to define the methods. JDK 8 introduced default methods, enabling backward-compatible evolution of interfaces while maintaining their core characteristics.

Uploaded by

mohanapriya.c
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views8 pages

Interfaces in Java Notes

Interfaces in Java define a contract for behavior, supporting abstraction and polymorphism without providing implementation. They allow multiple inheritance and can be reused across unrelated classes, with all implementing classes required to define the methods. JDK 8 introduced default methods, enabling backward-compatible evolution of interfaces while maintaining their core characteristics.

Uploaded by

mohanapriya.c
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 8

Interfaces in Java

Summary Notes
Introduction to Interfaces
• Defines what a class must do, not how it does
it.
• Supports abstraction and polymorphism.
• Declared using the 'interface' keyword.
• Similar to abstract methods but more
powerful.
Characteristics of Interfaces
• Method signatures only, no implementation.
• All implementing classes must define the
methods.
• A class can implement multiple interfaces.
• Interfaces can be reused across unrelated
classes.
Syntax of an Interface
• access interface InterfaceName {
• returnType method1(parameters);
• type CONSTANT1 = value;
• }
• Methods are implicitly public and abstract.
• Variables are public, static, and final.
Example: Series Interface
• public interface Series {
• int getNext();
• void reset();
• void setStart(int x);
• }
• Defines a number series interface.
Interface vs Abstract Class
• Interfaces: Only declarations, no constructors.
• Abstract Classes: Can have implementations,
constructors.
• Interfaces: Multiple inheritance supported.
• Abstract Classes: Single inheritance only.
Enhancements in JDK 8
• Introduced default methods in interfaces.
• Default methods can have implementations.
• Syntax: default void methodName() { ... }
• Allows backward-compatible interface
evolution.
Key Points to Remember
• Interfaces define a contract for behavior.
• Enable loose coupling and flexibility.
• Used for polymorphism and abstraction.
• Still relevant without default methods.

You might also like