Menu
Topics Index
...
`

Concat2185


If you need explanation Read this topic

If you need Answer Take test on this topic

Concat2185
What will be the output of following program?
public class Concat {
    public static void main(String args[]) {
        char[] c = {'k', 'e', 'y', 'b', 'o', 'a', 'r', 'd'};
        String s = "computer ";
        String s1 = new String(c);
        String s2 = s.concat(s1);
        System.out.print(s2);
    }
}

A. computer keyboard
B. computerkeyboard
C. computer
D. keyboard
E. Compilation Error or Runtime Error
Topic: concat() method In Java

If you need explanation Read this topic

If you need Answer Take test on this topic

User comments below. All of them might not be correct.

Ans: B  concat method combines both string and assigns to s2 .

Posted by Indrasena Reddy    2014-09-05 04:11:45


A

Posted by Akshay Bhatwadekar    2014-09-05 04:15:51


b..concat method combinws both th string n reslt is b

Posted by Wajahat Khan    2014-09-05 04:18:40


Ans: B concat method combines both string and assigns to s2 .

Posted by Shamee Shamee    2014-09-05 04:20:45


Ans is B

Posted by Raju VarshnEy    2014-09-05 04:26:47


Ans B. Concat method just combines both string without space

Posted by Ankur Verma    2014-09-05 04:34:09


a. is right answer because concat combines both string and s contain extra space which will added to s2 and gives the "computer keyboard"

Posted by Shubham Bansal    2014-09-05 09:04:06


B, it doesn't have a space between strings...

Posted by Mark Kovach    2014-09-05 12:28:32


B

Posted by Rohit Baranwal    2014-09-05 17:39:54


Congratulations Shubham Bansal. You are this dose winner. We will send you the link using which you can claim your recharge.

Posted by Merit Campus    2014-09-08 04:49:53


© meritcampus 2019

All Rights Reserved.

Open In App