About Question enthuware.ocajp.i.v7.2.1232 :
Posted: Sun May 21, 2017 9:12 pm
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;
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;