本人的面试题

1》面下对象的编程(00p)

  • 封装
    a.就是给对象提供了隐藏内部的特性和行为能力,一般在java中有3中(public,privater,protected)
  • 继承
    a.就是从父类中获取字段和方法的能力,当子类继承父类时,子类可以直接获取父类的属性和方法。
  • 多态
    a.就是不同类的对象对同一个消息做出响应,是类的多种表现方式,体现在重写和重载。
    2》创建bean实列的法式
    1.通过构造器(有参和无参)
    方式:<bean id="" class="">
    2.通过静态工厂方法
    方式:<bean id=""class="工程类"factory-method="静态工厂方法">
    3.通过实列的工厂方法创建
    方式:<bean id=""class="工厂类">
    <beanid =""factory-bean="factory" factory-method="实列的工厂方法"/>

    3》string是基本类型吗
    不是,基本类型就8个byte,short,int,long,double,float,char,boilean其它都是引用类型。
    4》int和interger的区别
    java是一个面下对象的语言,int是8个基本类型中的,java为每个基本类型都引入的包装类,Interger就是int的包装类,java5开始之后就引入了 自动拆和装箱。
    代码如下:
    class AutoUnboxingTest{
  public static void main(String[] args){
    Integer a = new Integer(3);
    //将3自动封装成Integer类型
    Integer b = 3;
    int c = 3;
    //false 两个引用没有引用同一个对象
    System.out.print(a == b);
    //true a自动拆箱成int类型再和c比较
    System.out.print(a == c);
  }
} 
public class Test{
  public static void main(String[] args){
    Integer f1 = 100,f2 = 100,f3 = 150,f4 = 150;
    //true
    System.out.println(f1 == f2);
    //false 
    //Integer值的范围在-128 ~ 127之间,如果在这个范围内,不会new新的Integer对象,而是直接引用常量池中的Integer对象.
    System.out.printlm(f3 == f4);
  }

5》spring

  • spring是一个开源的用来简化开发的框架,对常用的api做了封装,解耦,还有就是对事物的管理。
  • spring的容器就是用来管理对象的,在javaee中三成架构(1表示层,web层。2业务层,service层。3,数据访问层 dao层)
  • 表示层:springmvc
  • 业务层:springIoc
  • 数据访问层:spring的jdbc,template
  • springIoc的操作:
  • Ioc的操作:
  • 是控制反转,对象的实列化在spring容器创建,ioc分为注解和配置方式。
  • 1导入spring的jar包,(spring-beans,spring-core,spring-context,spring-expression,log4j)。
  • 2创建一个java类
public class User{
 public class add(){
    System.out.println("User Add Method);
    }
  @Overrde
  public String toString(){
  return "This is a object"
  }
  • 3创建spring的配置,进行bean的配置(applicationContext.xml)
<?xml version="1.0" encoding="UTF-8"?>
<beans default-lazy-init="true"
    xmlns="http://www.springframework.org/schema/beans" 
    xmlns:p="http://www.springframework.org/schema/p"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xmlns:mvc="http://www.springframework.org/schema/mvc"
    xsi:schemaLocation="  
       http://www.springframework.org/schema/beans   
       http://www.springframework.org/schema/beans/spring-beans-4.3.xsd  
       http://www.springframework.org/schema/mvc   
       http://www.springframework.org/schema/mvc/spring-mvc-4.3.xsd   
       http://www.springframework.org/schema/tx   
       http://www.springframework.org/schema/tx/spring-tx-4.3.xsd   
       http://www.springframework.org/schema/context  
       http://www.springframework.org/schema/context/spring-context-4.3.xsd" >  

    <!-- spring 包的扫描
     1)dao
     2)service (@Service)
     3)controller(@Controller)
     4).....
     -->
    <context:component-scan base-package="cn.tedu.ttms" />
    <!-- spring mvc 注解及类型转换 -->
    <mvc:annotation-driven conversion-service="conversionService" />
    <bean id="conversionService"
        class="org.springframework.format.support.FormattingConversionServiceFactoryBean">
    </bean>
    <!-- spring mvc 视图解析器 -->    
    <!-- 定义跳转的文件的前后缀 ,视图模式配置 -->
    <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <!-- 自动给后面action的方法return的字符串加上前缀和后缀,变成一个 可用的url地址 -->
        <property name="prefix" value="/WEB-INF/pages/" />
        <property name="suffix" value=".jsp"></property>
    </bean>  
    <!-- 配置文件上传的视图解析器 -->
    <bean id="multipartResolver"
        class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
        <!-- 默认编码 -->
        <property name="defaultEncoding" value="utf-8" />
        <!-- 文件大小最大值 -->
        <property name="maxUploadSize" value="10485760000" />
        <!-- 内存中的最大值 -->
        <property name="maxInMemorySize" value="40960" />
    </bean>


</beans>
  • 通过配置文件创建对象
@Test
public void TestIoc(){
//加载spring配置文件,创建对象
attionContext contect=new ClassPathXmlApplicationContex(attionContext.xml)
//获取对象
User user=contect.getbean("user");
user.add();
  • bean的实列化
  1.通过构造器(有参和无参)
      方式:`<bean id="" class="">`
    2.通过静态工厂方法
      方式:`<bean id=""class="工程类"factory-method="静态工厂方法">`
     3.通过实列的工厂方法创建
       方式:`<bean id=""class="工厂类">
         <beanid =""factory-bean="factory" factory-method="实列的工厂方法"/>`
  • 属性注入
set注入
public void setId(Integer id) {
        this.id = id;
    }
构造器注入
    public project(Integer id) {
        this.id = id;
    }
  • bean的配置
set配置:
     <bean id="teacher" class="">
     <property name="id" value="Teacher wu"></property>   
     </bean>
构造器的配置:
     <bean id="teacher" class=".....">
     <constructor-arg name="id"value="Dreaml"></constructor-arg >
     </bean>
  • 创建service类,dao的接口,dao类。
  • AOP:
  • 面向横切面编程,用于事物管理,日志管理,安全验证
  • 静态代理:
  • mainaction–>代理对象–>日志输出–>在代理对象中调用目标对象–>对象执行–>返回给代理–>返回给调用者。
  • 动态代理
  • 1实现接口InvocationHander
  • 2生成代理
  • 3自动调用invore方法
  • 4横切关注点
  • 5方面
  • 6通知
  • 7切入点
  • 8植入
  • 9连接点
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值