computer science ii - juniata collegejcsites.juniata.edu/.../rhodes/smui/exams/exam1s19key.docx ·...

7
Spring 2019 CS 305 Exam 1 Page 1 Software Models and User Interfaces 2/25/19 (100 points) Name _____________________________ 1. True/False on syntactic features of the C# language. [10 pts] __F___ C# has multiple inheritance. __ T ___ Strings are immutable in C# like in Java, but StringBuilder objects allow mutations of large strings with creating new strings. __ T ___ Strings can be compared like integers with < and == in C#. __ T ___ The verbatim string (@) permits multiple lines and special characters in a quoted string __ F ___ C# treats primitives (int, char, Boolean) differently as objects like Java. __ T ___ C# can automatically format the current time and date according to the locality of the development environment. __ T ___ The overloading of arithmetic operators and indexing [ ] can be applied to user-defined classes. __ F ___ Parameter passing is call-by-value only. __ T ___ ToString(string x) treats x as formatting string that controls how the object is to be converted to a string. __ F ___ The tryParse methods on strings have to be used in conjunction with exception handling for numeric input. 2. GUI widgets. [8 pts] Name 3 GUI widgets that can be used for input: textbox, button, checkbox, updown….. Name 3 different GUI widgets that can be used for output: label, textbox, status line Mouse click positions in a frame use what two properties to track the position? _X____ and __Y___ 3. Other advanced [C#] programming concepts. Short answer.

Upload: others

Post on 16-Feb-2020

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Computer Science II - Juniata Collegejcsites.juniata.edu/.../rhodes/smui/exams/exam1s19key.docx · Web viewIf the survey questions can be answered out of order and require numeric

Spring 2019 CS 305 Exam 1 Page 1Software Models and User Interfaces

2/25/19 (100 points)Name _____________________________

1. True/False on syntactic features of the C# language.[10 pts]

__F___ C# has multiple inheritance.

__ T ___ Strings are immutable in C# like in Java, but StringBuilder objects allow mutations of large strings with creating new strings.

__ T ___ Strings can be compared like integers with < and == in C#.

__ T ___ The verbatim string (@) permits multiple lines and special characters in a quoted string

__ F ___ C# treats primitives (int, char, Boolean) differently as objects like Java.

__ T ___ C# can automatically format the current time and date according to the locality of the development environment.

__ T ___ The overloading of arithmetic operators and indexing [ ] can be applied to user-defined classes.

__ F ___ Parameter passing is call-by-value only.

__ T ___ ToString(string x) treats x as formatting string that controls how the object is to be converted to a string.

__ F ___ The tryParse methods on strings have to be used in conjunction with exception handling for numeric input.

2. GUI widgets.[8 pts]

Name 3 GUI widgets that can be used for input: textbox, button, checkbox, updown…..

Name 3 different GUI widgets that can be used for output: label, textbox, status line

Mouse click positions in a frame use what two properties to track the position? _X____ and __Y___

3. Other advanced [C#] programming concepts. Short answer. [20 pts]

a. When do we need to serialize a C# object? [4]

When we need to save the object for future… persistence

b. How do you designate a class to be serializable? [2]

[Serializable]

c. How do you then serialize an object to a file? [4]

create a file that is designated binary or xml. Use a wrapper to transform the object writing it to the file

Page 2: Computer Science II - Juniata Collegejcsites.juniata.edu/.../rhodes/smui/exams/exam1s19key.docx · Web viewIf the survey questions can be answered out of order and require numeric

Spring 2019 CS 305 Exam 1 Page 2

d. What two forms of files can be created when using serialization? [2]

binary or xml

e. What is the intent of the params type[] type of parameter? How is it used? [4]

to pass variable numbers of parameters. Can then be treated as an array in the method

f. Sketch the definition of a C# object property definition for an instance variable year that will hold an integer representing the year. If the value being set is less than 100 (someone is passing in a two digit year), add 2000 to the value. Otherwise treat the value as the full year. The getter doesn’t need to check or transform anything. Perfect C# syntax isn’t required. [4]

public int year { get { return Year; } //read access

set //write access { if ( value <100 ) Year = 2000 + value; else Year = value; } }

4. Consider the Input-Process-Output (IPO) versus Event Driven (ED) / GUI program models. [22 pts]

a. If you are conducting a survey for which all questions must be answered in order but the responses are free form, explain why the IPO approach is reasonable. [5]

This is essentially a very synchronized situation and thus prompting, input, process cycle works effectively.

Page 3: Computer Science II - Juniata Collegejcsites.juniata.edu/.../rhodes/smui/exams/exam1s19key.docx · Web viewIf the survey questions can be answered out of order and require numeric

Spring 2019 CS 305 Exam 1 Page 3

b. If the survey questions can be answered out of order and require numeric and limited choices, why is an event driven/GUI approach more reasonable? [5]

A GUI allows users to select questions and based on their choice, a widget can be presented that permits only the domain of values to be entered.

c. Presuming survey results are appended to a CSV file and you want to regularly produce a standard report, which model would you choose and why? [5]

IPO. There’s little interaction

d. Draw a use case and activity chart for the scenario described in parts b and c. [7]

Page 4: Computer Science II - Juniata Collegejcsites.juniata.edu/.../rhodes/smui/exams/exam1s19key.docx · Web viewIf the survey questions can be answered out of order and require numeric

Spring 2019 CS 305 Exam 1 Page 4

5. Draw a Data-Flow Diagram for a GPS map display and log system for a public transportation vehicle. Assume this system, every second, takes a GPS location reading (latitude and longitude), updates a map display on the dashboard, and records the position and time to a log file.

Recall that input is shown as a , output is a , storage is and a process is Connecting lines are labeled with data.

There may be multiple process in an application.[12 pts]

6. Statecharts. [16 pts]

a. Assume there are 3 global state variables:- State variable A tracks the highest or outermost level. What states are those? ___7, 4, 8______

b. State variable B tracks the state chart in state 7. What states does B track?

____1,2,3_______

c. List all events modeled in the statechart:

__a,b,c,d_______

d. List all possible state combinations that would be considered when event b occurs:

(7,2), [8 or (8,5) and (8,6)]

e. Consider the starting event sequence, a,c,d,d,c. What is/are now the current state(s)? ____(7,1)______

Page 5: Computer Science II - Juniata Collegejcsites.juniata.edu/.../rhodes/smui/exams/exam1s19key.docx · Web viewIf the survey questions can be answered out of order and require numeric

Spring 2019 CS 305 Exam 1 Page 5

6. Final short answer.[12 pts]

a. In MVC, explain what the Model is, what the View is, and what the Controller is. [9]

Model – implementation of the tasks separated from its presentation. Should be limited in IO

View – the presentation of the tasks to the user either by console or GUI or some other input/output model

Controller – layer of software that can provide the bridge between the model and view.

b. When creating GUI application in Visual Studio using the drag and drop IDE for creating a form, you are not to edit a particular block of code in the forms class. Why? [3]

This block of code is updated and maintained by the IDE. Changes here can corrupt or simply be replaced by any updates to the rapid development tools of the IDA