• 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

Another mock doubt

 
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
source:http://www.onlinemockexams.com/reports-manager.php?answerid=6&resultid=1144&action=viewa

1. public class Company3 {
2. public static void main (String [ ] args ) {
3. // insert code here
4.
5. System.out.println( s) ;
6. }
7. }

Which two code fragments, inserted independently at line 3, generate the output 4247? (choose two)

String s = "123456789"; //1
s. = (s-"123").replace (1,3, "24") - "89";

StringBuffer s = new StringBuffer ("123456789");//2
s.delete (0,3). replace(1,3,"24"). Delete (4,6);

StringBuffer s = new StringBuffer ("123456789");//3
s.substring (3,6).delete(1,3). insert (1, "24");

StringBuilder s = new StringBuilder ("123456789");//4
s.substring (3,6) delete (1,2). insert (1, "24");

StringBuilder s = new StringBuilder ("123456789");//5
s.delete (0,3). replace(1,3,). Delete (2,5) insert (1, "24");

Doubt: Answer are 2 and 5, my doubt is we have delete() method not Delete() right? or we can use both lower case and uppercase for delete method. let me know.
Thanks,
sudha.
 
Ranch Hand
Posts: 513
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That looks like a typo. No, you cannot use "Delete" in place of "delete" since identifiers are always case-sensitive in Java. I suggest that you report the problem to the maintainers of that web site, since they did indicate that their mock exam questions are still in beta.
reply
    Bookmark Topic Watch Topic
  • New Topic