• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Shallow in static method ?

 
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, folks !
from javacaps
class MyTest {
public void myTest() {
System.out.println("Printing myTest in MyTest class");
}
public static void myStat() {
System.out.println("Printing myStat in MyTest class");
}
}
public class Test extends MyTest {
public void myTest() {
System.out.println("Printing myTest in Test class");
}
public static void myStat() {
System.out.println("Printing myStat in Test class");
}
public static void main ( String args[] ) {
MyTest mt = new Test();
mt.myTest();
mt.myStat();
}
}
C) Printing myTest in MyTest class followed by Printing myStat in MyTest class
I undestand perfect how de runtime choose the method , but I wnat to undestand the process when the method is static.
Why didn't choose the static version in Test if "this " reference is Test ? Why choose from MyTest ?
Thnaks in advance
 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
static methods never use dynamic binding. They are bound compile time.
 
Ricardo Polero
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks
Ricardo
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic