Oracle Java SE 8 Programmer II (1z0-809日本語版) - 1z0-809日本語 Exam Practice Test
Given:
public class Emp {
String fName;
String lName;
public Emp (String fn, String ln) {
fName = fn;
lName = ln;
}
public String getfName() { return fName; }
public String getlName() { return lName; }
}
and the code fragment:
List<Emp> emp = Arrays.asList (
new Emp ("John", "Smith"),
new Emp ("Peter", "Sam"),
new Emp ("Thomas", "Wale"));
emp.stream()
//line n1
.collect(Collectors.toList());
Which code fragment, when inserted at line n1, sorts the employees list in descending order of fName and then ascending order of lName?
public class Emp {
String fName;
String lName;
public Emp (String fn, String ln) {
fName = fn;
lName = ln;
}
public String getfName() { return fName; }
public String getlName() { return lName; }
}
and the code fragment:
List<Emp> emp = Arrays.asList (
new Emp ("John", "Smith"),
new Emp ("Peter", "Sam"),
new Emp ("Thomas", "Wale"));
emp.stream()
//line n1
.collect(Collectors.toList());
Which code fragment, when inserted at line n1, sorts the employees list in descending order of fName and then ascending order of lName?
Correct Answer: D
Vote an answer
与えられた情報: 従業員テーブルには 10 件のレコードがあります。
次のコードフラグメントを考えてみましょう:

結果はどうなりましたか?
次のコードフラグメントを考えてみましょう:

