-
What is the output of this program?
public class output
{
public static void main(String args[])
{
char ch[]={'p', '1', 'b' ,' ' ,'P' , '0'};
for (int k = 0; k < 5; ++k)
{
if(Character.isDigit(ch[k]))
System.out.println(ch[k]+" is a digit");
if(Character.isWhitespace(ch[k]))
System.out.println(ch[k]+" is a Whitespace character");
if(Character.isUpperCase(ch[k]))
System.out.println(ch[k]+" is an Upper case Letter");
if(Character.isLowerCase(ch[k]))
System.out.println(ch[k]+" is a lower case Letter");
k=k+3;
}
}
}
-
- b is a lower case Letter
is White space character - p is a lower case Letter
is White space character - p is a lower case Letter
0 is a digit - p is a lower case Letter
P is an upper case Letter - None of these
- b is a lower case Letter
Correct Option: D
Character.isDigit(ch[k]),Character.isUpperCase(ch[k]),Character.isWhitespace(ch[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.