CodeGym
Promotion
CodeGym University
Learning
Course
Tasks
Surveys & Quizzes
Games
Help
Schedule
Community
Users
Forum
Chat
Articles
Success stories
Activity
Reviews
Subscriptions
Light theme
Question
  • Reviews
  • About us
Start
Start learning
Start learning now
  • All questions
Jaisingh
Level 14
Hyderabad
  • 05.10.2018
  • 1302views
  • 3comments

i don't understand how to do this...??

Question about the task Task No. 4 about integer type conversions
Java Syntax,  Level 10,  Lesson 4
Under discussion


Add one type conversion to get the following answer: nine = 9
short number = 9;
char zero = '0';
int nine = (zero + number);

Requirements:
  • The program should display text on the screen.
  • Don't change the screen output command. You can only add cast operators to it.
  • The main() method must contain a short variable number.
  • The main() method must contain a char variable zero.
  • The main() method must contain an int variable nine.
  • Don't change the initial value of the variables during initialization. You can only add cast operators.
  • The program should display the number 9.
package com.codegym.task.task10.task1004; /* Task No. 4 about integer type conversions */ public class Solution { public static void main(String[] args) { short number = 9; //System.out.println(number); char zero = '0'; System.out.println(zero); int nine = (char) zero + number; System.out.println(nine); } }
0
Comments (3)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
Marek Pasierbek Working at Nexus Polska
23 July 2020, 11:02
You have to think about System.out.println(?????nine);
+1
Slawomir I.
Level 15 , Warsaw, Poland
2 May 2020, 09:50
Tip: check ascii table.
+1
Roman
Level 41
12 October 2018, 12:51
Hint : Don't change the screen output command. You can only add cast operators to it.
+2
Learn
  • Registration
  • Java Course
  • Help with Tasks
  • Pricing
  • Game Projects
  • Java Syntax
Community
  • Users
  • Articles
  • Forum
  • Chat
  • Success Stories
  • Activity
  • Affiliate Program
Company
  • About us
  • Contacts
  • Reviews
  • Press Room
  • CodeGym for EDU
  • FAQ
  • Support
CodeGym CodeGym is an online course for learning Java programming from scratch. This course is a perfect way to master Java for beginners. It contains 1200+ tasks with instant verification and an essential scope of Java fundamentals theory. To help you succeed in education, we’ve implemented a set of motivational features: quizzes, coding projects, content about efficient learning and Java developer’s career.
Follow us
Interface language
Programmers Are Made, Not Born © 2023 CodeGym
MastercardVisa
Programmers Are Made, Not Born © 2023 CodeGym
This website uses cookies to provide you with personalized service. By using this website, you agree to our use of cookies. If you require more details, please read our Terms and Policy.