-
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]));
}
}
-
- true false true
- false true true
- true true true
- false false false
- 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.