+ 3
public main?
What will happen if I write the main method signature as public instead static? Like this: public void main(String[ ] args)
7 Respuestas
+ 6
"static: method can be run without creating an instance of the class containing the main method".
+ 4
It must be both public and static.
+ 3
You'll get an error saying that the Main Method should be set to static
+ 3
No, not really. But it'll show a message error?
+ 1
Yes
+ 1
Here is what they meant by that statement:
https://code.sololearn.com/cYIUAWE6PLRE/?ref=app
0
Be aware that I did not call upon:
Animal dog = new Animal("Dog","Male","Woof");
I just used Animal.makeSound();
"static: method can be run without creating an instance of the class containing the main method".
The makeSound method is set to static thus I can access it directly from the class without creating an instance