CMS专题

单选题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.c

题目
单选题
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.

参考答案和解析
正确答案: D
解析: 暂无解析
如果没有搜索结果,请直接 联系老师 获取答案。
相似问题和答案

第1题:

Given:Which regular expression, inserted at line 12, correctly splits test into "Test A", "Test B", and "Test C"?()

A.String regex="";

B.String regex=" .";

C.String regex=".*";

D.String regex="\\s";

E.String regex="\\.\\s*";

F.String regex="\\w[\.]+";


参考答案:E

第2题:

Which two statements are true about the hashCode method?()

  • A、 The hashCode method for a given class can be used to test for object equality and object inequality for that class.
  • B、 The hashCode method is used by the java.util.SortedSet collection class to order theelements within that set.
  • C、 The hashCode method for a given class can be used to test for object inequality, but NOT object equality, for that class.
  • D、 The only important characteristic of the values returned by a hashCode method is that the distribution of values must follow a Gaussian distribution.
  • E、 The hashCode method is used by the java.util.HashSet collection class to group the elements within that set into hash buckets for swift retrieval.

正确答案:C,E

第3题:

You are writing a method that accepts a string parameter named message.Your method must break the message parameter into individual lines of text and pass each line to a second method named Process.Which code segment should you use?()

A.

B.

C.

D.


参考答案:D

第4题:

Which HttpSession method stores an object in a session?()

  • A、 put(String name. Object value)
  • B、 set(String name. Object value)
  • C、 setAttribute(String name. Object value)
  • D、 putAttribute(String name. Object value)
  • E、 addAttribute(String name. Object value)

正确答案:C

第5题:

When compressing data with the DeflateStream class, how do you specify a stream into which to write compressed data?()

  • A、 Set the BaseStream property with the destination stream, and set the CompressionMode property to Compression.
  • B、 Specify the stream to write into the DeflateStream object is created (for example, in the constructor).
  • C、 Use the Write method of the DeflateStream class.
  • D、 Register for the BaseSream event of the DeflateStream class.

正确答案:B

第6题:

If possible please suggest further improvement of the String class.

Question 3:

Given a link list, detect whether it's circular using only one loop.

Tips: Below implementation is allowed

for( ... )

{

...

}

The following implementations is NOT allowed

...

for( ... )

{

...

for( ... ) {...}

}

...

or

...

for( p = list->head, q = list->head; p != NULL && q != NULL; p = p->next )

{

...

}

...

for( ... )

{

...

}


正确答案:
 

第7题:

Given: 6. 7.<%="processing" %> 8. and a custom tag handler for foo which extends TagSupport. Which two are true about thetag handler referenced by foo?()

  • A、The doStartTag method is called once.
  • B、The doAfterBody method is NOT called.
  • C、The EVAL_PAGE constant is a valid return value for the doEndTag method.
  • D、The SKIP_PAGE constant is a valid return value for the doStartTag method.
  • E、The EVAL_BODY_BUFFERED constant is a valid return value for the doStartTag method.

正确答案:A,C

第8题:

Given:Which two can be results?()

A. java.lang.RuntimeException: Problem

B. run.java.lang.RuntimeException: Problem

C. End of method.java.lang.RuntimeException: Problem

D. End of method.run.java.lang.RuntimeException: Problem

E. run.java.lang.RuntimeException: Problem End of method.


参考答案:D, E

第9题:

Which methods from the String and StringBuffer classes modify the object on which they are called?()  

  • A、The charAt() method of the String class.
  • B、The toUpperCase() method of the String class.
  • C、The replace() method of the String class.
  • D、The reverse() method of the StringBuffer class.
  • E、The length() method of the StringBuffer class.

正确答案:D

第10题:

Given the ActionEvent, which method allows you to identify the affected component?()

  • A、 GetClass.
  • B、 GetTarget.
  • C、 GetSource.
  • D、 GetComponent.
  • E、 GetTargetComponent.

正确答案:C

更多相关问题