Java Classes Question:

In System.out.println() explain it.My doubt, we call static method with Class name but here what is "out"?

Java Classes Interview Question
Java Classes Interview Question

Answer:

Actually System is class define in java.lang package...

class System{ //Member variables... static PrintStream out;

.................................

//Member methods...

.................

}
so out is a static reference of PrintStream class,which is define in java.io package and println() is a method of PrintStream class...
So ultimately, we can call println() method of static out reference of System class.
Syste.out.println();


Previous QuestionNext Question
This can be used inside any method to refer to the current object

A) True
B) False
What is the difference between instantiation & initialization?