jQuery in Action, 2nd edition
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes which draw() is called? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Reply Bookmark "which draw() is called?" Watch "which draw() is called?" New topic
Author

which draw() is called?

Ankur kothari
Ranch Hand

Joined: Sep 06, 2009
Posts: 531


when the super class constructor is executed which draw method is called? I was expecting superclass's draw() to be called but that wasn't the case
Ankit Garg
Saloon Keeper

Joined: Aug 03, 2008
Posts: 9189
    
    2

I was expecting superclass's draw() to be called

Why would draw() in Shape class be called. The draw method in RoundShape class overrides the draw method of shape class so the call will be polymorphic...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Ankur kothari
Ranch Hand

Joined: Sep 06, 2009
Posts: 531
but draw() is being called from within the Shape constructor....
Ankur kothari
Ranch Hand

Joined: Sep 06, 2009
Posts: 531
Ankit is it because at run time the jvm decides which draw method to call based on the object?
Ankit Garg
Saloon Keeper

Joined: Aug 03, 2008
Posts: 9189
    
    2

ankur kothari wrote:Ankit is it because at run time the jvm decides which draw method to call based on the object?

Bang on target, that's right, the call will be decided based on the actual object
Ankur kothari
Ranch Hand

Joined: Sep 06, 2009
Posts: 531
Thanks a lot
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: which draw() is called?
 
Similar Threads
Help fast plz!!!!!!
cannot resolve symbol
Constructors and Polymorphism
polymorphic method in abstract constructor