How main method can be overriden in java? With what purpose? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

How main method can be overriden in java? With what purpose?

21st Jun 2018, 1:47 AM
Caty Zurano
Caty Zurano - avatar
4 Answers
+ 4
main method cant be overriden it can be overloaded. because it is a static and static methods cant be overidden.
21st Jun 2018, 6:42 AM
Sharofiddin
Sharofiddin - avatar
+ 2
Caty Zurano you are wellcome
22nd Jun 2018, 3:57 AM
Sharofiddin
Sharofiddin - avatar
+ 1
thank you
22nd Jun 2018, 2:18 AM
Caty Zurano
Caty Zurano - avatar
+ 1
Static methods can't be overriden however we can declare static methods with same signature in subclass, but it is not considered overriding as there won’t be any run-time polymorphism. If a derived class defines a static method with same signature as a static method in base class, the method in the derived class hides the method in the base class.
23rd Oct 2018, 6:13 AM
LG LG
LG LG - avatar