Archive

Archive for the ‘QUIZZES’ Category

Quiz 7 Solutions

December 27, 2011 Leave a comment

You can download solutions from quiz7sol.

UML Diagram is given below.

Advertisements
Categories: QUIZ-7

Quiz 7 Questions

December 27, 2011 Leave a comment

Refactor the following code segment and then reverse engineer the UML diagram from refactored code:

public class Player {
String playerName;
String address;
List<MatchInfo> matchesPlayed;
int goals;
int goalsConceeded;
int goalsSaved;
// public getter and setter methods.
}

public class GoalKeeper {
String goalKeeperName;
String goalKeeperAddress;
List<MatchInfo> matchesPlayed;
int goals;
int goalsConceeded;
int goalsSaved;
int penaltiesSaved;
// public getter and setter methods.
}

public class Coach {
String coachName;
String coachAddress;
List<MatchInfo> matchesCoached;
// public getter and setter methods.
}

public class Team {
Coach teamCoach;
List<Player> playerList;
GoalKeeper firstGoalKeeper;
List<GoalKeeper> otherGoalKeepers;
// public getter and setter methods.
}

public MatchInfo {
Team homeTeam;
Team awayTeam;
int homeGoals;
int awayGoals;
// public getter and setter methods.
}

You can download questions from CS319_quiz.

Categories: QUIZ-7

Quiz 6 Solutions

December 12, 2011 Leave a comment

You can download solutions from: BILKENT-CS319-DesignPatternsQuiz6-111212(x)

True / False Questions (each 1 pt.)
1. A class diagram is a dynamic view of the classes in a system. (T / F) (False)
2. There are built-in classes in Java SE API such as java.util.Observable. (T / F) (True)
3. Subject and Observers are tightly coupled. (T / F) (False)

Fill in the Blanks Questions (each 2 pt.)
1. Add / remove listener methods in AbstractButton (JButton’s superclass) are an example of ________ pattern. (Observer)
2. Find the matching pattern for the following scenario: A top level component like a Frame or a Panel, contains other components like menus, text panes, scrollbars and buttons. You tell the top level component to display, and count on that component to display all its parts. ______ (Composite)
3. The java.io package is largely based on _______. (Decorator)
4. The _________ design pattern lets you attach responsibilities to objects at runtime. (Decorator)
5. _________ provides a unified interface to a set of interfaces in a subsystem. (Facade)
6. _________ defines a family of algorithms, encapsulates each one, and makes them interchangeable. (Strategy)
7. The usage area of this pattern is as follows: Thread pools, Objects that handle preferences and registry settings, objects used for logging, objects that act as device drivers. Find the pattern. _______ (Singleton)
Classic Questions (each 3 pt.)
1. Why is synchronized keyword used in this code example?
public class Singleton {
private static Singleton uniqueInstance;
private Singleton( ) { }
public static synchronized Singleton getInstance( ) {
if(uniqueInstance == null)
uniqueInstance = new singleton();
return uniqueInstance;
}
}
To solve multithreading problem. By adding synchronized to getInstance( ), we force every thread to wait its turn before it can enter the method. That is, no two threads may enter the method at the same time.

Categories: QUIZ-6

Quiz 6 Questions

December 12, 2011 Leave a comment

You can download questions from here: BILKENT-CS319-DesignPatternsQuiz6-111212

True / False Questions (each 1 pt.)
1. A class diagram is a dynamic view of the classes in a system. (T / F)
2. There are built-in classes in Java SE API such as java.util.Observable. (T / F)
3. Subject and Observers are tightly coupled. (T / F)

Fill in the Blanks Questions (each 2 pt.)
1. Add / remove listener methods in AbstractButton (JButton’s superclass) are an example of ________ pattern.
2. Find the matching pattern for the following scenario: A top level component like a Frame or a Panel, contains other components like menus, text panes, scrollbars and buttons. You tell the top level component to display, and count on that component to display all its parts. ______
3. The java.io package is largely based on _______.
4. The _________ design pattern lets you attach responsibilities to objects at runtime.
5. _________ provides a unified interface to a set of interfaces in a subsystem.
6. _________ defines a family of algorithms, encapsulates each one, and makes them interchangeable.
7. The usage area of this pattern is as follows: Thread pools, Objects that handle preferences and registry settings, objects used for logging, objects that act as device drivers. Find the pattern. _______

Classic Questions (each 3 pt.)
1. Why is synchronized keyword used in this code example?
public class Singleton {
private static Singleton uniqueInstance;
private Singleton( ) { }
public static synchronized Singleton getInstance( ) {
if(uniqueInstance == null)
uniqueInstance = new singleton();
return uniqueInstance;
}
}

 

Categories: QUIZ-6

Quiz 5 Solutions

December 5, 2011 Leave a comment

Categories: QUIZ-5

Quiz 5 Questions

December 5, 2011 Leave a comment

Draw the class diagram for the following case.(20 pt)

The HIJ Car Company is a newly growing company about cars. The known information about the company is name, address, foundation date, founder and phone number.

The company has three main business departments as sales, renting and service. These departments have unique department id, name and a manager and are capable of discount notification. The sales department is employed with providing a test drive to the customers and selling cars and products about cars. The service department is employed with maintenance and repair operations of cars. Third department is concerned with hiring cars to customer. Also, booking is needed before service and hiring operations and booking date information is necessary.

Employees of this company have employee id, name, email, phone number and address information. Each employee works at least one department. Manager and founder are an employee of the company.

Some of the products provided in the company are wheel, door, light(as stoplight and headlight). Car is also another product of this company which consists of other products sold there. The products have the following information: id, name, price, properties. Car product contains model, color, category, speed and number of passengers information. Other products contain number of units remaining information. Car is capable of starting and stopping car.

Categories: QUIZ-5

Quiz 4 Solutions

November 28, 2011 Leave a comment

a-      (5) What would be the output when we run the main method?

Supervisor Jerry showed happiness level of 7

Supervisor Mary showed happiness level of 6

Worker Tom showed happiness level of 5

Supervisor Bob showed happiness level of 9

Worker Jimmy showed happiness level of 8

b-      (10) Draw UML class diagram?

c-    (5) Name the design pattern used?

Composite

http://www.codeproject.com/Articles/185797/Composite-Design-Pattern

 

You can download the solutions from Quiz4Solutions.

Categories: QUIZ-4