01-综合测试题

选择题(2/25)

  1. 如下代码中哪行语句是正确的()
1. String #name = "Jane Doe"; 
2. int $age=24; 
3. Double _height = 123.5; 
4. double ~temp = 37.5; 

A. 1,2.
B. 2,3. 
C. 3,4. 
D. 1,4.

  1. 下面程序代码块运行结果为()
Integer b = 200;
Integer a = 200;
int c = 200;
System.out.println(a.equals(b));
System.out.println(a == c);

A.fasle;true 
B.false;false 
C.true;fasle 
D.true;true	
  1. 以下程序的输出结果是什么()
public class Test03 {   
    private int x = 100;
    public static void main(String[] args) {
        int x =5;
        boolean b1 = true;
        boolean b2 = false;
        if((x==4) && !b2)
            System.out.print("l");
        System.out.print("2");
        if ((b2 = true) && b1)
            System.out.print("3");
    }//23
}

A.123 
B.23
C.3
D.2
  1. 如下语句的输出结果是什么?()
public class Test04 {
    public static void main(String[] args) {
        int x=0;
        int y=10;
        do {
             y--;
             if(y==6)continue;
             ++x;
        } while (x < 5);
        System.out.print(x + "," + y);
    }
}
A.5,4
B.4,5
C.5,6
D.6,6
  1. 如下对于数组的定义说法正确的是?()
1.int[] a={1,2,3};
2.int[] b=new int[5];
3.int[][] c={{1},{2}};
4.int[][]d =new int[5][];

A.1,2,3,4都正确
B.只有1,2正确
C.只有1正确
D.只有1,3正确
  1. 阅读如下代码,对运行结果说法正确的是:()
public class Test06 {
    static void f1(int...x) {
        System.out.println("x.length="+x.length);
    }
    static void f1(int y){
        System.out.println("y="+y);
    }
    public static void main(String[] args) {
        f1(10);
    }
}

A.编译错误
B.输出y=10
C.输出x.length=1
D.输出y=10;x.length=1

7.阅读如下代码,其运行结果正确的是?()

public class Test07 {
    public static void main(String[] args) {
        int a=10;
        int b[]={20};
        change(a,b);
        System.out.println(a+","+b[0]);
    }
    static void change(int a,int[] b){
        a=11;
        b[0]=21;
    }
}

A.10,20
B.11,21
C.11,20
D.10,21
  1. 选项中哪个放到code处可以保证程序正常编译? ()
public class Test08 {
  static void foo(int...x){
      //code(插入代码处)
  }
}

A. foreach(x) System.out.println(z); 
B. for(int z : x) System.out.println(z); 
C. while( x.hasNext()) System.out.println( x.next()); 
D. for( int i=0; i< x.length; i++ ) System.out.println(x[i]); 


  1. 阅读如下代码选择正确的运行结果? ()
public class Test09 {
    public static void main(String[] args) {
        String o = "";
        z :
        for(int x=0; x<3; x++){
            for(int y=0; y<2; y++){
                if(x == 1) break;
                if(x==2 && y==1) break z;
                o = o + x + y;
            }
        }
        System.out.println(o);
    }
}

A.  编译失败
B.  0001 
C.  000120 
D.  00012021 

  1. 以下程序的运行结果是()
public class Test10 {
    static void f1(){
        throw new RuntimeException();
    }
    static void f2(){
        f1();
        throw new Exception();
    }
    public static void main(String[] args) {
        f2();
    }
}

A. 程序会抛出RuntimeException
B. 程序会抛出Exception
C. 程序会抛出RuntimeException,Exception
D. 编译失败
  1. 以下程序的运行结果是:()
public class Test11 {
    static void test() throws RuntimeException{
        try{
            System.out.print("test");
            throw new RuntimeException();
        }catch(Exception e){
            System.out.print("exception");
        }
    }
    public static void main(String[] args){
        try{test();}
        catch(RuntimeException ex){
            System.out.print("runtime");
        }
        System.out.print("end");
    }
}

