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 / 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 |
What is matcher in java?
What is JVM and is it platform independent?
State the significance of public, private, protected class?
Can a class extend 2 classes in java?
Explain the use of shift operator in java. Can you give some examples?
What is an example of a keyword?
Variables used in a switch statement can be used with which datatypes?
What is the return type of a program?s main() method?
Is there any sort function in java?
What is the buffer limit?
How many types of string data types are there?
Is java a compiler?