日期:2014-05-20  浏览次数:20797 次

今天面试的几个题来分享一下
大家帮忙回答一下呀谢谢

1.STRUTS的工作原理是什么
2.列举几个SQL   server中的关键字
3.实现线程有几个方法?用1到2个实现一下
4.写个程序如:yy:mm:dd:时:分:秒
5.在当前目录下写个hello.txt.并用程序输出里面的内容

------解决方案--------------------
1.STRUTS的工作原理是什么
答:不知道
2.列举几个SQL server中的关键字
答:select by as from order update
3.实现线程有几个方法?用1到2个实现一下
答:方法一:定义一个类实现Runable接口
class NewThread implements Runnable
{
Thread t;
NewThread(String name)
{
t=new Thread(this,name);//创建一个新的线程Demo Thread
System.out.println( "Child thread: "+t);
t.start();//启动线程
}

public void run()//实现Runnable接口中定义的run()方法
{
。。。。
}
}


方法二:从Thread继承一个子类,在该类中重载方法run()

class Test extends Thread{
Test(){
}
public static void main(String[] args){
Thread t=new Test();
t.start();
}
public void run(){
System.out.println( "start ");
}
}
4.写个程序如:yy:mm:dd:时:分:秒
String dString = null;
Date d = new Date();
dString = DateFormat.getDateTimeInstance().format(d);
5.在当前目录下写个hello.txt.并用程序输出里面的内容
import java.io.*;
class Demo
{
public static void main(String args[])
{
try
{
byte buffer[] = new byte[];
FileInputStream filein =new FileInputStream( "hello.txt ");
int bytes = filein.read(buffer);
String s = new String(buffer,0,bytes);
System.out.println(s);
}
catch(Exception e)
{
System.out.println( "there is Exception be caught! ");
}
}

}