单选题:查看输出结果
    阅读代码:阅读代码,写结果
    20选择题
    程序题10
    简答:sleep waite区别
    虚假唤醒
    equals与==区别
    两个编程题(10分每题)

    我的答案
    QQ图片20210301215334.jpgQQ图片20210301215344.jpgQQ图片20210301215351.jpgQQ图片20210301215358.jpg

    一.单选题(2分 x 20)
    【单选题】
    1. 下列说法正确的是 _。
    A. Java程序经编译后会产生machine code
    B. Java程序经编译后会产生byte code
    C. Java程序经编译后会产生DLL
    D. 以上都不正确
    【单选题】

    1. 下列代码中,哪句代码会报错()
    2. byte b = 127;
    3. byte b = 10; b += 1;
    4. byte b = 11; b = b + 1;
    5. char c = 97;

    【单选题】
    3. 设 int x = 1 , int y = 2 , int z = 3,则表达式 y+=z— / ++x 的值是 _。
    A. 3
    B. 3.5
    C. 4
    D. 5
    【单选题】
    4. 0.6332的数据类型是 _。
    A. float
    B. double
    C. Float
    D. Double
    【单选题】
    5. 下列说法正确的有 _。
    A. class中的constructor不可省略
    B. constructor必须与class同名,但方法不能与class同名
    C. constructor在一个对象被创建时执行
    D. 一个class只能定义一个constructor
    【单选题】
    6. 以下关于继承的叙述正确的是 _。
    A. 在Java中类只允许单一继承
    B. 在Java中一个类只能实现一个接口
    C. 在Java中一个类不能同时继承一个类和实现一个接口
    D. 在Java中接口只允许单一继承
    【单选题】
    7. 构造方法名必须与_相同,它没有返回值,用户不能直接调用它,可以通过new使用。
    A. 类名
    B. 对象名
    C. 包名
    D. 变量名
    【单选题】
    8. 下列说法中,_是正确的。
    A. 子类拥有的成员数目大于父类拥有的成员数目
    B. 父类代表的对象范围比子类广
    C. 子类要调用父类的方法,必须使用super关键字
    D. 一个Java类可以有多个父类
    【单选题】
    9. 下列哪种异常是检查型异常,需要在编写方法时声明 _。
    A. NullPointerException
    B. ClassCastException
    C. FileNotFoundException
    D. IndexOutOfBoundsException
    【单选题】
    10. 下面哪个流类属于面向字符的输入流 _。
    A. BufferedWriter
    B. FileInputStream
    C. ObjectInputStream
    D. InputStreamReader
    【单选题】
    11. 阅读如下代码:
    1)class Super{
    2) public float getNum(){return 3.0f;}
    3) }
    4)
    5) public class Sub extends Super{
    6)
    7) }
    which method, placed at line 6, will cause a compiler error?
    A. public float getNum(){return 4.0f;}
    B. public void getNum(){}
    C. public void getNum(double d){}
    D. public double getNum(float d){return 4.0d;}
    【单选题】
    12. 阅读代码
    public class Equals{
    public static void add3(Integer i){
    int val = i.intValue();
    val += 3;
    i = new Integer(val);
    }
    public static void main(String args[]){
    Integer i=new Integer(0);
    add3(i);
    System.out.println(i.intValue());
    }
    }
    what is the result?
    A. compile fail
    B. print out “0”
    C. print out “3”
    D. compile succeded but exception at line 3
    【单选题】
    13. 下列场景中,_不会触发类加载过程。
    A. 创建类的实例
    B. Jvm加载子类
    C. 访问类的静态成员
    D. 访问对象的成员
    【单选题】
    14. 下面代码的运行结果为:()

    import java.io.;
    import java.util.
    ;

    public class foo{

    public static void main (String[] args){
    String s;
    System.out.println(“s=” + s);
    }
    }
    A. 代码得到编译,并输出“s=”
    B. 代码得到编译,并输出“s=null”
    C. 由于String s没有初始化,代码不能编译通过
    D. 代码得到编译,但捕获到 NullPointException异常
    【单选题】
    15. 以下对接口描述错误的有 _。
    A. 接口没有提供构造方法
    B. 接口中的方法默认使用public、abstract修饰
    C. 接口中的属性默认使用public、static、final修饰
    D. 接口不允许多继承
    【单选题】
    16. 关于守护线程的说法,正确的是 _。
    A. 所有非守护线程终止,即使存在守护线程,进程运行终止
    B. 所有守护线程终止,即使存在非守护线程,进程运行终止
    C. 只要有守护线程或者非守护进程其中之一存在,进程就不会终止
    D. 只要所有的守护线程和非守护线程终止运行之后,进程才会终止
    【单选题】
    17. 下列方法被调用后,一定使调用线程改变当前状态的是_。
    A. notify()
    B. run()
    C. sleep()
    D. isAlive()
    【单选题】
    18. 有如下程序
    1)public class X{
    2) public Object m(){
    3) Object o=new Float(3.14F);
    4) Object[] oa=new Object[1];
    5) oa[0]=o;
    6) o=null;
    7) oa[0]=null;
    8) System.out.println(oa[0]);
    9) }
    10) }
    对象o最早可以被垃圾回收器回收的位置是:
    A. After line 4
    B. After line 6
    C. After line 7
    D. After line 9(that is,as the method returns)
    【单选题】

    1. 下列说法正确的是()

    A. 所有的Java应用程序运行在同一个JVM中
    B. 任意类型的两个引用变量,都可以相互赋值(若编译器不允许,可以强制类型转化)
    C. 只要类加载完毕,我们就可以调用类中定义的普通成员方法
    D. 所有的缓冲流,都是包装流。
    【单选题】
    20. 在TCP/IP中,解决计算机到计算机之间通信问题的层次是 _。
    A. 网络接口层
    B. 网际层
    C. 传输层
    D. 应用层
    二【读程序题】(2分 x 10)
    21如下程序打印的结果是什么呢?
    (注:答案包括编译失败 或运行异常。请说明结果的同时注明原因,下面同上)
    String str1 = “hello”;
    String str2 = “he”;
    System.out.println(str1.compareTo(str2));

    1. 如下程序打印的结果是什么呢?
      如果在同包的某个main方法中运行Father father = new Son(1000),程序的输出结果是什么?
      class Father {

      int i = 10;
      public Father() {
      System.out.println(getI());
      }

      public int getI() {
      return i;
      }
      }

    class Son extends Father {

    1. int i = 100;
    2. public Son(int i) {<br /> this.i = i;<br /> }
    3. public int getI() {<br /> return i;<br /> }<br />}
    1. 如下程序打印的结果是什么呢?

    public class InTheLoop {
    public static final int END = Integer.MAX_VALUE;
    public static final int START = END - 100;
    public static void main(String[] args) {
    int count = 0;
    for (int i = START; i <= END; i++)
    count++;
    System.out.println(count);
    }
    }

    1. 如下程序打印的结果是什么呢?
      public class AnimalFarm{
      public static void main(String[] args){
      final String pig = “length: 10”;
      final String dog = “length: “ + pig.length();
      System.out. println(“Animals are equal: “ + pig == dog);
      }
      }

    2. 如下程序打印的结果是什么呢?
      class Dog {
      public static void bark() {
      System.out.print(“woof “);
      }
      }
      class Basenji extends Dog {

      public static void bark() {
      }
      }

    public class Bark {
    public static void main(String args[]) {
    Dog woofer = new Dog();
    Dog nipper = new Basenji();
    woofer.bark();
    nipper.bark();
    }
    }
    26. 如下程序打印的结果是什么呢?
    public class Indecisive {
    public static void main(String[] args) {
    System.out.println(decision());
    }
    static boolean decision() {
    try {
    return true;
    } finally {
    return false;
    }
    }
    }
    27. 如下程序打印的结果是什么呢?
    public class Test{
    public static void main(String[]args) {
    int[]x={0,1,2,3};
    for(int i=0;i<3;i+=2) {
    try{
    system.out.println(x[i+2]/x[i]+x[i+1]);
    }catch(ArithmeticException e){
    System.out.println(“errorl”);
    }catch(Exception e){
    System.out.println(“error2”);
    }
    }
    }
    }

    28. 如下程序打印的结果是什么呢?
    public class TestMain {
    static {
    System.out.println(“C”);
    }
    {
    System.out.println(“B”);
    }
    public TestMain(){
    System.out.println(“A”);
    }
    public static void main(String[] args) {
    TestMain testMain = new TestMain();
    }
    }
    29. 如下程序打印的结果是什么呢?
    public class Bground extends Thread{
    public static void main(String[] args){
    Bground bground=new Bground();
    bground.run();
    }

    public void start(){
    for (int i = 0; i < 10; i++) {
    System.out.println(“B ground.start()”+i);
    }
    }
    }
    30. 如下程序打印的结果是什么呢?
    public class Reluctant {
    private Reluctant internalInstance = new Reluctant();
    public Reluctant() throws Exception {
    throw new Exception(“I’m not coming out”);
    }
    public static void main(String[] args) {
    try {
    Reluctant b = new Reluctant();
    System.out.println(“Surprise!”);
    } catch (Exception ex) {
    System.out.println(“I told you so”);
    }
    }
    }
    三【简答题】(2分 x 10)
    31. 引用类型和基本数据类型有何区别?
    【简答题】
    32. java中父类中定义的哪些方法没有多态效果,为什么?
    【简答题】
    33. 如何理解静态上下文无法访问非静态的成员变量和成员方法?
    【简答题】
    34. 方法重载和方法重写的区别。
    【简答题】
    35. “==”和equals方法有何异同?
    【简答题】
    36. 字符流和字节流最主要的区别是什么?如何理解字符流=字节流+编码表?
    【简答题】

    1. 使用缓冲流是否可以在一定程度改善应用程序的IO的效率?为什么??

    【简答题】
    38. 同步和异步有何异同,在什么情况下分别使用他们?
    【简答题】
    39. Java语言多线程设计中,为什么wait, notify 和 notifyAll这些线程通信的方法不在thread类里面?

    【简答题】
    40. Java多线程中调用wait() 和 sleep()方法有什么不同?
    四.【编程题】(10分 x 2)
    41. 编程题:
    给定一个由 整数 组成的 非空 数组所表示的非负整数,在该数的基础上加一。
    最高位数字存放在数组的首位, 数组中每个元素只存储单个数字。
    你可以假设除了整数 0 之外,这个整数不会以零开头。
    比如,如果数组是[1, 2, 3]则加1之后的结果是[1, 2, 4], 如果数组是[1, 2, 9]加1之后的结果就是[1, 3, 0]

    【简答题】
    42. 编程题:输入一个整型数组,数组里面有正数也有负数,数组中连续的一个或多个整数组成子数组,每个子数组都有一个和。求所有子数组的和的最大值。例如,输入的数字为:1,-2,3,10,-4,7,2,-5,则和最大的子数组为3,10,-4,7,2和为18。