• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How can we call a method without class Object?

 
Jalli Venkat
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can we call a method from the class without creating the class Object?
Can you explain me the what are the alternative ways to call methods without Object?

Venkat
 
ahmed yehia
Ranch Hand
Posts: 424
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the method is "instance method" then it is tight to instances of the class, so you need an instance of the class to invoke such method.

If the method is "class method" i.e static, you can use the class name directly to invoke such method, you dont need an object of the class, but its still valid to call static methods on an object but then the compiler will substitute the class name.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic