can we declare the main method as final?

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");
	}
}

Output

Final main method

Java interview questions on final keyword

Please follow and like us:
Content Protection by DMCA.com