Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / February 2006

Tip: Looking for answers? Try searching our database.

Java Questions

Thread view: 
John Smith - 22 Feb 2006 17:14 GMT
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
Rajah - 22 Feb 2006 17:40 GMT
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(...)); "
Paul Hamaker - 22 Feb 2006 20:27 GMT
John Smith,
Here's an example and explanation of overriding/polymorphism :
http://javalessons.com/cgi-bin/fun/java-programming.cgi?subject=java-polymorphis
m&1cd=ovd&sid=ao789

As for synchronizing threads, here are lessons about that :
http://javalessons.com/cgi-bin/adv/java-j2ee-jdbc.cgi?subject=java-threads&1cd=t
h2&sid=ao789

http://javalessons.com/cgi-bin/adv/java-j2ee-jdbc.cgi?subject=java-threads&1cd=t
h3&sid=ao789

---------------
Paul Hamaker, SEMM, teaching ICT since 1987
http://javalessons.com


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.