Looking for good practical example where we can use the concept of Interface.
Not able to get any practical good example where the usage of interface is justified.
So any example with/without interface.
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Roei BarRank #1,271 · 1.4K reputationPosted Aug 4, 2009, 9:10 PM EDT
Kirtan PatelRank #292 · 8.6K reputationPosted Aug 4, 2009, 9:18 PM EDT
Act {interface
void act();
}
class Actor1 implements Act {
public void act() {
System.out.println("To be, or not to be");
}
}
class Actor2 implements Act {
public void act() {
System.out.println("Wherefore art thou Romeo?");
}
}
public class TryOut {
public static void main(String args[]) {
Actor1 hamlet = new Actor1();
Actor2 juliet = new Actor2();
tryout(hamlet);
tryout(juliet);
}
private static void tryout(Act actor) {
actor.act();
}
}
Happy Coding :)
Niradhip ChakrabortyRank #429 · 5.8K reputationPosted Aug 4, 2009, 9:20 PM EDT