Loading

Interview Questions of Java-First-Program

Q1. What is the meaning of 'public static void main(String[] args)' in Java ?
Solution: 
Explanation:


  • public -  Access Modifier
  • static  -  Reserved Keyword 
  • void   -   No value is returned after execution
  • main  -   The program start running for compiling 
  • String[] args -  Allows command-line input when executing the program.
Q2. What are the steps to compile and run a Java program ?
Solution:

Step - 01  Write the Java program in a .Java file (Ex- Helloworld.java).
Step - 02  Compile the program using command prompt by giving instruction.
  • javac Helloworld.java
Step - 03 Run the program using.
  • java Helloworld
Output will display.

Q3. What is the purpose of 'System.out.println()' in Java?
Solution:

  • System.out.println() is used to print messages to the console.
  • It is a built-in Java method from the System class.
Ex- System.out.println("Hello world!")
      Hello world! in the output will printed.

Q1. What is the meaning of 'public static void main(String[] args)' in Java ?
Solution: 
Explanation:


  • public -  Access Modifier
  • static  -  Reserved Keyword 
  • void   -   No value is returned after execution
  • main  -   The program start running for compiling 
  • String[] args -  Allows command-line input when executing the program.

Q2. What are the steps to compile and run a Java program ?
Solution:

Step - 01  Write the Java program in a .Java file (Ex- Helloworld.java).
Step - 02  Compile the program using command prompt by giving instruction.
  • javac Helloworld.java
Step - 03 Run the program using.
  • java Helloworld
Output will display.


Q3. What is the purpose of 'System.out.println()' in Java?
Solution:

  • System.out.println() is used to print messages to the console.
  • It is a built-in Java method from the System class.
Ex- System.out.println("Hello world!")
      Hello world! in the output will printed.