私は Java アソシエイト試験の勉強をしていますが、試験中に何がチェックされ、何がチェックされていないかを判断するのに苦労しています。ここで読んだものからコードを書くことができれば、それを調べたり、instanceofを実行したりできることはわかっていますが、それを判断する簡単な方法はありますか. いくつか取り上げましたが、全部覚えるのは大変です。以下は、この知識に基づく問題の試験です。
public static String readData (Path filePath)
throws IOException, IllegalArgumentException {
//implementation omitted
}
どの 2 つのコード フラグメントがコンパイルされますか?
public static void main(String[] args) {
try {
readData(Paths.get("test"));
} catch (IllegalArgumentException ex) {
System.err.println(ex);
}
}
public static void main(String[] args)
throws IOException{
readData(Paths.get("test.txt"));
}
public static void main(String[] args)
throws IllegalArgumentException{
readData(Paths.get("test.txt"));
}
public static void main(String[] args) {
readData(Paths.get("test.txt"));
}
public static void main(String[] args) {
try {
readData(Paths.get("test"));
} catch (IOException ex) {
System.err.println(ex);
}
}