Loading...

Can we override the main method in java?? #java #shorts #interviewquestion

192 8________

can we override the main method in java ??

No, we cannot override the main method of java because a static method cannot be overridden.
The static method in java is associated with class whereas the non-static method is associated with an object. Static belongs to the class area, static methods don’t need an object to be called. Static methods can be called directly by using the classname ( classname.static_method_name() ).
So, whenever we try to execute the derived class static method, it will automatically execute the base class static method.
Therefore, it is not possible to override the main method in java.

like and subscribe for more such type of videos and comment if you have any doubt.


#javaprogram #java #javaprogramming #javabasic #javaquestions #javatutorial #shorts #ytshorts #programming #codingwithankit #coding #practicequestion

コメント