You should look in the API. For example
this is the socket class documentation; if you look at the close() method, it tells you whether it throws any Exceptions. And I agree with JV’s suggestion you look for the Java™ Tutorials, which are well worth reading: try
here.
You should bookmark the API and the tutorial in your web browser.