面试题

普天合力

一共就两到题,时间30分钟

1. 完成一个方法public String[]  union(String[] array1,  String[]  array2)

要求,把array1和array2合并,并且里面不能有重复的字符串,

获取两个整型数组之间的重复元素集合

public class Test{
    /**
     * 获取两个整型数组之间的重复元素集合
     * @param array1 数组参数1
     * @param array2 数组参数2
     * @return
     */
    public List findSame(int array1[],int array2[]){
        List result=new ArrayList();//重复元素结果集合
        HashMap hashMap=new HashMap();//利用hashmap来寻找重复元素
        for(int i=0;i<array1.length;i++){//将第一个数组加入hashmap
            String temp=array1[i]+"";
            hashMap.put(temp,temp);
        }
        for(int i=0;i<array2.length;i++){//遍历第二个数组
            String temp=array2[i]+"";
            if(hashMap.get(temp)!=null){//在已经存在第一个数组所有元素的hashmap里寻找第二数组里的元素
                result.add(array2[i]);//将重复出现的元素加入结果集合
            }
        }
        return result;
    }
    public static void main(String args[]){
        long timeBegin=System.currentTimeMillis();
        int   a[]   =   {1,   6,   2,   8,   5,   8,   6,   9,   0};
        int   b[]   =   {4,   5,   4,   8,   7,   6,   2,   0};
                //获取重复元素集合
        List list=new Test().findSame(a, b);
        //遍历输出重复元素
        for(int i=0;i<list.size();i++){
            System.out.println(list.get(i));
        }
        }
}

面试中的问题

1.介绍一下你的OA项目,你负责什么

2.工作流是怎么实现的,

3.OA分几层,为什么?事务在那层控制?

4.界面也是你设计的吗

5.一个用户准备修改一条数据,查出来以后,在修改期间,另一个用户在他之后查的数据并修改提交了,问怎么保证数据的完整性(乐观锁)

6.Jboss和tomcat的区别

7.为什么使用tomcat

8.Struts2用过没,怎么用?

9.Spring用来干什么的

10.Oracle中怎么给用户授权

11.Vecot和arrayList的区别

12.什么是线程安全

首钢

笔试:写一个排序算法,并注明是什么算法(面试时他说考的是代码的格式和类名的定义)

面试:

1.struts和struts2的区别

2.Struts2中的验证框架怎么使用,以及验证配置文件怎么命名

3.说一下你项目中的技术架构

4.Ibatis用过没,基本是怎么使用的?

5.Dwr用过没?怎么用?Jsp需要引入几个基本的文件

6.Hibernate中id的生成策略

7.Oracle和mysql使用native生成策略时有什么不同

8.懂jbpm吗,怎么在一个节点中分配任务

9.你写的jbpm里都有什么方法

10.给了几道sql题,要求口述出来

东方景宏

1. 1问答题:

2. Hashcode、equals和“==”三者有什么关系,又有什么不同?

3. abstract修饰符可以修饰什么?分别是什么含义?

 

4. 是否可以继承String类?为什么?

我们在动态组织一个字符串时,可以只用String的“+”,也可以使用StringBuffer.append方法,两者有何区别?

5. Hashtable是线程安全的,HashMap不是线程安全,什么是线程安全,请简单描述?

6. JSP和Servlet有哪些相同点和不同点,他们之间的联系是什么?

7. 在Servlet提供这样一个方法getInitParameter(String name),用来获取Servlet的初始化参数,请问该数据是在什么地方配置的?web.xml  <param-name>

8. 如何让一个Servlet在Web Application启动的时候就装载? <load-on-startup>0

启运级别值越小,隔离级加越高。

9. 我们在web应用开发过程中经常遇到输出某种编码的字符,如iso8859-1等,如何输出一个某种编码的字符串?

text = new String( text.getBytes(“iso8859-1”),”gbk”); 

10. 请说出数据连接池的工作机制是什么?


一、 程序题

1、 下面的代码,运行结果是?

Class Value{

   public int i = 15;

}

public class Test{

   public static void main(String argv[ ]) {

       Test t = new Test();

       t.first();

   }

   public void first(){

  int i = 5;

  Value v = new Value();

  v.i=25;

  second(v,i);

  System.out.println(v.i+”&”+i+”\r\n”);

}

public void second(Value v, int i){

    i=0;

v.i=20;

Value val=new Value();

    v=val; //主要就在这

System.out.println(v.i+”&”+i+”\r\n”);

}

}

