aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Shallow in static method ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of JavaScript Promises Essentials this week in the JavaScript forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Shallow in static method ?" Watch "Shallow in static method ?" New topic
Author

Shallow in static method ?

Ricardo Polero
Ranch Hand

Joined: May 18, 2001
Posts: 128
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
vivek bawge
Greenhorn

Joined: Apr 19, 2001
Posts: 24
static methods never use dynamic binding. They are bound compile time.
Ricardo Polero
Ranch Hand

Joined: May 18, 2001
Posts: 128
Thanks
Ricardo
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Shallow in static method ?