Java 模擬問題集

ランダム 未解答 評価
問題文 (Java) 前回の結果 お気に入り
コメントについて書かれた次の文章について、正しいものを選択してください。

正解率:67% | 評価:0

次のプログラムの空欄ア~エを埋めてプログラム完成させてください。 import java.【 ア 】.*; class Sample { public static void main(String[] args) { ArrayList<String> al = new ArrayList<String>(); al.add("Java"); al.add("Program"); al.add("Sample"); Iterator it = al.【 イ 】; while(it.【 ウ 】) { System.out.println(it.【 エ 】); } } }

正解率:14% | 評価:1

以下の選択肢からオブジェクト指向の基本概念を3つ選択しなさい

正解率:62% | 評価:3

次のプログラムをコンパイルし、実行するとどうなるか。正しいものを選択してください。 class Sample { public static void main(String[] args) { int a = 3; do { a++; } while(a = 3); System.out.println(a); } }

正解率:43% | 評価:31

配列の宣言として誤っているものはどれか?

正解率:49% | 評価:20

メソッド名が同じで、引数が異なるメソッドを定義することを何というか。正しいものを1つ選んでください。

正解率:77% | 評価:0

public class Test3 { public static void main(String[] args) { String str = "null"; if(str == null) { System.out.print("null"); } else(str.length() == 0) { System.out.print("ZERO"); } else { System.out.print("some"); } } }

正解率:75% | 評価:0

java.util.zip.ZipFileクラスを利用するための正しいimport文をすべて選んでください。

正解率:50% | 評価:5

プログラミング言語をコンピュータが理解することのできる機械語へ翻訳するプログラムを何というか。 正しいものを1つ選択してください。

正解率:92% | 評価:0

次のプログラムをコンパイルし、実行するとどうなるか。正しいものを選択してください。 class Exam { static void textPrint() { System.out.println("Exam"); } } class Sample extends Exam { public static void main(String[] args) { Sample.textPrint(); } static void textPrint() { System.out.println("Sample"); } }

正解率:68% | 評価:6

次は、コンパイル、実行すると画面に「X」または「Y」と表示するプログラムです。空欄Aに入る文として適切なものを選んでください。 class Sample { public static void main(String[] args) { String s = null; 【 A 】 { System.out.println("X"); } else { System.out.println("Y"); } } }

正解率:48% | 評価:18

次のプログラムをコンパイルし、実行するとどうなるか。正しいものを選択してください。 01: class Sample { 02: static int a; 03: public static void main(String[] args) { 04: try { 05: int b = 2 / a; 06: System.out.println(b); 07: } catch(ArrayIndexOutOfBoundsException e) { 08: System.out.println("catch"); 09: } finally { 10: System.out.println("finally"); 11: } 12: } 13: }

正解率:48% | 評価:0

次の内、コンパイルエラーになるものは?

正解率:59% | 評価:26

次のプログラムをコンパイルし、実行するとどうなるか。正しいものを選択してください。 01: class Sample { 02: public static void main(String[] args) { 03: int a = 10; 04: byte b = (byte)a; 05: String c = (String)b; 06: System.out.println("OK"); 07: } 08: }

正解率:62% | 評価:94

次のプログラムをコンパイルし、実行するとどうなるか。正しいものを選択してください。 01: class Sample { 02: public static void main(String[] args) { 03: TextPrint1 tp1 = new TextPrint1(); 04: tp1.message(); 05: } 06: } 07: abstract class TextPrint1 { 08: abstract void message(); 09: } 10: class TextPrint2 extends TextPrint1 { 11: void message() { 12: System.out.println("Java"); 13: } 14: }

正解率:51% | 評価:31

public class Test { public static void hello(){ System.out.print("HelloJAVA "); } public static int sum(int a, int b){ int sum = a+b; return sum; } public static int max(int a, int b){ return a>b?a:b; } public static void main(String[] args) { hello(); sum(20, 21); System.out.print("[10と20の最大値]:"+max(10,20)); } }

正解率:55% | 評価:3

