Class Methods and Instance Methods

 S.No.  Class Methods  Instance Methods
 1. Class methods are methods which are declared as static. The method can be called without creating an instance of the class Instance methods on the other hand require an instance of the class to exist before they can be called, so an instance of a class needs to be created by using the new keyword.
Instance methods operate on specific instances of classes
 2. Class methods can only operate on class members and not on instance members as class methods are unaware of instance members. Instance methods of the class can also not be called from within a class method unless they are being called on an instance of that class.
 3. Class methods are methods which are declared as static. The method can be called without creating an  instance of the class. Instance methods are not declared as static.

 

Rate this post

Leave a Reply