Static methods executes at compile time then it executes before the object construction (as they get constructed during run time). But in our main method we create a class object and invoke class methods right . How does this happen when the method execution is happening at compile time it should throw an exception for object construction. Can you explain
public class animal {
public void behaviour() {
System.out.println("I am a dog");
}
}
public class Tiger {
public static void main(String[] args) {
Animal ani = new Animal(); // here we are construction animal object which gets created runtime. How come static method gets executed then? ani.behaviour();
}
}
sorry this is not related to GWt
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/groups/opt_out.
No comments:
Post a Comment