The Artima Developer Community
Sponsored Link

Java Answers Forum
Interfaces and Abstract Classes

2 replies on 1 page. Most recent reply: Jan 2, 2004 4:41 AM by mausam

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 2 replies on 1 page
Basant

Posts: 1
Nickname: basant
Registered: Dec, 2003

Interfaces and Abstract Classes Posted: Dec 19, 2003 2:49 AM
Reply to this message Reply
Advertisement
hi
everybody knows that an interface is a class which does not provide implementation to all its methods
but Serializable interface has no methods as such
so why it is called a interface.


Adam Duffy

Posts: 168
Nickname: adamduffy
Registered: Feb, 2003

Re: Interfaces and Abstract Classes Posted: Dec 19, 2003 3:33 AM
Reply to this message Reply
Taken from J2SE Javadocs.

Serializability of a class is enabled by the class implementing the java.io.Serializable interface. Classes that do not implement this interface will not have any of their state serialized or deserialized. All subtypes of a serializable class are themselves serializable. The serialization interface has no methods or fields and serves only to identify the semantics of being serializable.

Adam

mausam

Posts: 243
Nickname: mausam
Registered: Sep, 2003

Re: Interfaces and Abstract Classes Posted: Jan 2, 2004 4:41 AM
Reply to this message Reply
First point...

>everybody knows that an interface is a class which does not >provide implementation to all its methods
>but Serializable interface has no methods


Not having any method does not violate the rule "does not provide implementation to all its methods"

In any case its not providing any implentation to anymethod.

Now whats the use of such interface...

What i know (correct me plz if wrong) is that
interfaces like..

java.io.Serializable,
java.rmi.Remote,
java.util.EventListener,
javax.s ervlet.SingleThreadModel

are "marker" interfaces, with no methods of its own to be implement in implementing class.

like in case of Serializable the VM agrees to do the work if you simply implement Serializable.

Its like a main method is not a main method if its not static,public and has an array as parameter.

VM looks for such method and finds its a main.

Similary a class implenting Serializable interface is marked as VM for serialization.

Any more inputs??

Flat View: This topic has 2 replies on 1 page
Topic: Please consult a student on his simple work Previous Topic   Next Topic Topic: java class2exe

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use