Home » JAVA Programming » Object & Classes » Question
  1. What is the output of this program?
    public class Result 
    {
    public static void main(String args[])
    {
    char array[] = {'P', '8', 'Q', ' '};
    System.out.print(Character.isDigit(array[1]) + " ");
    System.out.print(Character.isWhitespace(array[2]) + " ");
    System.out.print(Character.isUpperCase(array[0]));
    }
    }
    1. true false true
    2. false true true
    3. true true true
    4. false false false
    5. false true false
Correct Option: A

Character.isDigit(a[1]) checks for array[1], whether it is 8 digit or not, since array[1] i:e ‘8’ is a digit true is returned. array[4] is a whitespace hence Character.isWhitespace(array[2]) returns a false. array[0] is an uppercase letter i:e ‘P’ hence Character.isUpperCase(array[0]) returns true.



Your comments will be displayed only after manual approval.