Hi Guest
MobileUser
HomePage
Jobs
WalkIn
Articles
Agile
DotNet
WebServices
Mathematics
OOPS
WEB
SharePoint
Java
DataBase
Artificial Intelligence
BigData
Android
XML
Agile
Software
SEO
Science Techonlogy
Repository Questions
PHP
Frameworks
Server
Testing
HR
Java
TPF
Tutorial
Tools
Test and Papers
Silverlight
Science Techonlogy
----- Select Country -----
----- Select Location -----
----- Select Category -----
:) Latest Topic
general knowledge
VB.NET
SQL Query
UDDI
CLASS
JavaScript Questions
SharePoint Interview
SilverLight
WCF
beans
ASP.NET
:) Hot Jobs
:) Latest Articles
Follow
In Java how can we create immutable class?
Question Posted on 13 May 2021
Home
>>
Java
>>
Java Questions
>>
In Java how can we create immutable class?
In Java how can we create immutable class?
Below are the some important facts about how to create immutable class
(1)First we declare class as final so that it cannot be extended.
(2)Second we create all fields as private so that direct access is not allowed.
(3)Third we will not provide setter methods for variables.
(4)Fourth create all mutable fields final so that its value can be assigned only once.
(5)Fifth we will initialize all fields via a constructor performing the deep copy.
(6)Sixth we will Perform cloning of objects in the getter methods to return a copy rather than returning the actual object reference.
0
0
Input Your Comments Or suggestions(If Any)
Name
Email
(optional)
Comments
Other Important Questions
What are the main difference between Array and Arraylist
What is classloader in Java and name of some classloader
Different modules of the Spring framework
Difference between Object and Class
Most important 15 aspects that Java Developer should learn in year 2020
Top Searches:
asp net questions
vb net questions
sql query
uddl questions
class
javascript Questions
sharepoint interview questions and concept
silverlight questions and concept
wcf questions
beans
general knowledge
ajax questions
PHP
|
Biztalk
|
Testing
|
SAP
|
HR
|
Privacy policy |
Terms and Conditions
| Blog
If the copyright of any questions or content or syntax belong to you email us we will remove that(info@crackyourinterview.com or crackyourinterview2018@gmail.com)
Home
About Us
GroupChat
Sitemap
Feedback
Contact us