wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes Just JAVA book - Interface vs class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Just JAVA book - Interface vs class" Watch "Just JAVA book - Interface vs class" New topic

Just JAVA book - Interface vs class

Alvin chew
Ranch Hand

Joined: Jan 08, 2004
Posts: 834
hi, peter, when should we apply interface ? should it replace class ? thank you !
Alvin chew
Ranch Hand

Joined: Jan 08, 2004
Posts: 834
peter, do you mind to brief the chapter 11 - interface in your just JAVA book ? thank you !
Ko Ko Naing
Ranch Hand

Joined: Jun 08, 2002
Posts: 3178
Originally posted by Alvin chew:
hi, peter, when should we apply interface ? should it replace class ? thank you !

We should apply interface, when we need multiple inheritance... They work differently from classes, so they should not replace class... Since Java does not allow multiple inheritance from classes, interfaces can mimic multiple inheritance...

Just my 2 cents..

Co-author of SCMAD Exam Guide, Author of JMADPlus
Chandra Sekhar
Ranch Hand

Joined: Sep 26, 2003
Posts: 90

When deciding to use interface,I think we should be correct at the first time.

If we need to add any methods to this interface in future it should be overridden in all classes implementing this interface,which can be over head.

I feel abstract class will be a suitable choice than interface in situations like this.

Chandrasekhar S

"Luck is when opportunity meets preparation"
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8904

This thread is also interesting

somkiat puisungnoen
Ranch Hand

Joined: Jul 04, 2003
Posts: 1312
First, you should be used Interface when you want create blueprint model of project. (Interface is like Abstract class But it's diferent.Interface VS Abstract Class)

Example in BookStore system you want to create MainSystem1, 2, 3, 4 all is business process for BookStore and each system can access to another system.


If you want to separate each system and hide implementation of each system, you should create Interface to define all method/behavior to access in each system.

Java Developer, Thailand
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: Just JAVA book - Interface vs class
Similar Threads
a good tutorial on Interfaces
does an abstract method require an abstract class?
When to use Abstract class and when to use Interface ?/
abstract class vs interface ?