面试题1

来源:互联网 发布:mac wine 安装 编辑:程序博客网 时间:2024/06/05 17:11

【1】将c://123.txt复制到D盘当中去 


publicvoid  testCopyFile()throws Exception {

      FileInputStream  fis  =new   FileInputStream("c://123.txt");

      FileOutputStream  fos  =new   FileOutputStream("d://123.txt");

     

      byte [] bys =new  byte[1024];

      int len = 0;

      while ((len =fis.read(bys)) != -1) {

        fos.write(bys, 0, len);

      }

      fos.close();

      fis.close();

   }


【2】面向对象的语言特征

封装 、继承 、多肽


【3】int 和Integer 类型有什么区别 

int 是基本数据类型,Integer是其包装类 
int的默认值为0,而Integer的默认值为null
【4】servlet生命周期
所谓生命周期,指的是servlet容器如何创建servlet实例、分配其资源、调用其方法、并销毁其实例的整个过程
阶段1:实例化当请求到达容器时,容器查找该servlet对象是否存在,如果不存在,才会创建实例。阶段2:初始化为servlet分配资源,调用init(ServletConfig config) 方法 config对象可以用来访问servlet的初始化参数;阶段3: 就绪/调用有请求到达容器,容器调用servlet对象的service()方法。HttpServlet的service()方法,会依据请求方式来调用doGet()或者doPost()方法阶段四: 销毁在服务器端停止且卸载Servlet时执行该方法,会调用servlet对象的destroy()方法。destroy()方法用于释放资源。在servlet的整个生命周期当中,init,destroy只会执行一次,而service方法会执行多次
【5】mvc 的含义
MVC是三个单词的缩写,分别为: 模型(Model),视图(View)和控制Controller)
 Model层实现系统中的业务逻辑,
 View层用于与用户的交互,通常用JSP来实现。
 Controller层是Model与View之间沟通的桥梁