aspose file tools*
The moose likes Java in General and the fly likes Need explanations of inheritance Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Need explanations of inheritance" Watch "Need explanations of inheritance" New topic
Author

Need explanations of inheritance

Mahpara Chowdhury
Greenhorn

Joined: Oct 20, 2010
Posts: 2
facing problems in tracing INHERITANCE...need some examples with exlpanation....


Mahpara Hyder Chowdhury
Saifuddin Merchant
Ranch Hand

Joined: Feb 08, 2009
Posts: 606

Tracing INHERITANCE? whats that??


Cheers - Sam.
Twisters - The new age Java Quiz || My Blog
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39885
    
  28
And welcome to the Ranch

As mentioned, there are different kinds of inheritance. Which do you mean?
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14352
    
  22

Welcome to JavaRanch.

Have a look at Learning the Java Language in Oracle's Java Tutorials; it explains what objects, classes and interfaces are and what inheritance is.

Your question is broad and vague. If you want more specific answers, then please ask a more specific question.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
Mahpara Chowdhury
Greenhorn

Joined: Oct 20, 2010
Posts: 2
well,here is an example that i can't figure out the exact output...



What is the output of the following code execution?
A a1 = new A(2);
B b1 = new B(3);
B b2 = new B(b1);
a1.methodB(1, 1);
b2.methodB(1, 2);
a1.methodB(3, 2);
b2.methodB(2, 2);
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19762
    
  20

Please UseCodeTags next time. I've added them for you this time.

Using the line numbers added by the code tags, which methods do you think are being called?


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39885
    
  28
Also, to avoid copyright problems, please tell us where that code comes from.
Saifuddin Merchant
Ranch Hand

Joined: Feb 08, 2009
Posts: 606

Why not run and see the output for yourself?
 
Don't get me started about those stupid light bulbs.
 
subject: Need explanations of inheritance