JAVA选择题

1.Java Application 中的主类需包含main方法,以下哪项是main方法的正确形参?( )
正确答案: B
A.String args
B String[] args
C Char arg
D StringBuffer[] args
2 将类的成员的访问权限设置为默认的,则该成员能被( )
正确答案: A
A 同一包中的类访问
B 其它包中的类访问
C 所有的类访问
D 所有的类的子类访问
3 一个类可以有多个不同名的构造函数 。( )

正确答案: B
A 正确
B 错误
4 Stack通常是指“先进先出”的容器。( )

正确答案: B
A 正确
B 错误
解释 Stack是栈, queue是对列;
栈是后进先出,对列是先进先出;
栈是出入从同一个位置;
对列是入从结构的一端进入,从另一端出队;
栈就像一个盒子,你把物体依次放入后,能先拿出来的只能是上面最后放进去的,下层的想要拿出需要将上层的先拿出,也就是先出栈;
5 对列是一个胡同,人们都进入胡同了,只有最前面的人从胡同出口出去,后面的人只有等前面的人走完后才能依次通过。
java中,用( )关键字定义常量?
正确答案: A
A final
B #define
C float
D const
6 以下程序运行的结果为 ( )
public class Example extends Thread{
@Override
public void run(){
try {
Thread.sleep(1000);
} catch (InterruptedException e){
e.printStackTrace();
}
System. out .print( “run” );
}
public static void main(String[] args){
Example example= new Example();
example.run();
System. out .print( “main” );
}
}
正确答案: A
A run main
B main run
C main
D run
E 不能确定
7运用下列哪个命令能够获取JVM的内存映像
正确答案: B
A jinfo
B jmap
C jhat
D jstat
8 下面关于JAVA的垃圾回收机制,正确的是( )
正确答案: B
A 当调用“System.gc()”来强制回收时,系统会立即回收垃圾
B 垃圾回收不能确定具体的回收时间
C程序可明确地标识某个局部变量的引用不再被使用
D程序可以显式地立即释放对象占有的内存
9 下面哪个标识符是合法的?
正确答案: D
A"9HelloWorld"
B"_Hello World"
C"HelloWorld"
D"Hello W o r l d " 解 释 1 、 j a v a 的 变 量 名 有 三 种 元 素 构 成 : 数 字 + 字 符 + World" 解释 1、java的变量名有三种元素构成:数字+字符+ World"1java+++下划线。
2、java对这三种元素的顺序也是有要求的:不能以数字开头+不能是关键字.
3、A中错在以数字开头、B中错在有空格、C中错在有
.
10 Which method you define as the starting point of new thread in a class from which n thread can be execution?
正确答案: B
A public void start()
B public void run()
C public void int()
D public static void main(String args[])
E public void runnable()
关于访问权限说法正确 的是 ? ( )

正确答案: B
外部类前面可以修饰public,protected和private
成员内部类前面可以修饰public,protected和private
局部内部类前面可以修饰public,protected和private
以上说法都不正确
11 运行代码,输出的结果是()
public class P {
public static int abc = 123;
static{
System.out.println(“P is init”);
}
}
public class S extends P {
static{
System.out.println(“S is init”);
}
}
public class Test {
public static void main(String[] args) {
System.out.println(S.abc);
}
}

正确答案: A
A P is init
123
B S is init
P is init
123
C P is init
S is init
123
D S is init
123
12 下面关于程序编译说法正确的是()

正确答案: C
A java语言是编译型语言,会把java程序编译成二进制机器指令直接运行
B java编译出来的目标文件与具体操作系统有关
C java在运行时才进行翻译指令
D java编译出来的目标文件,可以运行在任意jvm上
13 以下为 java 语法保留不能作为类名和方法名使用的是

正确答案: A B C D
A default
B int
C implements
D throws
14下面代码的运行结果为:()
import java.io.;
import java.util.
;
public class foo{
public static void main (String[] args){
String s;
System.out.println(“s=” + s);
}
}
正确答案: C
A 代码得到编译,并输出“s=”
B 代码得到编译,并输出“s=null”
C 由于String s没有初始化,代码不能编译通过
D 代码得到编译,但捕获到 NullPointException异常
15 以下代码定义了一个变量,如何输出这个变量的值?
正确答案: A C D
A. <% String myBean = (String)pageContext.getAttribute(“stringBean”,PageContext.PAGE_SCOPE);%>
B <%=myBean%>
C <bean:write name=“helloworld”/>
D <bean:write name=“stringBean”/>
E <%=stringBean%>

16下列有关java构造函数叙述正确的是()
正确答案: C D
A 构造器的返回值为void类型
B 如果一个源文件中有多个类,那么构造器必须与公共类同名
C 构造器可以有0个,1个或一个以上的参数
D 每个类可以有一个以上的构造器

17下面选项中,哪些是interface中合法方法定义?()
正确答案: A C D
A public void main(String [] args);
B private int getSum();
C boolean setFlag(Boolean [] test);
D public float get(int x);
18 Servlet的生命周期可以分为初始化阶段,运行阶段和销毁阶段三个阶段,以下过程属于初始化阶段是()。
正确答案: A C D
A 加载Servlet类及.class对应的数据
B 创建servletRequest和servletResponse对象
C 创建ServletConfig对象
D 创建Servlet对象

19 public class NameList
{
private List names = new ArrayList();
public synchronized void add(String name)
{
names.add(name);
}
public synchronized void printAll() {
for (int i = 0; i < names.size(); i++)
{
System.out.print(names.get(i) + ””);
}
}
public static void main(String[]args)
{
final NameList sl = new NameList();
for (int i = 0; i < 2; i++)
{
new Thread()
{
public void run()
{
sl.add(“A”);
sl.add(“B”);
sl.add(“C”);
sl.printAll();
}
} .start();
}
}
}
20 Which two statements are true if this class is compiled and run?

正确答案: E G
A An exception may be thrown at runtime.
B The code may run with no output, without exiting.
C The code may run with no output, exiting normally(正常地).
D The code may rum with output “A B A B C C “, then exit.
E The code may rum with output “A B C A B C A B C “, then exit.
F The code may ruin with output “A A A B C A B C C “, then exit.
G The code may ruin with output “A B C A A B C A B C “, then exit.

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

zzsaixuexi

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值