Java Questions

Discussion in 'Java' started by John Smith, Feb 22, 2006.

  1. John Smith

    John Smith Guest

    Hey all,

    I am wondering if anyone of you can explain me following questions in
    detail :
    what is runtime polymorphism? I know method overidding is its first
    step but describe it in more detail if you know.
    What is Compile time polymorphism?methos overloading is first step .I
    wonder if you can explain it in more detail.
    How can make our class synchronized?not method?How does sun make vector
    class synchronized?

    Thanks,
    Kiran
     
    John Smith, Feb 22, 2006
    #1
    1. Advertising

  2. John Smith

    Rajah Guest

    Hi, Kirian,
    This sounds like it might be a CS assignment, so instead of posting an
    answer, let me give you a couple of links. First, Bruce Eckel has an
    excellent book, "Thinking in Java," which is available online (start at
    http://www.mindview.net/Books/TIJ/). In Chapter 1, he has a great
    explanation of polymorphism. See the heading "Interchangeable objects
    with polymorphism."

    To figure out whether it's runtime or compile time, try to figure out
    when the code is deciding which class it's working on. If it can't
    figure it out from the code, then it's a runtime polymorphism. Eckel
    uses random numbers in his examples to demonstrate runtime
    polymorphism. See his Chapter 7 on polymorphism.

    I am not sure what you're asking for in your last question. According
    to the Javadocs (http://java.sun.com/j2se/1.4.2/docs/api/), it looks
    like Vector is already synchronized. If you would like to know how to
    make an unsynchronized object synchronized, I suggest you look at the
    explanation in the Javadocs for TreeMap.

    Without looking at the Java source, I am not sure how Sun makes Vector
    synchronized. However, they might use a class wrapper, such as that
    used for TreeMap.

    Here's an excerpt from the Javadocs for TreeMap:
    "If no such object exists, the map should be "wrapped" using the
    Collections.synchronizedMap method. This is best done at creation time,
    to prevent accidental unsynchronized access to the map:

    Map m = Collections.synchronizedMap(new TreeMap(...)); "
     
    Rajah, Feb 22, 2006
    #2
    1. Advertising

  3. John Smith

    Paul Hamaker Guest

    Paul Hamaker, Feb 22, 2006
    #3
  4. John Smith

    pavanuec

    Joined:
    Aug 28, 2007
    Messages:
    1
    The meaning of Polymorphism is something like one name many forms. Polymorphism is also known as dynamic binding or late binding or run-time binding. In java polymorphism exists in three distinct forms
    1. Method overloading
    2. Method overriding through inheritance
    3. Method overriding through the Java interface
    Check this site in case if you are interested in detail www.techpitcher.com
    Or http://j2eeinterview.blogspot.com
     
    Last edited: Nov 28, 2007
    pavanuec, Aug 28, 2007
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Bonnie Johnson
    Replies:
    2
    Views:
    511
    Andrew Thompson
    Jan 10, 2007
  2. Ali Syed
    Replies:
    3
    Views:
    572
    Mark McIntyre
    Oct 13, 2004
  3. pundeerd
    Replies:
    1
    Views:
    602
    pundeerd
    Jun 7, 2007
  4. Dharmendra
    Replies:
    1
    Views:
    1,385
    Andrew Thompson
    Mar 19, 2008
  5. Dharmendra
    Replies:
    2
    Views:
    419
    Andrew Thompson
    Aug 10, 2008
Loading...

Share This Page