一家公司的笔试题:
1. 将一个int类型正整数反转,只能使用int类型,只能使用+-*%/运算符,不能使用任何的函数。
实际在做的过程中,我使用了整数数组,后来一想不用数组也可以。
public static int reverse(int num) { int result = 0; while (0 < num) { int temp = num % 10; num = (num - temp) / 10; result = result * 10 + temp; } return result; }
2. 依据8 8 12 24 60 (),推测()处的数值:180,推断依据,2/2,2/3,2/4,2/5,2/6
3.forward,redirect的区别
4.cookie与session
5.
public void testSwitch() { char a = 'b'; switch (a) { case 'a': System.out.println("a"); case 'b': System.out.println("b"); case 'c': System.out.println("c"); default: System.out.println("default"); } }
6.
以下执行结果是什么:
public class HelloA { static { System.out.println("Hello A1!"); } { System.out.println("Hello A2!"); } } public class HelloB extends HelloA { static { System.out.println("Hello B1!"); } { System.out.println("Hello B2!"); } public static void main(String[] args) { HelloB helloB = new HelloB(); } }
7.final修饰字段,方法,类进行描述
8.SQL语句的执行顺序