Abstract and Interface in java [duplicate]

2020-05-11 00:28发布

Possible Duplicate:
Interface vs Abstract Class (general OO)
When to use abstract class or interface?

Can you provided implementations on a abstract class?

what's the difference between these two?

and when will I know when will I know to use them?

2条回答
闹够了就滚
2楼-- · 2020-05-11 00:41

Interface is used for defining a contract. Abstract classes are used for defining some methods which are common to all descendants and possibly some methods which will differ(they will be abstract). With interfaces or abstract classes polymorphism is reached.

查看更多
我想做一个坏孩纸
3楼-- · 2020-05-11 00:51

This pages gives a good comparison: http://download.oracle.com/javase/tutorial/java/IandI/abstract.html . You could have found it with a very quick google search.

查看更多
登录 后发表回答