This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes File IO Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "File IO" Watch "File IO" New topic
Author

File IO

nikhil nandu
Greenhorn

Joined: Jan 10, 2001
Posts: 4
Given method which extracts and returns file extension from the
given file name:
static String getName(String s) {
int n = s.indexOf('.');
return s.substring(n); }
Which of the following statements are true?
A. This method always returns a wrong extension
B. This method may return a wrong extension under certain
circumstances
C. This method may throw unchecked exception
D. This method works fine
Please help.
Thanks.
Bin Wu
Ranch Hand

Joined: Jan 03, 2001
Posts: 32
nikhil,
I think the ans should be 'a'.
Because the code return the extension name and '.', so right code should be:
return s.substring( n+1 );
hope to help you.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: File IO
 
Similar Threads
[Easy] Shift String
How can i restrict the selecting file type to XML and TXT in file upload..
NX: (Contractors) Regex vs. String.startsWith
Miscellaneous
How to use the FilenameFilter interface