Home » JAVA Programming » Files and I/O » Question
  1. What is the output of this program?
    public class Result
    {
    public static void main(String args[])
    {
    char array[]={'a','1','b',' ','A','0'};
    for (int k = 0; k < 5; ++k)
    {
    if(Character.isDigit(array[k]))
    System.out.println(array[k]+" is a digit");
    if(Character.isWhitespace(array[k]))
    System.out.println(array[k]+" is a Whitespace character");
    if(Character.isUpperCase(array[k]))
    System.out.println(array[k]+" is an Upper case Letter");
    if(Character.isLowerCase(array[k]))
    System.out.println(array[k]+" is a lower case Letter");
    k = k + 3;
    }
    }
    }
    1. a is a lower case Letter
      A is an Upper case Letter
    2. a is a lower case Letter
      is White space character
    3. b is a lower case Letter
      is White space characte
    4. a is a lower case Letter
      0 is a digit
    5. None of these
Correct Option: A

Character.isDigit(array[k]),Character.isUpperCase(array[k]),Character.isWhitespace(array[k]) are the function of library java.lang
they are used to find weather the given character is of specified type or not. They return true or false i:e Boolean variable.



Your comments will be displayed only after manual approval.