This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Need explanations of inheritance

 
Mahpara Chowdhury
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
facing problems in tracing INHERITANCE...need some examples with exlpanation....
 
Saifuddin Merchant
Ranch Hand
Posts: 607
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tracing INHERITANCE? whats that??
 
Campbell Ritchie
Sheriff
Posts: 48453
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And welcome to the Ranch

As mentioned, there are different kinds of inheritance. Which do you mean?
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15208
36
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Mahpara Chowdhury
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20495
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Campbell Ritchie
Sheriff
Posts: 48453
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, to avoid copyright problems, please tell us where that code comes from.
 
Saifuddin Merchant
Ranch Hand
Posts: 607
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why not run and see the output for yourself?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic