Home » Interview » Technology

What is the string contained in s after following lines of code? StringBuffer s = new StringBuffer(“Hello”); s.deleteCharAt(0); ?

Correct Answer: ello

Explanation:

deleteCharAt() method deletes the character at the specified index location and returns the resulting StringBuffer object.


So after deleting the character at 0 ie 'H', the string returns 'ello' as the output.


← Previous Question Next Question→

Discussion & Comments

No comments yet. Be the first to comment!
Join Discussion