-
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;
}
}
}
-
- a is a lower case Letter
A is an Upper case Letter - a is a lower case Letter
is White space character - b is a lower case Letter
is White space characte - a is a lower case Letter
0 is a digit - None of these
- a is a lower case Letter
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.