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
What is variable and example?
What is default constructors?
What does jre stand for?
How we can execute any code even before main method?
What do you mean by jjs in java8?
What are constants?
What is the implementation of destroy method in java. Is it native or java code?
What is scope & storage allocation of global and extern variables? Explain with an example
What is the purpose of the strictfp keyword?
What is fundamental datatype?
What is a instance variable in java?
What is jar?
What is arguments in java?
Can we override private method in java?
What is the use of flag?