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
Why pointers are not used in java?
What does percent mean in java?
What are the main concepts of oops in java?
Why java is used everywhere?
Which one of the following suits the description of a string better: derived or primitive?
What happens if an exception is throws from an object's constructor?
Give an example of use of pointers in java class.
Is java a digit method?
What is the size of boolean variable?
What is the private method modifier?
Why inputstreamreader is used in java?
What is the differences between heap and stack memory in java? Explain
What is classname class in java?
What is the right data type to represent a price in java?
Can we define a package statement after the import statement in java?