Register Now

Login

Lost Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

What will be the output of the following C# code snippet?
static void main(String args[])
{
char chars[] = {‘x’, ‘y’, ‘z’};
String s = new String(chars);
Console.WriteLine(s);
}

What will be the output of the following C# code snippet?
static void main(String args[])
{
char chars[] = {‘x’, ‘y’, ‘z’};
String s = new String(chars);
Console.WriteLine(s);
}
a) x
b) xy
c) z
d) xyz

Answer: d
Explanation: String(chars) is a constructor of class string, it initializes string s with the values stored in character array chars, therefore s contains “xyz”.
Output :
xyz

Join The Discussion