zoukankan      html  css  js  c++  java
  • 面试题整理 2017

    1. 在A,B,C字段上建了组合索引,查询时只用了字段A,或字段B,或字段A,B,这样会不会用到索引,能不能解释一下?

    可以

    2.Spring aop: 配置切面记录test方法的出入日志 demo如下:

    public class test{
    
    public void a()
    { b(); } public void b(){} public void c(){} }  

    当调用 方法a(); 会记录 方法b的 方法的出入日志?

    不会。

    3.10亿 数字排序,space 100m  code ?

    4. 类的加载顺序?

    	public static void main(String[] args) {
    		ClassLoader loader = Thread.currentThread().getContextClassLoader();
    		System.out.println("current loader:"+loader);
    		System.out.println("parent loader:"+loader.getParent());
    		System.out.println("grandparent loader:"+loader.getParent(). getParent());
    	}	     

    结果如下:

    current loader:sun.misc.Launcher$AppClassLoader@47858e
    parent loader:sun.misc.Launcher$ExtClassLoader@19134f4
    grandparent loader:null
    

      

    简介如下:

    (1)加载器介绍 
    1)BootstrapClassLoader(启动类加载器) 
      负责加载$JAVA_HOME中jre/lib/rt.jar里所有的class,加载System.getProperty(“sun.boot.class.path”)所指定的路径或jar。 
    2)ExtensionClassLoader(标准扩展类加载器) 
      负责加载java平台中扩展功能的一些jar包,包括$JAVA_HOME中jre/lib/*.jar或-Djava.ext.dirs指定目录下的jar包。载System.getProperty(“java.ext.dirs”)所指定的路径或jar。 
    3)AppClassLoader(系统类加载器) 
      负责记载classpath中指定的jar包及目录中class 
    4)CustomClassLoader(自定义加载器) 
      属于应用程序根据自身需要自定义的ClassLoader,如tomcat、jboss都会根据j2ee规范自行实现。

    (2)类加载器的顺序 
    1)加载过程中会先检查类是否被已加载,检查顺序是自底向上,从Custom ClassLoader到BootStrap ClassLoader逐层检查,只要某个classloader已加载就视为已加载此类,保证此类只所有ClassLoader加载一次。而加载的顺序是自顶向下,也就是由上层来逐层尝试加载此类。 
    2)在加载类时,每个类加载器会将加载任务上交给其父,如果其父找不到,再由自己去加载。 
    3)Bootstrap Loader(启动类加载器)是最顶级的类加载器了,其父加载器为null。

    demo

    public class Parent
    {
    
        static
        {
            System.out.println("static Parent");
        }
    
        {
            System.out.println("common Parent");
        }
        
        public Parent()
        {
            System.out.println("Parent");
        }
        
        public static void test()
        {
            System.out.println("Parent test");
        }
        
        public Parent(String name)
        {
           System.out.println("apple " + name);
        }
    
    }
    

      

    public class Child extends Parent
    {
        static
        {
            System.out.println("static Child");
        }
    
        {
            System.out.println("common Child");
        }
        public Child()
        {
            System.out.println("Child");
        }
    
        public Child(String name)
        {
            System.out.println("Child " + name);
            System.out.println();
            new Parent(name);
        }
    
        public static void test()
        {
            System.out.println("Child test");
        }
        public static void main(String[] args)
        {
           new Child("test");
        }
        
    }
    

     结果:

    static Parent
    static Child
    common Parent
    Parent
    common Child
    Child test
    
    common Parent
    apple test
    

    http://www.cnblogs.com/guoyuqiangf8/archive/2012/10/31/2748909.html

  • 相关阅读:
    SSH框架中使用注解和xml配置的区别
    web项目中log4j的配置
    嵌入式—ASCII码
    MATLAB
    MATLAB
    MATLAB
    MATLAB
    CentOS 7将网卡名称eno16777736改为eth0
    图像增强处理
    Debussy与modelsim联仿时 do 文件脚本
  • 原文地址:https://www.cnblogs.com/xue88ming/p/7263491.html
Copyright © 2011-2022 走看看