2015华数校招笔试详解

提示:试卷上的答案请忽略,以后续解答为准。

 

详细解答:

一、选择题

1、D

2、C  相联存储器是把存储单元所存内容的某一部分作为检索项(即关键字项),用来检索存储器,并读出或写入存储器中与该检索项相符的存储单元的内容。

3、C  DES是一种对称式加密算法,使用 16 个循环,使用异或,置换,代换,移位操作四种基本运算。

4、A   常见的对称加密算法有DES、3DES、Blowfish、IDEA、RC4、RC5、RC6和AES;常见的非对称加密算法有:RSA、ECC(移动设备用)、Diffie-Hellman、El Gamal、DSA(数字签名用);常见的Hash单向加密算法有MD2、MD4、MD5、HAVAL、SHA

5、C

6、A

7、A    因为是非剥夺式的,请求资源没有得到满足,则会进入阻塞状态。

8、B    由系统进程检查进程资源状态。

9、B    死锁的四个必要条件:

  (1) 互斥条件:一个资源每次只能被一个进程使用。
  (2) 请求与保持条件:一个进程因请求资源而阻塞时,对已获得的资源保持不放。
  (3) 不剥夺条件:进程已获得的资源,在末使用完之前,不能强行剥夺。
  (4) 循环等待条件:若干进程之间形成一种头尾相接的循环等待资源关系。

     该策略破坏了其中的请求和保持条件。

10、D   概要设计就是系统设计的说明书,不需要每个模块的伪代码。

11、A    原型化方法是为了破除阶段性严格定义的方案,它向用户提供以界面为主导的解决方案,是一种自外向内的设计过程。

12、C

13、A    像星型,网型,总线型,环型这些拓扑结构对网速影响不大,不同点在于拓扑的可靠性和费用。

14、B    多数情况下,一个堡垒主机使用两块网卡,每个网卡连接不同的网络。一块网卡连接你公司的内部网络用来管理、控制和保护,而另一块连接另一个网络,通常是公网也就是Internet。

15、B     参考维基百科http://zh.wikipedia.org/zh/MPEG-4

16、B     124个叶结点的完全二叉树,最多的情况是1+2+4+8+16+32+64+120+1(可补一个左结点)=248

17、D     面向对象三大特征:封装、继承、多态。

18、A     继承的目的之一就是代码复用。

19、A     remove可直接删除该对象

20、D     x是static静态变量,存放在静态存储区中,无论直接访问和实例化访问,都是同一对象。

21、D     没有无参的默认构造函数。

22、C     String是final类型的不可变量,字符串数组是对对象的引用进行操作。

23、D     StringBuffer是可变的字符串类,operate方法接受的是StringBuffer对象引用的复制,原始引用并未改变(基本类型传递是值的复制,对象传递是引用的复制),方法运行完后该复制自动消失,打印的是原始引用的对象信息,这里对引用a的对象添加b,而引用b的对象不变。故结果为AB,B。

24、B     访问权限并不是为自己访问而设置的,大多是不同类之间的相互引用限制。

25、D     继承后,子类实例化是首先进入父类的无参构造方法。

二、数据库

26、MySQL分页可直接通过limit实现:select * from 表名 limit m,size;从m+1条查询size条记录。SQLServer可以使用Top和not in实现:select top 10 * from 表名 where 主键 not in(select top 10 主键 from 表名);--查询显示11-20条记录(10条)。

27、以下解析仅供参考,用join实现更好。

  (1) select * from J where CITY='南京';

    (2) select SPJ.SN from SPJ,J where SPJ.JN=J.JN and J.CITY='上海';

  (3) select SPJ.SN from SPJ,J,P where SPJ.JN=J.JN and SPJ.PN=P.PN and J.CITY='上海' or J.CITY='北京' and P.COLOR='红色';

  (4) select SPJ.PN from SPJ,J,S where SPJ.JN=J.JN and SPJ.SN=S.SN and J.CITY=S.CITY;

  (5) select distinct SPJ.JN from SPJ,J,S where SPJ.JN=J.JN and SPJ.SN=S.SN and J.CITY <> S.CITY;

  (6) select SPJ.JN from SPJ,S where SPJ.SN=S.SN and SPJ.QTY=0 and S.CITY='上海';

  (7) select S.CITY,J.CITY from SPJ,J,S where SPJ.JN=J.JN and SPJ.SN=S.SN;

