A static method belongs to the class and a non-static method belongs to an object of a class. That is, a non-static method can only be called on an object of a class that it belongs to. A static method can however be called both on the class as well as an object of the class. A static method can access only static members. A non-static method can access both static and non-static members because at the time when the static method is called, the class might not be instantiated (if it is called on the class itself). In the other case, a non-static method can only be called when the class has already been instantiated. A static method is shared by all instances of the class. These are some of the basic differences. I would also like to point out an often ignored difference in this context. Whenever a method is called in C++/Java/C#, an implicit argument (the ‘this’ reference) is passed along with/without the other parameters. In case of a static method call, the ‘this’ reference is not passed as static methods belong to a class and hence do not have the ‘this’ reference.
Subscribe
Recent Posts
Links
Resources
Categories
- .NET
- ACM
- AJAX
- Albert Einstein
- Android
- Apple
- Art
- Bible
- Buddha
- Business
- Christianity
- Circle
- CNN
- Comic
- Computer Science
- CUDA
- Database
- Development
- Doraemon
- Education
- Electronic Arts
- Entrepreneurship
- Faith
- Fedora
- Funny
- Game
- Harvard
- Henry David Thoreau
- Hippo
- History
- HTC
- HTML
- Immigration
- Java
- Jet Propulsion Laboratory
- Law
- Life
- Linux
- Love
- Lyrics
- Mathematics
- Methodology
- Microsoft
- Mother Teresa
- Movie
- Music
- Music Video
- MySql
- NASA
- Natural User Interface
- News
- Nostalgia
- NVIDIA
- Olympics
- Open Source
- Parables
- Photography
- PHP
- PI
- Platform
- Plato
- Poem
- Politics
- Programming
- Puzzle
- Python
- Quotes
- Random Thoughts
- Samsung
- Security
- Social Networking
- Socrates
- Square
- Stanford
- Story
- Technology
- Testimony
- Ubuntu
- Video
- YouTube

Recent Comments