多做题,通过考试没问题!

Java认证考试

睦霖题库>其他计算机考试>Java认证考试

Which method implementations will write the given string to a file named "file", using UTF8 encoding?()   IMPLEMENTATION a:   public void write(String msg) throws IOException {   FileWriter fw = new FileWriter(new File("file"));   fw.write(msg);   fw.close();   }   IMPLEMENTATION b:   public void write(String msg) throws IOException {   OutputStreamWriter osw =  new OutputStreamWriter(new FileOutputStream("file"), "UTF8");  osw.write(msg);   osw.close();   }   IMPLEMENTATION c:   public void write(String msg) throws IOException {  FileWriter fw = new FileWriter(new File("file"));   fw.setEncoding("UTF8");   fw.write(msg);   fw.close();  }   IMPLEMENTATION d:   public void write(String msg) throws IOException {  FilterWriter fw = FilterWriter(new FileWriter("file"), "UTF8");   fw.write(msg);  fw.close();   }   IMPLEMENTATION e:   public void write(String msg) throws IOException {   OutputStreamWriter osw = new OutputStreamWriter(  new OutputStream(new File("file")), "UTF8"  );   osw.write(msg);   osw.close();   }  

  • A、Implementation a.
  • B、Implementation b.
  • C、Implementation c.
  • D、Implementation d.
  • E、Implementation e.
正确答案:B
答案解析:
进入题库查看解析

微信扫一扫手机做题