Java Silverに関する問題を出題していきます!
問題1
次のプログラムをコンパイル、実行した結果として正しいものはどれか。
public class Practice28_Q1 { public static void main(String[] args) { double d = 1.234; int i = (int) d; d = i; System.out.println(d); } }
- 「1.234」と表示
- 「1」と表示
- 「1.0」と表示
- コンパイルエラー
- 実行時エラー
問題2
次のプログラムをコンパイル、実行した結果として正しいものはどれか。
public class Practice28_Q2 { public static void main(String[] args) { int i = 128; System.out.println((byte)i); } }
- 「128」と表示
- 「127」と表示
- コンパイルエラー
- 実行時エラー
- 1~4以外
問題3
次のプログラムをコンパイル、実行した結果として正しいものはどれか。
public class Practice28_Q3 { public static void main(String[] args) { int i = 10; String str = (String)i; System.out.println(str); } }
- 「10」と表示
- 何も表示されない
- コンパイルエラー
- 実行時エラー
- 1~4以外
問題4
次のプログラムをコンパイル、実行した結果として正しいものはどれか。
public class Practice28_Q4 { public static void main(String[] args) { int i = 10; String str = new String(i); System.out.println(str); } }
- 「10」と表示
- 何も表示されない
- コンパイルエラー
- 実行時エラー
- 1~4以外
問題5
次のプログラムをコンパイル、実行した結果として正しいものはどれか。
public class Practice28_Q5 { public static void main(String[] args) { int i = 10; String str = String.valueOf(i); System.out.println(str); } }
- 「10」と表示
- 何も表示されない
- コンパイルエラー
- 実行時エラー
- 1~4以外