Results 1 to 2 of 2
- 03-06-2012, 04:39 PM #1
Member
- Join Date
- Mar 2012
- Posts
- 1
- Rep Power
- 0
Compile-time Polymorphism or Run-time Polymorphism ?
Hi everyone,
please check out the following code first: (I defined an anonymous inner class here)
__________________________________________________ ______________________
class Popcorn {
public void pop() {
System.out.println("popcorn");
}
}
class Food {
Popcorn p = new Popcorn() {
public void pop() {
System.out.println("anonymous popcorn");
}
};
}
__________________________________________________ _______________________
In this case, is it a compile-time polymorphism or a run-time polymorphism when the anonymous inner class is involved ?
Does the compiler know which pop() method to call at the compile-time?
Is there any way I can see if it is happening at compile-time or run-time?
Thanks a lot!!!
- 03-06-2012, 07:14 PM #2
Similar Threads
-
the compile time error is below
By nicholil in forum New To JavaReplies: 2Last Post: 11-07-2010, 01:52 AM -
Runtime/Compile Time Exceptions
By suresh.sa in forum New To JavaReplies: 1Last Post: 10-18-2010, 11:32 AM -
High Compile Time
By Mojito_gr in forum Advanced JavaReplies: 7Last Post: 08-02-2010, 04:47 AM -
Doubt in run time polymorphism
By Thennarasu in forum New To JavaReplies: 4Last Post: 07-21-2009, 08:17 AM -
Help with Compile time errors
By bri1547 in forum New To JavaReplies: 2Last Post: 08-24-2008, 11:22 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks