Question 31
Which Java collection class allows null key and null values, and maintains NO guaranteed insertion order?
Option E is correct. HashMap allows one null key and multiple null values without enforcing iteration order.
Which Java collection class allows null key and null values, and maintains NO guaranteed insertion order?
Option E is correct. HashMap allows one null key and multiple null values without enforcing iteration order.
What is the result of comparing two String objects in Java using the '==' operator (str1 == str2)?
Option B is correct. == in Java checks if two references point to the same heap address. .equals() checks actual string character content.
Which Java keyword is used by a class to implement an interface?
Option B is correct. Classes use 'implements' to satisfy interface contracts in Java.
What type of interface in Java contains zero methods and is used to signal JVM capabilities (e.g., Serializable, Cloneable)?
Option A is correct. Marker interfaces (empty interfaces) convey metadata to the runtime compiler/JVM.
Which modifier prevents a field variable in Java from being serialized during object stream saving?
Option C is correct. Fields marked 'transient' are skipped by the Java object serialization mechanism.