• 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

doubt: in one of the question on mock test

 
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is one of the question from the inquisition mock test.

I wanted to know how do they get the answer as mentioned below?


What is the result of attempting to compile and run this class?



answer: atto


This question arises , because , i cannot see any input in the above code with the characters that they are getting in the answer, or is there any typo error in the question itself? please clarify the doubt

thanks
 
Ranch Hand
Posts: 194
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
line 3 => "Foo"
line 4 => after append => "Foobar" => after delete => "Foar" => after reverse => "raoF" => after insert => "rattoF"
line 5 => "atto"

Remember StringBuilder.delete() deletes from start to end-1 and String.substring() returns from start to end-1. In case, you thought otherwise.

Hope that helps.>!>!>
 
mansi gupte
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks, doubt cleared.
 
reply
    Bookmark Topic Watch Topic
  • New Topic