🎴 Flashcard Mode

Programming Languages and OOP Concepts

Card1 / 20
Mastered0
Review0
QuestionClick to flip

System.out.format("Pi is approximately %d.", Math.PI); What is the result?

AnswerClick to flip back
A
An exception is thrown at runtime
💡 Explanation:

%d format specifier expects an integer but Math.PI is a double. This causes java.util.IllegalFormatConversionException at runtime. The code compiles successfully because the type mismatch is only detected during formatting, not at compile time.

Change Mode