今天的面试题 大家帮看一下!

camelkiss 2009-01-09 01:28:43
1.计算阶乘
2.N个人,每次数到三,减去一个人,重新开始数,到三再退出。问最后一个人几号
3.N个设备,每个设备有唯一id,且可能有父子节点,显示层级关系
4.Struts页面流,最好是struts2的
5.Hibernate中实体对象的关系有几种,如何配置
6.写出常见的五个异常,并指出何时出现
7.写出至少两种javascript中的调试方法
8.Spring中的拦截器机制
9.画出策略模式类图再说出struts哪里用到此模式。
10.写sql:有部门表:id,name,和员工表:id,name,depid。写出没有员工的部门。
11.已知一个整数的字符串,“123456656...”(长度不超过int上限)。写一个方法来判断该字符串代表的整数能否被6整除。

...全文
444 26 打赏 收藏 转发到动态 举报
写回复
用AI写文章
26 条回复
切换为时间正序
请发表友善的回复…
发表回复
jackdalsen 2009-02-10
  • 打赏
  • 举报
回复
7 用dojo的log,结合firebug的console
yjxqgd 2009-02-10
  • 打赏
  • 举报
回复
路过学习一下
烈焰 2009-02-10
  • 打赏
  • 举报
回复
学习了
mu_tou 2009-02-09
  • 打赏
  • 举报
回复
10.写sql:有部门表:id,name,和员工表:id,name,depid。写出没有员工的部门。

select *
from 部门表 a
where not exists (
select 1 from 员工表 b where a.id = b.deptid)

这个这么写应该是最好的了 ^_^ 说的不对,请拍砖..
liberpc 2009-01-10
  • 打赏
  • 举报
回复
站个位子看
birdzxy 2009-01-10
  • 打赏
  • 举报
回复
1.考的是递归吧,这个应该简单
2.好象是循环连表,可惜不太熟悉
3.是不是数据表设计?id, parentid, level?
4.struts2到没看过,好象是browser->actionForm->servletcontroller->action->....不太记得了
5.上面有答案了
6.FileNotException SQLException IOException NumberException Exception
7.alert, 打印到页面
8.before middle after error...不太记得
9.不知道
10.比较简单
11.return (Integer.parse(s) % 6) == 0
camelkiss 2009-01-10
  • 打赏
  • 举报
回复
真的很难吗? 我也是大部分不太明白,不过我还以为不难呢。。。。
salas79 2009-01-10
  • 打赏
  • 举报
回复
现在的面试真是BT啊
camelkiss 2009-01-10
  • 打赏
  • 举报
回复
1.计算阶乘
public int jc(int j){
if(j==1)return 1;
else if(j<=0)return -1;
else return j*jc(j-1);
}

5.Hibernate中实体对象的关系有几种,如何配置
一对一、一对多、多对多

7.写出至少两种javascript中的调试方法
alert

debugger


9.画出策略模式类图再说出struts哪里用到此模式。
10.写sql:有部门表:id,name,和员工表:id,name,depid。写出没有员工的部门。
select name from 部门表
where id not in

select distinct depid from 员工表

或者
select l.name from
(
select y.id yid,b.name,b.id from 部门表 b left join 员工表 y on y.depid=b.id
) l
where l.yid is null

11.已知一个整数的字符串,“123456656...”(长度不超过int上限)。写一个方法来判断该字符串代表的整数能否被6整除。
public boolean isMod(String s){
int i=Integer.parseInt(s);
if(i%6==0){
return true;
}
return false;
}
//我想到的也是这个方法,想不出比这个简单的了


我就会这么多 呵呵

OooxiamiooO 2009-01-09
  • 打赏
  • 举报
回复
第3个是不是这样啊,我也不确认

create table entity
(
eid int identity(1,1) not null primary key, //标识列
ename varchar(50) not null,
fatherid int //储存父节点的,因为是可能,所以没有加非空约束,
)

父设备和子设备都在这一张表中……

插入父设备

insert into entity(ename) values('汽车')

插入子设备
insert into entity(ename,fatherid) values('红旗轿车',1)
OooxiamiooO 2009-01-09
  • 打赏
  • 举报
回复
2.N个人,每次数到三,减去一个人,重新开始数,到三再退出。问最后一个人几号




import java.util.ArrayList;
import java.util.List;

