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 r in java?
What is the difference between access specifiers and access modifiers in java?
What do you understand by the term wrapper classes?
What is the use of a conditional inclusion statement in Java ?
What initialize variables?
Why pointers are not used in java?
What is a numeric literal?
What is the difference between this() and super() in java?
What is update method called?
Explain which of the following methods releases the lock when yield(), join(),sleep(),wait(),notify(), notifyall() methods are executed?
Given a singly linked list, how will you print out its contents in the reverse order? Can you do it with consuming any extra space?
What is boolean false?
What does indexof mean?
What is the type of lambda expression?
What is static variable with example?