explain System.out.println

Answer Posted / saurabh pal

System.out.println()

System is a built-in class present in java.lang package.
This class has a final modifier, which means that, it cannot be inherited by other classes.
It contains pre-defined methods and fields, which provides facilities like standard input, output, etc.

out is a static final field (ie, variable)in System class which is of the type PrintStream (a built-in class, contains methods to print the different data values).
static fields and methods must be accessed by using the class name, so ( System.out ).

out here denotes the reference variable of the type PrintStream class.

println() is a public method in PrintStream class to print the data values.
Hence to access a method in PrintStream class, we use out.println() (as non static methods and fields can only be accessed by using the refrence varialble)

System.out.println();

eg:

int i = 3;
System.out.println(i);


the above code prints the value of 3 in the screen and brings the control to the next line.

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How does a cookie work in Servlets?

351


What about main thread in java?

648


What is local variable and instance variable?

609


Can an object be null?

549


Explain the difference between throw and throws in java?

552






Is java a prime method?

553


Is java a security risk?

566


What is the difference between the direct buffer and non-direct buffer in java?

543


Why parsing is done?

505


What are autoboxing and unboxing? When does it occur?

536


What does the exclamation mark mean in java?

596


What is the file extension for java?

612


Why we override equals() method?

567


What are data types in oop?

553


do I need to use synchronized on setvalue(int)? : Java thread

559