遇到过的JAVA面试题

    技术2022-05-19  25

    1、List, Set, Map的区别

    List,Set继承于Colletions, Map另外。有序/无序、唯一/不唯一

    2、String系列问题

    参考String博文

    3、ArrayList, Vector;HashMap,HashTable的区别,(线程)

    4、ClassLoader相关问题

    5、Java反射机制(学习)

    6、一个实例设计模式

    实现一:

    public class Singleton {    private static Singleton s;   private Singleton(){};   /**    * Class method to access the singleton instance of the class.    */   public static Singleton getInstance() {     if (s == null)       s = new Singleton();     return s;   } }

    实现二:

    class SingletonException extends RuntimeException {   public SingletonException(String s) {     super(s);   } } class Singleton {   static boolean instance_flag = false; // true if 1 instance   public Singleton() {     if (instance_flag)       throw new SingletonException("Only one instance allowed");     else       instance_flag = true; // set flag for 1 instance   } } 在多线程的程序中,singleton可能会出现多个实例,解决的办法很简单,加个同步修饰符: public static synchronized Singleton getInstance() 这样就保证了线程的安全性。

    7、重写与重载

    8、EJB的LifeCycle

    9、数据库编程(学习)

    查询每门课程最高分的学生成绩

    select   *   from   表   a where   not   exists(         select   *   from   表   where   学生id   =   a.学生id   and   分数> a.分数)

    10、ArrayList和LinkedList的区别(数组、链表;查找快、修改快)

    11、JVM的性能优化、ClassLoader

    12、已排序数组A[],从位置K截断(K任意)后,将K之前的部分补到原数组的最后。

    编写查找算法程序。参考二分查找,递归思想。每次比较n/2,最大和最小位置。

    13、递归和非递归求解二叉树,前中后序遍历、层序遍历、兄弟节点连接。

    14、数据库优化方法

    索引、数据搜索结果缓存

    15、request.getRequestDispatch()和response.sendRedirect()的区别


    最新回复(0)