Ics2306:Computer Networks Question Paper
Ics2306:Computer Networks
Course:Computer Science
Institution: Meru University Of Science And Technology question papers
Exam Year:2010
INSTRUCTIONS: Answer question one and any other two questions
QUESTION ONE – 30 MARKS
a. Explain user interfaces. (2 Marks) b. View: (1 Mark) i. Controller (1 Mark) ii. Frame (2 Marks) iii. Panel (2 Marks) c. Explain the use of layout manager. (2 Marks) d. Explain two advantages and disadvantages of null layout. (2 Marks) e. With the help of a code, show how to choose to use no layout manager. (2 Marks) f. Define an event and explain how events are used in JAVA. (2 Marks) g. Discuss Hash Maps. (2 Marks) h. Differentiate between components and containers. (2 Marks) i. Explain two main sets of visual components and containers for user interface design in JAVA. (4 Marks) j. Write a java code application for the below boarder layout diagram. (3 Marks)
k. Explain five commonly used types of events in JAVA. (4 Marks)
2
QUESTION TWO – 20 MARKS
In this scenario we will create a BankAccountDialog that allows us to modify a BankAccount’s owner name, address and phone number. It will also show us the account number and balance, but we willnot be allowed to alter that information. We will design the dialog box to look like this:
Notice that it shows the name, address, phone number, account number and balance, but that the account number and balance are disabled (grayed out) so that we cannot edit them. Also, notice the OK and CANCEL buttons (which typically appear at the bottom right of a dialog box). Also, notice that there are no minimize or maximize buttons on the titlebar… we will make this window non-resizable.
a. We will create this window by first creating a JPanel containing the 5 text fields and their labels. We will set it up as the view part of the window so that the pane class will not have any behavior, it will simply allow us to access the three editable fields through public get methods. (8 Marks)
Notice:
? The constructor takes a bank account object. This is used to “fill-in” the initial values of the panel ? Instance variables and get methods are made only for the name/address/phone text fields since the other txt fields may not be changes. (i.e, they are disabled) ? The code here should not make changes to the model bank account in any way!!!
b. Explain Set Classes. (4 Marks) Here is the diagram representing the Movie object:
c. Write a java application code to define this Movie class. (4 Marks) d. Describe recursion. (4 Marks)
3
QUESTION THREE – 20 MARKS
a. Define menu and explain five menu classes. (6 Marks) b. Write a java application code for the above graphics. (8 Marks)
c. Explain the following terms: (4 Marks) i. Server ii. Client iii. TCP iv. Socket
QUESTION FOUR – 20 MARKS
Consider the following scenario: Let us look at a large example now in which a server application represents an auction. Items are put up for auction and clients bid over the network on the items. Clients must first register with the auction server and then they may make bids on the items as they are placed up for auction. The user at the server end decides when the item is no longer up for auctioning.
a. Explain three model classes. (2 Marks)
b. Write two communication classes. (2 Marks)
4
c. Discuss the user interface classes. (6 Marks) d. Write a java application code to implement Customer model class. (5 Marks) e. Write a java application code to implement Auction Item model class. (5 Marks)
QUESTION FIVE – 20 MARKS
Consider the following: We will now look at kinetic animation that is … animation that moves as opposed to staying in one location. Our task will be to move a bird around in a window. Here are the frames that we will use:
Cutting this bird to fly in a single location on the screen is now easy. We can use the Cardlayout manager if we want to … however, we will want to make the bird move around. Our choice will be to display it on a JFrame or JPanel. We will write the code such that the user gets to make the bird fly by causing it to flap its wings whenever h/she clicks the mouse. Notice that our bird will only fly from left to right. Getting this bird to fly in a single location on the screen is now easy. We can use the CardLayout manager if we want a… however, we will want to make the bird move around. Our choice will be to display it on a JFrame or JPanel. We will write the code such that the user gets to make the bird fly by causing it to flap its wings whenever he/she clicks the mouse. Notice that our bird will only fly from left to right.
a. Identify two class variables to keep track of how many frames the bird will have and the width of each frame. (in pixels) (2 Marks)
When making a bird, we must load up the images from the file and store them into the images array. We probably also want to choose some starting frame (in our case#4) as well as a starting location. We will not supply a “get” method for the image array. Instead, we will write a method called appearance() that will return the image corresponding to the current frame of the bird.
b. Write a java application to implement the above scenario. (5 Marks)
So each bird will keep track of its current frame, location and appearance. We will just need to apply some methods that we can call from the application that will tell the bird to advance its frame to the next one and move forward as necessary. For some added realism, we will have the bird “fall” when its wings are not flapping. That brings up some good questions:
? When is the bird flying and when is it falling? ? What does it look like when its falling? ? How do we make it fall?
5
These are easily answered: ? The bird is flying when its wings are flapping down and falling otherwise. ? We will choose frame three to represent the “falling” frame
We make it fall by increasing the y value of the location
c. Write a java code statement that moves the bird forward while advancing the frame and also takes into account gravity. (3 Marks) d. Write a java code statement that will make the bird flap its wings. (1 Mark)
The “follow-through” from the flapping(i.e the continuation and completion of the flapping motion) will be handled by successive calls to advance ().
Now that we have the bird working, let us get the interface going. We will make a JFrame and color the background white. We will set up a Timer that will cause the bird to advance every 1/5 of a second.
e. Write a java application code to implement the above flying bird application. (8 Marks) f. Write a java code statement that will add the Mouse Pressed event handler to make the bird flap its wings. (1 Mark)
More Question Papers