Open In App
Related Articles

Java | Functions | Question 8

Improve Article
Save Article
Like Article

Predict the output of the following program.

class Test
    public static void main(String[] args)
        StringBuffer a = new StringBuffer("geeks");
        StringBuffer b = new StringBuffer("forgeeks");

(A) gsforgeeks
(B) gksforgeeks
(C) geksforgeeks
(D) Compilation error

Answer: (B)

delete(x, y) function deletes the elements from the string at position ‘x’ to position ‘y-1’.
append() function concatenates the second string to the first string.

Quiz of this Question

Last Updated : 28 Jun, 2021
Like Article
Save Article
Similar Reads