A. test end   
B. 编译失败
C. test runtime end
D. test exception end
  1. 请指出以下代码的运行结果?()
public class Test12 {
    private static Integer b;
    public static void main(String[] args){
        int a = 10;
        print(a);
        print(b);
        b = a;
        print(b);
    }
    private static void print(Integer value){
        int add = value+5;
        System.out.println(add);
    }
}

A. 15,5,20   
B. 编译失败
C. 15,5,15  
D. 运行时出现NullPointerException
  1. 以下程序在JDK1.8的环境下,描述正确的是()
class A{
    int a=10;
    public A(int a){
        this.a=a;
    }
}
class B extends A{
    int a;
    public B(int a){
        this.a=a;
    }
}
public class Test13 {
    public static void main(String[] args) {
        A a=new B(20);
        System.out.println(a.a);
    }
}

A. 10
B. 20
C. 编译失败
D. 0
  1. 下面的程序输出的结果是?()
interface IC{
    int M = 10;
}
class C implements  IC{
    int M = 20;
    int N = 30;
}
public class Test14{
    public static void main(String[] args) {
        IC c1=new C();
        System.out.println(c1 instanceof C);
        System.out.println(c1.M);
        System.out.println(c1.N);
    }
}

A. true,10,30
B. false,10,30
C. true,20,30
D. 编译失败

  1. 下面程序的运行结果:()
public class Test15 {
    public static void main(String args[]) {
        Thread t = new Thread() {
            public void run() {
                pong();
            }
        };
        t.run();
        System.out.print("ping");
    }
    static void pong() {
        System.out.print("pong");
    }
}

A. pingpong 
B. pongping 
C. pingpong和pongping都有可能 
D. 编译错误
  1. 下列哪种异常是检查异常,需要在编写程序时声明 ()
A. NullPointerException
B. ClassCastException 
C. FileNotFoundException 
D. IndexOutOfBoundsException

  1. 如下代码运行时,正确的输出结果应该是什么?()
package com.cy.test;

import java.util.ArrayList;
import java.util.List;

public class Test16 {
    static void print(List<Object> list){
        System.out.println(list);
    }
    public static void main(String[] args) {
        List<Integer> list2=new ArrayList<>();
        list2.add(100);
        list2.add(100);
        print(list2);
    }
}

A. [100]
B. [100,100]
C. 输出list对象地址 
D. 编译错误
  1. 如下代码的运行结果是?()
package com.cy.test;

enum Gender{
    MALE,FEMALE,NONE;
    public Gender(){}
    public static void value(Gender gender){
        switch (gender){
            case MALE: System.out.println("男士");break;
            case FEMALE: System.out.println("女士");break;
            default: System.out.println("未知");
        }
    }
}
public class Test17 {
    public static void main(String[] args) {
       Gender.value(Gender.MALE);
    }
}

A. 男士
B. 女士
C. 未知 
D. 编译错误
  1. 阅读如下代码,给出正确运行结果?()
package com.cy.test;

@Target(ElementType.TYPE)
@interface Entity{
    String value();
}

@Entity(value="obj")
class Obj{}

public class Test18 {
    public static void main(String[] args) {
        Entity entity=Obj.class.getAnnotation(Entity.class);
        System.out.println(entity.value());
    }
}

A. obj
B. 编译错误
C. 运行时会出现空指针异常 
D. null
  1. 阅读如下代码,给出正确的输出结果。()
package com.cy.test;

import java.util.LinkedHashMap;

public class Test19{
    public static void main(String[] args) {
        LinkedHashMap<String,Object> map=
          new LinkedHashMap<>(3,0.75f,true);
        map.put("A", 100);
        map.put("B", 200);
        map.get("A");
        map.put("C", 300);
        map.put("D", 400);
        map.get("B");
        System.out.println(map);
    }
}

A. {A=100, B=200, C=300, D=400}
B. {A=100, C=300, D=400, B=200}
C. {B=200, A=100, D=400, C=300}
D. 不确定

