Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 3

Online Examination

QUESTION PAPER

Curriculum: ACCP2007 Exam Date:


Subject: GAJ 05/02/2010

Duration: 120 minutes Total Marks: 25

MODUL TEST PRACTICAL

GUIDE TO ADVANCED JAVA


Question 1: [13]
Create a java application to do the following task using MultiThread:
- Thread1: display a String message continuously, this String is a attribute

of thread. [3]
- Thread2: This thread have a attribute “number” type of int, pass the
value of it by the constructor. Create a random number from 1 to 10 continuously
when value of random number not equals attribute number. Display the times

create random number when the condition is false. [4]


- Write main() method to demo these Threads.
+ Create 2 threads type of Thread1, one has attribute message is “hello” and
one has attribute message is “bye”. Set Priority of the thread “bye” is MIN. Set the

two thread is deamon and Start them. [3]


+ Create a thread type of Thread2, set attribute number is 2, start and wait
for this thread to die. Create other thread type of Thread2, set arribute number is

7, start it. [3]


Question 2: [12]
Create a class Employee(int id, String name). [4]
- Write the method set and get for the attributes of it.
- Implement two interfaces: Comparable, Serializable.
- Override toString() method and return the information: id and name.
- Override compareTo(Object obj) method and compare the names of two
Employee object.

- Create a HashMap contains the 3 Employee objects with information id and name

pass by constructor, not require input data from keyboard. [3]


- Write the three objects to file “employee.txt” [2]
- Read the three objects from file to a HashMap and display information of them.

[2]
- Insert a new Employee and display to check the order of them in the HashMap.

[1]

You might also like