1.

Write the output of the code snippetchar c = 'A' ; int d = 5 ; int tot = (int)c + d ; System.out.println(tot);​

Answer»

Hey Buddy

Here's The Answer

-------------------------------------------------

=> int tot = ( int )c + d ;

In ( int )c we are casting the character into integer and it is KNOW as TYPE casting, if we are casting a character in integer, so the integer will store it's ASCII value.

=> tot = ASCII value of A + d

=> tot = 65 + 5

=> tot = 70

As tot is int we'll get final output in integer form

System.out.println( tot );

=> 70

Hope It Helps.



Discussion

No Comment Found