No you need to have a finally because even if an exception occurs you will still need to close the PrintWriter. The error happens because you declare PrintWriter inside try {....} and in the finally it is out of scope, it cannot be used outside try because this is where it declared. Try this:
import java.io.*;
import java.util.*;
public class Streams {
public static void main(String[] args) {
String studentFirstName = "Bob ";
String studentLastName = " Smith ";
String finalGrade = "A";
PrintWriter out = null;
try {
out = new PrintWriter(new FileOutputStream("Student.txt"));
out.print(studentFirstName);
out.println(studentLastName);
out.print(finalGrade);
}
catch (IOException e) {
System.out.println(e);
}
finally {
if (out!=null) out.close(); //in case you have an exception before PrintWriter takes value
}
}
}