Anda di halaman 1dari 16

0801/158.

326 ALB Internal

SC

MASSEY UNIVERSITY
ALBANY CAMPUS
EXAMINATION FOR 158.326 SOFTWARE CONSTRUCTION Semester One 2008

Time allowed: THREE (3) hours

There are 72 questions: ALL questions should be attempted This examination contributes 55 % to the final marks SECTION A 50 Multichoice questions SECTION B 20 True / False questions SECTION C Two questions

(Scantron Card)

50 Marks

(Scantron Card)

10 Marks

(Blue Answer booklet)

40 Marks Total: 100 Marks

THIS IS A CLOSED BOOK EXAMINATION. Calculators, Dictionaries or any type of electronic assistants ARE NOT ALLOWED.

Scantron Cards Ensure that your name and identification number are entered on your Scantron Card. Record your answer on your Scantron card by putting a solid horizontal pencil line through the character representing the best answer to the question with a blunt 2B or 3B pencil, please. The Scantron Card will not read properly if you do not follow these instructions. At the conclusion of the examination hand in the Scantron Card separately.

Page 1 of 16

0801/158.326 ALB Internal

SC

SECTION A
Attempt all the following questions. There is one (1) correct answer. Record the answer that applies best on your Scantron card The Scantron Card has five options. Ignore the fifth option (e) (Total: 50 marks) 1. Which of the following will generate a compilation error for a class? a. b. c. d. Declaring constructors with parameters. Declaring constructors as private. Declaring constructors which return a value. Declaring multiple constructors.

2. The static/ shared members of a class a. b. c. d. are at the same memory location for all objects of that class. can be referenced only after the object has been instantiated. maintain constant values throughout the run time environment of objects. can be overridden by the child class.

3. Which is a violation of the principle of encapsulation while declaring class members? a. b. c. d. Declaring properties as public. Declaring methods as public. Declaring variables as public. None of the above violates encapsulation. relationship.

4. Inheritance is best described by a. knows of b. has a c. is kind of d. acts as a

5. A base classs ____________ members can be accessed only in the base class and in the derived class. a. b. c. d. shared partial private protected

Page 2 of 16

0801/158.326 ALB Internal 6. System.Windows.Forms.Button represents a(n) ___________. a. b. c. d. assembly namespace class name event in a form

SC

7. Which statement is FALSE for Interfaces? a. b. c. d. Interfaces cannot have constructors. Interfaces cannot have public properties Interfaces cannot have public variables. Interfaces cannot have defined responsibilities in public methods.

8. The binding of data and functions together into a single class type is referred to as . a. b. c. d. Interfaces Polymorphism Inheritance Encapsulation

9. If a derived class dis-inherits even one of the base class operations, it is a violation of . a. b. c. d. Liskov Substitution Principle Indirection principle Principles of overloading and overriding Delegation principle

10. When overloading methods of a base class, the derived class should change the the base class method. a. b. c. d. return type of visibility level of number of parameters in name of the

Page 3 of 16

0801/158.326 ALB Internal

SC

