Java Socket Specification and Implementation

Asked

Viewed 53 times

1

I created a class MySocket that extends java.net.Socket, but I saw that class java.net.Socket implements the interface java.io.Closeable, and my question is: In my class MySocket I am obliged to implement also the interface Closeable, or for being a child of the class java.net.Socket it automatically already implements Closeable?

1 answer

1


Depends on what you did in your class. I would say probably not, I believe that what has been implemented in the mother class is enough, I don’t think you need to do anything else. But if you need to do something specific for your class when closing, then you have to override the close() in your class, doing what you need and calling super.close().

  • Thank you very much!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.