Saturday, July 31, 2010

Serialization: Computer.java

Courtesy of SCJP Sun® Certified Programmer for Java™ 6 Study Guide Exam (310-065) (9780071591065)
Chapter 6, Question 4

















This code will throw a run-time exception and print exc. Computer HAS-A Keyboard and because Keyboard does not implement Serializable, Computer won't get serialized.

If Keyboard also implemented Serializable, then both the objects Computer and Keyboard would be  serialized.

No comments:

Post a Comment