- Problem #1 (10 points)
The command ‘javap -private java.lang.Boolean’ produces the following output.
public final class java.lang.Boolean
extends java.lang.Object implements java.io.Serializable {
public static final java.lang.Boolean TRUE;
public static final java.lang.Boolean FALSE;
public static final java.lang.Class TYPE;
private boolean value;
private static final long serialVersionUID;
public java.lang.Boolean(boolean);
public java.lang.Boolean(java.lang.String);
public boolean booleanValue();
public static java.lang.Boolean valueOf(boolean);
public static java.lang.Boolean valueOf(java.lang.String);
public static java.lang.String toString(boolean);
public java.lang.String toString();
public int hashCode();
public boolean equals(java.lang.Object);
public static boolean getBoolean(java.lang.String);
private static boolean toBoolean(java.lang.String);
static {};
}
- 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.lang.Boolean 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
Ab.java’.
+--------------------------------+
| Field Summary |
+------------+-------------------+
| static int | i |
+------------+-------------------+
| Ab | p |
| | This is a comment |
+------------+-------------------+
+--------------------------------+
| Constructor Summary |
+--------------------------------+
| Ab() |
| This is also a comment |
+--------------------------------+
| Ab(int i) |
+--------------------------------+
+------------------------------------------+
| Method Summary |
+-------------+----------------------------+
| void | finalize() |
| | This is another comment |
+-------------+----------------------------+
| int | init(int a) |
+-------------+----------------------------+
| static void | m(java.lang.String[] args) |
+-------------+----------------------------+
- Problem #4 (10 points)
Add the needed class so that the given program
will compile (under javac) into an executable
code.
class prg{
public static void main( String[] args){
int ii;
Boolean bool;
Cls obj;
obj = new Cls();
obj = new Cls( 0 );
ii = Cls.a;
ii = obj.i;
bool = obj.b;
ii = obj.s ( true );
obj.v ();
} }
- Problem #5 (10 points)
Consider the following incomplete program.
class prg{
public static void main(String[] args){
int i;
double d;
Integer in;
String st1, st2;
i =
= 2.73;
in =
= new Double ( 3.14 );
st2 = new String("A string.");
st1 = .concat ( " Another String." );
System.out.println( in ); System.out.println( i );
System.out.println( db ); System.out.println( d );
System.out.println( st1 );
} }
Fix the program so that it will produce the output:
123
17
3.14
2.73
A string. Another String.
The following are the interfaces of some constructors and methods that may be of interest to you.
Integer(int value)
Integer(String s)
Double(double value)
Double(String s)
String()
String(String original)
String concat(String str)