- Static methods are owned by the class, while non-static methods are owned by the class instances.
- When passing parameter to non-static methods, an implicit "this" is passed which points to the class instance. Therefore, non-static methods can use "this" to access all those non-static members (methods).
- However, for static methods, "this" is not passed, so static methods have no way to access those non-static members (methods). On the other side, non-static methods can always access static members (methods).
This is a blog for interview questions. The questions are primarily from certain web forums, BBS or books. The owner of this blog doesn't claim any copyright of those questions. The blog is established primarily to help the blog owner prepare job interviews.
Tuesday, June 21, 2011
The difference between Static and Non-Static methods
Labels:
OOP,
programming
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment