Home » JAVA Programming » Strings » Question
  1. What is the output of this program?

    public class String_Example
    {
    public static void main(String args[])
    {
    char chars[] = {'I', 'L', 'U'};
    String obj = new String(chars);
    System.out.println(obj);
    }
    }
    1. ILU
    2. ULI
    3. IUL
    4. LUI
    5. LIU
Correct Option: A

String(chars) is a constructor of class string, it initializes string obj with the values stored in character array chars, therefore obj contains “ILU”.



Your comments will be displayed only after manual approval.