*
The moose likes Beginning Java and the fly likes what is Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "what is "interface"? and how to use it?" Watch "what is "interface"? and how to use it?" New topic
Author

what is "interface"? and how to use it?

nick cheng
Greenhorn

Joined: Oct 31, 2004
Posts: 11
thanks!
Joel McNary
Bartender

Joined: Aug 20, 2001
Posts: 1817

See this thread for an explaination.


Piscis Babelis est parvus, flavus, et hiridicus, et est probabiliter insolitissima raritas in toto mundo.
Harathi Rao
Ranch Hand

Joined: Oct 31, 2004
Posts: 42
Hi,
In one of the interviews i attended i was asked the following question:

" Abstract classes are more faster than Interfaces in implementation, then y do we go for interfaces over an abstarct class, and y in Java we find many interfaces? as almost everything is an interface."

what is the exact answer for this? My answers didn't satisfy them.

Thanks!
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
I doubt that there is an "exact answer". However, this topic has been discussed on several occassion here at the Saloon. You should use the Search tool to find these threads. Using something like "interface abstract class" as the search keywords should turn up some decent results.

Keep coding!

Layne


Java API Documentation
The Java Tutorial
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
As for why we find so many interfaces ... Many design patterns and object oriented principles are focused on reducing dependency between classes, packages and larger grained components. They try to isolate sites of change - if this class changes often keep it away from classes that never change so we can avoid breaking the stable class and better organize our testing - and make change possible - I can introduce a new widget without modifying the thing that uses widgets. It's a fascinating area of study that repidly takes you into fairly advanced territory!

Google for "patterns in Java" to see some examples. HERE is something I put together for my team that shows some examples, too.


A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: what is "interface"? and how to use it?