1 main 方法是 Java Application 程序执行的入口点,以下描述哪项是合法的()。
正确答案: B 你的答案: C (错误)
A public static void main( )
B public static void main( String args[] )
C public static int main(String [] arg )
D public void main(String arg[] )
2 java中,用( )关键字定义常量?
正确答案: A 你的答案: A (正确)
A final
B #define
C float
D const
3 下列叙述错误的是( )
正确答案: D 你的答案: A (错误)
A 在接口中定义的方法除了default和static关键字修饰的方法拥有方法体,其他方法都应是没有方法体的抽象方法(JDK1.8以后)
B 一个java类只能有一个父类,但可以实现多个接口
C 在类声明中,用implements关键字声明该类实现的接口
D 定义接口时使用implements关键字。
4 如果要建立一个java.com.computer的包放入当前java类,下列叙述正确的是? ( )
正确答案: D 你的答案: C (错误)
A 在代码中,不一定是第一句,只要是类定义前,加入package语句即可
B 只需在代码中加入“package java.com;”一个语句
C 必须在代码中加入“package java.com;”和“package java.com.computer;”两个语句
D 只需在代码中第一条非注释性语句加入“package java.com.computer;”
5
运行下面代码,输出的结果是()
class A {
public A() {
System.out.println("class A");
}
{ System.out.println("I'm A class"); }
static { System.out.println("class A static"); }
}
public class B extends A {
public B() {
System.out.println("class B");
}
{ System.out.println("I'm B class"); }
static { System.out.println("class B static"); }
public static void main(String[] args) {
new B();
}
}
正确答案: A 你的答案: C (错误)
A class A static
class B static
I’m A class
class A
I’m B class
class B
B class A static
I’m A class
class A
class B static
I’m B class
class B
C class A static
class B static
class A
I’m A class
class B
I’m B class
D class A static
class A
I’m A class
class B static
class B
I’m B class
6 What is the result of compiling and executing the following fragment of code:
Boolean flag = false;
if (flag = true)
{
System.out.println(“true”);
}
else
{
System.out.println(“false”);
}
正确答案: C 你的答案: D (错误)
AThe code fails to compile at the “if” statement.
B An exception is thrown at run-time at the “if” statement.
C The text“true” is displayed.
D The text“false”is displayed.
E Nothing is displayed.
7 It is an important feature of the Java language that it always provides a default constructor to a class.
正确答案: A 你的答案: B (错误)
A FALSE
B TRUE
8 下列叙述中,错误的是( )
正确答案: B 你的答案: A (错误)
A File类能够存储文件属性
B File类能够读写文件
C File类能够建立文件
D File类能够获取文件目录信息
9 问这个程序的输出结果
package Wangyi;
class Base
{
public void method()
{
System.out.println("Base");
}
}
class Son extends Base
{
public void method()
{
System.out.println("Son");
}
public void methodB()
{
System.out.println("SonB");
}
}
public class Test01
{
public static void main(String[] args)
{
Base base = new Son();
base.method();
base.methodB();
}
}
正确答案: D 你的答案: B (错误)
A Base SonB
B Son SonB
C Base Son SonB
D 编译不通过
10 在J2EE中,使用Servlet过滤器,需要在web.xml中配置()元素
正确答案: A B 你的答案: A B C D (错误)
A filter
B filter-mapping
C servlet-filter
D filter-config