Which statements about abstract classes are true?
1. They can be instantiated.
2. They allow member variables and methods to be inherited by subclasses.
3. They can contain constructors.
- 1, 2, and 3
- only 3
- 2 and 3
- only 2
answer: 3
抽象類別的參數可以被子類別繼承,並可以包含建構子,但無法被實例化
Why are ArrayLists better than arrays?
- You don't have to decide the size of an ArrayList when you first make it.
- You can put more items into an ArrayList than into an array.
- ArrayLists can hold more kinds of objects than arrays.
- You don't have to decide the type of an ArrayList when you first make it.
answer : 1
出這題的人應該怨念很深,只要被array雷過的應該都有感覺,Java中的array必須宣告大小,這也是筆者認為array不好用的地方,一不小心就會 ArrayIndexOutOfBounds
其餘三點,array也能放入物件
ex:
Integer[] arraySimple = new Integer[10];