質問 1:
*Item_ID, Integer: PK
*Item_name, Varchar (20)
*Price, Numeric (10, 2)
*Quan, Integer

public static void updatePrices{ // #1: missing line
Connection con) throws SQLException {
// #2: missing line
PreparedStatement updatePrices = con.prepareStatement (updatePricesString);
// #3: missing line { // #4: missing line updatePrices.executeUpdate(); } }
A. 1. HashMap<Integer, Float> newPrices,
2.StringupdatePriceString = "UPDATE inventory SET price =? WHERE item_id '?' ";
3.For (map.Entry<Integer, String> x : newPrices.entrySet())
4.UpdatePrices.setFloat(1, x.getvalue().floatValue()); updatePrice.setString (2,
x.getKey().intValue());
B. 1. HashMap<Integer, Float> newPrices,
2.StringupdatePriceString = "UPDATE inventory SET price =? Where item_id '?' ";
3.For (map.Entry<Integer, String> x : newPrices.entrySet())
4.UpdatePrices.setInt(1, x.getvalue().floatValue()); updatePrice.setString (2, x.getvalue().floatValue()
C. 1. HashMap<Integer, Float> newPrices,
2.StringupdatePriceString = "UPDATE inventory SET price =? Where item_id '?' ";
3.For (map.Entry<Integer, String> x : newPrices.entrySet())
4.UpdatePrices.setInt(1, x.getvalue().floatValue()); updatePrice.setString (2, x.getvalue());
D. 1. HashMap<Integer, String> newPrices,
2.StringupdatePriceString = "UPDATE inventory SET price =? WHERE item_name '?' ";
3.For (map.Entry<Integer, String> x : newPrices.entrySet())
4.UpdatePrices.setFloat(1, x.getvalue().floatValue()); updatePrice.setString (2, x.getKey());
E. 1. HashMap<Integer, String> newPrices,
2.StringupdatePriceString = "UPDATE inventory SET price =? Where item_id '?' ";
3.For (map.Entry<Integer, String> x : newPrices.entrySet())
4.UpdatePrices,setString(1, x.getKey()); updatePrices.setFloat(2, x.getValue().floatValue());
F. 1. HashMap<Integer> newPrices,
2.StringupdatePriceString = "UPDATE inventory SET price =? Where item_id '?' ";
3.For (Integer x: newPrice)
4.updatePrice.setInt(1, x);
正解:B
解説: (Topexam メンバーにのみ表示されます)
質問 2:
public static void main(String[] args) {
String source = "d:\\company\\info.txt";
String dest = "d:\\company\\emp\\info.txt";
//insert code fragment here Line **
} catch (IOException e) {
System.err.println ("Caught IOException: " + e.getmessage();
}
}
A. try {BufferedReader br = Files.newBufferedReader(Paths.get(source), Charset.forName ("UTF-
8"));
BufferedWriter bw = Files.newBufferedWriter (Paths.get(dest), Charset.forName ("UTF-8"));
String record = "";
while ((record = br.readLine()) != null){
bw.write (record);
bw.newLine();
}
Files.delete(Paths.get(source));
B. try {FileChannel in = new FileInputStream(source).getChannel();
FileChannel out = new FileOutputStream(dest).getChannel ();
in.transferTo (0, in.size(), out);
C. try {Files.copy(Paths.get(source), Paths.get(dest));
Files.delete(Paths.get(source));
D. try {Files.move (Paths.get(source), Paths.get(dest));
E. try {Files.copy(Paths.get(source), Paths.get(dest));
Files.delete(Paths.get(source));
正解:D,E
質問 3:
Path path1 = Paths.get("D:\\sales\\.\\quarterly\\..\\report");
path1 = path1.normalize();
Path path2 = path1.relativize(Paths.get("d:\\empdetails.dat"));
path2 = path2.resolve(path1);
System.out.println(path1);
System.out.println(path2);
}
A. D: \sales\report
B. \sales\report\empdetails.dat
C. D: \sales\report
D. \sales\report
E. D: \sales\quarterly\ . . . \report
F. \sales\report\empdetails.dat
G. \sales\report
H. D: \sales\quarterly\ . . .\report
正解:C
解説: (Topexam メンバーにのみ表示されます)
質問 4:
A. public static void setFileContent (String[] s) throws IOException {
File file= new File ("payroll\\salary.dat").getCanonicalFile();
try (BufferWriter br = new BufferWriter (new FileWriter(File))) {
br.write ("experience new features of java");
}
}
B. public static void setFileContent (String[] s) throws IOException {
path p=paths.get ("payroll\\salary.dat");
File file=p.toAbsolutePath(LinkOption.NOFOLLOW_LINKS).toFile();
try (BufferWriter br = new BufferWriter (new FileWriter(File))) {
br.write ("experience new features of java");
}
}
C. public static void setFileContent (String[] s) throws IOException {
File file= new file ("payroll\\salary.dat").getCanonicalFile();
try (BufferWriter br = new BufferWriter (new FileWriter(File))) {
br.write ("experience new features of java");
}
}
D. public static void setFileContent (String[] s) throws IOException {
File file=new File ("payroll\\salary.dat").getAbsolutePath();
try (BufferWriter br = new BufferWriter (new FileWriter(File))) {
br.write ("experience new features of java");
}
}
E. public static void setFileContent (String[] s) throws IOException {
path p=paths.get("payroll\\salary.dat");
File file=p.toAbsolutePath().toFile();
try (BufferWriter br = new BufferWriter (new FileWriter(File))) {
br.write ("experience new features of java");
}
}
正解:A,B
解説: (Topexam メンバーにのみ表示されます)
質問 5:
A. Option H
B. Option E
C. Option A
D. Option C
E. Option D
F. Option B
G. Option F
H. Option G
正解:B,C,D,E,H
解説: (Topexam メンバーにのみ表示されます)
質問 6:
A. Option E
B. Option A
C. Option C
D. Option D
E. Option B
F. Option F
正解:F
解説: (Topexam メンバーにのみ表示されます)
質問 7:
try {
String query = "SELECT * FROM Employee WHERE ID=110";
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery(query); // Line 13
System.out.println("Employee ID: " + rs.getInt("ID")); // Line 14
} catch (Exception se) {
System.out.println("Error");
}
A. Option A
B. Option C
C. Option D
D. Option B
正解:D
解説: (Topexam メンバーにのみ表示されます)
質問 8:
String query = "SELECT ID FROM Employee"; \\ Line 1 try (Statement stmt = conn.CreateStatement()) { \\ Line 2 ResultSet rs = stmt.executeQuery(query); \\ Line 3 stmt.executeQuery ("SELECT ID FROM Customer"); \\ Line 4 while (rs.next()) { \\process the results System.out.println ("Employee ID: " + rs.getInt("ID") ); } } catch (Exception e) { system.out.println ("Error"); }
A. Option A
B. Option C
C. Option D
D. Option B
正解:B
解説: (Topexam メンバーにのみ表示されます)
質問 9:
public class SampleClass {
public static void main(String[] args) {
SampleClass sc = new SampleClass();
sc.processCD();
}
private void processCD() {
try (CDStream cd = new CDStream()) {
cd.open();
cd.read();
cd.write("lullaby");
cd.close();
} catch (Exception e) {
System.out.println("Exception thrown");
}
}
class CDStream {
String cdContents = null;
public void open() {
cdContents = "CD Contents";
System.out.println("Opened CD stream");
}
public String read() throws Exception {
throw new Exception("read error");
}
public void write(String str) {
System.out.println("CD str is: " + str);
}
public void close() {
cdContents = null;
}
A. Option A
B. Option C
C. Option D
D. Option B
正解:A
解説: (Topexam メンバーにのみ表示されます)