Question

What is interface? Explain difference between abstract class and interface with the help of example. Write a java program to demonstrate use of interface.

15 Sep 2022
Answer :
Word Count : 1033

In computer science, an interface is a specification of a set of methods that a class should implement. An interface defines a contract for a class, specifying a set of methods that a class must implement in order for it to be considered as conforming to the interface. In other words, an interface defines the behavior that a class must exhibit in order to be considered as fulfilling the interface contract.

Interfaces are typically used to define common functionality that can be shared across multiple classes. This allows for the implementation of polymorphism, which means that objects of different classes can be used interchangeably as long as they implement the same interface.

Interfaces are typically defined using an interface keyword in languages such as Java and C#, or using a protocol keyword in Swift, or in other languages like C++ , C, Python, etc. They often uses "abstract class" as the way to implement interface.

Here is an example of an interface in Java:

interface Shape {
    double getArea();
}

In this example, any class that implements the Shape interface must provide an implementation for the getArea() method.

An interface also serves as a way to define a contract between different components of a system. One component may depend on another component only through the interface, which allows for greater flexibility and makes the system easier to maintain.

In summary an interface is a way for defining a contract about the behavior that an object must implement. It allows objects of different types to _______ __________ __________ _________ _________ ________ ____ ___ ____ ______.
__________ ________ _______ __________ __________ ___.
______ ____ _____ _________ __________ __________ ______ _______ __________ ________ ______.
______ ________ ___ __________ ________ ________ ________ ___ ________ ____.
___ _________ __________ _____ _____ ____ ____.
________ _________ __________ ______ ________ ________ _________ _________ __________.
___ _____ ________ _____ ______.
_____ _____ __________ _________ __________ _________ ___.
__________ _______ __________ _____ __________ __________ _______ ____ ____.
_______ _________ ____ _______ ____ _______ __________ __________ _______ _________.
________ _______ __________ _______ _________ ___ _______ __________ ________ ________ ________ ________.
_________ ______ _____ ______ _______ ______ _____ ___.
____ _________ ____ ________ _______ __________ ______ _______ _________.
_________ ________ __________ ___ ______ _________ ____ _______ _______ _________ _____.
_______ ______ ___ _______ _____ _________ ___ ____ ___.
_________ __________ ____ _______ ___ _________.
_______ __________ ____ ____ _______ ________.
___ ___ __________ _______ ______ _________.
________ ________ _______ ____ _______ ____ __________ __________.
________ _____ __________ ___ ________ _______ _____ _______ _________ ____ ______ ________.
_______ ________ ____ ______ ______.
______ _______ ______ _______ ____ ____ ____ _____ _________ __________ ______ ________.
_________ ____ ___ _________ _________ _____.
__________ ______ _____ _________ ______ ____.
__________ _____ ________ _______ _______ _____ _______ __________ _______ __________.
__________ _____ _____ ______ ___ ____ ___ ______ ______ ________ ___.
______ _________ ____ _________ ______ ___ _________ ___.
_____ _________ _____ ________ _______ _____ _____ _______ _____.
___ ___ ____ __________ _________ _______ ______ ________ ________.
_______ ___ __________ ____ __________ _____ ________ _____ _______ ______ _________ ___.
_________ ____ __________ __________ ____ ___ _____.
______ _______ __________ _____ ____ ___ ______ _____ ___ ___ _______ _________.
______ ______ ______ _____ ___ ________ ___ ___ ___ _________ ____.
______ ____ _____ _____ _______ _______ ____ __________.
___ ______ ____ ________ ____ ________ __________ ___.
__________ ____ ________ ____ ______ __________ _________ ______ ____.
_____ ____ ___ ______ _________ _______ ______.
______ _________ ______ _______ ___ ______ _______ _______ ___ ______ ____ _______.
_________ ______ _____ ___ _____.
________ ___ _______ _______ ___ _______ ______ __________.
_____ _______ ______ _______ ____ _________ _____ ______ _______ __________.
__________ _________ _________ ____ _______ ______ ____ _________.
___ _____ _______ _________ _______ __________ ______ _______ _____ __________.
___ ________ _______ ______ _____ __________ ___.
____ ________ ________ ________ _________ ______ _____ _________ __________.
_________ ______ _____ ________ ________ ______ _____ ___.
____ _____ ________ _______ ________ _____ ________ ______ _______ ___ _____ _________.
_______ ________ ________ _____ ______ ___ _____.
_______ _________ _____ ______ __________ ______ _____.
___ __________ ______ __________ _________ ____ ___ _____.
______ ______ ______ ___ ______ __________ _____ _____ _________ ____.
________ __________ ___ ___ _____ _____ _____ _______ _____ _______.
_______ __________ ________ ___ ________ __________ _________ ______ __________ ____.
________ _______ __________ _______ _______.
_________ _________ _____ _____ __________ _________ ____ _________.
__________ _____ _________ ____ ________ ______ ______ _______ _______ ____ __________.
______ ______ _________ ___ ____ _____ ___ ____ ____ _____ _____.
___ ____ ___ _______ ________ ____ ___ ___.
________ _____ _______ _________ ______.
___ ____ _________ ______ _________ ______ ________ ___ ______.
________ ______ ________ __________ __________ _____ ______ _________ ____ ________.
__________ _________ ________ ___ _________ ______ _____ _____ ______.
_________ _____ __________ ________ __________.
__________ __________ ___ ___ _____ ______ _________ __________ ____ ______.
_______ __________ __________ ______ ______ ________ _________ ___ __________.
______ _________ _____ ___ __________ __________ ________ ________ ____ ______ ________ _______.
______ _____ ___ _____ ______ ___ _______ ___ ___.
____ _______ _________ _______ ________.
__________ __________ ______ __________ _______ ___ _________ ______ _____ ___.
_______ ______ ________ _______ _____ ____.
_______ ____ ________ _________ ___ ______ _______ _______ ____ _________ __________ ______.
___ __________ __________ _____ ____.
_______ ____ ___ _______ _______ ____ ___ _________ ________ _________ ____ __________.
_______ ________ ___ ______ _________.
________ _____ ___ _____ ____ __________ ____ ______.
_____ ___ _______ ___ ____ _________ _______ ______.
_______ ___ _______ ______ _______ ______.
_______ _______ _____ __________ ______.
____ __________ _____ __________ ___ ____ _____ ________ ____ ___.
____ ______ ________ __________ _______ ____ _________ _______.
_____ ___ ______ _____ ________ _______ _______ _____ _________ ____.
_____ ________ _____ ________ ____ _____ _________ _________ __________ _____.
_________ _______ _______ _________ ____ ___.
__________ ____ ________ ____ ________ __________ ________ __________ _______.
____ ___ _________ ________ ____ ______ _______ __________ ________ ___ _______ __________.
_______ _________ _____ _________ ________ _____ ___ _______ ______ ___.
____ __________ ___ _________ ________ ____ ___ _________.
__________ ___ ____ _______ ____ _________.
_______ _________ _________ ___ ________ __________ _________ _________ ___ ____.
_____ ______ _________ ______ ______ __________ ___ _______.
_______ ______ __________.
Get Full Answer on WhatsApp

IGNOU NEWS
Assignment Submission Last Date Extended Till 30 June 2026 Click Here★★★IGNOU June 2026 TEE Date Sheet Released Click Here★★★
Top
📞
Call Support Instant phone assistance What is interface? Explain difference between abstract class and inter
🟢
WhatsApp Chat Fast live messaging
Email Us Business enquiries & support