给出以下代码,为了结果输出-12.0,方法method(d)应为以下哪个方法?
public class Example {
public static void main(String[] args) {
double d = -11.1;
double d1 = method(d);
System.out.println(d1);
}
}
现有如下代码:
public class Example {
public static void main(String[] args) {// a
new Example().topGo();
}
void topGo() {// b
middleGo();
}
void middleGo() {// c
go();
System.out.println("late middle");
}
void go() {// d
throw new Exception();
}
}
为了使代码能够编译通过,需要在哪个地方加入声明throws Exception?