
Asked in Ernst & Young
How can we create our own immutable class?
Anonymous
2y
Immutable class in java means that once an object is created, we cannot change its content. In Java, all the wrapper classes (like Integer, Boolean, Byte, Short) and String class is immutable. We can create our own immutable class as well. Prior to going ahead do go through characteristics of immutability in order to have a good understanding while implementing the same. Following are the requirements:
The class must be declared as final so that child classes can’t be created.
Data members in the class must be declared private so that direct access is not allowed.
Data members in the class must be declared as final so that we can’t change the value of it after object creation.
Help your peers!
Add answer anonymously...
Top Java Developer Interview Questions Asked at Ernst & Young
Q. Explain the SOLID principles of software development.
Q. What is the difference between checked and unchecked exceptions?
Q. Can you explain the working of Microservice Architecture?
Interview Questions Asked to Java Developer at Other Companies
Top Skill-Based Questions for Ernst & Young Java Developer
Java Interview Questions and Answers
250 Questions
Data Structures Interview Questions and Answers
250 Questions
Web Development Interview Questions and Answers
250 Questions
Algorithms Interview Questions and Answers
250 Questions
Software Development Interview Questions and Answers
250 Questions
Spring Boot Interview Questions and Answers
50 Questions
Stay ahead in your career. Get AmbitionBox app


Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+
Reviews
10L+
Interviews
4 Cr+
Salaries
1.5 Cr+
Users
Contribute to help millions
AmbitionBox Awards
Get AmbitionBox app

