您的位置:寻梦网首页编程乐园Java天地Core JavaJava Lecture Notes

Introduction

Content

Apply

Reflect

Extend

previous.gif
 (3087 bytes)

next.gif
 (2959 bytes)


Reflect Index

Reflect Page # 1

Review question 1

In `true' multiple inheritance, a subclass may inherit from two base classes that have a method with the same name. For example, suppose we have a class called `A' and a class called `B', and both have a method called `test()'. Class `C' is a subclass of both A and B, and it does not have its own `test()' method. So if we call the method C.test(), does it call A.test() or B.test()? This confusion is one of the arguments used by the Java developers for disallowing multiple inheritance in Java. Suppose we have an interface (not a class) called A and a class called B, and both have a method `test()'. What happens if class C extends B and implements A, and we call C.test()? How does this avoid the problem?

Discussion of Review Question 1

Back to top

basicline.gif (169 bytes)

RITSEC - Global Campus
Copyright ?1999 RITSEC- Middlesex University. All rights reserved.
webmaster@globalcampus.com.eg