CS506 Web Design and Development

Time Allowed: 90 Minutes

Please read the following instructions carefully before attempting any question:

1. This examination is open Handouts.

2. Answer all questions.

a. There is no choice.

b. You will have to answer correctly all questions in this examination to
get the maximum possible marks.

3. Do not ask any questions about the contents of this examination from
anyone.

a. If you think that there is something wrong with any of the questions,
attempt it to the best of your understanding.

b. If you believe that some essential piece of information is missing,
make an appropriate assumption and use it to solve the problem.

You are allowed to use Software J2SE 5.0 or 1.5.0.

**WARNING: Please note that Virtual University takes serious note of unfair
means. Anyone found involved in cheating will get an `F` grade in this course.

Question No. 1

Short Questions. (5 + 5 + 5 = 15 pts)

1. What restrictions are placed on method overriding?
2. What is a Container in a GUI?
3. What are the problems faced by Java programmers who don't use layout managers?

Question No. 2

In Java a final class must be sub-classed before it.

True
False

Question No. 3

A top level class without any modifier is accessible to

any class
any class within the same package
any class within the same file
any subclass of this class

Question No. 4

A top level class may have only the following access modifier.

Package
Private
Protected
Public

Question No. 5

In Java an abstract class cannot be sub-classed

True
False

Question No. 6

Fig-1

Fig-2

Fig-3

Fig-4

You will write the program whose interface is show above.
The panel consists of Two Buttons and one Text box and a string “Hello World”.
Toggle Button: The functionality of the Toggle button is that when it is pressed the color of
the text shown on the panel will be changed. Initially you will use two colors for text (here in
the figure 1 and 2 blue and red colors are used) but if you want to use more color it will be
appreciated.
Green Button
Green button will simply change the color of the text to Green.
Text Box
Whatever string you will write in the text box will appear on the panel and on this text
“Toggle” and “Green” operations can be performed as shown in Fig-4.

1- “Toggle” button will be pressed the color of text will be changed and By press the Toggle
button again the color will be changed again you have to use two colors at least for toggling
(Here in this case blue and red color are shown).
2- When you press the “Green” button the text will become green
3- There is a text box, when you write some string in the text box the Text on the Panel will
change as shown in Fig-3.

Question No. 7

Given a one dimensional array arr, what is the correct way of getting the number of elements in
arr

arr.length
arr.length – 1
arr.size – 1
arr.length()

Question No. 8

When recursive method is called to solve a problem, the method actually is capable of solving
only the simpler case(s), or base case(s).

Sponsored Links

True
False

Question No. 9

Which of these are valid declarations for the main method?

public void main();
public static void main(String args[]);
static public void main(String);
public static int main(String args[]);

Question No. 10

Map interface is derived from the Collection interface.

True
False

Question No. 11

In Java, which of these classes implement the LayoutManager interface?

RowLayout
ColumnLayout
GridBagLayout
FlowLayoutManager

Question No. 12

BorderLayout is the default layout manager for a JFrame’s content pane

True
False