explain System.out.println
Answer Posted / gaurav kamra
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 ? | 2 Yes | 0 No |
Post New Answer View All Answers
How do you sort objects in java?
What is the difference between menuitem and checkboxmenu item?
Explain the difference between serializable and externalizable in java?
What is array length?
Does it matter in what order catch statements for filenotfoundexception and ioexception are written?
Can this keyword be used to refer static members?
What is string example?
Explain about instanceof operator in java?
Which class is the superclass for every class in java programming?
What is difference between equals and hashcode method?
What is a finally block? Is there a case when finally will not execute?
What are thread groups?
What is an argument in java?
Explain the access modifiers for a class, method and variables?
What is encapsulation in java?