Java J2EE Portal
Enterprise Java Station
J2EE curve
Java News / Articles
Java News / Articles
Java's failure at shared hosting will contribute to its downfall
What are Digital Signatures? Compute and Verify a Digital Signature Using J
Happenings @ IndicThreads.com Conference On Java Technology 2007
Processing...
Buy Java, Deals On Software Technology Store
Click here for great deals on computers, laptops, software and books
Test your Java language skills - Quiz 1 PDF Print
Written by Content Team   
Sep 12, 2006 at 11:04 PM

[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


User Comments

Comment by kailashdhar.ch@rediff.com on 2008-06-21 06:34:59
nice
Your Name / Email Address
Comment
Spam Protection - Please enter the code in the image -

Listen to code




Add This Feed Button

Enter your Email


Java Expert Interviews
DaveCraneAJAXinterview
Ajax technologies aren't particularly new or sexy
GuillaumeLaforgeGroovy
Groovy bridges the scripting and the enterprise Java worlds
JonathanAgileXPSoftwareTestingX
The good and bad of XP and Agile notions of software testing
Processing...
Go to top of page  Home |
SiteMap

Copyright 2004 to 2008 Rightrix Solutions. All rights reserved. All product names are trademarks of their respective companies. Java and all Java-based marks are trademarks or registered trademarks of Sun Microsystems, Inc. in the United States and other countries. Rightrix Solutions and IndicThreads.com are independent of Sun Microsystems, Inc.

Views expressed at IndicThreads.com reflect the views of the authors alone, and do not necessarily reflect those of IndicThreads.com. IndicThreads.com and it's authors are not responsible for reader comments and opinions.

Enterprise Java J2EE JEE Portal >> IndicThreads.com