Are you sure that your code compiled when you commented the lines 4 and 5? It did not compile fine when I tried to do it.
It gave an error saying that the show6() method in the child class must throw IOException or it must be caught. After commenting the line throw new IOException(); your code compiled fine.
Now when the lines 4 and 5 are uncommented then there you are trying to implement polymorphism which is a runtime phenomenon. So at compile time the Parent class show6() method is referred and hence the compiler gives the error.
To compile that code you need to put the p.show6() code in a try catch block or declare the main method as throwing the IOException.