• Post Reply Bookmark Topic Watch Topic
  • New Topic

Inheritance main() function calling concept  RSS feed

 
Aditya Soni
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

See the following code:




Here why when we run java Algo in cmd outputs the Parent main() method code?

 
Tim Cooke
Marshal
Posts: 4041
239
Clojure IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you expect something different to happen?

You have the answer in your topic title: Inheritance. Perhaps a read through the Oracle Tutorial on Inheritance might help you understand what's going on here.
 
Aditya Soni
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I still didn't understand why main() method of Example class called implicitly when we execute Algo Class(also we didn't compiled it directly run it)?
 
Campbell Ritchie
Marshal
Posts: 56536
172
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Draw a diagram showing which methods each of the two classes has.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!