开发者

information hiding , polymorphism and scalability

开发者 https://www.devze.com 2023-02-10 09:28 出处:网络
I\'ve got a few questions: 1)开发者_运维知识库 given a class named class WavPanel extends JPanel

I've got a few questions:

1)开发者_运维知识库 given a class named class WavPanel extends JPanel

Can I say that :

a) it's an example of inheritance

b) it's an example of polymorphism since the class WavPanel methods override JPanel methods?

2) is a private method within a class, an example of information hiding?

3) adding a method to a class ( a new functionality) , can I say that the application is scalable?

Those questions may sound trivial to you but they are vital to me.

Thanks a lot.MAX


a) true: keyword "extends"

b) true, if WavPanel would override some JPanel-methods. false, if it just would add functionality (e.g. new methods).

c) false Since a method is not a piece of "information" - it's an interface or an ability of the class - private methods do not hide information. (see comment, too)

d) false: Scalability usually is not reached by inheritance or new methods. An application using object composition is much more scalable and dynamic than one based on inheritance. Additionally, adding new methods changes the interface of a class. So all users of the class must be updated in order to benefit of this change, what means that you have write code => scalability is very low.

0

精彩评论

暂无评论...
验证码 换一张
取 消