File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Sahil Kapoor
Ranch Hand
Posts: 316
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 !!!
Cheers!!!


Reference for rules:
http://www.coderanch.com/t/498524/java-programmer-SCJP/certification/ID-SCJP-day-Wednesday-June
 
Martin Vanyavchich
Ranch Hand
Posts: 241
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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


Regards,

Martin
 
Lalit Mehra
Ranch Hand
Posts: 384
Eclipse IDE Firefox Browser Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 34
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic