1z1-809 試験問題 96

次のコードフラグメントが与えられます:
クラスCallerはCallable<String>を実装します。
文字列 str;
パブリック呼び出し元 (文字列 s) {this.str=s;}
public String call() は例外をスローします { return str.concat ("Caller");}
}
クラス Runner は Runnable を実装します {
文字列 str;
パブリックランナー (文字列 s) {this.str=s;}
パブリック void run () { System.out.println (str.concat ("ランナー"));}
}
そして
public static void main (String[] args) throws InterruptedException, ExecutionException { ExecutorService es = Executors.newFixedThreadPool(2); Future f1 = es.submit (new Caller ("Call")); Future f2 = es.submit (new Runner ("Run")); String str1 = (String) f1.get(); String str2 = (String) f2.get();//行 n1 System.out.println(str1+ ":" + str2);
}
結果はどうなりましたか?
  • 1z1-809 試験問題 97

    与えられた条件:
    1. 抽象クラス Shape {
    2 . Shape() { System.out.println("Shape"); }
    3 . 保護されたvoid area ( ) { System.out.println ("Shape"); }
    4 . }
    5 .
    6 . クラス Square は Shape を拡張します {
    7 . int 側;
    8 . 正方形のint側{
    9 . /* ここにコードを挿入 */
    1 0. this.side = サイド;
    1 1. }
    1 2. public void area ( ) { System.out.println ("Square"); }
    1 3. }
    1 4. クラス Rectangle は Square を拡張します {
    1 5. int len, br;
    1 6. 長方形 (int x, int y) {
    1 7. /* ここにコードを挿入 */
    1 8. len = x、br = y;
    1 9. }
    2 0. void area ( ) { System.out.println ("Rectangle"); }
    2 1. }
    どの 2 つの変更によりコードのコンパイルが可能になりますか?
  • 1z1-809 試験問題 98

    customers.txt にアクセス可能であり、複数の行が含まれていると想定します。
    どのコードフラグメントが customers.txt ファイルの内容を出力しますか?
  • 1z1-809 試験問題 99

    次のコードフラグメントがあるとします:

    結果はどうなりましたか?
  • 1z1-809 試験問題 100

    与えられた条件:
    パブリッククラス Product {
    int id; int 価格;
    パブリック製品 (int id, int 価格) {
    this.id = id;
    this.price = 価格;
    }
    パブリック文字列toString(){ID + ":" +価格を返します;)
    }
    そしてコードフラグメント:
    List<Product> products = new ArrayList <> (Arrays.asList(new Product(1, 10), new Product (2, 30), new Product (3, 20)); Product p = products.stream().reduce(new Product (4, 0), (p1, p2) -> { p1.price+=p2.price; return new Product (p1.id, p1.price);}); products.add(p); products.stream().parallel()
    .reduce((p1, p2) - > p1.price > p2.price ? p1 : p2)
    .ifPresent(System.out: :println);
    結果はどうなりましたか?