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 1104961
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T01:33:24+00:00 2026-05-17T01:33:24+00:00

Why its printing X88 public static void main(String [] args) { char x =

  • 0

Why its printing X88

public static void main(String [] args)
{
      char x = 'X';
      int i = 0;
      System.out.print(true  ? x : 0);
      System.out.print(false ? i : x);
}
  • 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-05-17T01:33:25+00:00Added an answer on May 17, 2026 at 1:33 am

    In the first print statement, the type of the conditional expression is char (i.e. ‘X’) because this part of section 15.25 of the JLS (which is about the type of a conditional expression) applies:

    If one of the operands is of type T where T is byte, short, or char, and the other operand is a constant expression of type int whose value is representable in type T, then the type of the conditional expression is T.

    So the first statement prints “X”.

    In the second print statement, that part doesn’t apply because i isn’t a constant expression. Instead, this section applies:

    Otherwise, binary numeric promotion (§5.6.2) is applied to the operand types, and the type of the conditional expression is the promoted type of the second and third operands. Note that binary numeric promotion performs unboxing conversion (§5.1.8) and value set conversion (§5.1.13).

    Binary numeric promotion converts the char ‘X’ to an int (88) and the second statement prints “88” – hence the overall result of “X88”.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a controller function like this public static void renderCustomersList() { System.out.println(renderArgs+renderArgs.toString()); render(renderArgs);
following program should print error but its printing success.why? #include<iostream> using namespace std; int
I am using the code below to print from an array but its printing
Why its not working? :| import subprocess p = subprocess.Popen([rsnmpget,-v,1,-c,public,-Oqv,,-Ln,192.168.1.1 1.3.6.1.2.1.2.2.1.10.7],stdout=subprocess.PIPE).communicate()[0] print p Run
Doing some work on controlling printing via the System.Printing framework (main classes are PrintQueue,
I'm expecting the code below to print 1 but its printing a random large
Here is my code: #include<stdio.h> #include<stdlib.h> #include<sys/stat.h> #include<sys/types.h> #include<fcntl.h> #include<unistd.h> #include<errno.h> int main(int argc,char
The following method does its job but keeps printing a warning also, im pretty
I have a Winforms application that generates its own PrintDocument object for printing. It
using System; using System.Collections; namespace Iterator_test { class Day { int days_idx = -1;

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.