Java OCA OCP Practice Question 1726

Question

Given the following declaration:.

char c = 'A';

What is the simplest way to convert the character value in c into an int?.

Select the one correct answer.

(a)  int i = c;
(b)  int i = (int) c;
(c)  int i = Character.getNumericValue(c);


(a)

Note

A value of type char can be assigned to a variable of type int.

An widening conversion will convert the value to an int.




PreviousNext

Related