Fundamentals

greenspun.com : LUSENET : Java Programming : One Thread

Hello! We are new to Java Programming and have some problems with basic concepts. We have seen many books+tutorials+articles but still have confusions. When we inherit a class A from class B. What does happen? {1}. Do all members of B are inherited to A. or they get just reference. (2). When we creates an object of Class A, an object of Class B is also created (True/False). why? (3). What is Dynamic Method Dispatch ? We have stuied (Java2 the Complete reference of Herbert Shield), (Thinking in Java) (Begining Java2) and others too? Can any one provide some examples illustrating these concepts. Thanks

Regards Anis

-- Muhammad Anis (anisd2k@yahoo.com), November 23, 2000

Answers

when class A inherits class from class B, every thing except private members & constructors get inherited to child class. definitely when we create an object of class A object of super classs i.e class b will first gets created. when we call a method using a reference of super class, the overridden method in child class gets called, this is dynamic method dispatch

-- Mohammed Irfan Tabrez (irfan_t@rediffmail.com), May 06, 2001.

Moderation questions? read the FAQ