Java基础强化练习题2.docxVIP

  • 3
  • 0
  • 约4.2千字
  • 约 5页
  • 2021-10-12 发布于湖南
  • 举报
Java基础强化练习题2 1. 下列代码的输出结果是:(A) public class Yikes { public static void go(Long n) { System.out.println(\ } public static void go(Short n) { System.out.println(\ } public static void go(int n) { System.out.println(\ } public static void main(String[] args) { short y = 6; long z = 7; go(y); go(z); } } A. Long Long B. Short Long C. int Long D. int int 2. 下面不属于接口的是:(D)。 A. java.sql.Connection B. java.sql.Driver C. java.sql.DriverManager D. java.sql.ResultSet 3. synchronized关键字做同步,可以使用在:( A. 方法上 B. 接口上 C. 变量上 D. 类上 A)。 4. 类A的定义如下: class A { protected void f() throws FileNotFoundException { ……… } } 下列代码段没有编译错误的是:(A)。 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); } } } 5. 下列选项中能够得到字符串的一部分的单行函数是()。 A. INSERT B. SUBSTR C. LPAD D. LEAST 6. ResultSet提供了获取数据库中某个字段值的方法,如果某个字段为NUMBER类型,可以获取该字段值的方法是:(A )。 A. getNumber() B. getDouble() C. setNumber() D. setDouble() 7. 下列代码编译和运行的结果是(A) public class A { void process() throws Exception { throw new Exception(); } public static void main(String[] args) { A a = new B(); cess(); } } class B extends A { void process() { System.out.println(\ } } A. 输出:B B. 无输出 C. B类的process方法处,出现编译错误 D. 代码cess();行,出现编译错误 8. 下列代码编译和运行的结果是:(A) public static void main(String[] args) { Float pi = new Float(3.14f); if (pi 3) { System.out.print(\ } else { System.out.print(\ } finally { 不能单独使用 System.out.println(\ } } A. 编译失败 B. 输出:

文档评论(0)

1亿VIP精品文档

相关文档