Beruflich Dokumente
Kultur Dokumente
July 2005
NOTE:
1. There are TWO PARTS in this Module/Paper. PART ONE contains FOUR questions
and PART TWO contains FIVE questions.
2. PART ONE is to be answered in the TEAR-OFF ANSWER SHEET only, attached to the
question paper, as per the instructions contained therein. PART ONE is NOT to be
answered in the answer book.
3. Maximum time allotted for PART ONE is ONE HOUR. Answer book for PART TWO
will be supplied at the table when the answer sheet for PART ONE is returned. However,
candidates, who complete PART ONE earlier than one hour, can collect the answer book
for PART TWO immediately after handing over tRe answer sheet for PART ONE.
PART ONE
1. Each question below gives a multiple choice of answers. Choose the most appropriate one
and enter in the "tear-off" answer sheet attached to the question paper, following
instructions therein.(1 x 10)
1.2 The methods defined by Thread class that help to manage threads are:
A) joined
B) stop
C) getName
D) all of the above
1.10 When no specific buffer length is requested, String Buffer allocates room for how many
additional characters
A) 8
B) 16
C) 0
D) Not fixed
2. Each statement below is either TRUE or FALSE. Choose the most appropriate one and
ENTER in the "tear-off' sheet attached to the question paper, following instructions
therein.(1 x 10)
2.2 Objects declared within the inner scope will be visible outside it.
2.6 The Applet.stop() method is invoked automatically by Java run-time system when the web
page in which it is embedded is reloaded.
X Y
Normally, Java resolves calls to methods
3.1 A. join
dynamically at run time
3.2 The method waits for a thread to terminate B. late binding
These are bundles of information passed
3.3 C. static binding
between machines
3.4 The method initiates garbage collection D. datagrams
This event class is generated when a list item is
3.5 E. gc()
double clicked
This compares two object references to see
3.6 F. gcol()
whether they refer to the same instance.
It is an object that will check the status of an
3.7 G. Action Event
arbitrary number of images in parallel
This method sets the vector's capacity equal to
3.8 H. Item Event
the number of elements that it currently holds.
Constructor[] getConstructors[] throws
3.9 I. ==
SecurityException
Constructor[] getDeclaredConstructors[] throws
3.10 J. compare To()
SecurityException
K. media tracker
L. image observer
A1-R3 Page 3 of 5 JULY, 2004
M. final void trimToSize( )
returns a Constructor object for all
N.
the public constructors of this class
returns a Constructor object for all
O. the constructors that are declared
by this class
4. Each statement below has a blank space to fit one of the word(s) or phrase(s) in the list
below. Enter your choice in the "tear-off' answer sheet attached to the question paper,
following instructions therein. (1 x 10)
A.valueof( ) B.finalize( ) C.double buffering D.overridden E.50 F.100 G.APPLET H.ALT I.wait(
) J.sleep() K.context switch L.preemptive switching M.streams N.container event O.screen
flicker
4.1 The method tells the calling thread to give up monitor until some other thread enters the same
monitor.
4.3 The _______ method converts data from its internal format into a human-readable form.
4.5 A thread priority is used to decide when to move from one running thread to the next. This is
called _______
4.6 A method is _______ when another method with the same signature is declared in a subclass.
4.7 ServerSocket(int port) creates server socket on the specified port with a queue length of
_______
4.8 The _______ tag is used to start an applet from both an HTML document & from an applet
viewer.
4.9 ________ class is generated when a component is added to or removed from a container.
PART TWO
5.
a) Explain the principal advantages of object-oriented programming.
b) What do you understand by dynamic initialization?
c) Explain through an example. Explain multiple catch clauses in exception handling.
6.
a) What is a Class? How does it accomplish data hiding?
b) Write a Java Applet using swing methods and classes to find maximum out of n given
numbers.
(6+9)
7.
a) Discuss the role of inheritance in object-oriented programming. A class that has been declared
as private is not accessible by any code outside its class, including subclasses. Explain this with
the help of coding.
b) Explain dynamic method dispatch with the help of an example.
c) What do you understand by implementing interfaces? Explain with an example.
(5 x 3)
8.
a) What do you understand by thread priorities?
a) What are transcendental functions?
b) Explain the general procedure to use a tabbed pane in an applet.
(5 x 3)
9.
a) Explain TCP/IP server sockets.
b) Explain Interthread communication.
c) How database connections are established?
(5 x 3)
January, 2004
NOTE:
1. There are TWO PARTS in this Module/Paper. PART ONE contains FOUR questions
and PART TWO contains FIVE questions.
2. PART ONE is to be answered in the TEAR-OFF ANSWER SHEET only, attached to the
question paper, as per the instructions contained therein. PART ONE is NOT to be
answered in the answer book. .
3. Maximum time allotted for PART ONE is ONE HOUR. Answer book for PART TWO
will be supplied at the table when the answer sheet for PART ONE is returned. However,
candidates, who complete PART ONE earlier than one hour, can collect the answer book
for PART TWO immediately after handing over the answer sheet for PART ONE.
PART ONE
1. Each question below gives a multiple choice of answers. Choose the most appropriate one
and enter in the "tear-off" answer sheet attached to the question paper, following
instructions therein. (1 x 10)
1.2 Which of the following variable declaration would NOT compile in Java program?
A) int VAR;
B) int var1;
C) int var_1;
D) int 1_var;
1.3 Which of the following special method is used to initialize the instance variable of a class?
A) Class
B) Public
C) Constructor
D) Destructor
1.5 You are programming a game of dice. You need to generate a random integer that can be 1,
2, 3, 4, 5 or 6. Which of the following expression would you select? Recall that Math.random()
returns a random double >= 0 and <1.
A) ((int)Math.random())*6+1
B) (int)(Math.random()*6)+1
C) (int)(Math.random()+6)
D) (int)(Math.random()*6)
1.7 Consider the following truth table for a logical operator "implies"
P Q P implies Q
TT T
TF F
FTT
FF T
Which of the following java conditional expressions would reproduce the above truth table?
A) (!P) && (!O)
B) P && (!Q)
C) (!P) || Q
D) (!P) && Q
1.8 Which of the following is TRUE about the switch statement in Java?
A) A default sends execution immediately to the end of the switch statement.
B) A break sends execution immediately to the end of the switch statement.
C) A case sends execution immediately to the end of the switch statement.
D) The statements in a switch continue to execute as long as the condition at the top of the
switch remains true.
1.9 Which one of the following is a loop construct that will always be executed once?
A) switch
B) for
C) while
D) do .... while
2. Each statement below is either TRUE or FALSE. Choose the most appropriate one and
ENTER In the "tear-off" sheet attached to the question paper, following Instructions
therein. (1 x 10)
2.2 The more comments in a program, the faster the program runs.
2.3 A class have always a constructor (possibly automatically supplied by the java compiler).
2.4 If a source file includes a public class, the class name must match the unextended filename.
2.6 At least one of the following three top-level elements must appear in every source file. If
they are included in the source file, they must appear in the following order.
A. package declaration
B. import declarations
C. class definitions
2.7 The Boolean type cannot be cast from or to any other data type.
2.8 JVM automatically initializes every numeric instance or class variable, except local variables
to zero before it is used.
2.9 Java allows for multiple inheritances, where a class has more than one superclass.
2.10 The root class of all the exception classes is the Exception class.
3. Match words and phrases In column X with the closest related meaning/ word(s)/phrases
in column Y. Enter your selection In the "tear-oft" answer sheet attached to the question
paper, following instructions therein. (1 x 10)
X Y
3.1 throws A. allows only one thread to execute the function at a time
3.2 synchronized B. Used for the caller's thread to wait for this thread to die
3.8 this H. This occurs if threads are waiting for each other's key to proceed
4. Each statement below has a blank space to fit one of the word(s) or phrase(s) in the list
below. Enter your choice in the "tear-off' answer sheet attached to the question paper,
following instructions therein. (1 x 10)
4.1 To change Web Page background colors you use the _______ attribute in the <BODY> tag.
4.3 A(n) _______ is an abnormal condition that disrupts normal program flow.
4.4 Java automatically reclams memory used by an object when no object variables refer to that
object. This process is known as _______.
4.5 Class _______ is an input stream whose data is sourced from an everyday file.
4.7 Class _______ can be used to turn any input stream into a stream of tokens.
4.8 _______ are combinations of variables, keywords or symbols that evaluate to a value of
some type.
4.9 A(n) _______ statement is used to return control to the caller from within a method or
constructor.
4.10 _______ is the high level swing package primarily consists of components, adapters, default
component models and interfaces for all the delegates and models.
PART TWO
(3 x 5)
(3 x 5)
7. Write a program of threads in Java showing interleaving of actions from two threads: t1 and t2
synchronizing on a shared object.
Let t1 print message "ping-->" and t2 print message "<----pong".
Take as command line arguments, the following inputs to the program:
Sleep Interval for thread t1
Sleep Interval for thread t2
Messages per cycle
No. of cycles
(15)
(3 x 5)
OR
8.
a) Write a Java program that input (ten) numbers and determines; and prints the number of
negative number; the number of positive numbers and the number of zeroes inputs.
b) Write an application that inputs a line of text, tokenizes the line with an object of class string
Tokenizer and outputs the tokens in reverse order.
(7+8)
9. Write a program MenuActio.java, which makes a small frame with a menu, which will pop up
after Java starts and loads the (small) class file. The menu items each should embody their own
actionPerformed method, which should just set the status (the body of the frame).
(15)