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 Java program?
class String_demo
{
public static void main(String args[])
{
char chars[] = {‘a’, ‘b’, ‘c’};
String s = new String(chars);
System.out.println(s);
}
}

What will be the output of the following Java program?
class String_demo
{
public static void main(String args[])
{
char chars[] = {‘a’, ‘b’, ‘c’};
String s = new String(chars);
System.out.println(s);
}
}
a) a
b) b
c) c
d) abc

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 “abc”.
output:
abc

Join The Discussion