Data Structures and Algorithms in Java
Data Structures and Algorithms in Java
6th Edition
ISBN: 9781118771334
Author: Michael T. Goodrich
Publisher: WILEY
Expert Solution & Answer
Book Icon
Chapter 2, Problem 8R

Explanation of Solution

Extending the interfaces:

Yes”, it is possible to extend two interfaces exclusively.

Interface:

The interface is similar to the class and it can be declared with the keyword interface.

  • The interface does not contain any constructors with it and all the methods in the interface are “abstract”.
  • A class only “implements” the interface and it cannot “extends” the interface.
  • But the interface can extend multiple interfaces.
  • The interface extends another interface using the “extends” keyword in java.
    • While extending the interface, the child interface inherits the methods of parent interface.

Sample code:

//Declare the interface Animal

public interface Animal

{

  // Create the method run()

  public void run();

}

//Declare the interface Goat that extends Animal interface

public interface Goat extends Animal

{

  // Create the method

  public void milk();

 &...

Blurred answer
Students have asked these similar questions
Why are interfaces beneficial, exactly? Is it not simpler to just make instances of a class?
How do abstract classes and interfaces differ?
What is the benefit of interfaces? why not just instanciate objects of a class directly?
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education