Last active
August 31, 2021 12:09
-
-
Save minte9/e9b73252ec64711bd43f5f110282057c to your computer and use it in GitHub Desktop.
Java / OOP / Interface - https://www.minte9.com/java/oop-introduction-interface-1186
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Define Dog class which | |
* Dog class must implement the correct class | |
*/ | |
class App { | |
public static void main(String[] args) { | |
Dog d = new Dog(); | |
d.bark(); // The dog is barking | |
} | |
} | |
interface Canine { | |
public abstract void bark(); | |
} | |
interface Feline { | |
public abstract void roar(); | |
} | |
/** | |
* SOLUTION | |
*/ | |
class Dog implements Canine { | |
@Override | |
public void bark() { | |
System.out.println("The dog is barking"); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment