Multiple choice java

HashMap is thread-safe whereas Hashtable is not10, Which of the following assignment statements is invalid?

  1. double D = 45456.444;

  2. long L = 45784;

  3. int I = L;

  4. int J = (int) D;

Reveal answer Fill a bubble to check yourself
C Correct answer
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.