āœļø Explanatory Question

Which of the following will compile correctly?

  1. float f=10f;
  2. float f=10.1;
  3. float f=10.1f;
  4. byte b=10b;
šŸ‘ 14 Views
šŸ“˜ Detailed Answer
🟢 Easy
šŸ’”

Answer with Explanation

āœ” Correct:

  • float f=10f;
  • float f=10.1f;

āŒ Incorrect:

  • float f=10.1; → double by default
  • byte b=10b; → no such literal suffix

šŸ‘‰ Note:

  • Decimal numbers → default type is double
  • Use f for float