• 検索結果がありません。

問題 過去の定期試験問題 tkunishi exam

N/A
N/A
Protected

Academic year: 2018

シェア "問題 過去の定期試験問題 tkunishi exam"

Copied!
2
0
0

読み込み中.... (全文を見る)

全文

(1)

1 / 2

2006 年度「計算機言語II」定期試験問題

2007-02-07 担当教員:国島丈生

I. 用語説明

Java言語における以下の用語について説明せよ。(各10点) コンストラクタ

1.

フィールド宣言やメソッド宣言で用いられる予約語 static 2.

フィールド宣言やメソッド宣言で用いられる予約語 private 3.

インタフェース 4.

II. 継承, 抽象クラス

次のようなJavaクラスがあるとする。 public abstract class A { public abstract int a(); public abstract int a(int x); public int b() { return 100; } }

public class B extends A { private int x = 50;

public int a() { return x; } public int a(int x) { return x; } }

public class C extends B { private int y = 200; public int x = 70;

public int a() { return x+y; } public int b() { return a(20); } }

このとき、次のクラスを実行するとどのような結果が出力されるか。(1)∼(6)それぞれについて出力結果 を示せ。(各5点)

public class Example {

public static void main(String[] args) { B b = new b();

C c = new c();

System.out.println(b.a()); // (1) System.out.println(b.a(30)); // (2) System.out.println(b.b()); // (3) System.out.println(c.a()); // (4) System.out.println(c.a(30)); // (5) System.out.println(c.b()); // (6) }

}

(2)

2 / 2

III. ファイル操作

次に示すのは、引数で指定したテキストファイルの中に @ という文字がいくつ含まれているかを調べる Javaプログラムである。ただし一部未完成の箇所がある。意図通りの動作をするように、未完成の箇所を 完成させよ。(15点)

import java.io.*; public class CountAt {

public static void main(String[] args) { int count = 0; // @ の出現数を表す変数 if (args.length != 1) {

System.out.println("ファイル名を指定して下さい"); System.exit(1);

} try {

// この部分未完成

} catch (FileNotFoundException e) {

System.out.println(e); // エラー情報を表示 } catch (IOException e) {

System.out.println(e); }

System.out.println("@ の出現数は " + count); }

}

IV. 配列

次の2次元配列の合計を求め、標準出力に出力するJavaプログラムを書け。(15点) int[][] matrix = {

{4, 8, 2, 1}, {3, 2},

{7, 11, 19, 3, 2} };

参照

関連したドキュメント

問題集については P28 をご参照ください。 (P28 以外は発行されておりませんので、ご了承く ださい。)

しかし,物質報酬群と言語報酬群に分けてみると,言語報酬群については,言語報酬を与

Guasti, Maria Teresa, and Luigi Rizzi (1996) "Null aux and the acquisition of residual V2," In Proceedings of the 20th annual Boston University Conference on Language

(7) I often heard it came on the wor1d to banish all out of it,and... た,thatは殆ど常に省かれている。

では,この言語産出の過程でリズムはどこに保持されているのか。もし語彙と一緒に保

Aの語り手の立場の語りは、状況説明や大まかな進行を語るときに有効に用いられてい

[1] J.R.B\"uchi, On a decision method in restricted second-order arithmetic, Logic, Methodology and Philosophy of Science (Stanford Univ.. dissertation, University of

Relaxation of the muscles are highly relevant in the initiation of pitch fall and rise: a quick fall from the high pitch range is initiated by suppressing