001 牛客网-java-专项练习-2021-05-29

  1. 以下哪个不是Collection的子接口?
  1. List
  2. Set
  3. SortedSet
  4. Map
  1. 构造方法用于创建类的实例对象,构造方法名应与类名相同,返回类型为void。
  1. 正确
  2. 错误
  1. 在一个基于分布式的游戏服务器系统中,不同的服务器之间,哪种通信方式是不可行( )
  1. 管道
  2. 消息队列
  3. 高速缓存数据库
  4. 套接字
  1. 程序的输出结果是什么?

public class A2{
public static void main(String[] args){
    int[] a={2,4,6,8,3,6,9,12};
    doSomething(a,0,a.length-1);
    for(int i=0;i<=a.length-1;i++)
    System.out.print(a[i]+” “);
}
private static void doSomething(int[] a,int start,int end){
    if(start<end){
        int p=core(a,start,end);
        doSomething(a,start,p-1);
        doSomething(a,p+1,end);
    }
}
private static int core(int[] a,int start,int end)
{
    int x=a[end];
    int i=start;
    for(int j=start;j<=end-1;j++){
        if(a[j]>=x){
            swap(a,i,j);
            i++;//交换了几次
        }
    }//把最大的放到最后
    swap(a,i,end);//把最大的放到i的位置
    return i;
}private static void swap(int[] a,int i,int j)
{
    int tmp=a[i];
    a[i]=a[j];
    a[j]=tmp;
}
}

A. 找到最大值
B. 找到最小值

C. 从大到小的排序
D. 从小到大的排序

  1. 以下Java程序运行的结果是

public class Teste{

public static void main(String[] args){

   Integer var1=new Integer(1);

   Integer var2=var1;

   doSomething(var2);

   System.out.print(var1.intValue());

   System.out.print(var1==var2);

}

public static void doSomething(Integer integer){

    integer=new Integer(2);

    }

}

  1. 1true
  2. 2true
  3. 1false
  4. 2false
  1. 关于下面的程序Test.java说法正确的是(    )。

public class Test {

    static String x="1";

    static int y=1;

    public static void main(String args[]) {

        static int z=2;

        System.out.println(x+y+z);

    }

}

  1. 3
  2. 112
  3. 13
  4. 程序有编译错误
  1. 以下程序输出()

public static void main(String[] args) {

   int num = 2;

   switch (num) {

   case 1:

        ++num;

   case 2:

        ++num;

   case 3:

        ++num;

   default:

        ++num;

   break;

   }

   System.out.println(num);

 }

}

  1. 2
  2. 3
  3. 4
  4. 5
  1. 以下JAVA程序的输出是什么()

public class HelloSogou{

     public static synchronized void main(String[] a){

         Thread t=new Thread(){

             public void run(){Sogou();}

     };

     t.run();

     System.out.print("Hello");

     }

     static synchronized void Sogou(){

     System.out.print("Sogou");

    }

}

  1. HelloSogou
  2. SougouHello
  3. Hello
  4. 结果不确定

 

  1. 对于语句NSString*obj = [[NSData alloc] init]; obj在编译时和运行时分别时什么类型的对象?
  1. 编译时是NSString的类型;运行时是NSData类型的对象
  2. 编译时是NSString的类型;运行时是NSString类型的对象
  3. 编译时是NSData的类型;运行时是NSString类型的对象
  4. 编译时是NSData的类型;运行时是NSData类型的对象

 

  1. 以下关于final关键字说法错误的是()
  1. final是java中的修饰符,可以修饰类、接口、抽象类、方法和属性
  2. final修饰的类不能被继承
  3. final修饰的方法不能被重载
  4. final修饰的变量不允许被再次赋值
  1. String s = null;

会抛出NullPointerException异常的有()。

  1. if( (s!=null) & (s.length()>0) )
  2. if( (s!=null) && (s.length()>0) )
  3. if( (s==null) | (s.length()==0) )
  4. if( (s==null) || (s.length()==0) )

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值