21.对如下代码描述错误的是?()

@FunctionalInterface
interface IA{
  void show();  
}

A. @FunctionalInterface 描述的是JDK8推出的函数式接口。
B. @FunctionalInterface 描述的接口中只能有一个抽象方法
C. @FunctionalInterface 描述的接口中可以有多个抽象方法
D. @FunctionalInterface 描述的接口中允许有静态方法。
  1. 对如下说法描述错误的是?()
package com.cy.test;

import java.util.Arrays;
import java.util.List;

public class Test21 {
    public static void main(String[] args) {
      List<String> list=Arrays.asList( "B", "A", "C" );
      list.sort((String e1,String e2) -> {
          int result = e1.compareTo( e2 );
          return result;
      } );
      list.add("D");
      System.out.println(list);
    }
}

A. 程序在JDK8环境下可以正确编译。
B. 程序的输出结果是[A,B,C,D]
C. 程序中e1,e2两个变量左侧的String类型可以省略。
D. 输出list时,默认底层会调用list变量指向的对象的toString()方法

  1. 阅读如下代码,正确的说法是?()
package com.cy.test;

import java.util.Arrays;
import java.util.List;

public class Test22 {
    public static void main(String[] args) {
        List<Integer> list = Arrays.asList(3, 2, 12, 5, 6, 11, 13);
        long count = list.stream()
                         .filter(i -> i % 2 == 0||i % 3 == 0)
                         .count();
        System.out.println(count);
    }
}

A. JDK8环境下编译失败。
B. 输出的结果为 6
C. 输出的结果为 4
D. 输出的结果为 3
  1. 阅读如下程序,给出正确的结果。()
package com.cy.test;

interface IM{
    default void f1(){
        System.out.println("f1()");
    }
    static void f2() {
        System.out.println("f2()");
    }
}
class ClassM implements  IM{
    public void f1(){
        System.out.println("ClassM.f1()");
    }
    static void f2() {
        System.out.println("ClassM.f2()");
    }
}

public class Test23 {
    public static void main(String[] args) {
         IM m1=new ClassM();
         m1.f1();
         m1.f2();
    }
}

A.f1() f2()
B.ClassM.f1() ClassM.f2()
C.ClassM.f1() f2()
D.编译失败

  1. 有关SimpleDateFormat说法错误的是?( )
A. 将将Java中的Date日期对象转换为字符串
B. 可以将日期格式字符串转换为Java中的Date日期对象。
C. JDK8中可使用DateTimeFormatter对象替换SimpleDateFormat对象。
D. 允许多线程共享使用。

简答题(3/10)

  1. 如何理解对象的浅拷贝和深拷贝?

  1. 描述内存溢出和内存泄漏的区别?

  1. 描述一下Java中的四大引用数据类型?

  1. 描述一下Java中的反射以及有什么优势和劣势?

  1. 描述一下你对Synchronized关键字的理解?


  1. Java线程池ThreadPoolExecutor对象构建时的常用参数有哪些?

  1. 描述一下JVM的体系结构是怎样的?

  1. 请描述一下数据库设计时的三大设计范式?

  1. 请描述查询语句中各部分的执行顺序?
select distinct id,name,age from A join B join C on A.xx=B.xx and B.xx=C.xx where xx=? and xx=? group by xx having xx=? order by xx desc/asc limit m,n
      
  1. 设有职工基本表EMP(ENO,ENAME,AGE,SEX,SALARY,DNO),其属性分别表示:职工号,姓名,年龄,性别,工资,所在部门id。部门表DEPT(DNO,DNAME),其属性分别表示:部门id,部门名称.用SQL语句写出每个部门的部门名称及平均薪水,并按平均薪水降序排序。

设计题(5/2)

  1. 如何设计才能保证商品出现超卖现象?

  1. 如何设计才能保证缓存和数据库的一致性?

实践题(5/2)

  1. 基于数组实现一个阻塞式队列?

  1. 基于lru算法设计并实现一个LruCache对象?

答案

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值