1.new一个子类对象时,会先new出父类的对象

2.Arrays.sort(Object[] a);

先排序数字,再排序字母  如1,1c,3b

3.The finalize() method for a given object is called no more than once by the garbage collector.

4.Cannot use super in a static context

 
  
  1. public static int multiply(int a, int b) {  
  2.     int c = super.multiply(a, b);  
  3.     return c;  

 5.属性的话,根据声明对象的类,方法则看new的是哪个类,考题举例:

 
  
  1.  class Foo {  
  2.  public int a = 3;  
  3.  public void addFive() { a += 5; System.out.print("f "); }  
  4.  }  
  5.  class Bar extends Foo {  
  6.  public int a = 8;  
  7.  public void addFive() { this.a += 5; System.out.print("b " ); }  
  8.  }  
  9. Invoked with: Foo f = new Bar(); f.addFive(); System.out.println(f.a); 

输出b   3

6.异或
真^假=真
假^真=真
假^假=假
真^真=假

7.变量:only public, static & final are permitted in InterFace

  方法:only public & abstract are permitted in InterFace

构造器是不能用synchronized来修饰的(一句话:不能用abstract,final,static,synchronized及native来修饰只能是public ,protected,private

8.Cannot make a static reference to the non-static field counter

 9.

 
  
  1. Inner i = new Inner();  
  2. Outer o = new Outer();  
  3. int n = 10;  
  4. i.setX(n);  
  5. o.setY(i);  
  6. i.setX(100);  
  7. System.out.println(o.getY().getX()); 
输出为100,修改对象时对其地址进行修改,故不用重复set

10.

 
  
  1. Dogs myDog = Dogs.collie;  
  2. switch (myDog) {  
  3.     case collie:  
  4.         System.out.print("collie ");  
  5.     case harrier:  
  6.         System.out.print("harrier ");  
如果各个case后没有break,则符合第一个case后,忽略下面各个case的判断,直接执行结果

 11.

 
  
  1. public static void main(String[] args) {  
  2.     Integer i = new Integer(1) + new Integer(2);  
  3.     switch (i) {  
  4.         case 3:  
  5.             System.out.println("three");  
  6.             break;  
  7.         default:  
  8.             System.out.println("other");  
  9.             break;  
  10.     }  

swith可接受Integer,以上输入为three

12.抽象类继承接口时可不实现接口内方法

 13.因为接口定义的方法默认是public的,意思就是你没有任何访问修饰符的情况下,系统给接口的方法加上了一个public的访问修饰符,实现接口的方法不能降低其访问权限,故一定要为public

14.TreeSet的API中有如下一句话:基于 TreeMap 的 NavigableSet 实现。使用元素的自然顺序对元素进行排序,或者根据创建 set 时提供的 Comparator 进行排序,具体取决于使用的构造方法。也就是说TreeSet中的元素的相同与否有里面对象的Comparator决定,由于你的Comparator中的cmpareTo()方法恒返回的是0也就是恒等所以在用迭代器遍历你的TreeSet的时候会认为里面的两个对象是同一个对象所以只访问了第一个就输出了Coffee.

 
  
  1. public class TestA implements Comparable {  
  2.     public String name;  
  3.  
  4.     public int compareTo(Object o) {  
  5.         return 0;  
  6.     }  
  7.  
  8.     public static void main(String[] args) {  
  9.         TestA one = new TestA();  
  10.         TestA two = new TestA();  
  11.         one.name = "Coffee";  
  12.         two.name = "Tea";  
  13.         TreeSet set = new TreeSet();  
  14.         set.add(one);  
  15.         set.add(two);  
  16.         System.out.println(set.size());  
  17.         for (Iterator iterator = set.iterator(); iterator.hasNext();) {  
  18.             TestA name = (TestA) iterator.next();  
  19.             System.out.println(name.name);  
  20.         }  
  21.     }  

 15

 
  
  1. ((TestA)new TestB()).start(); //这个理解成   
  2.  
  3. TestA t = new TestB();   
  4. t.start();  

 16.default修饰符只允许同包的的类访问,若不同包则不能覆盖。

17.

 
  
  1. public static void main(String...a)  
  2. public static void main(String[]... a)  

can be used

18.hibernate中,不可2个相同对象同时存在于session中

 

19.

Which three are valid? (Choose three.)

 
  
  1. class ClassA {} 
  2. class ClassB extends ClassA {} 
  3. class ClassC extends ClassA {} 
  4.  
  5. ClassA p0 = new ClassA(); 
  6. ClassB p1 = new ClassB(); 
  7. ClassC p2 = new ClassC(); 
  8. ClassA p3 = new ClassB(); 
  9. ClassA p4 = new ClassC();  
20.
ClassA是父类,ClassB,ClassC是两个子类,

子类对象可以直接赋给父类变量,父类对象赋值给子类对象需要强制转换,所以:
A. p0 = p1;正确
C. p2 = p4;错误,应该是:p2 = (ClassC)p4;
E. p1 = (ClassB)p3;正确
F. p2 = (ClassC)p4;正确


父类的两个子类对象不可以互相赋值:所以:

B. p1 =p2;错误
D. p2 = (ClassC)p1;错误

答案:A E F 
21.
JavaBean Listener Naming Rules
Listener method names used to "register" a listener with an event source must use the prefix add, followed by the listener type. For example,addActionListener() is a valid name for a method that an event source will have to allow others to register for Action events.
Listener method names used to remove ("unregister") a listener must use the prefix remove, followed by the listener type (using the same rules as the registration add method).
The type of listener to be added or removed must be passed as the argument
Listener method names must end with the word "Listener".

所以listener的规则是添加是add 删除是remove并且要跟上listener的具体类型
所以是两个
addMouseListener和removeMouseListener 
22.this的用法:http://www.examda.com/JAVA/Instructs/060626/14071782.html
23.assert的用法: