About Question enthuware.ocajp.i.v7.2.1232 :

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

Moderator: admin

Post Reply
Shri Shri
Posts: 5
Joined: Sun May 21, 2017 9:01 pm
Contact:

About Question enthuware.ocajp.i.v7.2.1232 :

Post by Shri Shri »

Which of the following lines can be inserted at line 1 to make the program run? //line 1

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

Assume that PrintWriter and OutputStreamWriter are valid classes in java.io package.
Enthuware answer say option 3 is correct answer, but when i put this code, it needs both option 2 & 3 to compile this code without error. (import java.io.*; and also import java.io.OutputStreamWriter;)

I was given following options

1) import java.lang.*;
2) import java.io.*;
3) import java.io.OutputStreamWriter;
4) include java.io.*;
5) include java.lang.System;

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

Re: About Question enthuware.ocajp.i.v7.2.1232 :

Post by admin »

I see that option 2 i.e. import java.io.* is marked as the correct option. If you have already imported java.io.*; you shouldn't need to import java.io.OutputStreamWriter; because OutputStreamWriter is a member of java.io package.
If you like our products and services, please help us by posting your review here.

Shri Shri
Posts: 5
Joined: Sun May 21, 2017 9:01 pm
Contact:

Re: About Question enthuware.ocajp.i.v7.2.1232 :

Post by Shri Shri »

Thanks for your response. Does that mean answer from the test is wrong ? As you mentioned, even i select import java.io.*;
Probably you need to update the question bank.
Thanks
Shri

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

Re: About Question enthuware.ocajp.i.v7.2.1232 :

Post by admin »

No, what I mean to say is that the correct option set in the question bank for this question is option 2. Option 3 is not set as the correct answer. In other words, the question bank is correct.
See attached image. If this is not what you see, please post the screen shot of what you see.
test.png
test.png (26.15 KiB) Viewed 3159 times
If you like our products and services, please help us by posting your review here.

Post Reply

Who is online

Users browsing this forum: No registered users and 61 guests