File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes KB queston pg 5o1 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "KB queston pg 5o1" Watch "KB queston pg 5o1" New topic

KB queston pg 5o1

Dinesh Tahiliani
Ranch Hand

Joined: Aug 06, 2007
Posts: 486
class Keyboard

class Computes extends Keyboard implements Serialoizable
KeyBoard k = new keyboard();
public static void main(String a[])
Computer c = new Computer();

void storeit()
ObjectOutputStream os = new ObjectOutputStream( new FileOutputStream("myfile"));
os. writeObject(c);


catch(Exception x)


Answer - exc

Can anyone please explain the output..

Thanks<br />Dinesh
Deepak Bala

Joined: Feb 24, 2006
Posts: 6662

Can you post the error you get ?

From a glance it appears that the entire object graph is not serializable and that is why an exception is thrown.

SCJP 6 articles - SCJP 5/6 mock exams - More SCJP Mocks
Yaroslav Ashurin

Joined: Apr 25, 2008
Posts: 22

Hey Dinesh,
The Keyboard class does not implement Serializable interface; Computer class has-a Keyboard, and Runtime error happens when you attempt to serialize the c object. Declare Keyboard k as transient, that should help.


SCJP 1.5
I agree. Here's the link:
subject: KB queston pg 5o1
It's not a secret anymore!