當前位置:才華齋>IT認證>SUN認證>

2017年Java筆試模擬試卷

SUN認證 閱讀(5.37K)

Java 不同於一般的編譯執行計算機語言和解釋執行計算機語言。下面是關於Java筆試模擬試卷,希望大家認真閱讀。

2017年Java筆試模擬試卷

  試題1

下列不屬於介面的是

A. Statement

B. PreparedStatement

C. Driver

D. DriverManager

E. 這個真不會,但我很厚道

  試題2

關於ResultSetMetaData API描述錯誤的是

A. getColumnCount() 返回列的數目

B. getColumnTypeName(int index) 返回指定列的型別的名稱

C. getColumnType(int index) 返回字串表示形式的指定列的型別

D. isNullable 指定列是否為空

E. 這個真不會,但我很厚道

  試題3

emp表資料如下

EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO

—– ———- ——— —– ———– ——— ——— ——

7369 SMITH CLERK 7902 1980/12/17 800.00 20

7499 ALLEN SALESMAN 7698 1981/2/20 1600.00 0.00 30

下面程式碼輸出的結果是:

ResultSet rs = uteQuery (“select comm from emp”);

while(()) {

tln(ouble(1) + “,” +ull());

}

A. 0, true

0, false

B. null, true

0,false

C. 0, false

0, false

D. 0, true

0, true

E. 這個真不會,但我很厚道

  試題4

下面的程式碼用於將存放於檔案中的圖片資訊(mouse.bmp)和文字資訊()插入到Oracle資料庫(Oracle 10g 以上驅動)

應該填入的程式碼是:

public void testSaveLOB() throws Exception {

Connection con = onnection();

PreparedStatement stmt = con

areStatement(“insert into sd_user (id, photo,mem) values(?,?,?)”);

nt(1, 30);

File file = new File(“d:/mouse.bmp”);

FileInputStream fis = new FileInputStream(file);

File xml = new File(“d:/”);

InputStreamReader reader = new InputStreamReader(new FileInputStream(

xml), “utf-8〃);

int n = uteUpdate();

tln(n);

e();

e();

e();

}

A. tream(2, fis, (int) th());

eader(3, reader, (int) th());

B. inaryStream(2, fis, (int) th());

haracterStream(3, reader, (int) th());

C. nputStream(2, fis, (int) th());

haracterStream(3, reader, (int) th());

D. inaryStream(2, fis, (int) th());

ileReader(3, reader, (int) th());

E. 這個真不會,但我很厚道

  試題5

下面描述不屬於連線池的功能的是

A. 可以緩解連線頻繁的關閉和建立會造成系統性能的下降

B. 可以大幅度提高查詢語句的執行效率

C. 可以限制客戶端的連線數量

D. 可以提高系統的伸縮性

E. 這個真不會,但我很厚道

  試題6

下面的`程式碼用於實現對emp表的分頁查詢(Oracle),在每頁10行的前提下查詢第8頁的語句是:

A.

String sql = “select ename,sal from emp where limit ?,?”

PreparedStatement stmt = areStatement(sql);

nt(1,10*7+1+10);

nt(2,10*7+1);

uteQuery();

B.

String sql = “select ename,sal from emp limit ?,?”

PreparedStatement stmt = areStatement(sql);

nt(1,10*7+1+10);

nt(2,10*7+1);

uteQuery();

C.

String sql = “select ename, sal from emp

(select enam, sal, rownum n from foo where rownum>=?)

where n

PreparedStatement stmt = areStatement(sql);

nt(1,10*7+1);

nt(2,10*7+1+10);

uteQuery();

D.

String sql = "select ename, sal from

(select ename, sal, rownum n from foo where rownum

where n>=?”

PreparedStatement stmt = areStatement(sql);

nt(1,10*7+1+10);

nt(2,10*7+1);

uteQuery();

E. 這個真不會,但我很厚道

  試題7

下面程式碼空白處應該填入的是:

public void tstAuto() throws Exception {

ame(“er”);

Connection con = onnection(

“jdbc:mysql://localhost:3306/test”, “root”, “root”);

utoCommit(false);

PreparedStatement stmt = con

areStatement(“insert into emp(name, hire_date, dept_id) values(?,?,?)”);

uteUpdate(“insert into dept (name, location)value(‘R&D’,'Beijing’)”);

// 獲取剛剛產生的主鍵

… … …

e();

e();

}

A. ResultSet key = eys();

B. int key = eneratedKeys();

C. ResultSet key = eneratedKeys();

D. int key = eys();

E. 這個真不會,但我很厚道

  試題8

已知資料表emp的資料為:

EMPNO ENAME

—– ———-

7369 SMITH

7499 ALLEN

7521 WARD

下面程式碼的執行結果是

int empno = 6000;

String ename = “hello’ or ’1′=’1〃;

Statement stmt = teStatement();

ResultSet rs = uteQuery(“select count(*) from emp

where empno=”+empno+” and ename=’”+ename+”‘”);

();

tln(nt(1));

A. 0

B. 1

C. 2

D. 3

E. 這個真不會,但我很厚道

  試題9

下面關於PreparedStatement的說法錯誤的是

A. PreparedStatement繼承了Statement

B. PreparedStatement可以有效的防止SQL注入

C. PreparedStatement不能用於批量更新的操作

D. PreparedStatement可以儲存預編譯的Statement,從而提升執行效率

E. 這個真不會,但我很厚道

  試題10

下面關於Oracle資料庫連線URI正確的拼寫格式是:

A. jdbc:oracle:thin:@hostname:1521:orcl

B. jdbc/oracle/thin/@hostname:1521/orcl

C. jdbc:oracle/thin/@hostname:1521/orcl

D. jdbc:oracle:thin/@hostname:1521/orcl

E. 這個真不會,但我很厚道