|
Page 2 of 2 [Answers]
1 - Correct Choice:
A
Explanation
Choice A is the correct answer.
The Formatter class provides format conversions that let you display numbers, strings, time, and date according to the specified format string. The %t specifier lets you format date and time information; it uses a suffix to describe the exact format required. The suffix 'r' is replaced by the 'hh:mm:ss' format (12 hr format), which in this case, is '09:05:28 PM'. The suffix 'Z' gives the time zone, which in this case is 'GMT+05:30'.
To know more about the Formatter, refer to
http://java.sun.com/developer/JDCTechTips/2004/tt1005.html#2
http://java.sun.com/j2se/1.5.0/docs/api/java/util/logging/Formatter.html
2 - Correct Choice: F
Explanation:
Choice F is the correct answer.
This code compiles fine and prints "123null". The StringBuffer object s is constructed using the parameterless constructor, so it is empty at first. If the argument passed to the append method is null, then the four characters "null" are appended to the invoking StringBuffer object. So now sb refers to null.
The insert method causes the characters of the String argument to be inserted, in order, into this StringBuffer at the indicated offset, moving up any characters originally above that position and increasing the length of this sequence by the length of the argument. Here the insert method is invoked with an offset of 0, and the argument passed is "123". So the result is "123null" which is printed out.
For more information, you may refer to http://java.sun.com/j2se/1.5.0/docs/api/java/lang/StringBuffer.html
Related
Get your JSP / Servlet skills certified
A guide to the Sun Certified Java Programmer exam for J2SE 5.0
Learn J2EE programming with passion and for free
Recruiting like crazy
|
Comment by kailashdhar.ch@rediff.com on 2008-06-21 06:34:59 nice |
|