課程名稱︰物件導向程式設計 (Object-Oriented Programming)
課程性質︰系定必修
課程教師︰陳俊良
開課系所︰資訊系
考試時間︰94/06/21 6:30pm - 8:30pm
試題 :
Examination of Object-Oriented Programmint
2005/06/21, NTUCS&IE
1. The class java.util.Calendar has the following methods:
public static Calendar getInstance()
Gets a calendar using the default time zone and locale. The
Calendar returned is based on the current time in the default
time zone with the default locale.
Returns:
a Calendar.
public int get (int field)
Returns the value of the given calendar field.
Parameters:
field - the given calendar field.
Returns:
the year if field is Calendar.YEAR
the month if field is Calendar.MONTH
the day if field is Calendar.DAY_OF_MONTH
The following program segment is used to get the year, month and day of
the current time.
int year = Calendar.getInstance().get(Calendar.YEAR);
int month = Calendar.getInstance().get(Calendar.MONTH);
int day = Calendar.getInstance().get(Calendar.DAY_OF_MONTH);
It has a logical bug. Why? (20%)
2. A way to create a thread is to declare a class that implements the
Runnable interface. That class then implements the run method. For example,
class MyRunnable implements Runnable {
public void run() {
// the code of the new thread
}
}
The following code would then create a thread and start it running.
new Thread (new MyRunnable()).start();
Please describe this mechanism in detail. (30%)
3. Please compare the following terms: (50%)
(a) method overloading vs. method overriding
(b) static method invocation vs. virtual method invocation
(c) class variable vs. interface variable
(d) procefure-oriented vs. object-oriented
(e) scope vs. encapsulation
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.112.30.82