Home / Questions / Which of the following will compile correctly? float f=10f; float f=10.1; float f=10.1f; byte b=10b;
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;
👁 0 Views
📘 Detailed Answer
🕒 Easy to Read
Read the answer carefully and go through the related questions on the right side to improve your understanding of this topic.

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