About Question com.enthuware.ets.scjp.v6.2.685 :

Help and support on OCA OCP Java Programmer Certification Questions
1Z0-808, 1Z0-809, 1Z0-815, 1Z0-816, 1Z0-817

Moderator: admin

Post Reply
sarmadys
Posts: 4
Joined: Thu Jul 10, 2014 12:03 am
Contact:

About Question com.enthuware.ets.scjp.v6.2.685 :

Post by sarmadys »

This program runs but does not produce any output (not in eclipse, not in command line). Why is that? Furthermore osw serves no purpose.

Code: Select all

public class TestClass
{
  public static void main(String[] args)
  {
     PrintWriter pw = new PrintWriter(System.out);
     OutputStreamWriter osw  =  new OutputStreamWriter( System.out);
     pw.print("hello");
  }
}

admin
Site Admin
Posts: 10388
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question com.enthuware.ets.scjp.v6.2.685 :

Post by admin »

The purpose of the question is to test you on imports. Output is not important here. But you can get the output if you add a line pw.flush() at the end.

HTH,
Paul.

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests