aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes help in overridding and overloading ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of JavaScript Promises Essentials this week in the JavaScript forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "help in overridding and overloading ?" Watch "help in overridding and overloading ?" New topic
Author

help in overridding and overloading ?

gurpeet singh
Ranch Hand

Joined: Apr 04, 2012
Posts: 924
    
    1

please consider the following paragraph from kb6 book page no. 115, table 2-3

Reference type determines which overloaded version (based
on declared argument types) is selected. Happens at compile
time. The actual method that’s invoked is still a virtual method
invocation that happens at runtime, but the compiler will
already know the signature of the method to be invoked. So at
runtime, the argument match will already have been nailed
down, just not the class in which the method lives.


what does it mean? specifically what is "virtual method" ? secondly what does the last line means when the author says "nailed down, just not the class in which the method lives" ?
John Jai
Bartender

Joined: May 31, 2011
Posts: 1776
At compile time, it detects which overloading method to be invoked for the given reference (The reference on which the method gets called). Runtime determines which class' method should be called. This depends on the object referred to by the reference.

Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

As a side note : in Java non-static,non-final and non-private methods are virtual by default.

and Yes *just not the class in which the method lives* this sentence is bit confusing

Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

gurpeet singh wrote:specifically what is "virtual method" ?

try googling
gurpeet singh
Ranch Hand

Joined: Apr 04, 2012
Posts: 924
    
    1

thanks John and Seetharaman.
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

gurpeet singh wrote:thanks John and Seetharaman.

You are welcome
Helen Ma
Ranch Hand

Joined: Nov 01, 2011
Posts: 451
Is virtual method a C++ term?
I think virtual method is abstract method that has not implementation and is overriden.
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Helen Ma wrote:Is virtual method a C++ term?
I think virtual method is abstract method that has not implementation and is overriden.

I dont know whether virtual born from c++ or not but definitely it an OOP term.

virtual method not necessarily to be an abstract. any method that can be overridden is a virtual method.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: help in overridding and overloading ?