Results 1 to 4 of 4

Thread: Polymorphism

  1. #1
    blug is offline Member
    Join Date
    Oct 2010
    Posts
    26
    Rep Power
    0

    Default Polymorphism

    Hey hey,

    For university I am reading through the book "Absolut Java" and I am reading through the polymorphism chapter and have hit a bit of snag. It's just a few definitions which confuse me..

    Whats the difference between a method definition and a method invocation?

    I assumed a method definition was...

    public int getInt(){
    return intValue;
    }

    I thought that would be a definition, but when I think about it, a method invocation is essentially same thing which confuses me. I thought an invocation when it goes running a part of a program between those squiggly brackets (eg. a for loop invocation).

    So is an invocation the act of a method being run and the definition is just the method itself? It confuses me zzzz

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,651
    Blog Entries
    7
    Rep Power
    21

    Default

    Yep, a method invocation evaluates the actual parameters and transfers control to the body of the (defined) method.

    kind regards,

    Jos

  3. #3
    blug is offline Member
    Join Date
    Oct 2010
    Posts
    26
    Rep Power
    0

    Default

    Quote Originally Posted by JosAH View Post
    Yep, a method invocation evaluates the actual parameters and transfers control to the body of the (defined) method.

    kind regards,

    Jos
    Cool thanks, just wanted to make sure I wasn't drifting in the wrong direction..

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,091
    Rep Power
    20

    Default

    Or put another way this is your definition:
    Java Code:
    public int getInt(){
        return intValue;
    }
    and this is your invocation:
    Java Code:
    public void someOtherMethodThatInvokesTheAbove() {
        int i = getInt();  // I invoke getInt here.
    }

Similar Threads

  1. Polymorphism Help
    By AWPtic in forum New To Java
    Replies: 5
    Last Post: 04-06-2009, 04:13 PM
  2. question about polymorphism
    By becky in forum New To Java
    Replies: 4
    Last Post: 02-11-2009, 10:59 PM
  3. inheritance and polymorphism
    By tester in forum Eclipse
    Replies: 1
    Last Post: 12-21-2008, 04:58 AM
  4. what is polymorphism
    By Nari in forum New To Java
    Replies: 5
    Last Post: 04-04-2008, 03:14 AM
  5. what's polymorphism?
    By christina in forum New To Java
    Replies: 2
    Last Post: 08-05-2007, 10:29 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •