Before starting your job search, look at these common Java interview questions asked during real interviews and understand the answers, but instead of memorizing the answers try to complete further research and come with your own personal solution for the interview question. The more prepared you are for what you will encounter, the more successful you will be. This collection of Java interview question could be also useful for software developers who need to interview Java developer.

Java interview question 1: Explain public static void main(String[] args) method

In Java language, every application must contain a main method whose signature is one of the following method heading

public static void main(String[] args)

public static void main(String... args)

public static void main(String args[])

  • public - can be accessed from anywhere
  • static – can be invoked without instantiating the class
  • void - the method returns nothing
  • main – the name of the method
  • String args[] – the method arguments
Java developer could write the modifiers public and static in either order (public static or static public), but the general convention is to use public static as shown above. Java developer can name the argument anything s/he wants, but most software developers choose "args" or "argv".

No comments: