• 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Liutauras Vilda
Sheriffs:
  • Paul Clapham
  • Jeanne Boyarsky
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
Bartenders:
  • Jesse Duncan
  • Frits Walraven
  • Mikalai Zaikin

A question about String class!

 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Given the following sequence of Java statements
1.StringBuffer sb = new StringBuffer("abc");
2.String s = new String("abc");
3.sb.append("def");
4.s.append("def");
5.sb.insert(1, "zzz");
6.s.concat(sb);
7.s.trim();
Which of the following statements are true:
a.The compiler would generate an error for line 1.
b.The compiler would generate an error for line 2.
c.The compiler would generate an error for line 3.
d.The compiler would generate an error for line 4.
e.The compiler would generate an error for line 5.
f.The compiler would generate an error for line 6.
g.The compiler would generate an error for line 7.
The answer is f. But I have checked the documention and I don't find the append() method in the String class.
 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The Answer Should Be d & f
Compiler Errors Will be:
for Line 4,
Error:[18]method append[java.lang.String] not found in class java.lang.String

for Line 6,
Error:[20]method
concat[java.lang.StringBuffer]
not found in class java.lang.String

If it's not please verify...

Thanks
Dushan.


[This message has been edited by dushan (edited September 21, 2000).]
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic