以下题目需要当场编写实现,并有本人讲解
1、 写一个通用方法把任何一个类似“abcdefg”的字符串倒叙排。
2、 把字符数组String[] str={“6”,”5”,”3”,”1”,”2”,”4”}中的字符数字按照从小到大调整位置。
两种方法
3、 用杨辉三角规律打一个数字三角型。
4、 把List容器中的数字元素“6”  ”5”  ”3”  ”1”  ”2”  ”4”,按照从大到小排序进行重新存放。 
5、 有一个接口,接口中有一个抽象的方法,然后一个普通的类implements该接口,但该类并不自己去实现从接口中继承的抽象方法,如何来完成,举个例子。
6、 写一个通用的方法,该方法有一个参数,当给该方法传递一个浮点数字,该方法进行四舍五入的保留两位小数的处理,然后在返回处理之后的浮点数字,两种方法实现。
7、 单态(单实例)模式类,两种实现方法实现,并当场解释为什么?
8、 有一个接口和接口的子类,接口中有一个print的方法,子类实现该方法, 而且子类中有一个自己声明的方法make,编程运用上行机制调用子类中的方法print,同时解释在上行时能否调用make,为什么?
9、 面向对象实现表现在那些方面,举例说明,并解释面向对象的这些方面对开发有什么意义。
10、对一个Map类型的容器中元素“6”  ”5”  ”3”  ”1”  ”2”  ”4”进行排序。
11、对一个Map类型的容器中元素{new Box(1,2,6),new Box(2,3,4),new Box(3,4,5),new Box(5,6,7)}进行排序,其中Box构造函数中参数分别为(长,宽,高),具体按照Box实例长的降序和升序分别排序。 
12、写一个通用的方法(该方法有一个目录参数),使用IO输入输出知识实现用递归把传递给该方法的目录下的文件,子文件夹,以及子文件夹下的子文件夹和文件,子文件夹下的子文件夹、、、、、的名称和类型(是文件还是文件夹,最好有一定的层次感)打印到控制台上。
13、在控制台上打一个菱形
*
* * *
* * * * *
  * * *
    *
14、如下的递归调用的打印的结果是多少:
package org.itfuture.www.test;public class Test5 { public Test5(){
}
public static void main(String[] args)
{
System.out.println("Factorial of 3 is " + fact(3));
System.out.println("Factorial of 4 is " + fact(4));
System.out.println("Factorial of 5 is " + fact(5));
}
public static int fact(int n) 
{
int result; 
if(n==1)return 1;
result = fact(n-1) * n;
result = fact(n-1) * n;
result = fact(n-1) * n;
return result; 
   }
}
15、用多线程实现,三个学生同时从教室跑到一个饮水机旁,然后排队接水,先接完水的要在饮水机旁等待,直到所有的学生都接完水后,一块在返回到教室。
16、三个线程都要完成打印1-100但在打印时要求三个线程分阶段打印,每个阶段为10个数字,即都先打印完1-10,之后都再开始打印第二阶段11-20,然后都再开始打印第三阶段、、、、、依次类推。
17、用多线程描述实现10张票(票的编号为1-10)三个窗口来同时买,要把每个窗口买的票的编号打出来。
18、描述什么是Struts,及Struts和MVC的关系,Struts的实现原理(包括Struts中Action单态的实现原理),以及在实际开发当中的如何正确的使用。

解决方案 »

  1.   

    10、对一个Map类型的容器中元素“6”  ”5”  ”3”  ”1”  ”2”  ”4”进行排序。Map中不是键值对吗?用TreeMap好了.
      

  2.   

    7、 单态(单实例)模式类,两种实现方法实现,并当场解释为什么? 
    public class StringPool {
    private static StringPool pool=new StringPool();

    private StringPool(){};

    public static StringPool getPool(){
    return pool;
    }
    }线程安全
    public class StringPoolA {
    private static StringPoolA pool;

    private StringPoolA(){

    }

    public static StringPoolA getPool(){
    if(pool==null){
    pool=new StringPoolA();
    }
    return pool;
    }
    }
    线程不安全
    是指这样吗,对设计模式刚开始看
      

  3.   

    11.public class Box implements Comparable < Box > {    private int height = 0;    private int width = 0;    private int length = 0;    public Box(int l, int w, int h) {
            height = h;
            width = w;
            length = l;
        }    public int compareTo(Box otherBox) {
            return Integer.valueOf(this.length).compareTo(
                    Integer.valueOf(otherBox.length));
        }    public int getHeight() {
            return height;
        }    public int getWidth() {
            return width;
        }
        
        public int getLength() {
            return length;
        }
    }public class Test {
        public static void main(String[] args) throws Exception{
            Map<Box,String> map = new HashMap<Box,String>();
            map.put(new Box(1,2,6),"");
            map.put(new Box(5,6,7),"");
            map.put(new Box(2,3,4),"");
            
            List<Box> sortBoxs = new ArrayList<Box>();
            for(Box box : map.keySet()) 
                sortBoxs.add(box);
            
           Collections.sort(sortBoxs);
           
           for(Box box : sortBoxs) 
               System.out.println(box.getLength());
           
        }
    }
      

  4.   


    public class StringPoolA {
        private static StringPoolA pool;
        
        private StringPoolA(){
            
        }
        
        public static StringPoolA getPool(){
            if(pool == null){
             synchronized(JdbcUtilsSing.class){
             if(pool == null) {
             pool=new StringPoolA();
             }
             }
            }
            return pool;
        }
    }
      

  5.   

    我最近也在复习基础,我会答第五题可以用组合的方法先写一个类,实现这个接口,比如叫ImplInterfaceA,
    然后写这个普通类 class A implements interfaceA
    在A里 建一个ImplInterfaceA的实例
    把所有需实现的抽象方法的实现都转发给这个实例附代码InterfaceA { A(); }ImplInterfaceA implements InterfaceA{ A(){}}class A implements InterfaceA{
    ImplInterfaceA a = new ImplInterfaceA();
     A(){ a.A; }
    }
      

  6.   

    5、 有一个接口,接口中有一个抽象的方法,然后一个普通的类implements该接口,但该类并不自己去实现从接口中继承的抽象方法,如何来完成,举个例子。难到是缺省适配器模式??
      

  7.   

     第五题:用一个抽象类先实现了接口,再用这个普通类继承以及实现
     第一题:private String SortString(String st){
    String[] nu = new String[st.length()];
    for(int i = 0;i<nu.length;i++){
    nu[i] = ""+st.charAt(i);
    }
    int a = 0;
    int b = st.length()-1;
    while (a!=b&&a<b) {
    String temp = nu[a];
    nu[a] = nu[b];
    nu[b] = temp;
    a++;
    b--;
    }
    StringBuffer sb = new StringBuffer();
    for (int i = 0; i < nu.length; i++) {
    sb.append(nu[i]);
    }
    return sb.toString();
    }