| Author |
doubts regarding OCJP questions
|
Nikhitha Pai
Greenhorn
Joined: Sep 17, 2012
Posts: 13
|
|
1) How to convert hexadecimal octal values to their corresponding decimal equivalents.?
Say for example we are given
float f3 = 0x12345;
It is a silly question i guess. But pease do reply
Another Question
How will you calculate what character is represented actually , if given a character literal like ‘\ufeeg’
Example : Which three are valid declarations of a char? (Choose three.)
A. char c1 = 064770;
B. char c2 = ‘face’;
C. char c3 = 0xbeef;
D. char c4 = \u0022;
E. char c5 = ‘\iface’;
F. char c6 = ‘\uface’;
Thanks and Regards
Nikhitha
|
 |
Seetharaman Venkatasamy
Ranch Hand
Joined: Jan 28, 2008
Posts: 5575
|
|
answer to your first question, when you assign hex value to a float variable
then compiler implicitly convert the hex value to decimal and assigned to the float variable.
just print f3 and see.
coming to your second question,
you need to go through char declaration in JLS => here
|
 |
Seetharaman Venkatasamy
Ranch Hand
Joined: Jan 28, 2008
Posts: 5575
|
|
and Please, UseOneThreadPerQuestion
|
 |
Nikhitha Pai
Greenhorn
Joined: Sep 17, 2012
Posts: 13
|
|
Hi,
Thank you for the reply.
Often we find questions where they give octal or hexadecimal values and ask what is the resut of shift operations . In such cases to evaluate the expression, how do you convert the hexadecimal and octal values to decimal equivalents manually, do the shift operations and get the answer . Could you please give an example.
Sorry for posting two questions in the previous thread.
|
 |
 |
|
|
subject: doubts regarding OCJP questions
|
|
|