java 项目英语面试问题_Java 英文面试题

1.

Q: What is HashMap and Map?

A: Map is Interface and Hashmap is class that implements that.

2.

Q: Difference between HashMap and HashTable?

A:HashMap allows null values as key and value whereas Hashtable doesnt allow

HashMap is unsynchronized and Hashtable is synchronized.

(All the elements  in the HashMap  and HashTable are not ordered).

3

.Q: Difference between Vector and ArrayList?

A: Vector is synchronized whereas arraylist is not.

(All the elements  in the Vector and ArrayList are ordered).

4.

Q: What if I write static public void instead of public static void?

A: Program compiles and runs properly.

5.

Q: What is the difference between an Interface and an Abstract class?

A:  The interface is mainly used for framework design.

An Interface can only declare constants and instance methods, but cannot implement default behavior and all methods are implicitly public and abstract .

The abstract class  is mainly used for code reuse and interface implementation.

An abstract class can have instance methods that implement a default behavior.

The methods  can be declared  as public ,private, protected; An abstract class can  also declare some variables and construction methods and staic methods, but cannot have abstract construction methods and abstract  staic  methods.

(接口和抽象类

接口更多的是在系统架构设计方法发挥作用,主要用于定义模块之间的通信契约。而抽象类在代码实现方面发挥作用,可以实现代码的重用,可以实现接口的空实现。

含有抽象方法的类必须定义为抽象类,抽象类中可以没有抽象方法。

抽象类不能实例化对象,子类需要实现抽象类中所有的抽象方法,所以抽象类中不能有抽象的构造方法和抽象静态方法,可以有构造方法和静态方法。

如果子类没有实现抽象类中的抽象方法,则子类也要定以为抽象的。

如果抽象方法实现某个接口,则子类还要实现抽象类中没有实现的接口方法。

接口可以说是抽象类的特例,接口中所有的方法必须为抽象的即 public abstract 通常省略,所有的成员变量必须为静态的 public static final .

下面比较一下两者的语法区别:

1.抽象类可以有构造方法,接口中不能有构造方法。

2.抽象类中可以有普通成员变量,接口中没有普通成员变量

3.抽象类中可以包含非抽象的普通方法,接口中的所有方法必须都是抽象的,不能有非抽象的普通方法。

4. 抽象类中的抽象方法的访问类型可以是public,protected和(默认类型,虽然

eclipse下不报错,但应该也不行),但接口中的抽象方法只能是public类型的,并且默认即为public abstract类型。

5. 抽象类中可以包含静态方法,接口中不能包含静态方法

6. 抽象类和接口中都可以包含静态成员变量,抽象类中的静态成员变量的访问类型可以任意,但接口中定义的变量只能是public static final类型,并且默认即为public static final类型。

7. 一个类可以实现多个接口,但只能继承一个抽象类。)

6.Q: What is an abstract class?

A: Abstract class must be extended. It serves as a template. A class that is abstract may not be instantiated (ie, you may not call its constructor), abstract class may contain static data. Any class with an abstract method  must be declared as abstract class .

A class may be declared abstract even if it has no abstract methods. This prevents it from being instantiated.·

7.Q: What is the difference between a constructor and a method?

A: A constructor is  used to create objects of that class. It has the same name as the class itself, has no

  • 0
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值