单项选择题
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.
相关考题
-
多项选择题
Given the following code, which code fragments, when inserted at the indicated location, will succeed in making the program display a button spanning the whole window area?() import java.awt.*; public class Q1e65 { public static void main(String args[]) { Window win = new Frame(); Button but = new Button("button"); // insert code fragment here win.setSize(200, 200); win.setVisible(true); } }
A.win.setLayout(new BorderLayout()); win.add(but);
B.win.setLayout(new GridLayout(1, 1)); win.add(but);
C.win.setLayout(new BorderLayout()); win.add(but, BorderLayout.CENTER);
D.win.add(but);
E.win.setLayout(new FlowLayout()); win.add(but); -
单项选择题
Whichstatementsconcerningtheeffectofthestatementgfx.drawRect(5,5,10,10)aretrue,giventhatgfxisareferencetoavalidGraphicsobject?()
A.The rectangle drawn will have a total width of 5 pixels.
B.The rectangle drawn will have a total height of 6 pixels.
C.The rectangle drawn will have a total width of 10 pixels.
D.The rectangle drawn will have a total height of 11 pixels. -
单项选择题
What will be written to the standard output when the following program is run?() public class Qcb90 { int a; int b; public void f() { a = 0; b = 0; int[] c = { 0 }; g(b, c); System.out.println(a + " " + b + " " + c[0] + " "); } public void g(int b, int[] c) { a = 1; b = 1; c[0] = 1; } public static void main(String args[]) { Qcb90 obj = new Qcb90(); obj.f(); } }
A.0 0 0
B.0 0 1
C.0 1 0
D.1 0 0
E.1 0 1
