/**
* 10道题系列会持续更新,每日的10道题都是我做过的,做错或者觉得需要复习的有价值的
* 请关注我,每日和我一同进步,有更好的建议或有问题的请在评论区提出或私信我
*/
1.关于类的叙述正确的是
B.局部变量的作用范围仅仅在定义它的方法内,或者是在定义它的控制流块中
C.使用别的类的方法仅仅需要引用方法的名字即可
D.只要没有定义不带参数的构造函数,JVM都会为类生成一个默认构造函数
2.在使用super 和this关键字时,以下描述正确的是
A.在子类构造方法中使用super()显示调用父类的构造方法,super()必须写在子类构造方法的第一行,否则编译不通过
B.super()和this()不一定要放在构造方法内第一行
C.this()和super()可以同时出现在一个构造函数中
D.this()和super()可以在static环境中使用,包括static方法和static语句块
3.下面的程序 编译运行后,在屏幕上显示的结果是()
public class test {
public static void main(String args[]) {
int x,y;
x=5>>2;
y=x>>>2;
System.out.println(y);
}
}
A.0
B.2
C.5
D.80
4.有如下代码:请写出程序的输出结果。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
public
class
Test
{
public
static
void
main(String[] args)
{
int
x =
0
;
int
y =
0
;
int
k =
0
;
for
(
int
z =
0
; z <
5
; z++) {
if
((++x >
2
) && (++y >
2
) && (k++ >
2
))
{
x++;
++y;
k++;
}
}
System.out.println(x + ”” +y + ”” +k);
}
}
|
B.531
C.421
D.523
5.以下代码结果是什么?
public class foo {
public static void main(String sgf[]) {
StringBuffer a=new StringBuffer(“A”);
StringBuffer b=new StringBuffer(“B”);
operate(a,b);
System.out.println(a+”.”+b);
}
static void operate(StringBuffer x,StringBuffer y) {
x.append(y);
y=x;
}
}
A.代码可以编译运行,输出“AB.AB”。
B.代码可以编译运行,输出“A.A”。
C.代码可以编译运行,输出“AB.B”。
D.代码可以编译运行,输出“A.B”。
6.以下描述正确的是
A.CallableStatement是PreparedStatement的父接口B.PreparedStatement是CallableStatement的父接口
C.CallableStatement是Statement的父接口
D.PreparedStatement是Statement的父接口
7.在java中,下列标识符不合法的有( )
A.new
B.$Usdollars
C.1234
D.car.taxi
8.类的析构函数是一个对象被( )时自动调用的。
A.建立
B.撤消
C.赋值
D.引用
9.给出以下代码,请给出结果.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
class
Two{
Byte x;
}
class
PassO{
public
static
void
main(String[] args){
PassO p=
new
PassO();
p.start();
}
void
start(){
Two t=
new
Two();
System.out.print(t.x+””);
Two t2=fix(t);
System.out.print(t.x+” ” +t2.x);
}
Two fix(Two tt){
tt.x=
42
;
return
tt;
}
}
|
B.null 42 42
C.0 0 42
D.0 42 42
1
2
3
4
5
6
7
|
byte b1=1,b2=2,b3,b6,b8;
final byte b4=4,b5=6,b7;
b3=(b1+b2);
/*语句1*/
b6=b4+b5;
/*语句2*/
b8=(b1+b4);
/*语句3*/
b7=(b2+b5);
/*语句4*/
System.out.println(b3+b6);
|
B.语句1
C.语句3
D.语句4