Java Silverに関する問題を出題していきます!
■問題1
次のプログラムをコンパイル、実行した結果として正しいものはどれか。
1 2 3 4 5 6 7 8 9 10 | public class Sample { public static void main(String[] args) { for ( int i = 0 ; i < 10 ; i++) { System.out.print(i); if (i % 3 == 0 ) { continue ; } } } } |
- 「0123456789」と表示
- 「123456789」と表示
- 「0124578」と表示
- 「124578」と表示
- コンパイルエラー
■問題2
次のプログラムをコンパイル、実行した結果として正しいものはどれか。
1 2 3 4 5 6 7 8 9 10 | public class Sample { public static void main(String[] args) { for ( int i = 0 ; i < 10 ; i++) { if (i % 3 == 0 ) { continue ; System.out.print(i); } } } } |
- 「0123456789」と表示
- 「123456789」と表示
- 「0124578」と表示
- 「124578」と表示
- コンパイルエラー
■問題3
次のプログラムをコンパイル、実行した結果として正しいものはどれか。
1 2 3 4 5 6 7 8 9 10 | public class Sample { public static void main(String[] args) { for ( int i = 0 ; i < 10 ; i++) { if (i % 3 == 0 ) { continue ; } System.out.print(i); } } } |
- 「013456789」と表示
- 「123456789」と表示
- 「0124578」と表示
- 「124578」と表示
- コンパイルエラー
■問題4
次のプログラムをコンパイル、実行した結果として正しいものはどれか。
1 2 3 4 5 6 7 8 9 10 11 12 | public class Sample { public static void main(String[] args) { mylabel: for ( int i = 1 ; i <= 3 ; i++) { for ( int j = 1 ; j <= 3 ; j++) { if (i == 1 ) { break ; } System.out.print(i * j); } } } } |
- 「123246369」と表示
- 「246369」と表示
- 「234669」と表示
- 何も表示されない
- コンパイルエラー
■問題5
次のプログラムをコンパイル、実行した結果として正しいものはどれか。
1 2 3 4 5 6 7 8 9 10 11 12 | public class Sample { public static void main(String[] args) { mylabel: for ( int i = 1 ; i <= 3 ; i++) { for ( int j = 1 ; j <= 3 ; j++) { if (i == 1 ) { break mylabel; } System.out.print(i * j); } } } } |
- 「123246369」と表示
- 「246369」と表示
- 「234669」と表示
- 何も表示されない
- コンパイルエラー