File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Inheritence and Interfaces question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Inheritence and Interfaces question" Watch "Inheritence and Interfaces question" New topic

Inheritence and Interfaces question

Alok Pota
Ranch Hand

Joined: Mar 07, 2001
Posts: 185
class SuperObject implements Serializable {
class SubObject extends SuperObject {
Do I have to make SubObject implement Serializable or does it automatically become Serializable?

Ranch Hand

Joined: Mar 06, 2001
Posts: 123
It would inherit that from its super class ...
public class Sample {
public static void main(String[] args) {
C1 c1 = new C1();
System.out.println((c1 instanceof;
C2 c2 = new C2();
System.out.println((c2 instanceof;
class C1 implements {}
class C2 extends C1 {}
Frank Zheng
Ranch Hand

Joined: Jun 12, 2001
Posts: 76
This is a little addtion to your question.
You can use the key word "transient "to say some variables are not to be serialized and this is used to protect sensitive data from being written to a stream.

Sun Certified Java Programmer
Manfred Leonhardt
Ranch Hand

Joined: Jan 09, 2001
Posts: 1492
Hi Alok,
Prashanth is correct. In order to support the answer I can point to the AWT classes. If you have noticed that all AWT classes are subclasses of Component.
Component implements Serializable
Button doesn't implicitly implement any interface
Yet from experience and/or books we know that all AWT components are serializable! Therefore you have real proof that subclasses inherit all the functionality of the superclass.
I agree. Here's the link:
subject: Inheritence and Interfaces question
It's not a secret anymore!