IOException vs RuntimeException Java

class Y {
    public static void main(String[] args) throws RuntimeException{//Line 1
        try {
            doSomething();
        }
        catch (RuntimeException e) {
            System.out.println(e);
        }
    }
    static void doSomething() throws RuntimeException{ //Line 2
        if (Math.random() > 0.5) throw new RuntimeException(); //Line 3
        throw new IOException();//Line 4
    }
}

Quando eu executo dois tipos de exceção (IOException em Line4 e RunTimeException em Line3), descobri que meu programa não compila até que eu indique "IOException" em minhas cláusulas throws na Linha 1 e na Linha 2.

Considerando que, se eu inverter "throws" para indicar que IOException está sendo lançada, o programa compila com sucesso como mostrado abaixo.

class Y {
    public static void main(String[] args) throws IOException {//Line1
        try {
            doSomething();
        }
        catch (RuntimeException e) {
            System.out.println(e);
        }
    }
    static void doSomething() throws IOException {//Line 2
        if (Math.random() > 0.5) throw new RuntimeException();//Line 3
        throw new IOException();//Line 4
    }
}

Por que eu deveria sempre usar "throws" para IOException mesmo que RuntimeException também seja lançado (Linha 3)?

questionAnswers(2)

yourAnswerToTheQuestion