1~10の中で偶数のみを合計する関数を作成する。 正しいものを全て選べ。 public class hoge { public static void main(String[] args) { int sum = 0; int i = 1; //1~10の整数のうち、偶数を足す 【ア、イ】 { // 偶数か 【ウ、エ】 } System.out.println(sum); } } ウ if (i % 2 ==0 ) { sum += i; } エ switch(i % 2) { case 0: sum += i; break; default: break; }

正解率:35% | 評価:0

次のプログラムをコンパイルし、実行するとどうなるか。 正しい答えを選んでください。 class superClass { public void textPrint() { System.out.println("superClass"); } } class subClass extends superClass { void textPrint() { System.out.println("subClass"); } } class Sample { public static void main(String[] args) { superClass sc = new subClass(); sc.textPrint(); } }

正解率:44% | 評価:0

次のプログラムをコンパイルし、実行するとどうなるか。正しいものを選択してください。 01: interface Exam { 02: void setNum(int a); 03: } 04: class Lesson implements Exam { 05: int num; 06: void setNum(int a) { 07: num += a; 08: } 09: } 10: class Sample { 11: public static void main(String[] args) { 12: Lesson lesson = new Lesson(); 13: lesson.setNum(10); 14: System.out.println(lesson.num); 15: } 16: }

正解率:34% | 評価:22

次のプログラムをコンパイルし class Sample { public static void main(String args[]) { System.out.println(args[2]); } } コマンドプロンプトから >java Sample A B C D を実行すると、何が表示されるか、正しい答えを選んでください。

正解率:95% | 評価:5

次のプログラムをコンパイルし、実行するとどうなるか。正しいものを選択してください。 1. 2. public class Person { 3. String name = "no name"; 4. public Person(String nm){ name = nm;} 5. } 6. 7. public class Employee extends Person{ 8. String empId = "0000"; 9. public Employee(String id){ 10. empId = id; 11. } 12. } 13. 14. public class EmployeeTest { 15. public static void main(String[] args) { 16. Employee e = new Employee("4321"); 17. System.out.println(e.empId); 18. } 19. } 20.

正解率:41% | 評価:28

次の文章で、間違っているものを選んでください。

正解率:47% | 評価:1

次のプログラムをコンパイルし、実行した結果、画面には何が表示されるか。正しいものを選択してください。 class Sample { public static void main(String[] args) { int a = 2; int b = 5; int c = 5; int d = 3; System.out.println(a + (b + c) / 3); } }

正解率:74% | 評価:62

以下のプログラムをコンパイル、実行した場合の結果として、正しいものを以下から選びなさい。 public class Test { public static void main(String[] args) { int i = 3; i+= 5.0; System.out.println(i); } }

正解率:53% | 評価:22

次のプログラムをコンパイルし、実行するとどうなるか。正しいものを選択してください。 import java.util.*; class Sample { public static void main(String[] args) { ArrayList<String> al = new ArrayList<String>(); al.add(10); al.add(20); al.add(30); Iterator it = al.iterator(); while(it.hasNext()) { System.out.println(it.next()); } } }

正解率:47% | 評価:8

次はコンパイルし実行すると、画面にAとBを表示するプログラムです。空欄ア~空欄ウを埋めてプログラムを完成させてください。 class Sample { class TxtPrint1 { void message() { System.out.println("A"); } } static class TxtPrint2 { void message() { System.out.println("B"); } } public static void main(String[] args) { TxtPrint1 tp1 = 【 ア 】.【 イ 】; TxtPrint2 tp2 = 【 ウ 】; tp1.message(); tp2.message(); } }

正解率:13% | 評価:22

次のプログラムをコンパイルし、実行すると画面に表示される文字列は何か。表示される順に2つアとイに解答してください。 abstract class Animal { String getText() { return "Animal"; } abstract String getWalk(); } class Lion extends Animal { String getText() { return "Lion"; } String getWalk() { return "walk"; } } class Sample { public static void main(String[] args) { Lion lion = new Lion(); System.out.println(lion.getText()); System.out.println(lion.getWalk()); } }

正解率:80% | 評価:0

次は、コンパイル後実行すると、カレントフォルダにあるテキストファイル「data.txt」を読み込み、その内容を画面に表示するプログラムです。 テキストファイル「data.txt」が存在しない場合には、画面に「A」を表示します。 空欄ア~エを埋めてプログラムを完成させてください。 import java.【 ア 】.*; class Sample { public static void main(String[] args) { try { 【 イ 】 br = new 【 イ 】(new 【 ウ 】("data.txt")); String moji; while((moji = br.readLine()) != null) { System.out.println(moji); } br.close(); } catch(【 エ 】 e) { System.out.println("A"); } catch(IOException e) { System.out.println("B"); } catch(Exception e) { System.out.println("C"); } } }

正解率:22% | 評価:11

次のプログラムのメソッド中で生成する文字列「Java」を持つString型オブジェクトが、ガベージコレクションの対象となるのはいつか。正しいものを選択してください。 01: class Sample { 02: void textPrint() { 03: String a = new String("Java"); 04: String b = new String(""); 05: b = a; 06: System.out.println(a); 07: a = null; 08: b = null; 09: } 10: }

正解率:40% | 評価:11

次のプログラムをコンパイルし、実行するとどうなるか。正しいものを選択してください。 class Sample { public static void main(String[] args) { int num = 10; int nuM = 30; System.out.println(num); } }

正解率:89% | 評価:1

class tour{ private String country="JAPAN"; public String getC(){return country;} } class Money extends tour{ public String getC(){return super.country;} } public class Yen extends Money{ public String getC(int x){return super.getC();} public static void main(String[] args0){ System.out.print(new Money().getC()+" "+new Yen.getC()); } }

正解率:71% | 評価:2

配列について説明した次の文章について、正しいものはどれか。選択してください。

正解率:38% | 評価:0

クラス「ArrayList」はどのパッケージに定義されているか。

正解率:78% | 評価:10

次のプログラムをコンパイルし、実行するとどうなるか。正しいものを選択してください。 class Sample { public static void main(String[] args) { TextPrint2 tp2 = new TextPrint2(); tp2.message(); } } class TextPrint1 { void message() { System.out.println("TextPrint1"); } } class TextPrint2 extends TextPrint1 { void message() { System.out.println("TextPrint2"); } }

正解率:87% | 評価:15

次のプログラムをコンパイルし、実行するとどうなるか。正しい答えを選んでください。 1 : public class Sample { 2 : public static void main(String[] args) { 3 : for(int i = 1; i < 3; i++) { } 4 : System.out.println(i); 5 : } 6 : }

正解率:59% | 評価:0

変数名として使えるものはどれか。

正解率:43% | 評価:0

次のプログラムをコンパイルし、実行するとどうなるか。正しいものを選択してください。 class MyException extends Exception { public MyException() { super("MyException"); } } class Sample { public static void main(String[] args) { try { message(1); } catch(MyException e) { System.out.println(e.getMessage()); } finally { System.out.println("finally"); } } static void message(int num) throws MyException { if(num > 0) { throw new MyException(); } } }

正解率:64% | 評価:0

次のプログラムをコンパイルし、カレントフォルダに「data.txt」が存在しない状態で実行した場合、画面に「catch」と表示させるには、空欄Aに何を記述すればよいか。選択してください。 import java.io.*; class Sample { public static void main(String[] args) { try { BufferedReader br = new BufferedReader(new FileReader("data.txt")); br.close(); } catch(【 A 】 e) { System.out.println("catch"); } catch(IOException e) { System.out.println("IOException"); } } }

正解率:92% | 評価:0

Javaの例外処理について書かれた次の文章について正しいものを全て選択してください。

正解率:56% | 評価:12

次のプログラムをコンパイルし、実行した結果画面に表示される変数「a」の値は何か。解答欄アに入力してください。 class Sample { public static void main(String[] args) { int a = 0; for(int i = 0; i < 3; i++) { a += 2; i = a; } System.out.println(a); } }

正解率:51% | 評価:10

次のコードは、コンパイルエラーになるか? double d = 10; float f = d;

正解率:76% | 評価:10

以下のプログラムをコンパイル、実行した場合の結果として、正しいものを以下から選びなさい。 public class Test { public static void main(String[] args) { for (int i=3; i<3; i++){ System.out.println(i); } } }

正解率:83% | 評価:0

次のプログラムをコンパイルし、実行するとどうなるか。正しいものを選択してください。 import java.util.*; class Sample { public static void main(String[] args) { ArrayList al = new ArrayList<String>(); al.add(10); al.add("20"); al.add(30); Iterator it = al.iterator(); while(it.hasNext()) { System.out.println(it.next()); } } }

正解率:40% | 評価:14

Javaプログラムの特徴として正しいものを2つ選択してください。

正解率:85% | 評価:2

次のプログラムをコンパイルし、実行した場合、画面に「catch」と表示させるには、空欄Aに何を記述すればよいか。選択してください。 class Sample { public static void main(String[] args) { try { int a = 0; System.out.println(5 / a); } catch(【 A 】 e) { System.out.println("catch"); } } }

正解率:64% | 評価:0

次の中で変数名として使えないものを全て選んでください。

正解率:40% | 評価:9

以下の式を実行したときの結果として、正しいものを選びなさい(ただし各式が正常に実行されるように、クラスは正しく作成されているものとする)。 System.out.println(5%3); System.out.println(5%-3); System.out.println(-5%3); System.out.println(-5%-3);

正解率:46% | 評価:6

次のプログラムをコンパイルし、実行するとどうなるか。 正しい答えを選んでください。 interface IF { void textPrint(); } class SampleIF implements IF { void textPrint() { System.out.println("SampleIF"); } } class Sample { public static void main(String[] args) { IF sif = new SampleIF(); sif.textPrint(); } }

正解率:0% | 評価:0

次のプログラムをコンパイルし、実行するとどうなるか。正しいものを選択してください。 class Exam { private int num = 0; void setNum(int a) { this.num = a; } int getNum() { return this.num; } } class Sample { public static void main(String[] args) { Exam exam1 = new Exam(); Exam exam2 = new Exam(); exam1.setNum(10); exam2.setNum(20); exam1 = exam2; exam2.setNum(30); System.out.println(exam1.getNum() + ", " + exam2.getNum()); } }

正解率:62% | 評価:12

次のプログラムをコンパイルし、実行するとどうなるか。正しいものを選択してください。 class MyException extends Exception { public MyException() { super("MyException"); } } class Sample { public static void main(String[] args) { try { System.out.println("A"); throw new MyException(); } catch(Exception e) { System.out.println("B"); } catch(MyException e) { System.out.println("C"); } } }

正解率:43% | 評価:22