Which of the following can fill in the blank in this code to make it compile? (Select 2 options.)



public void method() ˍˍˍˍ Exception{
    ˍˍˍˍˍ Exception();
}

A. On line 1, fill in throws
B. On line 1, fill in throws new
C. On line 2, fill in throw new
D. On line 2, fill in throws
E. On line 2, fill in throws new

題解

要讓方法將例外往外拋出,需使用「throws」關鍵字。要拋出一個新的例外,需使用「throw」關鍵字。要實體化出一個例外,需使用「new」運算子。