InterviewSolution
Saved Bookmarks
| 1. |
Can we declare main method final in Java? |
|
Answer» The final keyword is a non-access MODIFIER in Java that is only applicable for variables, methods or classes. The MAIN method can be declared as final in Java and the JVM has no problem with that. However, it is not possible to override the main method in Java unlike any final method. A program that declares the main method as final in Java is given as follows: public class Demo { public final static VOID main(STRING[] args) { System.out.println("The Main Method is declared final"); } }The OUTPUT of the above program is as follows: The Main Method is declared final |
|