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
What design pattern you have used in your project? I answered Factory pattern, how it is implemented? What are its advantage? Do know about Abstract Factory?
Why is it called buffering?
What is bitwise complement?
Explain the difference between treeset and treemap in java?
What is boolean example?
What is module in oop?
What is getkey () in java?
What is the base class of all classes?
How do you control extraneous variables?
Can subclass overriding method declare an exception if parent class method doesn't throw an exception?
Why are arrays useful in java?
What is a prefix function.write down a code to compute prefix function.
Does variable declaration allocate memory?
Why object class is super class for every class in java?
How can you avoid serialization in child class if the base class is implementing the serializable interface?