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.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Niradhip ChakrabortyPosted Aug 5, 2009, 1:20 AM
Kirtan PatelPosted Aug 5, 2009, 1:18 AM
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 :)
Roei BarPosted Aug 5, 2009, 1:10 AM