File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

extending a class which implements Serializable

 
abinash das
Ranch Hand
Posts: 52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
class A implements Serializable
{
}
class B extends A
{
}
I that mean class B is serialized ?
 
Rob Spoor
Sheriff
Pie
Posts: 20396
47
Chrome Eclipse IDE Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by abinash das:
class A implements Serializable
{
}
class B extends A
{
}
I that mean class B is serialized ?

Yes it is.

Through inheritance, B also implements Serializable.
 
Ulf Dittmer
Rancher
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That doesn't mean that B is serializable, though. You need to ensure that it does not contain non-transient fields that are not serializable.
 
abinash das
Ranch Hand
Posts: 52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If So, then Why
In case Of servlets
both GenericServlet and Httpservlet both are implementing Serializable
interface,though Httpservlet extends GenericServlet .
 
Ulf Dittmer
Rancher
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There's no harm in class B declaring that it implements Serializable as well. It helps anyone looking at the source code or the javadocs, because they can see the implemented interfaces right away (without having to look at the superclass).
 
abinash das
Ranch Hand
Posts: 52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Now I understood.
Thank you.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic