Kapil,
Welcome to JavaRanch!
That code matches 0 or more digits. The regular expression tries to find a match as soon as it can. So it thinks something like this.
Position 0 - finds a letter (a). Yup - that's zero digits.
Position 1 - Another letter (b). Great - zero digits.
Position 2 - Ooh - a number. Let's keep looking. Two digits. Outputs "34" and skips outputting the index for the third position since it already matched the "4"
Position 4 - Another letter (e) - Zero digits
Position 5 - Another letter (f) - Zero digits
Position 6 - "End of string" - Yup - zero digits
Kapil Shardha wrote:Moreover, the answer to question 2 of same test is also not clear. Any explanation to these two questions will be of great help.
Can you share question 2 (or a shorter version of it) ? I have the SCJP 5 book (not 6 so things may have changed.) My question #2 deals with Serializable not regular expressions. If you have a question about Serializable, you want to start a new
thread. You'll also want to share what your specific doubt is as that isn't a question that can be traced/diagrammed.