- Problem #1 (10 points)
The following is part of the listing provided by the command ‘javap -package java.util.Calendar’.
public abstract class java.util.Calendar {
public static final int YEAR;
public static final int MONTH;
protected long time;
protected boolean isTimeSet;
static final int UNSET;
static final long serialVersionUID;
protected java.util.Calendar();
protected java.util.Calendar(java.util.TimeZone,java.util.Locale);
public static java.util.Calendar getInstance();
public static java.util.Calendar getInstance(java.util.Locale);
protected abstract void computeTime();
public final java.util.Date getTime();
public final void setTime(java.util.Date);
public long getTimeInMillis();
public void setTimeInMillis(long);
public int get(int);
final void internalSet(int, int);
public final void set(int, int, int);
public final void set(int, int, int, int, int);
}
- What are the primitive types mentioned in the above listing.
- What are the class types mentioned in the above listing.
- What are the modifiers mentioned in the above listing.
- What are the packages mentioned in the above listing.
- Problem #2 (10 points)
Provide the following information for the class java.util.Calendar displayed in the previous problem.
- List the names of all the instance fields in the class.
- List the names of all the class (static) fields in the class.
- Show the signatures of all the constructors in the class.
- Show the signatures of all the class methods in the class.
- Show the signatures of all the instance methods in the class.
- Problem #3 (10 points)
Provide a class that offers the following tables when compiled with the command ‘javadoc -package
Sample.java’.
+------------------+
| Field Summary |
+--------------+---+
| Sample | v |
+--------------+---+
|static Sample | w |
+--------------+---+
+---------------------+
| Constructor Summary |
+---------------------+
| Sample() |
+---------------------+
| Sample(Sample x) |
+---------------------+
+-------------------------------------+
| Method Summary |
+--------+----------------------------+
| void | finalize() |
+--------+----------------------------+
| Sample | h(java.lang.String[] args) |
+--------+----------------------------+
| Sample | init(Sample a) |
+--------+----------------------------+
- Problem #4 (10 points)
Consider the following incomplete program.
class prg{
public static void main(String[] args){
Boolean bb;
double d;
st = "abc";
= 6.2;
dd = new Double ( 3.14 );
= new Boolean( true );
= st.concat ( " String." );
b = true;
} }
Fix the program so that it will be compilable by javac.