zoukankan      html  css  js  c++  java
  • 两道Java面试题!

    自己最近在面试的时候,遇到两个面试题记忆比较深刻,这里记下来分享给大家.
     
    1.  如下给出了两个Java类
    父类(Parent)
    public class Parent {
        static{
            System.out.println("Parent_1");
        }
     
        {
            System.out.println("Parent_2");
        }
     
        public Parent(){
            System.out.println("Parent_3");
        }
    }
     
    子类 (Child)
    public class Child extends Parent {
        static{
            System.out.println("Child_1");
        }
        
        {
            System.out.println("Child_2");
        }
        
        public Child(){
            super();
            System.out.println("Child_3");
        }
        
        public static void main(String args[]){
            new Child();
        }
    }
    请写出正确的打印顺序.
     
     
    2. 给出如下的Java代码(这道题很有意思哟!)
    public class Test {
        public static void main(String[] args){
            Integer m1 = 25;
            Integer m2 = 25;
            Integer n1 = new Integer(25);
            Integer n2 = new Integer(25);        
            Integer x1 = 127;
            Integer x2 = 127;
            Integer y1 = 128;
            Integer y2 = 128;
     
            System.out.println(m1==m2);
            System.out.println(n1==n2);
            System.out.println(x1==x2);
            System.out.println(y1==y2);
        }
    }
    请写出最后的输出结果.


      

  • 相关阅读:
    Linxu 挂载光盘和硬盘
    Linux firewall
    指纹获取 Fingerprint2
    Vue 封装的组件生命周期钩子
    vue富文本编辑,编辑自动预览,单个图片上传不能预览的问题解决:
    vue 集成百度富文本编辑器
    axios 的二次封装
    element 列表中已选的标记
    element 表单的input循环生成,并可单个input失去焦点单个验证并保存; (多个表单实例)
    axios 二进制流导出
  • 原文地址:https://www.cnblogs.com/cookray/p/3165020.html
Copyright © 2011-2022 走看看