某公司的java笔试题,来测测你的基础如何吧

这是一套提供给中级以上程序员使用的笔试题:

1。

public class Test {

	public static boolean get() {
		try {
		       return  false;
		} finally {
		       return  true;
		}
	}
	
	public static void main(String[] args) {
		System.out.println(get());
                }
}

 

求打印结果?

2。以下哪些变量名的定义是不合法的?

String a , a.b , 0a , _a , a_ , a0 ;

 

3。

public static void main(String[] args) {
         String classPath = "java.lang.String";
         System.out.println(classPath.replaceAll(".", "/"));
}

 

求打印结果?

4。

public static void main(String[] args) {
         StringBuilder sb = new StringBuilder();
         switch(1) {
	case 1 : sb.append("Hello a");
	case 2 : sb.append("b");
	case 3 : sb.append("c");
	default : sb.append("d");
          }
          System.out.println(sb.toString());
}

 求打印结果?

5。

public class Increment {
    public static void main(String[] args) {
        int j = 0;
        for (int i = 0; i < 100; i++)
            j = j++;
        System.out.println(j);
    }
}

 

求打印结果?

6。

public class HelloGoodbye {
    public static void main(String[] args) {
        try {
            System.out.println("Hello world");
            System.exit(0);
        } finally {
            System.out.println("Goodbye world");
        }
    } 
}

 

写出打印结果并给出简单描述。

7。

import java.util.*;

public class DatingGame {
    public static void main(String[] args) {
        Calendar cal = Calendar.getInstance();
        cal.set(1999, 12, 31); // Year, Month, Day
        System.out.print(cal.get(Calendar.YEAR) + " ");

        Date d = cal.getTime();
        System.out.println(d.getDay());
    }
}

 

写出打印结果?

 

。。。。。。

总共20多个题吧,太多了,后续再加上

主要还有涉及内部类、异常处理、final方法、final域、浮点数的精度问题、集合类HashMap、HashSet的操作,泛型、包装类、char、short和int值的混合计算、静态变量和方法的初始化(类的初始化)

接口和抽象类的区别,还有写sql的,比较简单。

另外,有两个上机笔试题,上机测试是在笔试通过之后才有的流程,二选一

1。 编写一个类,将指定路径下的所有文件的名称打印出来(递归方法)

2。 给你一个文本文件,请找出文件中数据的规律,并且将指定日期范围内的数据列表抽取出来(io操要比较熟悉)

记不起来了,以上是我在机器里跑了一遍的,拿过来跟大家分享下

写了这么多,好辛苦啊,希望朋友们别抨我口水哈,欢迎投精,我会继续补充剩下的那些笔试题的。

你可能感兴趣的:(java,sql,J#)