🎴 Flashcard Mode
Java Fundamentals: Types, Control Flow, and Classes
Card1 / 10
Mastered0
Review0
QuestionClick to flip
HashMap is thread-safe whereas Hashtable is not10, Which of the following assignment statements is invalid?
AnswerClick to flip back
A
int I = L;
💡 Explanation:
Java requires explicit casting when assigning a larger type (like long or double) to a smaller type (like int) because of potential data loss. Assigning a long to an int directly (Option C) is a compile-time error without a cast. Option D is valid because it uses an explicit cast.