explain System.out.println

Answer Posted / anil kumar

System is a final class in java.lang package

println() is a method define in PrintStream class of
java.io package.
the Printstream class like as

Class PrintStream
{
public void print()
{..........}
public void println(String a)
{...........}

..
..
..

}
and the System class like as

class System
{
public static void PrintStream out;

..
..
out=new PrintStream();
}

this is clear that System is a class and println is a
method but what is out.

out is a reference variable of PrintStream Type that hold
the object of printstream class;
out is a static type so it can be call with its class name
so we can access out with System.out and then we can call
println method on this out object
System.out.println();

now why sunmicrosystem do this
because we haveto not create a new object of Printstream
class for each time when we call println mehod
now we can call println method with the help of precreated
object of printStream class

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is space character in java?

642


Differentiate between == and equals().

655


What is a java predicate?

594


Is assembly language a low level language?

560


When we should use serialization?

636






What is the meaning of course?

656


What data type is string java?

610


What does jre stand for?

683


Explain about OOPS concepts and fundamentals.

669


What are the classes of java?

605


What is a line separator in java?

606


What happens if a try-catch-finally statement does not have a catch clause to handle an exception that is thrown within the body of the try statement?

720


What is functional interface in java example?

603


Lowest Common ancestor in a Binary Search Tree and Binary Tree.

622


What isan abstract class and when do you use it?

965