Menu
Topics Index
...
`

Character Demo


If you need explanation Read this topic

If you need Answer Take test on this topic

Character Demo
What will be the output of the following program?
public class Character Demo {
    public static void main(String[] args) {
        int num = 3;
        int num2 = 16;
        char ch = Character.forDigit(num, 10);
        char ch1 = Character.forDigit(num2, 36);
        System.out.print(ch + ", " + ch1);
    }
}

A. 10, g
B. 3, e
C. 3, g
D. Some other output
E. Compilation Error or Runtime Error
Topic: Java Character Class

If you need explanation Read this topic

If you need Answer Take test on this topic

User comments below. All of them might not be correct.

E.compilation error because Class name having blank space in between so definitely compilation error.

Posted by Shabaaz Shaikz    2014-04-02 12:49:22


forDigit() method returns the character representation of a digit in the radix passed to it. Here the character representation of 3 in radix 10 is 3 and the character representation of 16 in radix 36 is g. So the answer is C. (Correcting the error in the class name)

Posted by Shaileshwar Sharma    2014-04-02 13:02:28


Congratulations Shabaaz Shaikz. You are this dose winner. We will send you the link using which you can claim your recharge.

Posted by Merit Campus    2014-04-03 04:34:32


© meritcampus 2019

All Rights Reserved.

Open In App