What will be the output of the following C# code snippet? [code] static void main(String args[]) { char chars[] = {'x', 'y', 'z'};

What will be the output of the following C# code snippet?
Code:
 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 :
Code:
xyz
 

Tìm kiếm

Back
Top