单选题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(); }AImplementation a.BImplementation b.CImplementation c.DImplementation d.EImplementation e.
单选题
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.
参考解析
解析:
暂无解析
相关考题:
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.
Given:Which two can be results?() A. java.lang.RuntimeException: ProblemB. run.java.lang.RuntimeException: ProblemC. End of method.java.lang.RuntimeException: ProblemD. End of method.run.java.lang.RuntimeException: ProblemE. run.java.lang.RuntimeException: Problem End of method.
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[\.]+;
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 allowedfor( ... ){...}The following implementations is NOT allowed...for( ... ){...for( ... ) {...}}...or...for( p = list-head, q = list-head; p != NULL q != NULL; p = p-next ){...}...for( ... ){...}
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.
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.
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.
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.
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)
Given the ActionEvent, which method allows you to identify the affected component?()A、 GetClass.B、 GetTarget.C、 GetSource.D、 GetComponent.E、 GetTargetComponent.
Given an EL function declared with:11. 12.spin 13.com.example.Spinner 14. 15.java.lang.String spinIt() 16. 17. Which two are true?()A、The function method must have the signature: public String spin().B、The method must be mapped to the logical name "spin" in the web.xml file.C、The function method must have the signature: public String spinIt().D、The function method must have the signature public static String spin().E、The function method must have the signature: public static String spinIt().F、The function class must be named Spinner, and must be in the package com.example.
Which statement is true?()A、A class’s finalize() method CANNOT be invoked explicitly.B、super.finalize() is called implicitly by any overriding finalize() method.C、The finalize() method for a given object is called no more than once by the garbage collector.D、The order in which finalize() is called on two objects is based on the order in which the two objects became finalizable.
Given: 11.String test = "Test A. Test B. Test C."; 12.// insert code here 13.String[] result = test.split(regex); 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*";
单选题Given the ActionEvent, which method allows you to identify the affected component?()A GetClass.B GetTarget.C GetSource.D GetComponent.E GetTargetComponent.
多选题Which two are true?()AA finalizer may NOT be invoked explicitly.BThe finalize method declared in class Object takes no action.Csuper.finalize()is called implicitly by any over riding finalize method.DThe finalize method for a given objec twill be called no more than once by the garbage collector.EThe order in which finalize will be called on two objects is based on the order in which the two objects became finalizable.
单选题Given that t1 is a reference to a live thread, which is true?()AThe Thread.sleep() method can take t1 as an argument.BThe Object.notify() method can take t1 as an argument.CThe Thread.yield() method can take t1 as an argument.DThe Thread.setPriority() method can take t1 as an argument.EThe Object.notify() method arbitrarily chooses which thread to notify.
单选题You are developing a method to decrypt data that was encrypted with the Triple DES Algorithm. The method accepts the following parameters: The byte array to be decrypted, which is named cipherMessage The key, which is named key An initialization vector, which is named iv You need to decrypt the message by using the TripleDES class and place the result in a string. Which code segment should you use?()A AB BC CD D
单选题Which statement is true?()AA class’s finalize() method CANNOT be invoked explicitly.Bsuper.finalize() is called implicitly by any overriding finalize() method.CThe finalize() method for a given object is called no more than once by the garbage collector.DThe order in which finalize() is called on two objects is based on the order in which the two objects became finalizable.
单选题Which methods from the String and StringBuffer classes modify the object on which they are called?()AThe charAt() method of the String class.BThe toUpperCase() method of the String class.CThe replace() method of the String class.DThe reverse() method of the StringBuffer class.EThe length() method of the StringBuffer class.
填空题Given the following code, write a line of code that, when inserted at the indicated location, will make the overriding method in Extension invoke the overridden method in class Base on the current object. class Base { public void print( ) { System.out.println("base"); } } class Extention extends Base { public void print( ) { System.out.println("extension"); // insert line of implementation here } } public class Q294d { public static void main(String args[]) { Extention ext = new Extention( ); ext.print( ); } } Fill in a single line of implementation.()
单选题Given this method in a class: public String toString() { StringBuffer buffer = new StringBuffer(); buffer.append(‟‟); return buffer.toString(); } Which is true?()A This code is NOT thread-safe.B The programmer can replace StringBuffer with StringBuilder with no other changes.C This code will perform well and converting the code to use StringBuilder will not enhance the performance.D This code will perform poorly. For better performance, the code should be rewritten: return ““+ this.name + “”;
多选题Given: String value = getServletContext().getInitParameter("foo"); in an HttpServlet and a web applicationdeployment descriptor that contains: foo frodo Which two are true?()AThe foo initialization parameter CANNOT be set programmatically.BCompilation fails because getInitParameter returns type Object.CThe foo initialization parameter is NOT a servlet initialization parameter.DCompilation fails because ServletContext does NOT have a getInitParameter method.EThe foo parameter must be defined within the element of the deployment descriptor.
单选题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)
多选题Which two statements are true about the hashCode method?()AThe hashCode method for a given class can be used to test for object equality and object inequality for that class.BThe hashCode method is used by the java.util.SortedSet collection class to order theelements within that set.CThe hashCode method for a given class can be used to test for object inequality, but NOT object equality, for that class.DThe only important characteristic of the values returned by a hashCode method is that the distribution of values must follow a Gaussian distribution.EThe hashCode method is used by the java.util.HashSet collection class to group the elements within that set into hash buckets for swift retrieval.
单选题Given that login.getName() returns a java.lang.String value and given the JSP code: Welcome Which is equivalent?()A% Welcome % out.print(login.getName()); % B Welcome % writer.print(login.getName()); % C Welcome % response.out.print(login.getName()); %D Welcome % response.writer.print(login.getName()); % E Welcome % response.getOutputStream().write(login.getName()); %
多选题Given an EL function declared with:11. 12.spin 13.com.example.Spinner 14. 15.java.lang.String spinIt() 16. 17. Which two are true?()AThe function method must have the signature: public String spin().BThe method must be mapped to the logical name spin in the web.xml file.CThe function method must have the signature: public String spinIt().DThe function method must have the signature public static String spin().EThe function method must have the signature: public static String spinIt().FThe function class must be named Spinner, and must be in the package com.example.
单选题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[/.]+";