Question: Question: In Java, what is the primary role of the transient keyword when applied to a field in a class? A) It prevents the field
Question: In Java, what is the primary role of the transient keyword when applied to a field in a class?
A) It prevents the field from being included in the serialized form of the object, thus not being saved or restored during serialization.
B) It ensures that the field is initialized to a default value when an object of the class is created.
C) It makes the field thread-safe by preventing multiple threads from accessing it simultaneously.
D) It allows the field to be accessed only within the class where it is declared, regardless of its access modifier.
Step by Step Solution
There are 3 Steps involved in it
The detailed answer for the above question is provided below The correct option is A It prevents the field from being included in the serialized form ... View full answer
Get step-by-step solutions from verified subject matter experts
