サンプル問題
1Z0-804 問題集 Oracle Java SE 7 Programmer II
問題:
DataFormat df;
どの文は、英国のローカルのデフォルトの日付形式を表示する新しいDateFormatオブジェクトを定義していますか?
(A). df = DateFormat.getdatDataInstance (DateFormat.DEFAULT, Locale (UK));
(B). df = DateFormat.getdatDataInstance (DateFormat.DEFAULT, UK);
(C). df = DateFormat.getdatDataInstance (DateFormat.DEFAULT, Locale.UK);
(D). df = new DateFormat.getdatDataInstance (DateFormat.DEFAULT, Locale.UK);
(E). df = new DateFormat.getdatDataInstance (DateFormat.DEFAULT, Locale (UK));
解答:C
問題:
public class DoubleThread {
public static void main(String[] args) {
Thread t1 = new Thread() {
public void run() {
System.out.print("Greeting");
}
};
Thread t2 = new Thread(t1); // Line 9
t2.run();
}
}
どの2つは正しいですか?
(A). ランタイム例外は、9行目でスローされます。
(B). 何も出力されません。
(C). Greetingが一度出力されます。
(D). Greetingが二回出力されます。
(E). 実行のいかなる新たなスレッドも、mainメソッド内で開始されていません。
(F). 実行の一つの新しいスレッドは、mainメソッド内で開始されます。
(G). 。実行の2つの新しいスレッドがmainメソッド内で起動されます。
解答:C、E
問題:
import java.util.*;
public class AccessTest {
public static void main(String[] args) {
Thread t1 = new Thread(new WorkerThread());
Thread t2 = new Thread(new WorkerThread());
t1.start(); t2.start; // line1
}
}
class WorkPool {
static ArrayList<Integer> list = new ArrayList<>(); // line2
public static void addItem() { // line3
list.add(1); // Line4
}
}
class WorkerThread implements Runnable {
static Object bar = new Object ();
public void run() { //line5
for (int i=0; i<5000;i++) WorkPool.addItem(); // line6
}
}
どの4つが、スレッドt1とt2の間の有効なリストへのアクセスを同期するための有効な変更が加えられたものですか?
(A). line 1を以下で置き換えます
Synchronized (t2) (t1.start();) synchronized(t1) (t2.start();)
(B). Line 2 with:
static CopyWriteArrayList<Integer> list = new CopyWriteArrayList<>();
(C). line 3を以下で置き換えます
synchronized public static void addItem () {
(D). line 4を以下で置き換えます
synchronized (list) (list.add(1);)
(E). line 5を以下で置き換えます
Synchronized public void run () {
(F). line 6を以下で置き換えます
Synchronized (this) {for (in i = 0, i<5000, i++) WorkPool.addItem(); }
(G). line 6を以下で置き換えます:
synchronized (bar) {for (int i= 0; i<5000; i++) WorkPool.addItem(); }
解答:F
問題:
サムは、アプリケーションを設計しています。それほど頻繁にクリティカルでないタスクから重要かつ頻繁に実行されるタスクを分離します。その実行の重要性と頻度で、これらのタスクに優先順位を付けています。厳重な検査の後、彼はクリティカルでないと判断したタスクはあまり実行されないことに気づきます。
どのタイプの問題をアプリケーション抱えますか?
(A). race condition
(B). starvation
(C). deadlock
(D). livelock
解答:C
問題:
Class Employee {
public int checkEmail() {/* . . . */}
public void sendEmail (String email) {/* . . . */}
public Boolean validDateEmail(){/* . . . */}
public void printLetter (String letter) {/* . . . */}
}
どれが正しいのですか?
(A). Employeeは、組成物を利用しています。
(B). EmployeeはEmail持っている"。
(C). EmployeeはLetterPrinterです。
(D). Employeeは、低凝集力を持っています。
解答:D
問題:
どの2つは、synchronizedキーワードの有効な使用メソッドを示しますか?
(A). interface ThreadSafe {
synchronized void doIt();
}
(B). abstract class ThreadSafe {
synchronized abstract void doIt();
}
(C). class ThreadSafe {
synchronized static void soIt () {}
}
(D). enum ThreadSafe {
ONE, TWO, Three;
Synchronized final void doIt () {}
}
解答:C
問題:
submit(Data) {
if(Data.size < SMALL_ENOUGH) {
_________________(Data); // line x
}
else {
List<Data> x = _________________(Data); // line Y
for(Data d: x
______________(d); // line z
}
}
And given the missing methods:
process, submit, and splitInHalf
どの3つの挿入が適切に擬似コードを完了しますか?
(A). ラインXにsubmitを挿入
(B). ラインXでsplitInHalfを挿入
(C). ラインXでprocessを挿入
(D). ラインYでprocessを挿入
(E). ラインYにsplitInHalfを挿入
(F). ラインZでprocessを挿入
(G). 。ラインZ.でsubmitを挿入
解答:C、E、G、
問題:
ITEM Table
* ID, INTEGER: PK
* DESCRIP, VARCHAR(100)
* PRICE, REAL
* QUALITY, INTEGER
try {
String query = "SELECT * FROM Item WHERE ID=110";
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery(query);
while (rs.next ()) {
System.out.println("ID: " + rs.getInt("Id"));
System.out.println("Description: " + rs.getString("Descrip"));
System.out.println("Price: " + rs.getDouble("Price"));
System.out.println("Quantity: " + rs.getInt("Quantity"));
}
} catch (SQLException se) {
System.out.println("Error");
}
このコードをコンパイルして実行した結果はどれですか?
(A). 例外が実行時にスローされます
(B). コンパイルは失敗します
(C). コードは、エラーを出力します
(D). コードは、Item110についての情報を出力します
解答:A
問題:
class Deeper {
public Number getDepth() {
return 10;
}
}
どの2つのクラスが正しくgetDepthメソッドをオーバーライドしますか?
(A). public class deep extends Deeper {
protected integer getDepth(){
return 5;
}
}
(B). public class deep extends Deeper {
public double getDepth() {
return"5";
}
}
(C). public class deep extends Deeper {
public String getDepth () {
}
}
(D). public class deep extends Deeper {
public Long getDepth (int d) {
return 5L;
}
}
(E). public class deep extends Deeper {
public short getDepth () {
return 5;
}
}
解答:A、E
問題:
public class App {
public static void main (String [] args){
Path path = Paths.get("C:\\education\\institute\\student\\report.txt");
System.out.println("get.Name(0): %s", path.getName(0));
System.out.println ("subpath(0, 2): %s", path.subpath (0, 2));}
}
結果はどれですか?
(A). getName (0): C:\
subpath (0, 2): C:\education\report.txt
(B). getName(0): C:\
subpth(0, 2): C:\education
(C). getName(0): education
subpath (0, 2): education\institute
(D). getName(0): education
subpath(0, 2): education\institute\student
(E). getName(0): report.txt
subpath(0, 2): insritute\student
解答:C
問題:
System.out.print( new Item ()):
どのシグネチャを持つメソッドを、Itemクラスに追加する必要がありますか?
(A). public String asString()
(B). public Object asString()
(C). public Item asString()
(D). public String toString()
(E). public object toString()
(F). public Item toString()
解答:D
問題:
public class DisplaValues {
public void printNums (int [] nums){
for (int number: nums) {
System.err.println(number);
}
}
}
データを含む有効な配列が渡され、メソッドprintNumsを想定しています。なぜ、このメソッドでは、コンソールに出力を生成しないのですか?
(A). コンパイル?エラーがあります。
(B). ランタイム例外があります。
(C). 可変数は初期化されません。
(D). 標準エラーは、別の宛先にマッピングされます。
解答:D
問題:
あなたは、呼び出し可能インターフェースを実装するクラスにどのメソッドを供給しますか?
(A). callable ()
(B). executable ()
(C). call ()
(D). run ()
(E). start ()
解答:C
問題:
既存の転送先ファイル、1000バイト長だけソースファイル、およびコード?フラグメントを与えられた:
public void process (String source, String destination) {
try (InputStream fis = new FileInputStream(source);
OutputStream fos = new FileOutputStream(destination)
) {
byte [] buff = new byte[2014];
int i;
while ((i = fis.read(buff)) != -1) {
fos.write(buff,0,i); // line ***
}
} catch (IOException e) {
System.out.println(e.getClass());
}
}
結果はどれですか?
(A). ソースファイルの内容とリンク先のファイルの内容を上書きします
(B). 新しい行の後に宛先ファイルへのソースファイルのコンテンツを追加します
(C). フロー内のブレイクなしでファイルへのソースファイルのコンテンツを追加します
(D). ライン***にランタイム例外がスローされます
解答:A
問題:
どの2つのコードは正しく標準言語ローカルコードを表しますか?
(A). ES
(B). FR
(C). U8
(D). Es
(E). fr
(F). u8
解答:A、D
問題:
どのコード?フラグメントは、JDBCリソースを処理するための適切なメソッドを示していますか?
(A). Try {
ResultSet rs = stmt.executableQuery (query);
statement stmt = con.createStatement();
while (rs.next()) (/* . . . */)
} catch (SQLException e) {}
(B). Try {statement stmt = con.createStatement();
ResultSet rs = stmt.executableQuery (query);
while (rs.next()) (/* . . . */)
} catch (SQLException e) {}
(C). Try {
statement stmt = con.createStatement();
ResultSet rs = stmt.executableQuery (query);
while (rs.next()) (/* . . . */)
} finally {
rs.close();
stmt.close();
}
(D). Try {ResultSet rs = stmt.executableQuery (query);
statement stmt = con.createStatement();
while (rs.next()) (/* . . . */)
} finally {
rs.close();
stmt.close();
}
解答:C
問題:
import java.io.IOException;
import java.io.file.Path;
import java.io.file.Paths;
public class Path12 {
public static void main(String s[]) throws IOException {
Path path = Paths.get("\\sales\\quarter\\..\\qtrlreport.txt");
path.relativize(Paths.get("\\sales\\annualreport.txt"));
if(path.endsWith("annualreport.txt")) {
System.out.println(true);
} else {
System.out.println(false);
}
System.out.println(path);
}
}
結果はどれですか?
(A). false
\sales\quarter\ . . \qtrlreport.txt
(B). false
\quarter\ . . \qtrlreport.txt
(C). true
. . \ . . \ . . \ annualreport.txt
(D). true
\ . . \ . . \annualreport.txt
解答:A
問題:
public class CustomerApplication {
public static void main (String args[]) {
CustomerDAO custDao= new CustomerDAOMemoryImpl(); // Line 3
// … other methods
}
}
3行目には、2つの有効な選択肢は、特定の場所からCustomerDAOの実装のアプリケーションを分離しますか?
(A). CustomerDAO custDao = CustomerDAO();
(B). CustomerDAO custDao = (CustomerDAO) new Object ();
(C). CustomerDAO custDao = CustomerDAO.getInstance();
(D). CustomerDAO custDao = (CustomerDAO) new CustomerDAOmemoryImp1();
(E). CustomerDAO custDao = customerDAOFactory.getInstance();
解答:B、E
問題:
あなたのアプリケーションを実行するとき、このエラーメッセージを与えられた:
Exception in thread "main" java.util.MissingResourceException: Can't find bundle for base name
MessageBundle, locale
And given that the MessageBundle.properties file has been created, exists on your disk, and is
properly formatted.
エラー?メッセージの原因はどれですか?
(A). ファイルには、environmentパスにはありません。
(B). ファイルがclassパスに含まれていない。
(C). ファイルがjavapathではありません。
(D). あなたは、ResourceBundleを格納するファイルを使用することはできません。
解答:D
問題:
デフォルトではないソースバンドルファイル名を表すファイルはどれですか?
(A). MessageBundle_fr_FR.properties
(B). MessageBundle_fr_FR.profile
(C). MessageBundle_fr_FR.xinl
(D). MessageBundle__fr__FR.Java
(E). MessageBundle__fr__FR.Locale
解答:A