笔试题2
来源:互联网 发布:python config模块 编辑:程序博客网 时间:2024/04/28 00:16
1、 在子查询中不能使用order by 子句。
如: select * from emp a where a.deptno in(select deptno from emp)——正确;
而: select * from emp a where a.deptno in (select deptno from emp order by empno);——错误
2、 复制表:
create table test
as
select * from dept;
复制表结构:
create table test
as
select * from dept where 1=0;
3、 由一道智力题所想到的:
题目: 1元钱一瓶汽水,喝完后两个空瓶换一瓶汽水, 问: 你有20元钱最多可以喝到几瓶汽水?
答案为: 20+10+5+2+1+1=39。
起初我虽然觉得自己不能给这个答案一个严谨的说明, 但是直觉上也认可。 今天与一同学在聊天谈到这个问题时他想了一会儿就将这个问题抽象为一个“哈弗曼问题”, 并很快地得出了结论。
感触很深, 什么是功力? 概念都是很简单的, 但是其背后真正的内涵得费一番思量... ...
4、 关于在JAVA中如何实现类似C语言中的 宏定义 的功能?
例如:
#define max(a,b) ((a)<(b)? : (a))
#define abs(a) ((a)>0?(a): -(a)) 这样子的功能?
————————可能探索:
采取 类似于全局变量限定域的 static 关键字。
写一个Constants类,再里面定义
外面的类去调用啊
public static final String mystring="myString";
public static final int myint =6;
....
5、 在循环结构中 i++与++i效果相同, 如:
public static void testCircle(){
for(int i=0; i<5; i++){
System.out.println(i);
}
System.out.println("****************************************");
for(int j=0; j<5; ++j){
System.out.println("j is : "+j);
}
} //结果输出都是为: 0、1、2、3、4。
^_^ ^_^ 这个其实很好理解, 只是我平时忽略掉了。
6、 double a = 3.1251111111;