04-13-2013, 10:39 AM
|
#27
|
FFR Veteran
Join Date: Nov 2006
Posts: 382
|
Re: Teach me CS stuff for interviews
Quote:
Originally Posted by Reincarnate
myPuppy.pissOnFloor();
|
I lol'd.
But yes you're right. Static methods can be called using the class name and do not require an actual instantiation of an object:
Puppy.getNumPuppies();
Calling an instance method requires an instance of the object:
myPuppy = new Puppy();
myPuppy.pissOnFloor();
Java allows you to call static methods by using an instance of the class but I think doing so is considered bad style:
myPuppy = newPuppy();
myPuppy.getNumPuppies();
__________________
|
|
|