Serializable interface in Java

0 votes

Since Serializable is an empty interface which makes Java robust when it is implemented, why it's not implemented to all the classes by default?

Please explain.

Jun 12, 2018 in Java by misc.edu04
• 1,380 points

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

Serializable is a marker interface that has no data member and method. It is used to mark java classes to provide them with certain capabilities. If automatic serialization support is provided it will make the class internal a part of public API. This restricts from making any changes to class design which breaks encapsulation. Moreover, serialization sometimes can also lead to many security issues such as now any class can access data which normally it can’t. Also, the serialized form of an inner class is generally not being well defined.

So, if we make all the classes Serializable, it will only worsen the issue. Hope now you get the reason behind why classes are not Serializable by default.

answered Jun 12, 2018 by code.reaper12
• 3,450 points

Related Questions In Java

0 votes
1 answer

Retrieve all the implementations of an interface in Java

Hi...I think you can achieve this by ...READ MORE

answered Jul 23, 2018 in Java by anto.trigg4
• 3,420 points
0 votes
1 answer
+1 vote
3 answers

What is the syntax to declare and initialize an array in java?

You can use this method: String[] strs = ...READ MORE

answered Jul 25, 2018 in Java by samarth295
• 2,190 points
0 votes
1 answer

How can I convert a String variable to a primitive int in Java

You can convert a String to int by using a function: int ...READ MORE

answered Apr 12, 2018 in Java by sharth
• 3,310 points
0 votes
1 answer

What is the use of serialVersionUID ?

The docs for are probably about as good ...READ MORE

answered Jun 21, 2018 in Java by Rishabh
• 3,520 points
0 votes
1 answer

How to tell Jackson to ignore a field during serialization if its value is null?

To suppress serializing properties with null values ...READ MORE

answered Jul 4, 2018 in Java by Rishabh
• 3,520 points
0 votes
1 answer

Use annotation for excluding specific fields from serialization

Simply mark the desired fields with the ...READ MORE

answered Feb 1 in Java by developer_1
• 3,220 points
+5 votes
3 answers

How to execute a python file with few arguments in java?

You can use Java Runtime.exec() to run python script, ...READ MORE

answered Mar 27, 2018 in Java by DragonLord999
• 8,360 points

edited Nov 6, 2018 by Omkar 4,557 views
0 votes
1 answer

Purpose of “String args[]” in the “psvm” of Java

Let me give you the complete explanation ...READ MORE

answered May 7, 2018 in Java by code.reaper12
• 3,450 points
0 votes
1 answer

Need for finalize() in Java

finalize() is a method called by the ...READ MORE

answered May 8, 2018 in Java by code.reaper12
• 3,450 points

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.