每日10道JAVA题(20180608)

89 篇文章 2 订阅

/**
 * 10道题系列会持续更新,每日的10道题都是我做过的,做错或者觉得需要复习的有价值的
 * 请关注我,每日和我一同进步,有更好的建议或有问题的请在评论区提出或私信我
 */

1.关于类的叙述正确的是

A.在类中定义的变量称为类的成员变量,在别的类中可以直接使用
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);
     }
}

A.432
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;
     }
}
A.null null 42
B.null 42 42
C.0 0 42
D.0 42 42
10.
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);
下列代码片段中,存在编译错误的语句是()
A.语句2
B.语句1
C.语句3
D.语句4

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

StrideBin

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

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

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

打赏作者

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

抵扣说明:

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

余额充值