• 【深圳X金技术公司】Java笔试题


    前言
    今年 8 月份,一个同学内推的面试,好吧,笔试题我做得一塌糊涂,然后被面试官一顿血虐。

    正文

    一 选择题
    1)关于 C++ / Java 类中 static 成员和对象成员的说法正确的是()

    • A static 成员变量在对象构造时生成
    • B static 成员函数在对象成员函数中无法使用
    • C 虚成员函数不可能时 static 成员函数
    • D static 成员函数不能访问 static 成员变量

    2)袋中有红球,黄球,白球各一个,每次任意取一个又放回,如此连续抽取 3 次,则下列事件中概率是 8/9 的是()

    • A 颜色不全相同
    • B 颜色全相同
    • C 颜色全不同
    • D 颜色无红色

    3)通常不采用 () 方法来解除死锁

    • A 终止一个死锁进程
    • B 终止所有死锁进程
    • C 从死锁进程处抢夺资源
    • D 从非死锁进程处抢夺资源

    4)32 位系统环境,编译选项为 4 字节对齐,那么 sizaof (A) 和 sizeof(B)分别()

    structA{
     int a;
     short b;
     int c;
     char d;
    }
    
    
    structB{
     int a;
     short b;
     char d;
     int c;
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • A 16, 16
    • B 16, 12
    • C 13, 12
    • D 11, 16
    1. 下面() 是合法的 Java 标识符。
    • A #_pound
    • B _underscore
    • C 5Interstate
    • D class
    1. 当需要在文件中写入字符而不是字节时,在下面的类中最好选用()类。
    • A java.io.RandomAccessFile
    • B java.io.PrintWriter
    • C java.io.PrintStream
    • D java.io.PrintOutputStream
    1. 下面这段代码会产生 () 个 String 对象。

      String s1 = “hello”;
      String s2 = s1.substring(2,3);
      String s3 = s1.toString();
      String s4 = new StringBuffer(s1).toString();

    • A、1
    • B、2
    • C、3
    • D、4

    8)Swtich 不能作用在下面那个数据类型上?

    • A、int
    • B、short
    • C、String
    • D、byte
    1. 对 hashmap ,arraylist 内存储的数据是否有序的描述那个是正确的?()
    • A 、无序,有序
    • B、 有序,有序
    • C、 无序,无序
    • D、 有序,无序

    10)关于下面程序,()的结论是正确的。

    class J_SubClass extends J_Test{}
    public class J_Test{
    	J_Test(int i ){
    	System.out.println(i);
     }
     public static void main(String[] args){
    	J_SubClass a = new J_SubClass();
     }
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • A、不能通过编译,因为类 J_Test 没有定义无参数的构造方法
    • B、 不能通过编译,因为类 J_SubClass 没有定义无参构造方法
    • C、不能通过编译,因为没有实现 J_SubClass( int i) 的构造方法
    • D、可以成功通过编译

    二、问答题
    1)读程序,写出和程序输出格式一致的输出结果。

    public class J_Test{
    	 public static void main(String[] args){
            int sum= 0;
            outer:for(int i = 1; i < 10; ++i){
                inner:for(int j = 1; j < 3; ++j){
                    sum +=j;
                    if(i + j > 6){
                        break inner;
                    }
                }
                System.out.println("sum = " + sum);
            }
        }
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14

    结果:

    sum = 3
    sum = 6
    sum = 9
    sum = 12
    sum = 15
    sum = 16
    sum = 17
    sum = 18
    sum = 19
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    1. 读程序,写出和程序输出格式一致的输出结果。

      public class J_Test{
      public static void mb_method(int i) {
      try {
      if (i == 1) {
      throw new Exception();
      }
      System.out.println(“1”);
      } catch (Exception e) {
      System.out.println(“2”);
      return;
      } finally {
      System.out.println(“3”);
      }
      System.out.println(“4”);
      }

      public static void main(String[] args) {
          mb_method(0);
          mb_method(1);
      }
      
      • 1
      • 2
      • 3
      • 4

      }

    运行结果:

    1
    3
    4
    2
    3
    
    • 1
    • 2
    • 3
    • 4
    • 5
    1. 读程序,写出和程序输出格式一致的输出结果。

      public class J_Test{
      public static void mb_method(StringBuffer x, StringBuffer y){
      x.append(y);
      y = x;
      }
      public static void main(String[] args){
      StringBuffer a = new StringBuffer(“A”);
      StringBuffer b = new StringBuffer(“B”);
      mb_method(a, b);
      System.out.println(a + “,” + b);
      }
      }

    运行结果:

    AB,B
    
    • 1
    1. 读程序,写出和程序输出格式一致的输出结果。

      int func(int m, int n){
        if(m%n == 0){
        	return n;
        }else{
        	return func(n, m%n);
        }
      }
      
      • 1
      • 2
      • 3
      • 4
      • 5
      • 6
      • 7

    请问 func(2012, 2020) 的结果是( 4 )

    1. 读程序,写出和程序输出格式一致的输出结果。

      int i = 0, j = 9;
      do {
      if (i++ > --j) {
      break;
      }
      }
      while (i < 4) ;
      System.out.println("i = " + i + "and j = " + j);

    运行结果:

    i = 4and j = 5
    
    • 1
  • 相关阅读:
    npm、yarn到pnpm的发展历程
    数据响应式原理
    d区间函数属性实践
    Android使用AndServer在安卓设备上搭建服务端(Java)(Kotlin)两种写法
    《MATLAB 神经网络43个案例分析》:第30章 基于随机森林思想的组合分类器设计——乳腺癌诊断
    完善的会员体系对消费品企业来说有多重要?
    Unity的碰撞检测(三)
    Dynamsoft Dynamic .NET TWAIN for net Crack
    打游戏的蓝牙耳机推荐哪一款?吃鸡蓝牙游戏耳机推荐
    Python二进制序列类型(二)array、struct和memoryview
  • 原文地址:https://blog.csdn.net/m0_67401746/article/details/126553385