Can we override the main method?

Answer Posted / nikhil agrawal

Main method is static and static method is not override.
For example:- if i have Class A having main method and Class B extends Class A and also having the main method. in that case Class B hide the main method of A not override.
overriding process occur on run time and but static method load on compile time. that's its the reason we can not override main method but we can hide it.

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the difference between compiler and jvm?

551


What are the application of stack?

498


What are exceptions

640


What exactly is a .class file?

573


What is a flag and how does it work?

503






What is a locale?

689


What is thread count in java?

543


What is java volatile?

541


Can a constructor be private and how are this() and super() method used with constructor?

521


What is an anonymous class in java?

539


What are data types in oop?

547


What is an immutable class?

610


Can we instantiate interface in java?

670


What is the purpose of main function in java?

535


What is :: operator in java 8?

552