code for all the snippets described in the core java training