Computer Science, asked by sabeenakabaskar, 2 months ago

Write the type of literal for the following:
i) “school"
ii) 12.45
iii) True
iv)0x998​

Answers

Answered by RoDipu
0

Explanation:

Write the type of literal for the following:

i) “school"

ii) 12.45

iii) True

iv)0x998

Answered by dreamrob
0

Answer:

1) "school" → String literal

ii) 12.45 → Floating point literal

iii) True → Boolean literal

iv) 0x998​ → Integer literal (Hexadecimal literal)

Types of literals in Java:

  • Integer Literals
  • Boolean Literals
  • Character Literals
  • String Literals
  • Floating Point Literals

Integer Literal

  • Decimal Literals: int a = 34
  • Binary Literals: int a = 0b101
  • Hexadecimal Literals: int a = 0x19
  • Octal Literals: int a = 024
  • Long Literals: long a = 123456789

Boolean Literal

bool a = true;

bool b = false;

Character Literal

char a = 'g'

String Literal

String a = "Hello World";

Floating Point Literal

  • float a = 2.4f;
  • double a = 23.5456d;
Similar questions