What will be the output of the program?
public class Sketch31
{
private static void report()
{
char c = '7';
boolean digit = Character.isDigit(c);
int numeric = Character.getNumericValue(c);
System.out.println(digit + " " + numeric);
}
public static void main(String[] args)
{
report();
}
}
Answer: C
isDigit answers true for the character seven, and getNumericValue returns the value the character stands for, which is 7. Casting the char to int instead would give its code point, 55. The two are easy to confuse and differ by 48 for every digit.
Please log in or register to report this question.