Skip to content

W3schools

Subscribe Youtube For Video Tutorials
  • Academics
    • Physics
    • Chemistry
    • Math
    • Biology
    • English
    • Hindi
  • Tutorials
    • Quartz scheduler
    • Log4j
    • JUnit
    • Java Mail
    • Java Generics
    • JAXB
    • Jsoup
    • JSON
    • XML Parser
    • Data structure
  • Java
    • Java
    • Collection framework
    • Java date time api
    • Java regex
    • Design patterns
  • Android
  • Servlet
    • JSP
  • Spring
    • Spring
    • Spring AOP
    • Spring DI
    • Spring MVC
    • Spring spel
    • Spring boot
    • Spring security
  • Hibernate
  • WS
    • Stories
  • Python
  • Web
    • Ajax
    • HTML
    • CSS
    • Javascript
    • jQuery
      • jQuery UI
    • PHP
    • TypeScript
    • ReactJS
    • Backbone.js
    • Bootstrap
      • Bootstrap 4
    • XML
      • XML DOM
      • XPath
      • XQuery
      • XSD
      • XSLT
  • Angular
    • AngularJS
    • Angular 7 Tutorial
    • Angular 8 Tutorial
  • DB
    • SQL
    • SQLite
    • MongoDB
    • MySQL
    • Oracle
    • PL/SQL
    • PostgreSQL
    • PouchDB
    • DBMS
  • C
  • More
    • Q&A
    • Quiz
    • Ant
    • CPP
    • JDBC
    • JPA
    • JSF
    • JAR
    • Maven
    • WAR
    • WordPress

can we declare the main method as final?

by

Yes, we declare the main method as final.

public static final void main(String[] args){}

Example

public class Main
{
	public static final void main(String[] args) {
		System.out.println("Final main method");
	}
}

public class Main { public static final void main(String[] args) { System.out.println("Final main method"); } }

Output

Final main method

Final main method

Java interview questions on final keyword

  • what is final in java?
  • What is final variable in java?
  • What is final method in java?
  • What is final class in java?
  • What is blank final variable in java?
  • What is static blank final variable in java?
  • What is final parameter in java?
  • Can we initialize blank final variable in java?
  • Can we declare the main method as final?
  • What is the use of final keyword in java?
  • Can we change the state of an object to which a final reference variable is pointing?
  • Difference between abstract method and final method in java?
  • Can we change the value of an interface field?
  • Can we declare constructor as final in java?
Categories Interview questions
Initialize blank final variable in java
Can we change the state of an object to which a final reference variable is pointing?
© 2024 W3schools • Built with GeneratePress