close

 

 

 

第六十六題:

Given:

5.    class Thingy{ Meter m = new Meter(); }
6.    class Component {void go() { System.out.print("c");}}
7.    class Meter extends Component {void go() { System.out.print("m"); }}
8.
9.    class DeluxeThingy extends Thingy {
10.        public static void main(String[] args) {
11.            DeluxeThingy dt = new DeluxeThingy();
12.            dt.m.go();
13.            Thingy t = new DeluxeThingy();
14.            t.m.go();
15.        }
16.    }

Which two are true? (Choose two.)

A. The output is mm.
B. The output is mc.
C. Component is-a Meter.
D. Component has-a Meter.
E. DeluxeThingy is-a Component.
F. DeluxeThingy has-a Component.

答案:AF

題目範圍:物件觀念

解析:

不論是Thingy物件還是DeluxeThingy物件,都使用Meter中的方法

 

第六十七題:

Given:

10. abstract public class Employee {
11.     protected abstract double getSalesAmount();
12.     public double getCommision() {
13.         return getSalesAmount() * 0.15;
14.     }
15. }
16. class Sales extends Employee {
17.     //insert method here
18. }

Which two methods, inserted independently at line 17, correctly complete the Sales class? (Choose two.)

A. double getSalesAmount() { return 1230.45; }
B. public double getSalesAmount() { return 1230.45; }
C. private double getSalesAmount() { return 1230.45; }
D. protected double getSalesAmount() { return 1230.45; }

答案:BD

題目範圍:物件觀念,抽象類別

解析:

抽象類別中需要被實作的方法,可見度等級只可以提升或相同,不可以降低

 

第六十八題:

Given the following six method names:

addListener
addMouseListener
setMouseListener
deleteMouseListener
removeMouseListener
registerMouseListener

How many of these method names follow JavaBean Listener naming rules?

A. 1
B. 2
C. 3
D. 4
E. 5

答案:

題目範圍:命名規則

解析:

Listener可以被加在某物件上,因此會有addXXXListener
移除Listener使用的是removeXXXListener

因此正確的是addMouseListenerremoveMouseListener

 

第六十九題:

Given:

11. public interface Status {
12.     /* insert code here */ int MY_VALUE = 10;
13. }

Which three are valid on line 12? (Choose three.)

A. final
B. static
C. native
D. public
E. private
F. abstract
C. protected

答案:ABD

題目範圍:介面interface

解析:

介面內變數的修飾,只允許finalstaticpublic

 

七十題圖片太多跳過…

arrow
arrow

    yaya741228 發表在 痞客邦 留言(0) 人氣()