File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes ID:5 SCJP Question of the day : Friday June 11 2010 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "ID:5 SCJP Question of the day : Friday June 11 2010" Watch "ID:5 SCJP Question of the day : Friday June 11 2010" New topic

ID:5 SCJP Question of the day : Friday June 11 2010

Sahil Kapoor
Ranch Hand

Joined: Sep 12, 2009
Posts: 316
Source :- Sahil Rally's Creation !!!

Quote at each line , Compilation Error or Runtime Error or Nothing???

Please be ready for ( Only for SCJP aspirants , even SCJP aspirants dont mind my statement , This is just to impart your more focus on the above question and to make you feel interested and enthusiastic )

Best Wishes !!!

Reference for rules:

SCJP 6.0 96%

(Connecting the Dots ....)
Martin Vanyavchich
Ranch Hand

Joined: Sep 16, 2008
Posts: 241
Line 1, runtime error IndexOutOfBoundsException
Line 2, Compile error, Expecting String got anything
Line 3, Compile time error, something with the char literal being empty
Line 4, Compile error, Expecting char, char got char, anything
Line 5, prints out "sahil", the substring method can take length argument, it just returns same string
Line 6, I'm gonna go with IndexOutOfBoundsException
Line 7, false

Sahil, thanks for the effort you put in these questions



I no good English.
Lalit Mehra
Ranch Hand

Joined: Jun 08, 2010
Posts: 384

line 1: string index out of bound
line 2: false
line 3: i am really confused with this one ... if the two '' have no space then there has to be a compilation error otherwise it replaces fine
line 4: String.replace() does not accept boolean values as replacement parameter
line 5: again string out of bound
line 6: wrong end parameter .. string out of bound
line 7: true because i think no constructor will be called here as the string is already in uppercase ... i might be wrong though

good one sahil ... i really appreciate your efforts buddy ... these questions are really helping me to prepare for my scjp
Abhinav Yadav
Ranch Hand

Joined: Nov 08, 2009
Posts: 34
@sahil nice question buddy, to me every line seems to give error except that last one,which will surely be true ,but the two sirs have already given the answers but i will also try ,here it goes:

Line 1, StringIndexOutOfBoundsException
Line 2, Should be false
Line 3, Char literal being empty compile time error
Line 4, Compile error,but cant think of a reason
Line 5, this should not print anything as there is no substring at 5
Line 6, may be index out of bounds
Line 7, true ,both the objects refer to same sequence of characters hence interned ,therefore its should be true

No Dream Too Big
I agree. Here's the link:
subject: ID:5 SCJP Question of the day : Friday June 11 2010
It's not a secret anymore!