Computer Science, asked by pallavigupta91, 1 year ago

Are both the statement given below are same ? Give reason .
char alpha=65;
char alpha='A';​

Answers

Answered by salonisingh160oztp48
16

Answer:Yes they are equal...its all about type conversion (implicit & explicit)

Here we have every character a numeric value , A has ASCII value 65.

Explanation:

char a = 'A';

int x = (int) a;

System.out.println(x);

// output will be 65...

Hope it helps!

Answered by ParvezShere
1

Both statements have the same effect: they declare alpha to be a char and initialize it with the value 65. Since this is the ASCII code for 'A', that character constant can also be used to initialize alpha to 65.

  • ASCII was the first character set (encoding standard) used between computers on the Internet.
  • ASCII is a 7-bit character set containing 128 characters.
  • It contains the numbers from 0-9, the upper and lower case English letters from A to Z, and some special characters.
  • The character sets used in modern computers, in HTML, and on the Internet, are all based on ASCII.
  • One has the value other has the code in the given values of alpha.

#SPJ3

Similar questions