当前位置:文档之家› 某内Java第二次月考试题(附答案)

某内Java第二次月考试题(附答案)

1.(单选)下面关于PreparedStatement说法错误的是:()。

A.PreparedStatement是Statement的子接口。

B.使用PreparedStatement预编译SQL可以有效的防止SQL注射。

C.PreparedStatement具有批处理执行SQL的功能。

D.PreparedStatement的setXXX方法可以用于设置预留的表名、字段名等参数。

正确答案:D2.(单选)下列会自动创建索引的约束的是:()。

A.UNIQUEB.NOT NULLC.FOREIGN KEYD.CHECK正确答案:A3.(单选)Oracle数据库中,在SQL语句中连接字符串的方法是:()。

A.CATB.CONCATC.JOIND.UNION正确答案:B4.(单选)在Oracle中,控制年龄必须在18到50之间(包含18和50),可使用的代码是()。

A.age>18and age<50B.age>=18and age<=50C.age>=18&&age<=50D.age>18&&age<50正确答案:B5.(单选)在JDBC连接数据库编程应用开发中,可以实现数据库连接的是()。

A.Connection接口B.PreparedStatement类C.CallableStatement类D.Statement类正确答案:A6.(单选)下列Oracle语句中,属于DDL语句的是()A.DROPB.INSERTC.DELETED.SELECT正确答案:A7.(单选)下面的代码用于删除emp表中的id为100的记录:Class.forName("orcale.jdbc.OracleDriver");Connection con= DriverManager.getConnection("jdbc:oracle:thin:@192.168.0.26:1521:tarena","openlab","open1 23");(空白处)stmt.close();con.close();空白处应填入的代码是:()。

A.Statement stmt=con.createStatement("delete from emp where id=100");int updateRows= stmt.executeUpdate();B.Statement stmt=con.createStatement();int updateRows=stmt.executeUpdate("delete from emp where id=100");C.Statement stmt=con.createStatement();int updateRows=stmt.execute("delete from emp where id=100");D.Statement stmt=con.createStatement("delete from emp where id=100");int updateRows= stmt.execute();正确答案:B8.(单选)在Oracle数据库中,关于主键约束与唯一约束说法错误的是()。

A.主键列的数据类型不限,但此列必须是唯一并且非空B.一张数据表只能有一个唯一约束C.唯一性约束所在的列允许空值D.数据库支持两个列做联合主键正确答案:B9.(单选)有关流描述错误的是:A.InputStream,OutputStream,Reader,Writer是四个抽象类B.FileInputStream,FileOutputStream是文件读写中的字节流,不能读写汉字C.FileReader,FileWriter是文件读写中的字符流,能读写英文字母D.BufferedReader是字符缓冲流,能一次读一行,速度更快。

正确答案:B10.(单选)现有如下建表SQL语句:CREATE TABLE departments(department_id NUMBER(4) PRIMARY KEY,department_name VARCHAR2(20),city VARCHAR2(20),province VARCHAR2(20))下面插入语句正确的是:()。

A.INSERT INTO departments VALUES(300,’abc’);B.INSERT INTO departments(department_name,department_id)VALUES(300,’design’);C.INSERT INTO departments(department_name,city)VALUES(‘design’,’bj’);D.INSERT INTO departments VALUES(300,’abc’,null,null);正确答案:D11.(单选)类A的定义如下:class A{protected void f()throws FileNotFoundException {………}}下列代码段没有编译错误的是:()。

A.class B extends A{public void f()throws Exception{………}}B.class B extends A{public void g()throws IOException{f();}}C.class B extends A{public void g(){try{f();………}catch(IOException e) {………}catch(FileNotFoundException e1){………}}}D.class B extends A{public void g(){try{f();}catch(FileNotFoundException e){throw new RuntimeException(e);}}}正确答案:D12.(单选)JDBC的Connection接口不包含的方法是()。

A.createStatement()B.prepareStatement(String sql)C.createPrepareStatement(String sql)mit()正确答案:C13.(单选)关于Java异常,下列说法错误的是()。

A.异常是定义了程序中遇到的非致命的错误,而不是编译时的语法错误B.try……catch语句中对try内语句监测,如果发生异常,则把异常信息放入Exception类的对象中C.throws用来表示一个方法有可能抛出异常给上一层,则在调用该方法时必须捕捉异常,否则无法编译通过D.main方法不可以使用throws抛出异常正确答案:D14.(单选)以下选项中可以用来在books表的isbn列上创建一个主键约束pk_books的是()。

A.CREATE PRIMARY KEY ON books(isbn);B.CREATE CONSTRAINT pk_books PRIMARY KEY ON books(isbn);C.ALTER TABLE books ADD CONSTRAINT pk_books PRIMARY KEY(isbn);D.ALTER TABLE books ADD PRIMARY KEY(isbn);正确答案:C15.(单选)在Oracle中,若想查询家庭地址在’北京’,’上海’,’广州’的用户信息,下列Sql 语句正确的是()。

A.SELECT*FROM student WHERE address=’北京’,’上海’,’广州’B.SELECT*FROM student WHERE address LIKE(’北京’,’上海’,’广州’)C.SELECT*FROM student WHERE address IN(’北京’,’上海’,’广州’)D.SELECT*FROM student WHERE address=‘北京’AND address=’上海’AND address=‘广州’正确答案:C16.(单选)在service表中,查询os账号名为:huangr的unix服务器ip地址,os帐号名,下列sql语句正确的是:A.select unix_host,os_username from service where os_username='huangr';B.select unix_host,os_username from service where os_username='HUANGR';C.select unix_host,os_username from service where os_username="huangr";D.select unix_host,os_username from service where os_username="HUANGR";正确答案:A17.(单选)查询客户姓名以及他的推荐人,没有推荐人的客户信息不显示,下列sql语句正确的是:A.select a1.real_name customer,a2.real_name recommender from account a1join account a2 on a1.id=a2.id;B.select a1.real_name customer,a2.real_name recommender from account a1join account a2 on a1.recommender_id=a2.recommender_id;C.select a1.real_name customer,a2.real_name recommender from account a1join account a2 on a1.recommender_id=a2.id;D.select a1.real_name customer,a2.real_name recommender from account a1,a2on a1.recommender_id=a2.id;正确答案:C18.(单选)对于Oracle数据库采用分页查询的方式查询表emp的no和name从第100(包括)条到110(不包括)条记录的SQL语句是:()。

A.select no,name from emp where rownum<110and rownum>=100B.select no,name from(select no,name rownum num from emp where rownum>=100) where num<110C.select no,name from(select no,name rownum num from emp where rownum<110)where num>=100D.select no,name from emp limit99,10正确答案:C19.(单选)查询tarena23和tarena20上的远程登录业务使用了哪些相同的资费标准,下列sql语句正确的是:A.select cost_id from service where unix_host='192.168.0.20'intersect select cost_id from service where unix_host='192.168.0.23';B.select cost_id from service where unix_host='192.168.0.20'union select cost_id from service where unix_host='192.168.0.23';C.select cost_id from service where unix_host='192.168.0.20'union all select cost_id from service where unix_host='192.168.0.23';D.select cost_id from service where unix_host='192.168.0.20'minus select cost_id from service where unix_host='192.168.0.23';正确答案:A20.(单选)如果查询表a(有3行数据)和表b(有4行数据),使用SELECT*FROM a,b,返回的查询结果的行数是:()。

相关主题