java abstract classes +! concrete method@@

Often u make it an interface but there are a few justifications

Q: I think an interface must be public ??
A: non-public interface can be nested inside a class.

* all fields in interfaces must be public static final
* all methods in interface must be public
* #1 justification: Say you plan to add concrete methods to your abstract class. You make it abstract now (instead of interface) to forbid subtypes extending something else. Consider the nightmare — U make it an interface, a subtype extends something else, and now u want it to extend your abstract class instead …. the required change could be huge and painful.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s