2080 1

BIT401 ยท 2080 ยท 10 marks

Why do we need interface? Define an interface named shape with area ( ) method. Create a class named Rectangle with length and breadth circle with radius that implements shape interface. Now create the object of both classes and display their area.

Why do we need interface? Define an interface named shape with area ( ) method. Create a class named Rectangle with length and breadth circle with radius that implements shape interface. Now create the object of both classes and display their area.[10]

Advanced Java ProgrammingChapter 1: Object-Oriented Programming FundamentalsInterface design and implementation

Interfaces are needed for the following reasons: 1. Abstraction: Interfaces define a contract that specifies what methods a class must implement, without specifying how they should be implemented. 2. Polymorphism: Interfaces allow objects of different classes to be treated uniformly through a com...