1,Class.forName做什么
A call to Class.forName("X") causes the class named X to be dynamically loaded (at runtime).A call to forName("X") causes the class named X to be initialized.Class.forName("X") loads the class if it not already loaded. The JVM keeps track of all the classes that have been previously loaded. This method uses the classloader of the class that invokes it. The "X" is the fully qualified name of the desired class.
2,java.lang.RuntimeException和一般异常有什么不同?
Java中有两种异常: checked exceptions and un-checked exceptions. A checked exception must be handled explicitly by the code. you either have to put a try/catch block around the code that could potentially throw the exception, or add a "throws" clause to the method, to indicate that the method might throw this type of exception.RuntimeException is un-checked. RuntimeExceptions do not need to be explicitly handled by the calling code.
3,String转为int的方法。
Integer x = Integer.valueOf(str);
int y = Integer.parseInt(str);
4,比较String.equals(String other)和==
String.equals(String other)比较两个字符串的值是否相同
==标记String的引用是否相同
5,Java中抽象类和接口的区别。
an interface is a reference type can contain only constants, method signatures, and nested types.
接口不能包含instance fields,可以包含用static或final来修饰的field。抽象类可以申明和使用fields。
接口不能包含构造函数。抽象类可以。
类可以实现多个接口,但只能继承一个抽象类。
接口包含的方法申明等都是隐式public的,抽象类包含的方法可以是public,private,protected或者默认的package。
接口中的方法都是抽象的,抽象类中可以包含具体的方法。