Computer Applications
Find the output of the following program snippet:
char ch = 'y';
char chr = Character.toUpperCase(ch);
int p = (int) chr;
System.out.println(chr + "\t" + p);
Java
Java Library Classes
49 Likes
Answer
Y 89
Working
Character.toUpperCase()
method converts small y to capital Y so chr
gets the value of 'Y'. Casting chr
to int
gives the ASCII code of 'Y' which is 89.
Answered By
29 Likes
Related Questions
Find the output of the following program snippet:
String s= "7"; int t =Integer.parseInt(s); t=t+1000; System.out.println(t);
Find the output of the following program snippet:
char c = 'B'; int i = 4; System.out.println(c+i); System.out.println((int)c+i);
Find the output of the following program snippet:
int n = 97; char ch = Character.toUpperCase((char)n); System.out.println(ch + " Great Victory");
Find the output of the following program snippet:
char ch = 'x'; int n = 5; n = n + (int)ch; char c = (char)n; System.out.println((char)((int)c-26));