title: Java - socket inheritance
body: <p>I've written a class which extends Socket class - with the intention of retaining all the methods from a regular socket, while adding two methods of my own:</p>
  
  <pre><code>public class ClientSocket extends Socket{
  
  private long lastOnline;
  
  public ClientSocket() {
        super();
  }
  
  public long getLastOnline() {
      return lastOnline;
  }
  
  public void setLastOnline(long lastOnline) {
      this.lastOnline = lastOnline;
  }
  </code></pre>
  
  <p>When I'm trying to initialize a new instance of this class, and to add an open socket to it, I'm doing something wrong (or maybe something is wrong with me ), and it tells me that I cannot set a socket to ClientSocket object (although it extends Socket):</p>
  
  <pre><code>ClientSocket socket = serverSocket.accept();
  </code></pre>
  
  <p>How can I resolve this? Thanks!</p>