Welcome Guest | Sign in | Register
File - Discussion Page For Q.2714 | Java Programming Questions and Answers | Java Programming Free Online-Tests | LucentBlackBoard | LucentBlackBoard.com

Home > Java Programming > File > Questions and Answers

Q: Which is the correct way of Instantiate BufferedWriter object?
A. BufferedWriter b1 = new BufferedWriter(new File("file.txt")); B. BufferedWriter b1 = new BufferedWriter(new FileWriter("file.txt"));
C. Both are true D. None of the above

Answer and Explanation

Answer:BufferedWriter b1 = new BufferedWriter(new FileWriter("file.txt"));

Explanation:
Constructor of BufferedWriter is public BufferedWriter(Writer out) {
}
so BufferedWriter b1 = new BufferedWriter(new FileWriter("file.txt")); is correct one.

Comment on this Question

Name:

Loading...




Partner Sites
LucentBlackBoard.com                  SoftLucent.com                  LucentJobs.com
All rights reserved 2012-2015 SoftLucent.