【1】以下( B  )是编写Servlet必须导入的包.
A.java.sql.*
B.java.servlet.*
C.java.util.*
D.java.lang.*
【2】下面哪项不属于SQL语句的子类(  D )
A. 数据定义语言(DDL)
B. 数据查询语言(DQL)
C. 事务控制语言(TCL)
D. 数据插入语言 (DIL)
【3】选出所有正确的答案
public class Outer{
public void someOuterMethod() {
// Line 3
}
public class Inner{}
public static void main( String[]argv ) {
Outer o = new Outer();
// Line 8
}
}
Which instantiates an instance of Inner?  A 
A. new Inner(); // At line 3
B. new Inner(); // At line 8
C. new o.Inner(); // At line 8
D. new Outer.Inner(); // At line 8
【4】JDBC中,用于表示数据库连接的对象是:  B
A.Statement
B.Connection
C.DriverManager
D.PreparedStatement
【5】 请指出哪些声明和初始化数组是正确的(  BD )
A.  Array a = new Array(5)
B.  int[] a = {23,22,21,20,19} java面试题及答案2020
C.  int[] array
D.  int array[] = new int[5] 
【6】阅读以下代码,选择正确的答案,并说明原因 ( D 发生空指针异常 )
public class TestDogs{
  Dog[][] theDogs = new Dog[3][];
  System.out.println(theDogs[2][0].toString());
  }
  class Dog{
  }
  A. null  B. theDogs  C. Compilation fails  D. An exception is thrown at runtime
【7】请选择你认为不正确的声明,并说明原因?
  A. final abstract class Teat{} 抽象列用于继承,不能被声明为final
  B. public static interface Test{}接口定义只能是public,abstract
  C. final public class Test{} 对
  D. protected interface Test{}接口定义只能是public,abstract
  E. protected abstract class Test{} 只能定义为public abstract
  F. abstract public class Test{} 对
【8】阅读以下代码,选择正确答案,并说明原因 (E  counter是 final 类型的)
Interface Count{
  short counter = 0;
  viod countUp();
  }
  public class TestCount implements Count{
  public static void main(String[]args){
  TestCount t = new TestCount();
  t.countUp();
  }
  public void countUp(){
  for(int x = 6 ; x>counter ; x--, ++counter)
  {
    System.out.print(“”+counter);
  }
  }
  }
  A. 012  B. 123 C. 0123 D. 1234
  E. Compilation fails  F. An exception is thrown runtime
【9】阅读以下代码,选择正确答案,并说明原因 (C  原因老师讲 写不出来)
class Test {
public static void main(String[] args) {
int x = 0;
int y = 0;
for (int z = 0; z < 5; z++) {  //
if ((++x > 2) && (++y > 2)) {
x++;
}
}
System.out.println(x + "" + y);
}
}
A. 52  B. 53 C. 63 D. 64 E. 75 F. 85
【10】阅读以下代码,选择程序的输出结果。  B
class A {
public void baz() {
System.out.println("A");
}
}
public class B extends A {
public static void ma
in(String[] args) {
A a = new B();
a.baz();
}
public void baz() {
System.out.println("B");
}
}
A. A  B. B  C. Compilation fails D. An exception is thrown at runtime
【18】阅读以下代码,选择程序的输出结果。  E
class Parent {
public Parent() {
System.out.println("instantiate a parent");
}
}
class Child extends Parent {
public Child() {
System.out.println("instantiate a child");
}
super();
}
class TestPoly {
public static void main(String[] args) {
Parent p = new Child();
}
}
A.instantiate a child
B. instantiate a parent
C. instantiate a child  instantiate a parent
D. instantiate a parent  instantiate a child
E. Compilation fails
F. An exception is thrown at runtime

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。