結果はどうなりましたか?
Correct Answer: D
Vote an answer
Given the code fragment:
9. Connection conn = DriveManager.getConnection(dbURL, userName,
passWord);
10. String query = "SELECT id FROM Employee";
11. try (Statement stmt = conn.createStatement()) {
12. ResultSet rs = stmt.executeQuery(query);
13.stmt.executeQuery("SELECT id FROM Customer");
14. while (rs.next()) {
15. //process the results
16.System.out.println("Employee ID: "+ rs.getInt("id"));
17.}
18. } catch (Exception e) {
19. System.out.println ("Error");
20. }
と仮定する:
-必要なデータベースドライバーがクラスパスで構成されています。
-適切なデータベースには、dbURL、userName、および
passWordが存在します。
-EmployeeテーブルとCustomerテーブルが使用可能であり、各テーブルにはIDがあります
いくつかのレコードとSQLクエリを含む列は有効です。
このコードフラグメントをコンパイルして実行した結果はどうなりますか?
9. Connection conn = DriveManager.getConnection(dbURL, userName,
passWord);
10. String query = "SELECT id FROM Employee";
11. try (Statement stmt = conn.createStatement()) {
12. ResultSet rs = stmt.executeQuery(query);
13.stmt.executeQuery("SELECT id FROM Customer");
14. while (rs.next()) {
15. //process the results
16.System.out.println("Employee ID: "+ rs.getInt("id"));
17.}
18. } catch (Exception e) {
19. System.out.println ("Error");
20. }
と仮定する:
-必要なデータベースドライバーがクラスパスで構成されています。
-適切なデータベースには、dbURL、userName、および
passWordが存在します。
-EmployeeテーブルとCustomerテーブルが使用可能であり、各テーブルにはIDがあります
いくつかのレコードとSQLクエリを含む列は有効です。
このコードフラグメントをコンパイルして実行した結果はどうなりますか?
Correct Answer: A
Vote an answer
STUDENTテーブルの構造を考えます:
学生(id INTEGER、name VARCHAR)
与えられた:
public class Test {
static Connection newConnection =null;
public static Connection get DBConnection () throws SQLException {
try (Connection con = DriveManager.getConnection(URL, username, password)) { newConnection = con;
}
return newConnection;
}
public static void main (String [] args) throws SQLException {
get DBConnection ();
Statement st = newConnection.createStatement();
st.executeUpdate("INSERT INTO student VALUES (102, 'Kelvin')");
}
}
と仮定する:
必要なデータベースドライバーは、クラスパスで構成されます。
適切なデータベースにアクセスするには、URL、userName、およびpassWordを使用します。
SQLクエリは有効です。
結果は何ですか?
学生(id INTEGER、name VARCHAR)
与えられた:
public class Test {
static Connection newConnection =null;
public static Connection get DBConnection () throws SQLException {
try (Connection con = DriveManager.getConnection(URL, username, password)) { newConnection = con;
}
return newConnection;
}
public static void main (String [] args) throws SQLException {
get DBConnection ();
Statement st = newConnection.createStatement();
st.executeUpdate("INSERT INTO student VALUES (102, 'Kelvin')");
}
}
と仮定する:
必要なデータベースドライバーは、クラスパスで構成されます。
適切なデータベースにアクセスするには、URL、userName、およびpassWordを使用します。
SQLクエリは有効です。
結果は何ですか?
Correct Answer: D
Vote an answer
コードの断片を考えると:
ZonedDateTime depart = ZonedDateTime.of(2015, 1, 15, 1, 0, 0, 0, ZoneID.of("UTC-7")); ZonedDateTime arrive = ZonedDateTime.of(2015, 1, 15, 9, 0, 0, 0, ZoneID.of("UTC-5")); long hrs = ChronoUnit.HOURS.between(depart, arrive); //line n1 System.out.println("Travel time is" + hrs + "hours"); 結果は何ですか?
ZonedDateTime depart = ZonedDateTime.of(2015, 1, 15, 1, 0, 0, 0, ZoneID.of("UTC-7")); ZonedDateTime arrive = ZonedDateTime.of(2015, 1, 15, 9, 0, 0, 0, ZoneID.of("UTC-5")); long hrs = ChronoUnit.HOURS.between(depart, arrive); //line n1 System.out.println("Travel time is" + hrs + "hours"); 結果は何ですか?
Correct Answer: A
Vote an answer
コードの断片を考えると:
List<String> codes = Arrays.asList ("DOC", "MPEG", "JPEG");
codes.forEach (c -> System.out.print(c + " "));
String fmt = codes.stream()
.filter (s-> s.contains ("PEG"))
.reduce((s, t) -> s + t).get();
System.out.println("\n" + fmt);
What is the result?
List<String> codes = Arrays.asList ("DOC", "MPEG", "JPEG");
codes.forEach (c -> System.out.print(c + " "));
String fmt = codes.stream()
.filter (s-> s.contains ("PEG"))
.reduce((s, t) -> s + t).get();
System.out.println("\n" + fmt);
What is the result?
Correct Answer: C
Vote an answer
コードの断片を考えると:
UnaryOperator<Integer> uo1 = s -> s*2;line n1
List<Double> loanValues = Arrays.asList(1000.0, 2000.0);
loanValues.stream()
.filter(lv -> lv >= 1500)
.map(lv -> uo1.apply(lv))
.forEach(s -> System.out.print(s + " "));
What is the result?
UnaryOperator<Integer> uo1 = s -> s*2;line n1
List<Double> loanValues = Arrays.asList(1000.0, 2000.0);
loanValues.stream()
.filter(lv -> lv >= 1500)
.map(lv -> uo1.apply(lv))
.forEach(s -> System.out.print(s + " "));
What is the result?
Correct Answer: B
Vote an answer
コードの断片を考えると:
List<Double> doubles = Arrays.asList (100.12, 200.32);
DoubleFunction funD = d -> d + 100.0;
doubles.stream (). forEach (funD); // line n1
doubles.stream(). forEach(e -> System.out.println(e)); // line n2
What is the result?
結果は何ですか?
List<Double> doubles = Arrays.asList (100.12, 200.32);
DoubleFunction funD = d -> d + 100.0;
doubles.stream (). forEach (funD); // line n1
doubles.stream(). forEach(e -> System.out.println(e)); // line n2
What is the result?
結果は何ですか?
Correct Answer: B
Vote an answer
Explanation: Only visible for PassTestking members. You can sign-up / login (it's free).
Given:
public enum USCurrency {
PENNY (1),
NICKLE(5),
DIME (10),
QUARTER(25);
private int value;
public USCurrency(int value) {
this.value = value;
}
public int getValue() {return value;}
}
public class Coin {
public static void main (String[] args) {
USCurrency usCoin =new USCurrency.DIME;
System.out.println(usCoin.getValue()):
}
}
指定されたコードのコンパイルを可能にする2つの変更はどれですか?
public enum USCurrency {
PENNY (1),
NICKLE(5),
DIME (10),
QUARTER(25);
private int value;
public USCurrency(int value) {
this.value = value;
}
public int getValue() {return value;}
}
public class Coin {
public static void main (String[] args) {
USCurrency usCoin =new USCurrency.DIME;
System.out.println(usCoin.getValue()):
}
}
指定されたコードのコンパイルを可能にする2つの変更はどれですか?
Correct Answer: A,C
Vote an answer
内容は次のとおりです:

次のコードフラグメントを考えてみましょう:

どの 2 つのコード フラグメントを 1 行目に挿入すると、独立してコード フラグメントで「Hallo」を印刷できるようになりますか?

次のコードフラグメントを考えてみましょう:

どの 2 つのコード フラグメントを 1 行目に挿入すると、独立してコード フラグメントで「Hallo」を印刷できるようになりますか?
Correct Answer: A,D
Vote an answer
Given:
public class Test<T> {
private T t;
public T get () {
return t;
}
public void set (T t) {
this.t = t;
}
public static void main (String args [ ] ) {
Test<String> type = new Test<>();
Test type 1 = new Test ();//line n1
type.set("Java");
type1.set(100);//line n2
System.out.print(type.get() + " " + type1.get());
}
}
結果は何ですか?
public class Test<T> {
private T t;
public T get () {
return t;
}
public void set (T t) {
this.t = t;
}
public static void main (String args [ ] ) {
Test<String> type = new Test<>();
Test type 1 = new Test ();//line n1
type.set("Java");
type1.set(100);//line n2
System.out.print(type.get() + " " + type1.get());
}
}
結果は何ですか?
Correct Answer: B
Vote an answer
