Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8781789
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T20:23:50+00:00 2026-06-13T20:23:50+00:00

I have my head stuck in the SCJP 6 Study guide, and am confused

  • 0

I have my head stuck in the SCJP 6 Study guide, and am confused about a point they make here.

Regarding casting ints to chars, they say that the following are perfectly legal, but you get a loss of precision (which I can totally understand):

    char d = (char)-98;
    char c = (char)70000;
    System.out.println("d = " + d + " c = " + c);

The result of this is:

d = ? c = ?

The point here that I am confused on is that the resultant char value is printing out as just a question mark in both cases. I would have expected a nonsensical numeric value, possibly bearing little or no relation at all to the original value, but nevertheless numeric.

Why is the result a question mark? I don’t understand how just a question mark is a “loss of precision” here?

I have looked at many char related questions here on SO, and also googled a lot, but can’t find an answer to this.

Does it differ with other JVM’s? Or is it the standard response to all out-of-range char casts?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T20:23:52+00:00Added an answer on June 13, 2026 at 8:23 pm

    When you append a char to a String, the char is appended (‘a’ for example), and not its numeric value (97 for example). If you want to know what the numeric value of the char is, use

    System.out.println("d = " + ((int) d) + " c = " + ((int) c));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a head file which I am using for a few different pages.
Input rz value In the head I have: Event.observe(window, 'load', function() { $$(input).each(function(field){ Event.observe(field,
How do I define security access in Elasticsearch? I have the elasticsearch-head plugin but
I have been banging my head on this one for too long. I have
I have been banging my head on and on, i cant seem to work
I have been cracking my head for hours on what I thought to be
I have this script $('head').append('<link rel=stylesheet href=css/file1.css type=text/css />'); $('head').append('<link rel=stylesheet href=css/jquery.jscrollpane.css type=text/css />');
i have tried till my head hurts and have been reading so much my
I have been banging my head against the wall with this odd behaviour on
I have been banging my head on this one for hours and I am

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.