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

What is a lightweight component?

0 Answers  


what is the reason behind non static method cannot be referenced from a static Context?

2 Answers  


What is the disadvantage of java?

0 Answers  


Which data type is class in java?

0 Answers  


What is difference between hashset and hashmap in java?

0 Answers  






What does @param args mean in java?

0 Answers  


What Method and class used for Connection pooling ?

5 Answers   TCS, Wipro,


Explain java coding standards for constants?

0 Answers  


I have 100 records in a table with two rows. I need to display 10 records per page like Google Search. I need only the Logic(Pagination) in Pure Java. No JSP and all..Thanks in Advance...

2 Answers   Cybernet,


Differentiate between vector and array list.

0 Answers  


Does java set allow duplicates?

0 Answers  


Can we execute java program without main method?

0 Answers  


Categories