A10-r3

  • November 2019
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View A10-r3 as PDF for free.

More details

  • Words: 2,836
  • Pages: 10
A10.2-R3: Introduction to Object Oriented Programming Through Java Previous Question Papers

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. TOTAL TIME: 3 HOURS TOTAL MARKS: 100 (PART ONE - 40; PART TWO - 60)

PART ONE (Answer all the questions) 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.1 Which of the following are not Java reserved keywords A) Finally B) Volatile C) Abstract D) That 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.3 Which of these is true about constructors? A) It initializes an object immediately upon creation. B) It is syntactically similar to a method. C) The return type of class constructor is the class type itself. D) All of the above

A1-R3

Page 1 of 5

JULY, 2004

1.4 Which of the following is not a byte stream class? A) FilterlnputStream B) PipedOutputStream C) InputStreamReader D) RandomAceessFile 1.5 What is not true about applets? A) Applets do not need a main() method. B) Applets should be run under a Java-compatihle browser. C) Applet uses the interface provided by AWT. D) User I/O is accomplished with Java's stream I/O classes. 1.6 Which of the following statement is not true? A) Variables declared inside of interface declaration may be changed by implementing class B) Interfaces are designed to support dynamic method resolution at run time. C) When an interface method is implemented it must be declared as public. D) Variables declared inside interface declaration are implicitly final. 1.7 Which of the following is not a constructor of JRadioButton? A) JRadioButton(lcon i) B) JRadioButton(String s) C) JRadioButton(boolean state) D) JRadioButton(lcon i, boolean state) 1.8 The order of precedence from highest to lowest is: A) ~,%,^,& B) ~, ^, ||, && C) >= , !=, <<, + D) -, <<<, ==, | 1.9 Methods defined by Math class are: A) static double random() B) static double sin(double arg) C) static double to Degrees(double angle) 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.1 Java does not support unsigned, positive integers only. 2.2 Objects declared within the inner scope will be visible outside it. A1-R3

Page 2 of 5

JULY, 2004

2.3 char[ ] [ ] twod = new char[3][4]; is a valid array declaration. 2.4 Stack overflow is an example of Runtime exception. 2.5 Instantiation exception means an attempt to create an abstract class or interface. 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. 2.7 A cloneable interface defines no members. 2.8 A break statement can be used as a form of GOTO. 2.9 A interface defined by java.lang are Cloneable, Comparable and Runnable. 2.10 In, out and new are predefined stream variables. 3. Match words and phrases in column X with the closest related meaning/word(s)/phrase(s) in column Y. Enter your selection in the "tear-off' answer sheet attached to the question paper, following instructions therein.(1 x 10) X

Y

3.1

Normally, Java resolves calls to methods dynamically at run time

A. join

3.2

The method waits for a thread to terminate

B. late binding

3.3

These are bundles of information passed between machines

C. static binding

3.4

The method initiates garbage collection

D. datagrams

3.5

This event class is generated when a list item is double clicked

E. gc()

3.6

This compares two object references to see whether they refer to the same instance.

F. gcol()

3.7

It is an object that will check the status of an arbitrary number of images in parallel

G. Action Event

3.8

This method sets the vector's capacity equal to the number of elements that it currently holds.

H. Item Event

3.9

Constructor[] getConstructors[] throws SecurityException

I.

3.10

Constructor[] getDeclaredConstructors[] throws SecurityException

J. compare To()

==

K. media tracker L. image observer A1-R3

Page 3 of 5

JULY, 2004

M. final void trimToSize( ) N.

returns a Constructor object for all 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.2 A(n)_______ is an abstraction that either produces or consumes information. 4.3 The _______ method converts data from its internal format into a human-readable form. 4.4 _______ is called before an unused object is recycled. 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. 4.10 Use of an offscreen image to reduce flicker is called _________

PART TWO (Answer any Four Questions) 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. A1-R3

Page 4 of 5

JULY, 2004

(5 x 3) 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.

A1-R3

Page 5 of 5

JULY, 2004

TOTAL TIME: 3 HOURS TOTAL MARKS: 100 (PART ONE - 40; PART TWO - 60)

PART ONE (Answer all the questions) 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.1 Among these expressions, which is(are) of type String? A) "0" B) '0' C) A) and B) D) None of the above 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.4 What is bytecode in the context of Java? A) The type of code generated by a Java compiler B) The type of code generated by a Java Virtual Machine C) It is another name for a Java source file D) It is the code written within the instance methods of a class 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.6 Consider the following code snippet String river=new Strlng("Columbia"); System.out.println(river.length());

What is printed? A) 7 B) 8 A1-R3

Page 6 of 5

JULY, 2004

C) Columbia D) River 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 1.10 What is garbage collection in the context of Java? A) The operating system periodically deletes all of the java files available on the system. B) Any package imported in a program and not used is automatically deleted. C) The JVM checks the output of any Java program and deletes anything that doesn't make sense. D) When all references to an object are gone, the memory used by the object is automatically reclaimed. 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.1 Int is the name of a class available in the package java.lang. 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. A1-R3

Page 7 of 5

JULY, 2004

2.5 Each source file that you compile will produce one file with an extension .class. 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.3

native

C.

This interface is required to be implemented by a class if we want to run a task concurrently with other tasks

3.4

transient

D.

variable whose value may change independent of the Java program

3.5

join( )

E.

Required if a method throws an exception

3.6

import

F.

To refer to the current instance of the class in which the code is written

3.7

Runnable

G.

This modifier means not to save the variable

3.8

this

H.

This occurs if threads are waiting for each other's key to proceed

3.9

Deadlock

I.

Methods implemented in other languages, such as C

3.10

Volatile

J.

Allows classes and interfaces to be referred to solely by the class names instead of the fully qualified names

A1-R3

Page 8 of 5

JULY, 2004

K.

Method is called by the server after the server constructs its instances

L.

When a client connects to a server and .makes an HTTP request

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. main B. BG COLOR C. Garbage Collection D. Exception E. Expressions F. Return G. Javax.swing H. File input stream I. Computer dependent J. Stream Tokenizer K. System.out.print L. if 4.1 To change Web Page background colors you use the _______ attribute in the tag. 4.2 Java applications begin execution at method _______. 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.6 The number of bytes used by Java primitive long is _______. 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 (Answer any Four Questions) 5. Answer the following in brief: a) What is the maior difference between extending classes and extending interfaces? b) What is a proxy server? c) What are factory classes? d) Abstract identifier can be applied to classes as well as interface. Explain what this modifier indicates in each case. A1-R3

Page 9 of 5

JULY, 2004

e) What is the difference between a runtime error and a compile time error? Explain using a suitable example. (3 x 5) 6. Write a short note on the following: a) Java Virtual Machine b) Multithreading c) Utility classes d) Applets e) layout Managers (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) 8. Write a program to illustrate a simple client/server pair. (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)

A1-R3

Page 10 of 5

JULY, 2004