三、Android题

28、Android四大组件:http://www.eoeandroid.com/thread-33435-1-1.html

  Activity:Activity是Android程序与用户交互的窗口,是Android构造块中最基本的一种,它需要为保持各界面的状态,做很多持久化的事情,妥善管理生命周期以及一些跳转逻辑
  service:后台服务于Activity,封装有一个完整的功能逻辑实现,接受上层指令,完成相关的事务,定义好需要接受的Intent提供同步和异步的借口
  Content Provider:是Android提供的第三方应用数据的访问方案,可以派生Content Provider类,对外提供数据,可以像数据库一样进行选择排序,屏蔽内部数据的存储细节,向外提供统一的借口模型,大大简化上层应用,对数据的整合提 供了更方便的途径
  BroadCast Receiver:接受一种或者多种Intent作触发事件,接受相关消息,做一些简单处理,转换成一条Notification,统一了Android的事件广播模型。

29、Android五大布局:http://mobile.51cto.com/android-229801.htm

四、Java题

30、常见的七种排序算法:快速、归并、堆、选择、冒泡、插入和希尔。

冒泡排序(稳定):

public static void bubbleSort(int[] a)
{
    for(int i=a.length-1;i>0;i--)
    {
        for(int j=0;j<i;j++)
         {
            if(a[j]>a[j+1])
            {
                int temp=a[j];
                a[j]=a[j+1];
                a[j+1]=temp;
            }
        }
    }
}        

选择排序(不稳定):

    public static void selectSort(int[] a){
        for(int i =0;i<a.length;i++)
        {
            int k = i;
            for(int j =i+1;j<a.length;j++)
            {
                if(a[k]>a[j])
                    k=j;
            }
            if(k!=i){
                int temp = a[i];
                a[i]=a[k];
                a[k]=temp;
            }
        } 
    }

插入排序(稳定):在部分已排序的序列中使用插入排序可达到最少的比较次数。

public static void insertSort(int[] a){
        for(int i =1;i<a.length;i++){
            int temp = a[i];
            int j;
            for(j =i-1;j>=0&&temp<a[j];j--)
                    a[j+1]=a[j];
            a[j+1] = temp;
        }
}

希尔排序(不稳定):

public static void shellSort(int[] a){
        int gap = 0;
        while(gap<=a.length){ //改进版insert排序,增加gap跨区域排序
            gap = gap*3+1;
        }
        while(gap>0){
            for(int i =gap;i<a.length;i+=gap){
                int temp = a[i];
                int j;
                for(j =i-gap;j>=0&&temp<a[j];j-=gap){
                    a[j+gap]=a[j];
                }
                a[j+gap] = temp;
            }
            gap = (gap-1)/3;
        }
}

快速排序(不稳定):

public static void quickSort(int[] a,int low,int high){
        if(low >=high){
            return;
        }
        int start = low;
        int end = high;
        int temp = a[low];
        while(low<high){
            while(low<high&&a[high]>temp){
                high--;
            }
            a[low] = a[high];
            while(low<high&&a[low]<temp){
                low++;
            }
            a[high]=a[low];
        }
        a[low] = temp;
        quickSort(a,start,low-1);
        quickSort(a,low+1,end);
    }

归并排序(稳定):

