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



printstream class method println() is calling using System class and its static object out .how it ..

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

Post New Answer

More Core Java Interview Questions

Is oracle charging for java?

0 Answers  


A abstract class extending an abstract class.Super class has both abstract and non-abstract methods.How can we implement abstract and non-abstract mehtods? Explain with snippet

3 Answers  


Does windows 10 need java?

0 Answers  


Ducking is automatic in checked exception?True or false

2 Answers  


Can we have a abstract class withought any method? What is a purspose of this?

3 Answers  






Can a class be private or protected in java?

0 Answers  


Program to Find the second largest element in an array.

0 Answers   Amazon,


Can we nested try statements in java?

0 Answers  


Is java pass by value or pass by reference?

0 Answers  


When parseint method can be used?

0 Answers  


finalize() method?

5 Answers  


In Serialization, whether you will use Static variables?

3 Answers   HCL,


Categories