当前位置:文档之家› Java基础强化练习题2(附答案)

Java基础强化练习题2(附答案)

B. SELECT DISTINCT(cid) FROM ORDERS o1,orders o2 WHERE o1.pid=’p01’ AND o2.pid=’p02’ AND o1.cid=o2.cid
C. SELECT DISTINCT(cid) FROM orders WHERE pid=’p01’ AND cid IN(select cid FROM orders WHERE pid=’p02’)
………
}
}
下列代码段没有编译错误的是:()。
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 {
C.
select a1.real_name customer, a2.real_name recommenderfrom account a1 join account a2on a1.recommender_id = a2.id;
D.
select a1.real_name customer, a2.real_name recommenderfrom account a1, a2on a1.recommender_id = a2.id;
B. new InputStreamReader(new FileInputStream(“fileName”));
C. new BufferedReader(new InputStreamReader(new FileInputStream(“fileName”)));
D. new RandomAccessFile(“fileName”,”+rw”);
throw new RuntimeException(e);
}
}
}
正确答案:D
分析:子类重写父类的方法时候不能声明抛出比父类大的异常
5.
A. INSERT
B. SUBSTR
C. LPAD
D. LEAST
正确答案:B
6. ResultSet
A. getNumber()
B. getDouble()
C. setNumber()
A. java.sql.Connection
B. java.sql.Driver
C. java.sql.DriverManager
D. java.sql.ResultSet
正确答案:C
3. synchronized
A.方法上
B.接口上
C.变量上
D.类上
正确答案:A
4.
class A {
protected void f() throws FileNotFoundException {
System.out.print(index + "");
index += str1.length();
}
}
控制台输出的结果是:()。
A. 1 10 21
B. 2 11 22
C. 3 13 23
D. 5 13 22
正确答案:B
11.
A. String st1 = "abc";
System.out.println("abc" == st1);
B. String st2 = "abc";
System.out.println(st2.equals(new String("abc")));
C. Integer i = 100;
System.out.println(100 == i);
D. ArrayList list = new ArrayList();
D. SELECT DISTINCT(cid) FROM orders o1,orders o2 WHERE o1.pid=’p01’ AND o2.pid=’p02’
正确答案:C
20.
A. Connection的commit()
B. Connection的setAutoCommit()
C. Connection的rollback()
}
}
class B extends A {
void process() {
System.out.println("B ");
}
}
A.输出:B
B.无输出
C. B类的process方法处,出现编译错误
D.代码a.process();行,出现编译错误
正确答案:D
8.
public static void main(String[] args) {
C. throws用来表示一个方法有可能抛出异常给上一层,则在调用该方法时必须捕捉异常,否则无法编译通过
D. main方法不可以使用throws抛出异常
正确答案:D
19.
A. SELECT DISTINCT(cid) FROM orders o1 WHERE o1.pid IN(‘p01’,’p02’)
正确答案:A
16.
A.
select a1.real_name customer, a2.real_name recommenderfrom account a1 join account a2on a1.id = a2.id;
B.
select a1.real_name customer, a2.real_name recommenderfrom account a1 join account a2on a1.recommender_id = a2.recommender_id;
正确答案:D
15.
public class Foo {
public static void main(String[] args) {
try {
test();
System.out.println("condition 1");
} catch (ArrayIndexOutOfBoundsException e) {
System.out.println("condition 2");
} catch (Exception e) {
System.out.println("condition 3");
} finally {
System.out.println("finally");
}
}
public static void test() {
public void g() {
try{
f();
………
}
catch(IOException e) {
………
}
catch(FileNotFoundException e1) {
………
}
}
}
D.
class B extends A {
public void g() {
try {
f();
}
catch(FileNotFoundException e) {
正确答案:C
17.
public class Forest implements Serializable {
private Tree tree = new Tree();
public static void main(String[] args) {
Forest f = new Forest();
try {
正确答案:C
10.
public static void main(String[] args) {
String str = "**oracle***oracle*****oracle***";
String str1 = "oracle";
int index = 0;
while ((index = str.indexOf(str1, index)) != -1) {
FileOutputStream fs = new FileOutputStream("Forest.ser");
ObjectOutputStream os = new ObjectOutputStream(fs);
os.writeObject(f);
os.close();
} catch (Exception ex) {
D. ResultSet的的方法getString(...)意为取得该列的数据以字符串的形式返回,数据库中的该列类型并不一定必须是字符类型
正确答案:A
13.
A. COMMIT
ቤተ መጻሕፍቲ ባይዱB. INSERT
C. DROP
D. GRANT
正确答案:B
14.
A.事务具备ACID四个基本特性,即A(Atomicity)—原子性、C(Consistency)—一致性、I(Isolation)—隔离性、D(Durability)—持久性。
Float pi = new Float(3.14f);
if (pi > 3) {
System.out.print("pi is bigger than 3. ");
} else {
System.out.print("pi is not bigger than 3. ");
}
finally {
相关主题