public class Main{
public static void main(String[] args){
ArrayList<Integer> list = new ArrayList<Integer>();
list.add(new Integer(1));
list.add(new Integer(2));
list.add(new Integer(3));
list.add(new Integer(4));
list.add(new Integer(5));
list.add(new Integer(6));
list.add(new Integer(7));
list.add(new Integer(8));
list.add(new Integer(9));
list.add(new Integer(10));
int index = run(list);
System.out.println("最后一位是:"+index+"号");
}

private static int run(List list){

int result = 0; //保存结果
int index = 0; //计算数的个数,满三次,还原为0
int i = 0; //集合的下标
while(list.size() != 0){
index ++;
if(index == 3){ //数三次,踢出一位
System.out.println(list);
System.out.println(list.get(i));
result = (Integer)list.remove(i);
index = 0;
}else{
i++;
}
//如果集合下标末尾了,则从头开始
if(i==list.size()){
i=0;
}
}
return result;
}
}

afdzhu 2009-01-09
  • 打赏
  • 举报
回复
怎么面试这么难啊!
bill_hai 2009-01-09
  • 打赏
  • 举报
回复
public static boolean isModSix(String s ){
String last = s.substring(s.length() - 1);
if("0".equals(last) || "2".equals(last)
|| "4".equals(last) || "6".equals(last)
|| "8".equals(last) || "0".equals(last)){
int sum = 0;
for(int i = 0; i < s.length(); i ++){
sum += Integer.parseInt(s.substring(i, i + 1));
sum %= 3;
}
if(sum == 0){
return true;
}else{
return false;
}
}else{
return false;
}
}
machao299 2009-01-09
  • 打赏
  • 举报
回复
select * from 部门表
where id not in(
select id from 部门表, 员工表 where 部门表.id=员工表.id
) (刚才看见上边有个用 ····in 的方式查询的 ,个人建议最好不要用 in 不怎么合理,理论挺多的,我也表达不清楚,就不说了。无意冒犯)

5.hibernate实体对象关系(我记得好像是有 4 种) 一对一 一对多 多对一 多对多

算术异常类:ArithmeticExecption

空指针异常类:NullPointerException

类型强制转换异常:ClassCastException

数组负下标异常:NegativeArrayException

数组下标越界异常:ArrayIndexOutOfBoundsException

违背安全原则异常:SecturityException

文件已结束异常:EOFException

文件未找到异常:FileNotFoundException

字符串转换为数字异常:NumberFormatException


操作数据库异常:SQLException


输入输出异常:IOException


方法未找到异常:NoSuchMethodException(http://hi.baidu.com/sy527/blog/item/cc67337b0f316ef70bd1874b.html)


public boolean isMod(String s){
int i=Integer.parseInt(s);
if(i%6==0){
return true;
}
return false;
}(我也是这么想的。)
不对的地方请指教。谢了
chejingquan 2009-01-09
  • 打赏
  • 举报
回复
JavaScript调试,我只知道用alert('');其他不知道了,不过上面说debugger也可以,这是什么东西啊不懂啊他可以调试吗?
ph09227 2009-01-09
  • 打赏
  • 举报
回复
有难度啦 我都是写应用 你那上面得很多算法用不上啦
grrr28 2009-01-09
  • 打赏
  • 举报
回复
11.

public boolean isMod(String s){
int i=Integer.parseInt(s);
if(i%6==0){
return true;
}
return false;
}
lihan6415151528 2009-01-09
  • 打赏
  • 举报
回复
捡着别人么有回答过的吧
7.写出至少两种javascript中的调试方法

  1、在代码中用alert的方法。
  2、在代码中使用debugger 关键字。
flylovejings 2009-01-09
  • 打赏
  • 举报
回复
5.hibernate实体对象关系(3种)--一对多--多对一-- 多对多
-1.单向一对多,在'一'的一方加入一个set集合存放多的一方--

<set name=''>
<key colums='id' />
<one-to-many class='' />
</set>

-2.单向多对一和单向一对多可以分别配置,如果同时配置了双方就成了‘双向一对多’关联
-3.单向多对一,在多一方的实体类种实例化一个'一'方类

<!--多的一方配置-->
<many-to-one name='' column='id' class=''--'一'方类/>

-4.多对多要借助第三方表(以一个项目表和雇员表为例--第三方和这两张表建立主外键关系)配置一方为单向 两方为双向
看业务对数据的具体要求!

--Project一方
<class name="Project" table="t_project">
...--属性
<set name="members" table="r_emp_proj">
<key column="r_proj_id" >
<many-to-many class="Emplyee" column="r_emp_id">
</set>
</class>
---Employee一方
<class name="Employee" table="t_employee">
...属性
<set name="projects" class="r_emp_proj">
<key column="r_emp_id"/>
<many-to-many class="Project" column="r_proj_id">
</set>
<class>

总结的有点零乱 看看大家还有别的总结没!
ip_moon 2009-01-09
  • 打赏
  • 举报
回复
1、public class JieCeng{
public static void main(String[] args){
int j=1;
for(int i=1;i<=6;i++){
j = j*i;
}
System.out.println(j);
}
}
加载更多回复(6)

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