Search This Blog

---Question for all Java learners and Java Job seeker---

In this article, I will discuss, some important questions of java.

What is System.out.println() in Java?  What is public static void main(String args[])?

If you know advance questions then ok, if you do not know silly questions then you will definitely be rejected on the interview hence focus on fundamentals then go for an advance topic.

What is System.out.println() in Java?  

System is the predefined final class of Java, which exists under java.lang package, It is used to manage input and output operation in java.
When we want to take input from the keyboard in Java then the reference variable will use, if we want to display output on any output screen such as to monitor, laptop, desktop, etc then System.out the reference variable will work.

out is the static reference or static variable of PrintStream Class which is declared under System class.

println():-  It is the predefined method of PrintStream Class which will be accessed by out variable under System class.

Our objective is to access println(), but it exists under PrintStream hence first create reference "out" 


 class Hello
   public static void main(String args[])
       System.out.println("hello world");


java.lang   ------>   Default package

System  ------>      Final class of Java

PrintStream--> out                                  InputStream---> in

print()                                                                     read()


print():-  it will print statements using a single line.

println():-  It will print statement under a new line, ln stands for a line break.

What is public static void main(String args[])?

public:-   it is an access specifier of java that provides global accessibility means we can access public access control outside of the project, package, and class.

Static:-  it is called a non-access modifier that provides a static memory area to main().Static memory allocation will be assigned after compilation. 

void:-   it is the primitive data type of java that returns a null value.

main():-  It is entry point function of java program.for execution main() is mandatory.
main() will be declared as a String array type parameter to manage command line input operation in java.
JVM will not load class without main()

String args[]:-  It is used to take input from the command prompt, String is class and args[] is the String type array.

Why main() is STATIC?

because the main() will be called automatically without creating Object.

Sample Program

Addition Program:-

import java.util.Scanner;
class Addition
    public static void main(String args[])
        int a,b,c;
        Scanner sc = new Scanner(;
        System.out.println("Enter first number");
        a = sc.nextInt(); 
        System.out.println("Enter second number");
        b = sc.nextInt();  
        System.out.println("result is "+c);



Post a Comment

If you have any doubt in programming or join online classes then you can contact us by comment .

Previous Post Next Post