Give examples of literals for each of the following types: String, char, long, int, float, double, boolean.

a) "Hello", 'A', 123L, 42, 3.14f, 2.718, true
b) "123", 'X', 9876543210L, 55, 6.66f, 99.9, false
c) "abc", 'Z', 100L, 7, 1.0f, 2.5, true
d) "xyz", 'B', 999L, 18, 0.5f, 3.0, false

Answer :

Final answer:

Examples of literals for String, char, long, int, float, double, and boolean data types.

Explanation:

Examples of literals for each data type are:

  • String: 'Hello'
  • Char: 'A'
  • Long: 123L
  • Int: 42
  • Float: 3.14f
  • Double: 2.718
  • Boolean: true

These examples demonstrate different literals for the given data types, such as a string literal 'Hello', a char literal 'A', a long literal 123L, an int literal 42, a float literal 3.14f, a double literal 2.718, and a boolean literal true.