11. In the GreetMe function given below, the term ByRef (in VB) or ref (in C#) refers to passing of the strName as the parameter. VB Language
Function GreetMe(ByRef strNname As String) Return Hello & strName End Function

C# Language
private string GreetMe (ref string strName) { return Hello + strName; }

a. b. c. d.

address of value of copy of string

12. Interfaces need to be _____________ and Abstract classes need to be _____________. a. b. c. d. inherited, implemented inherited, encapsulated implemented, inherited encapsulated, implemented

13. With reference to Figure A, an instance of ROBOT (in VB.Net or C#) would be constructed if Figure A HUMAN breatheWithLungs( ) COMPUTER breatheWithBattery( )

ROBOT breatheWithLungs( ) breatheWithBattery( ) a. b. c. d. HUMAN and COMPUTER are abstract classes. HUMAN and COMPUTER are delegates. HUMAN and COMPUTER are interfaces. HUMAN, COMPUTER and ROBOT are interfaces.

Page 4 of 16

0801/158.326 ALB Internal 14. Which of the following is FALSE? a. b. c. d. Abstract classes can be defined with empty methods. Abstract classes can contain non overridable methods. Abstract classes can have properties. Abstract classes can be used as concrete child classes.

SC

15. The summary information of all objects belonging to the same class in VB/C# is declared with the keyword __________. a. b. c. d. By Ref/ ref shared/static Partial/partial summary

16. In a part-whole relationship of objects, when the part object can exist outside of the whole object, they are said to have a(n) relationship. a. b. c. d. composition aggregation symbiotic packaged

17. In .Net, the relationship between Exception and ApplicationException is shown by the following figure

a.

b.

c.

d.

Page 5 of 16

0801/158.326 ALB Internal 18. methods require same signatures, but different signatures. a. b. c. d. Abstract, shared/static Shared/ static, abstract Overloaded, overridden Overridden, overloaded methods require

SC

19. The ________ pattern presents a unified interface to a set of interfaces in a subsystem. a. b. c. d. Adapter Composite Faade Singleton

20. The _________________ separates the construction of a complex object from its representation, so that the same construction process can create different representations. a. b. c. d. State Pattern Chain of Responsibility Pattern Singleton Pattern Builder Pattern

21. ________________ is the object oriented principle to reduce coupling between objects when their physical location is constantly changing. a. b. c. d. Referential Integrity Indirection Shared/Static Liskov Substitution

22. The ODBC interface to connect an ASP.NET Web page to a relational database in pattern. Access is an example of a. b. c. d. Builder Factory Method Faade Chain of Responsibility

Page 6 of 16

0801/158.326 ALB Internal

SC

23. To design Person in Figure B as a Singleton Pattern, we should _____________. Figure B

a. b. c. d.

define UniqueInstance as a private instance variable. define the constructor as shared/static. define the method getInstance as shared/static. All of the above are correct.

24. A Weather Reporting Application displays latest weather data on screen. The weather screen displays in two formats graphic screen and text report. When the weather changes the reporter sends updates and each display is updated accordingly. The pattern. pattern that describes the above scenario is a. b. c. d. Multiton Observer Faade Chain of Responsibility

25. The ________________ pattern does not guarantee that a clients request will be handled and that it will not be lost. a. b. c. d. Multiton Observer Faade Chain of Responsibility

26. A ________ pattern is used for clients to treat a collection of objects uniformly irrespective of the fact that they are made up of other objects or are just primitive objects. a. b. c. d. Builder Adapter Composite Factory Method

Page 7 of 16

0801/158.326 ALB Internal 27. All the methods in the Interface should be marked as a. b. c. d. Private /private Public/ public Protected / protected Protected Friend / protected package

SC

28. Which statement is FALSE for the Observer Pattern? a. Observer Patterns are used when a change in one object requires change in the others. b. Observer Patterns are used when the numbers of dependent objects are not known. c. Observer Patterns are used to support broadcast communication. d. Observer Patterns are used to change complex many-to-many relationships with simple one-to-many interactions 29. Which of the following is NOT defined in an operations signature? a. b. c. d. Method name Parameters or arguments Return value data-type Class name

30. In the Builder Pattern, the ___________ class uses only shared/ static method(s). a. b. c. d. Builder Client Product Director

31. The ____________ pattern provides an interface for creating families of related or dependent objects without specifying their concrete classes. a. b. c. d. Builder Abstract Factory Factory Method Singleton

Page 8 of 16

0801/158.326 ALB Internal

SC

32. Client sends a Request along the chain, and the handler accepts a request and either handles it or passes it along to the next handler in the chain (successor). What is the multiplicity at X in the Figure C? Figure C

a. b. c. d.

* 1 0..1 0..*

33. Which statement is FALSE about composition? a. b. c. d. It implies exclusive containment of the part inside a whole object. It implies lifetime dependency between the part and the whole objects. It implies direct access to source code of the part by the whole object. It implies that the part can be used dynamically by different whole objects.

34. Many bidders are registered in an on-line auction. During an auction, when a bidder accepts a bid, the bid price changes. The auctioneer then broadcasts the new bid price to all the bidders. This is an example of the ____________ pattern. a. b. c. d. Observer Chain of Responsibility Abstract Factory Factory Method

Page 9 of 16

0801/158.326 ALB Internal

SC

35. A network connection responds differently as per its present situation. The different situations can be Established, Listening or Closed. The connection class should be a(n) _____________ class. This scenario represents an example of the ____________pattern. a. b. c. d. concrete, State abstract, Composite concrete Composite abstract, State

36. A cricket teams score is considered as an aggregate of its individual players. Which pattern will best represent the individual and the team performance? a. b. c. d. Abstract Factory Mediator Composite Faade

37. Chatrooms serve as a central hub between people and facilitates loosely coupled communication between the different participants. The chatroom can be designed using a ____________ pattern. a. b. c. d. Mediator Composite Factory method Multiton

38. Which of the following is correct for Delegation? a. b. c. d. Delegation favours inheritance over composition. Delegation composes behaviour at run- time. Delegation is an extreme form of Object Inheritance. All of the above are correct

39. Which of these objects is NOT an intrinsic object? a. b. c. d. Session Application Cookie Request

Page 10 of 16

0801/158.326 SC ALB Internal 40. To store information that is used in multiple web pages, we should use ___________. a. b. c. d. a namespace object the viewstate property the controlstate property a session object

41. You store cookies from the __________ object and you retrieve cookies using the ________________ object. a. b. c. d. Redirect, Transfer Transfer, Redirect Request, Response Response, Request

42. __________ is/ are tightly bound to a specific page. If user navigates to another page, this information is lost. a. b. c. d. Cookies Session Viewstates Application

43. Which ListBox property or event causes the current page to be posted back immediately when the user makes a selection? a. b. c. d. PostBack AutoPostback SelectedIndexChanged SelectedValue

44. The functions of a business tier in a three-tier application do NOT include ______________. a. b. c. d. validation calculation storage of data business logic

45. Which of the following is true? a. b. c. d. All abstract classes are interfaces. All interfaces are abstract classes. All delegates are abstract classes. All delegates are interfaces.

Page 11 of 16

0801/158.326 ALB Internal 46. Which of these patterns works on the principle of Indirection? a. b. c. d. 47. The a. b. c. d. 48. Adapter Pattern Singleton pattern Observer Pattern All of the above are examples of Indirection principle. is a reference of an object to itself. Me (in VB) or this (in C#) This (in VB) or me (in C#) My (in VB and C#) Same (in VB) or same(in C#)

SC

helps to present different representations of subsets of data retrieved from the database on a Web page. a. b. c. d. DataSet DataAdapter DataView DataSource encapsulates the SQL commands (SELECT, DELETE, UPDATE,

49. The INSERT). a. b. c. d.

DataSet DataAdapter DataView DataConnection , ,

50. In the Figure D, the components X, Y and Z represent and respectively. Figure D

X
a. b. c. d.

DataAdapter, DataSet, DataView DataConnection, DataSet, DataView DataAdapter, DataConnection, DataSet DataConnection, DataAdapter, DataSet

Page 12 of 16

0801/158.326 ALB Internal

SC

SECTION B
Attempt all of the following questions. Record your answers on your Scantron Card The Scantron Card has five options. Use (a) for True and (b) for False.

Ignore the third, fourth & fifth options (c), (d) & (e)
(Total Marks = 10) State True or False 51. Interfaces can be destroyed by using destructors. a. True b. False 52. An object has its own state and its own behaviour. The behaviour is not shared amongst objects created from the same class. a. True b. False 53. The session objects are stored in the clients machine. a. True b. False 54. Master pages allow you to create a consistent look for all Web pages within an application. a. True b. False 55. The machine.config file is inherited from the web.config file. a. True b. False 56. When a class implements an interface, it should provide an implementation for each interface member. a. True b. False

Page 13 of 16

0801/158.326 ALB Internal 57. We should program to an implementation and not to an interface. a. True b. False 58.

SC

Both Inheritance and Delegation are examples of tight coupling between classes. a. True b. False

59.

Web applications cannot use classes having shared/ static properties or methods. a. True b. False

60.

The Request object sends HTML to render a Web page on the browser. a. True b. False

61.

Exceptions are caught in the control class, and thrown by the boundary class. a. True b. False

62.

The Server.Transfer is used to transfer to a web page belonging to the same server, but Response.Redirect will transfer to a web page belonging to another server. a. True b. False

63.

A method declared as Shared (in VB) or static (in C#) will not be able to access itself with the Me reference (in VB) or this reference (in C#). a. True b. False

64.

Too many session objects for multiple users could slow down the server. a. True b. False

Page 14 of 16

0801/158.326 ALB Internal 65.

SC

Datasets are disconnected from the datasource, and are copies of the data stored in temporary memory storage. a. True b. False

66.

A session object loses it value if the user closes the browser and then again restarts the browser. a. True b. False

67.

In .NET we can remove inheritance by declaring a class as NonOverridable (in VB) or nonoverridable (in C#). a. True b. False

68.

All web controls are recreated each time a Web page is rendered on the users browser. a. True b. False

69.

When a web page is loaded for the first time, then its IsPostBack property is true. a. True b. False

70.

Constructors cannot be declared with a(n) overridable/ virtual keyword. a. True b. False

Page 15 of 16

0801/158.326 ALB Internal

SC

SECTION C
(Total Marks = 40) Attempt BOTH of the following questions. Write your answers in the blue answer booklet. CASE STUDY Aotearoa Road Cover Insurance (ARCI) is an organisation dealing with insurance policies for all types of vehicles on New Zealand roads. ARCI applies premium rates based upon different categories of licenses that may be held by the applicants and also upon the number of years a person has held a license. The different categories of licenses are a. New Zealand Full License b. New Zealand Restricted License c. Overseas License The following business rules apply to ARCI policy holders ARCI refers to a premium rate table for the different license categories. If a policy holder has held a license for a minimum of 5 years, he/she gets a 10% discount on the premium rate. If a policy holder has not claimed any insurance benefits in the last two years, he gets a 30% discount on the premium rate.

You have been asked to develop a system to help ARCI make decisions on the premium rates for policy holders. Questions 71. Draw a class diagram for the above scenario. (25 marks)

HINT: Your diagram should have provision for flexibility and scalability (e.g. it should be able to add another category of license) through use of some design pattern(s). Name the design pattern(s) used and explain how they help in improving the flexibility and scalability of the design. 72. Draw a user friendly graphical user interface (GUI) which is used by ARCI staff to enter details of the applicant and which also displays the final premium amount. (15 marks)

++++++++ Last Page +++++++

Page 16 of 16