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 pojo class in java?
Explain about sets?
What is the default value of float and double datatype in java?
Mention a package that is used for linked list class in java.
How arrays are stored in memory in java?
What are the main differences between notify and notifyAll in Java?
What is skeleton and stub? What is the purpose of those?
Which package is always imported by default?
Does collectionutils isempty check for null?
What does @override mean?
What about interthread communication and how it takes place in java?
What is function declaration?
What is java used for?
How do you override a method?
What is object english?