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

    public class Result
    {
    public static void main(String args[])
    {
    char chars;
    chars = "hello".charAt(0);
    System.out.println(chars);
    }
    }
    1. h
    2. e
    3. l
    4. o
    5. None of these
Correct Option: A

“hello” is a String literal, method charAt() returns the character specified at the index position. Character at index position 0th is h of hello, hence chars contains h.



Your comments will be displayed only after manual approval.