You are on page 1of 2

Birla Institute of Technology & Science, Pilani Distance Learning Programmes Division Second Semester 2007-2008 Mid-Semester Test

(EC-1 Regular) Course No. Course Title Nature of Exam Weightage Duration Date of Exam Note:
1. 2. 3. 4.

: BITS ZC411 : OBJECT ORIENTED PROGRAMMING : Closed Book : 40% No. of Pages =2 : 2 Hours No. of Questions = 4 : 02/02/2008 (FN)

Please follow all the Instructions to Candidates given on the cover page of the answer book. All parts of a question should be answered consecutively. Each answer should start from a fresh page. Mobile phones and computers of any kind should not be brought inside the examination hall. Use of any unfair means will result in severe disciplinary action.

Q.1

Write short answers for the following questions. Justify your answers.
(a). (b). (c).

(d).

[5 x 2 = 10] Can we declare two instance variables with the same name in a class? (Yes or No) Is the operations y >> 3 and y >>> 3 produce the same result when y > 0? Yes/No. When declaring a field, what is the access-level specifier you use so that only classes in the same package as the class that declares the field can access that field? Choose from the list. [public, private, protected, none] Given the code: String s = new String("abc"); Which of the following calls are valid? (A) s.trim() (B) s.replace('a', 'A') (C) s.substring(3) (D) s.toUppercase() (E) s.setCharAt(1,'A') (F) s.append("xyz") Can two or more reference variables refer to the same object at the same time? Yes/No

(e).

Q.2

Write a method: public static Object maximum(ArrayList a, Comparator c) that computes the largest object in the array list, using the ordering relationship that is defined by the given comparator. [8]

BITS ZC411 (EC-1 REGULAR)

SECOND SEMESTER 2007-2008

PAGE 2

Q.3

You have to provide an OO design for airplane reservation system. Assume that each airplane has 20 seats in first class ( 5 rows of 4 seats each, separated by an aisle) and 180 seats in economy class ( 30 rows of 6 seats each, separated by an aisle). A person can book a ticket for one or more passengers, and cancel the trip for a particular passenger (If the ticket contains more passengers a new ticket will be issued with the same ticket number, but without the name of this particular passenger). At the time of reservation the person who is booking the ticket has to provide the following information: the names of the passengers, address, phone number, boarding point and to which city they are fling to, flight number , the date of journey and the seating preference (aisle or window in first class; aisle, center or window in economy). If the seats are available, but the available preferences are not matching with the preferences that are demanded by the passengers, an appropriate message is appeared on the screen. At this stage either ticket can be booked with the available preferences or ticket may not be booked, according to the wish of the booker. If seats are not available and if the booker is ready to book the ticket in waiting list, the system provides a waiting list number for each passenger. As the seats are cancelled, the system allots the seats to the waiting list passengers in first come first serve manner. Preferences can not be given for the waiting list passengers. [10] 3.1. 3.2. 3.3. Find out all the relevant classes. Write statement of purpose for each class. Write down all the use cases. Draw a UML class diagram.

Q.4

We need to compute the Course Grade for a Student in a course. For the course, there will be three tests (20 marks each) and one Final test (40 marks). There can be only two grades possible (i.e. A and B). For an Undergraduate student, average+20 is A grade (else B) and for a graduate student, average + 10 is A grade (else B). Each Student is identified by name and idno. Write proper get and set methods. Write the Driver Class (Test Class with main method) to compute for both kinds of students. Assume Average for the course is 55. [Hint : Use Inheritance, Abstract Class and Method Overriding] [12]

********

You might also like