(a)
For Example for Converting ascii to character in Java use the following code
char characterValue = (char)asciiValue;
class CharacterValue
{
public static void main(String[] args) {
int asciiValue='100';
char characterValue = (char)asciiValue;
/*
The Above Statement Shows that the ascii value will be converted into its
Corresponding Character Value and hence the char character = (char)ascii;
will print out the value as 'd'
*/
System.out.println("CharacterValue for ascii 100 is : " + characterValue);
}
}
Answer :
CharacterValue for ascii 100 is : 'd'
(b)
For Example for Converting character to ascii in Java use the following code
int asciiValue = (int)characterValue;
class AsciiValue
{
public static void main(String[] args) {
char characterValue='d';
int asciiValue = (int)characterValue;
/*
The Above Statement Shows that the character value will be converted into its
Corresponding Ascii Value and hence the int asciiValue = (int)characterValue;
will print out the value as '100'
*/
System.out.println("AsciiValue for character 'd' is : " + asciiValue);
}
}
Answer :
AsciiValue for character 'd' is :100
No comments:
Post a Comment