Master the Java Language Lexicon: From Identifiers to Comments. Tasks
1. Comments
Create a program that uses both single-line and multi-line comments.
Solution available on Patreon.
2. Practicing Literals
Create a program that prints the following types of literals to the console:
- Boolean
- String
- Character
- Binary integer
- Octal integer
- Decimal integer
- Hexadecimal integer
- Float literal
- Double literal
Solution available on Patreon.
3. Calculator
- Create a method that takes two
int
variables as input. - The method calculates their sum and returns the result.
- Call this method from the
main
method. - Create additional methods for subtraction, multiplication, and division.
Solution available on Patreon.
4. Type Conversion Table
Create a table in the following format:
byte | short | char | int | long | float | double | boolean | |
byte | ||||||||
short | ||||||||
char | ||||||||
int | ||||||||
long | ||||||||
float | ||||||||
double | ||||||||
boolean |
Write in the table:
- i (implicit) – if the conversion happens automatically.
- e (explicit) – if explicit casting is required.
- x – if conversion is not possible.
- t – if conversion is identical.
Solution available on Patreon.
5. Type Casting
Create a program that sequentially performs conversions between all compatible primitive types. Each conversion should be implemented in a separate method.
Solution available on Patreon.
6. Sum of Numbers
Create a program that calculates and displays the sum of two integers entered by the user using the Scanner class. If the input is incorrect, display an error message.
Solution available on Patreon.

Please log in or register to have a possibility to add comment.