Specification and Implementation Java Socket

1

I created a class MySocket that extends java.net.Socket , however I saw that the java.net.Socket class implements the java.io.Closeable interface, and my question is: In my MySocket class I have to implement the interface Closeable , or because it is a child of class java.net.Socket it automatically already implements Closeable ?

    
asked by anonymous 02.09.2016 / 20:34

1 answer

1

It depends on what you did in your class. I would say probably not, I believe that what was implemented in the parent class is enough, I do not think I need to do anything else. But if you need to do something specific to your class at the time of closing, you will have to overwrite the close() in your class, doing what you need and calling super.close() .

    
02.09.2016 / 20:48