Master the Java Language Lexicon: From Identifiers to Comments. Tasks

Author: Tatyana Milkina

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:

  1. Boolean
  2. String
  3. Character
  4. Binary integer
  5. Octal integer
  6. Decimal integer
  7. Hexadecimal integer
  8. Float literal
  9. Double literal

Solution available on Patreon.

3. Calculator

  1. Create a method that takes two int variables as input.
  2. The method calculates their sum and returns the result.
  3. Call this method from the main method.
  4. Create additional methods for subtraction, multiplication, and division.

Solution available on Patreon.

4. Type Conversion Table

Create a table in the following format:

Type conversion table
  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.

Курс 'Java для начинающих' на Udemy Курс 'Java для начинающих' на Udemy
Read also:
Comments