Search Interview Questions | More than 3000 questions in repository. There are more than 900 unanswered questions. Click here and help us by providing the answer. Have a video suggestion. Click Correct / Improve and please let us know. |
|
| ||||
Core Java - Interview Questions and Answers for 'Immutability classe' - 3 question(s) found - Order By Rating | ||||
| ||||
Ans. Immutable objects are thread-safe so you will not have any synchronization issues.Immutable objects are good for Map keys and Set elements, since these typically do not change once created.Immutability makes it easier to write, use and reason about the code (class invariant is established once and then unchanged)Immutability makes it easier to parallelize your program as there are no conflicts among objects.The internal state of your program will be consistent even if you have exceptions.References to immutable objects can be cached as they are not going to change. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  immutable  immutability classes   benefits of immutable  immutability classes Asked in 1 Companies | ||||
Related Questions | ||||
Why is String immutable in Java ? | ||||
Why Char array is preferred over String for storing password? | ||||
How does making string as immutable helps with securing information ? How does String Pool pose a security threat ? | ||||
How is string object immutable if we can concat a string to it ? | ||||
How to implement an immutable class ? | ||||
What is an immutable class ? | ||||
What is an Immutable Object ? | ||||
Does Declaring an object "final" makes it immutable ? | ||||
Is String final in Java ? | ||||
What are stateless objects ? How are they different from immutable objects ? Which of these two is thread safe ? | ||||
| ||||
Ans. string and wrapper class objects | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  immutability  immutable  immutability classes   immutable  immutability collections Asked in 3 Companies | ||||
Related Questions | ||||
Why is String immutable in Java ? | ||||
Why Char array is preferred over String for storing password? | ||||
How does making string as immutable helps with securing information ? How does String Pool pose a security threat ? | ||||
How is string object immutable if we can concat a string to it ? | ||||
How to implement an immutable class ? | ||||
What is an immutable class ? | ||||
What is an Immutable Object ? | ||||
Does Declaring an object "final" makes it immutable ? | ||||
Is String final in Java ? | ||||
What are stateless objects ? How are they different from immutable objects ? Which of these two is thread safe ? | ||||
| ||||
Ans. There is no concept of de referencing with primitive types and hence they are implicitly immutable. Having wrapper classes as mutable offers disadvantages compared to primitive types. Wrapper classes being immutable offer similar advantage as primitive types.It actually overshadows the disadvantage wrapper class could have if they are immutable. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  immutable  immutability classes  wrapper classes | ||||
Related Questions | ||||
Will this code give error if i try to add two heterogeneous elements in the arraylist. ? and Why ? | ||||
What are the Wrapper classes available for primitive types ? | ||||
What are wrapper classes ? | ||||
What are the benefits of using Wrapper classes over primitive types ? | ||||
Explain Autoboxing ? | ||||
What is the difference between uninitialized values for primitive types and Wrapper classes ? | ||||
Difference between boolean and Boolean ? | ||||
What are Wrapper Classes ? What are Primitive Wrapper Classes ? | ||||
What Design pattern Wrapper Classes implement ? | ||||
Can we compare Integers by using equals() in Java ? | ||||