Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

doubts regarding OCJP questions

 
Nikhitha Pai
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
and Please, UseOneThreadPerQuestion
 
Nikhitha Pai
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic