File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Char to Short Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Char to Short" Watch "Char to Short" New topic
Author

Char to Short

Roja Rani
Greenhorn

Joined: Sep 28, 2005
Posts: 22
Hi All,

In Java rules round up game, the following question is given.

Can you automatically/implicitly convert char to short?

I have answered True for this because, if the char is final variable and is within the range of short, it can be assigned to short implicitly.

But the answer given is False. How to answer this question?
Santana Iyer
Ranch Hand

Joined: Jun 13, 2005
Posts: 335
Can you automatically/implicitly convert char to short?

I have answered True for this because, if the char is final variable and is within the range of short, it can be assigned to short implicitly.


What you said is right but is it always going to be the case NO,
so when asked such question ask yourself is it always going to be true ANSWER IS NO.

Read question carefully if it is char is final variable and is in range of short can it be assigned to short implicitly now you can say YES.

short range is -32k to 32k while char is only positive 0 to 65k
also keep that in mind.
Roja Rani
Greenhorn

Joined: Sep 28, 2005
Posts: 22
Hi,

Thank you for the clarification.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Char to Short