• Post Reply Bookmark Topic Watch Topic
  • New Topic

Need explanations of inheritance  RSS feed

 
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: 53779
128
  • 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
Sheriff
Posts: 15865
81
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
Posts: 20903
81
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: 53779
128
  • 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?
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!