printstream class method println() is calling using System
class and its static object out .how it is explain any one
in detail with example ?

Answer Posted / chandan kumar

import java.io.*;
class Other
{
public static PrintStream wise;
static
{
try{
wise=new PrintStream(new FileOutputStream("abc.txt"));
}
catch(Exception e)
{

}
}

}
public class AB
{
public static void main(String arg[])
{
Other.wise.println("hi");
}
}
This will print hi on a file abc.txt
some thing like this is written in class System. A static
object out of PrintStream Class is defined in static block
and connected to a Stream Connected to Console.So everythin
that we write with in print()method comes out as output

Is This Answer Correct ?    12 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is variable and example?

730


What is default constructors?

739


What does jre stand for?

816


How we can execute any code even before main method?

803


What do you mean by jjs in java8?

776


What are constants?

813


What is the implementation of destroy method in java. Is it native or java code?

737


What is scope & storage allocation of global and extern variables? Explain with an example

804


What is the purpose of the strictfp keyword?

852


What is fundamental datatype?

737


What is a instance variable in java?

794


What is jar?

859


What is arguments in java?

747


Can we override private method in java?

844


What is the use of flag?

858