public static void mergeSort(int[] a,int start,int end){//分治法
        if(start<end){
            int mid = (start+end)/2;
            mergeSort(a,start,mid); //递推排序
            mergeSort(a,mid+1,end);
            merge(a,start,mid,mid+1,end);
        }
    }
    private static void merge(int[] a, int start, int mid, int i, int end) {
        // TODO Auto-generated method stub
        int m = start;
        int temp[] = new int[end-start+1];
        int k = 0;
        while(start<=mid&&i<=end){
            if(a[start]<a[i]){
                temp[k++] = a[start++];
            }else{
                temp[k++] = a[i++];
            }
        }
        while(start<=mid){
            temp[k++] = a[start++];
        }
        while(i<=end){
            temp[k++] = a[i++];
        }
        for(int element:temp){//将排好的数组替换以前的
            a[m++] = element;
        }
    }

堆排序(不稳定):这个排序面试问的最多,务必要手写出来

public static void heapSort(int[] a){
        createMaxHeap(a);
        for(int i=a.length-1;i>0;i--){
            int temp = a[0];
            a[0]=a[i];
            a[i]=temp;
            maxHeap(a,1,i);
        }
    }
    private static void createMaxHeap(int[] a) {
        // TODO Auto-generated method stub
        int startNode = a.length/2; 
        for(int i = startNode;i>0;i--){
            maxHeap(a,i,a.length);
        }
    }
    private static void maxHeap(int[] a, int startNode, int length) {
        // TODO Auto-generated method stub
        int leftNode = 2*startNode;
        int rightNode = 2*startNode+1;
        int maxNode = startNode;
        if(leftNode<=length&&a[leftNode-1]>a[startNode-1]){//只考虑length以内的家族,数组与节点相差1
            maxNode = leftNode;
        }
        if(rightNode<=length&&a[rightNode-1]>a[maxNode-1]){
            maxNode = rightNode;
        }
        if(maxNode!=startNode){
            int temp = a[maxNode-1];
            a[maxNode-1]=a[startNode-1];
            a[startNode-1]=temp;
            maxHeap(a,maxNode,length);//调整交换后的最大值对其孩子的影响
        }
    }

31、JDBC数据库查询的步骤:参考http://www.cnblogs.com/hongten/archive/2011/03/29/1998311.html

 try{   
    //加载MySql的驱动类   
    Class.forName("sun.jbdc.odbc.jdbcOdbcDriver") ;   
 }catch(ClassNotFoundException e){   
    System.out.println("找不到驱动程序类 ,加载驱动失败!");   
    e.printStackTrace() ;   
 }    
    //连接MySql数据库,用户名和密码都是root   
 String url = "jdbc:odbc:people" ;    
 String username = "root" ;   
 String password = "root" ;   
 try{   
    Connection con =    
             DriverManager.getConnection(url , username , password ) ;   
 }catch(SQLException se){   
    System.out.println("数据库连接失败!");   
    se.printStackTrace() ;   
}  
Statement stmt = con.createStatement() ;   
ResultSet rs = stmt.executeQuery("SELECT * FROM Staff where ID='001'") ;
while(rs.next()){   
        String name = rs.getString("name") ;   
        String name1 = rs.getString(1) ; // or此方法比较高效 
 }
if(rs != null){   // 关闭记录集   
        try{   
            rs.close() ;   
        }catch(SQLException e){   
            e.printStackTrace() ;   
        }   
}   
if(stmt != null){   // 关闭声明   
        try{   
            stmt.close() ;   
        }catch(SQLException e){   
            e.printStackTrace() ;   
        }   
 }   
if(con != null){  // 关闭连接对象   
         try{   
            con.close() ;   
         }catch(SQLException e){   
            e.printStackTrace() ;   
         }   
}  
        

32、面向对象三要素:封装、继承、多态

  封装:就是用一个自主式框架把对象的数据和方法连在一起形成一个整体。对象是封装的基本单位,相互之间通过接口访问。目的是隐藏细节,代码模块化。

  继承:子类拥有父类非private的属性和功能,通过继承的代码复用是一种“白盒式代码复用”,重写和覆盖会破坏封装性。目的是扩展代码模块,实现代码复用。

  多态:允许父类声明指向子类对象。即同一方法获得不同的行为特征(重载和覆盖)。目的是接口重用,是面向对象的核心。

posted @ 2014-11-20 21:16  百思求解  Views(4134)  Comments(1Edit  收藏  举报