输出给果 :15&0   20&5

 

2、 下面代码,运行结果(假如代码执行过程中没有异常抛出)是什么?

try{

System.out. println(“try is start!\n”);

 

-----

System.out. println(“try is end!\n”);

return;

}catch(Exception e){

   System.out. println(“exception is catch!\n”);

}  finally{

   System.out. println(“Finally is excuted!\n”);

}

 

3、 以下代码执行后结果如何?

import java.io.IOException;

public class Exception Test{

   public static void main(String[]args){

      try{

          methodA();

      }catch(IOException e){

         System.out. println(“Caught IOException”);

      }catch(Exception e){

         System.out. println(“Caught Exception”);

      }

   }

public static void methodA(){

throw new IOException();

}

}

 

A编译错误                           B输出“Caught Exception”

C输出“Caught IOException”           D正常执行,但是无输出

 

4、 下面代码:

        switch(x){

        case 1:

             System.out. println(“Test 1”);

             break;

        case 2:

        case 3:

             System.out. println(“Test 2”);

             break;

        default:

             System.out. println(“end”);

当x为什么值时,可以输出“Test 2”

 

 

5、 下面这段代码有多少次“OK”被输出

        for(int i=0;i<5;i++){

           if(i= =2){

               continue;

           }

           System.out. println(“OK”);

        }

小罗答:四次。

Continue 是跳出本次循环

 

 

 

6、 下面代码输出什么?

 public class   FatherClass

{

   public FatherClass()

{

System.out. println(“FatherClass Create”);

}

   }

   子类

   public Class   ChildClass extends FatherClass

   {

   public ChildClass()

{

System.out. println(“ChildClass Create”);

}

public static void main(String[]args)

{

FatherClass fc=new FatherClass();

ChildClass cc=new ChildClass();

}

}

3.下面数组声明中,哪些是正确的

A:  int a[][]=new int[][];

B:  int b[10][10]=new int[][]

C:  int c[][]=new int[10][] 对的

D:  int d[] []=new int[][10]

E:  int e[][]=new int[10][10] 对的

int num[5]; 这是错的 因为一个数组的大小将在数组使用new关键字真正创建时被给定

可前可后

 

19、下面这段代码

int list[]=new int[2];

for(int i =0;i<list.length;  i++)

{

   System.out. println(list[i]);

}

执行的时候,输出什么内容?两个零

 

20、下面代码的执行结果是什么?

假设public classA extend Object

public classB extend A

代码段:

   A a=new B();

If(a instanceof B){

    System.out. println(“B”);

}

If(a instanceof A){

    System.out. println(“A”);

}

 

 

21、下面这段程序的运行结果是什么?

     public class A{

         public static String getName(){

            return"AName";

         }

 

         public String getValue(){

            Return"AValue";

         }

      }

      public class B extends A{

          public static String getName(){

              Return"BName";

          }

           public String getValue(){

            Return"BValue";

          }

          public static void main(String[] argvs){

              A a=new B();

       System.out. println(a.getName()+“&” +a.getValue());

   }

}

静态的方法不能被重写

22、你写一段Jdbc连Oracle的程序,实现数据查询?

 

第三部分:数据库

有如下两张表,学生基本信息表(student)和考试成绩登记表(scope)

Student

学生证号

姓名

性别

年龄

1101001

张三

男

15

1101002

李娟

女

16

1101003

王武

男

15

1101004

张三

男

16

1101005

王兰

女

15

Scope

学生证号

语文

数学

地理

1101001

78

89

65

1101002

84

83

78

1101003

76

93

67

1101004

73

92

62

1101005

75

86

72

 

1、用一个sql语句,查询姓名为“张三”的如下信息:“学生证号/姓名/性别/语文/数学/地理”

2、用一个sql语句,查询该班级中语文成绩>数学成绩的学生的如下信息:“学生证号/姓名/性别/语文/数学/地理”

 

3、用一个sql语句,为学号“1101002”的学生语文、数学、地理成绩分别加5分

 

4、用一个sql语句,查询男、女学生的语文平均成绩

 

5、用一个sql语句,查询语文成绩大于语文平均成绩的学生的:“学号/姓名/语文”

 

 

 

 




查看原文:http://www.coder306.cn/?p=139
posted @ 2018-03-01 11:40  两粒  阅读(129)  评论(0)    收藏  举报