• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Ranch Hand
Posts: 316
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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:
https://coderanch.com/t/498524/java-programmer-SCJP/certification/ID-SCJP-day-Wednesday-June
 
Ranch Hand
Posts: 241
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 384
Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Montana has cold dark nights. Perfect for the heat from incandescent light. Tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic