Cis160 Final Review


Published on

Review for CIS-160 final exam

  • Be the first to comment

  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide
  • CIS-160 Final Review 12/4/2008
  • CIS-160 Final Review 12/4/2008
  • CIS-160 Final Review 12/4/2008
  • CIS-160 Final Review 12/4/2008
  • CIS-160 Final Review 12/4/2008
  • CIS-160 Final Review 12/4/2008
  • CIS-160 Final Review 12/4/2008
  • CIS-160 Final Review 12/4/2008
  • CIS-160 Final Review 12/4/2008
  • CIS-160 Final Review 12/4/2008
  • CIS-160 Final Review 12/4/2008
  • CIS-160 Final Review 12/4/2008
  • CIS-160 Final Review 12/4/2008
  • CIS-160 Final Review 12/4/2008
  • CIS-160 Final Review 12/4/2008
  • CIS-160 Final Review 12/4/2008
  • CIS-160 Final Review 12/4/2008
  • Cis160 Final Review

    1. 1. <ul><li>100 points </li></ul><ul><li>Open book, open notes </li></ul><ul><li>True/false, multiple choice, fill-in, short answer </li></ul>
    2. 2. <ul><li>Variable </li></ul><ul><ul><li>Memory locations that hold data that can be changed during project execution </li></ul></ul><ul><ul><li>Example: customer’s name </li></ul></ul><ul><li>Named Constant </li></ul><ul><ul><li>Memory locations that hold data that cannot be changed during project execution </li></ul></ul><ul><ul><li>Example: sales tax rate </li></ul></ul>3-
    3. 3. <ul><li>In Visual Basic when you declare a Variable or Named Constant </li></ul><ul><ul><li>An area of memory is reserved </li></ul></ul><ul><ul><li>A name is assigned called an Identifier </li></ul></ul><ul><li>Use Declaration Statements to create Variables and Constants </li></ul><ul><ul><li>Assign name and data type </li></ul></ul><ul><ul><li>Not executable unless a value is assigned on same line </li></ul></ul>3-
    4. 4. <ul><li>Must follow Visual Basic Naming Rules </li></ul><ul><ul><li>Cannot use reserved words or keywords that Basic has assigned a meaning such as print, name, and value </li></ul></ul><ul><ul><li>Must begin with a letter and no spaces or periods </li></ul></ul><ul><li>Should follow Naming Conventions </li></ul><ul><ul><li>Names should be meaningful </li></ul></ul><ul><ul><ul><li>Include class (data type) of variable (intQuota or Quota_Integer) </li></ul></ul></ul><ul><ul><li>Use mixed case for variables and uppercase for constants </li></ul></ul>3-
    5. 5. <ul><li>Visibility of a variable is its scope </li></ul><ul><ul><li>Where is that identifier valid? </li></ul></ul><ul><li>Scope may be </li></ul><ul><ul><li>Namespace : throughout project </li></ul></ul><ul><ul><li>Module : within current form/class </li></ul></ul><ul><ul><li>Local : within a procedure </li></ul></ul><ul><ul><li>Block : within a portion of a procedure </li></ul></ul><ul><li>Lifetime of a variable is the period of time the variable exists </li></ul>3-
    6. 6. <ul><li>Use static to declare local and block level variables that need to retain their value </li></ul><ul><ul><li>Variable will not be initialized next time procedure runs, and will have last value assigned </li></ul></ul><ul><li>If the variable is used in multiple procedures, declare it at the module level with private </li></ul>6-
    7. 7. <ul><li>Use Parse methods to convert a string to its numeric value before it’s used in a calculation </li></ul><ul><li>Each numeric data type class has a Parse method </li></ul><ul><ul><li>Parse method returns a value that can be used in calculations </li></ul></ul><ul><li>Parse method fails if user enters nonnumeric data, leaves data blank, or entry exceeds data type size </li></ul>3-
    8. 8. <ul><li>Enclose statements that might cause a run-time error within Try/Catch block </li></ul><ul><ul><li>If an exception occurs while statements in the Try block are executing, code execution is moved to the Catch Block </li></ul></ul><ul><ul><li>If a Finally statement is included, the code in that section executes last, whether or not an exception occurred </li></ul></ul>3-
    9. 9. <ul><li>This OOP feature allows the Messagebox Show method to act differently for different arguments </li></ul><ul><ul><li>Each argument list is called a signature : the Show method has multiple signatures </li></ul></ul><ul><li>Supplied arguments must exactly match one of the signatures provided by the method </li></ul>3-
    10. 10. <ul><li>Used to make decisions </li></ul><ul><li>If true, only the Then clause is executed, if false, only Else clause, if present, is executed </li></ul><ul><li>Block If…Then…Else must always conclude with End If </li></ul><ul><li>Then must be on same line as If or ElseIf </li></ul><ul><li>End If and Else must appear alone on a line </li></ul>4-
    11. 11. <ul><li>Test in an If statement is typically based on a condition </li></ul><ul><li>Six relational operators are used for comparison of numbers, dates, and text </li></ul><ul><ul><li>An equal sign is used to test for equality </li></ul></ul><ul><li>Strings can be compared using ANSI value of each character </li></ul><ul><ul><li>CIS is less than CNA </li></ul></ul><ul><ul><li>MATH is less than MATH& </li></ul></ul>4-
    12. 12. <ul><li>Compound conditions can combine multiple logical conditions </li></ul><ul><ul><li>And describes conditions where both tests are true </li></ul></ul><ul><ul><li>Or describes conditions where either or both tests are true </li></ul></ul><ul><li>When both And and Or are evaluated And is evaluated before the Or </li></ul><ul><li>Use parenthesis to change the order of evaluation </li></ul>4-
    13. 13. <ul><li>Check to see if valid values were entered or available </li></ul><ul><li>Can check for a range of values (often called “reasonableness”) </li></ul><ul><ul><li>If Integer.Parse(scoreTextBox.Text) >= 0 Then </li></ul></ul><ul><ul><li>‘ Code to perform calculations…. </li></ul></ul><ul><li>Check for a required field (not blank) </li></ul><ul><ul><li>If studentIDTextBox.Text <> &quot;&quot; Then ... </li></ul></ul>4-
    14. 14. <ul><li>Use Select Case to test one value for different matches (“cases”) </li></ul><ul><ul><li>Usually simpler and clearer than nested If </li></ul></ul><ul><ul><li>No limit to number of statements that follow a Case statement </li></ul></ul><ul><ul><li>When using a relational operator must use the word Is </li></ul></ul><ul><ul><li>Use the word “To” to indicate a range with two endpoints </li></ul></ul>4-
    15. 15. <ul><li>Add object/event combinations to the Handles clause at the top of an event procedure </li></ul><ul><ul><li>Allows the procedure to be associated with different events or other controls </li></ul></ul><ul><li>Sender argument identifies which object had the event happen </li></ul><ul><ul><li>Cast (convert) sender to a specific object type using the CType function </li></ul></ul>4-
    16. 16. <ul><li>Calling an event procedure allows reuse of code </li></ul><ul><ul><li>[Call] ProcedureName ( arguments ) </li></ul></ul><ul><ul><ul><li>Keyword Call is optional and rarely used </li></ul></ul></ul><ul><li>Examples </li></ul><ul><ul><li>Call clearButton_Click (sender, e) </li></ul></ul><ul><ul><li>--OR-- </li></ul></ul><ul><ul><li>clearButton_Click (sender, e) </li></ul></ul>4-
    17. 17. <ul><li>Breakpoints allow you to follow the execution of your code while program is running </li></ul><ul><li>Can hover the cursor over a variable or property to see the current value in the current procedure </li></ul><ul><li>Can execute each line, skip procedures </li></ul><ul><li>Can use Console.Writeline to output values to track code execution </li></ul><ul><li>Variables and property values can be seen in different windows (autos, locals) while code is executing </li></ul>5-
    18. 18. <ul><li>A general procedure is reusable code which can be called from multiple procedures </li></ul><ul><li>Useful for breaking down large sections of code into smaller units </li></ul><ul><li>Two types </li></ul><ul><ul><li>Sub Procedure performs actions </li></ul></ul><ul><ul><li>Function Procedure performs actions AND returns a value (the return value ) </li></ul></ul>
    19. 19. <ul><li>If a procedure includes an argument, any call to the procedure must supply a value for the argument </li></ul><ul><li>Number of arguments, sequence and data type must match </li></ul><ul><li>Arguments are passed one of two ways: </li></ul><ul><ul><li>ByVal – Sends a copy of the argument’s value, original cannot be altered </li></ul></ul><ul><ul><li>ByRef - Sends a reference to the memory location where the original is stored and the procedure may change the argument’s original value </li></ul></ul><ul><ul><li>If not specified, arguments are passed by value </li></ul></ul>5-
    20. 20. <ul><li>Show method displays a form as modeless - means that both forms are open and the user can move from one form to the other </li></ul><ul><li>ShowDialog method displays a new form as modal - the user must close the form in order to return to the original form </li></ul><ul><ul><li>No other program code can execute until the user responds to and hides or closes the modal form </li></ul></ul>6-
    21. 21. <ul><li>Provide the user with a list of choices to select from </li></ul><ul><li>Various styles of display, choose based on </li></ul><ul><ul><li>Space available </li></ul></ul><ul><ul><li>Need to select from an existing list </li></ul></ul><ul><ul><li>Need to add to a list </li></ul></ul><ul><li>Listboxes and comboboxes share most of the same properties and operate in a similar way </li></ul><ul><ul><li>Combo box control has a DropDown Style property </li></ul></ul><ul><ul><li>Combo box allows text entry </li></ul></ul>
    22. 22. <ul><li>List of items in a ListBox or ComboBox is a collection </li></ul><ul><ul><li>Collection is group of like objects </li></ul></ul><ul><ul><li>Items referenced by number (zero-based) </li></ul></ul><ul><li>VB Collections are objects that have properties and methods that allow </li></ul><ul><ul><li>Adding items </li></ul></ul><ul><ul><li>Removing items </li></ul></ul><ul><ul><li>Referring to an individual element/member </li></ul></ul><ul><ul><li>Counting items </li></ul></ul>
    23. 23. <ul><li>Index number of currently selected item is stored in the SelectedIndex property </li></ul><ul><ul><li>Property is zero-based </li></ul></ul><ul><li>If no list item is selected, SelectedIndex property is negative 1 (-1) </li></ul><ul><li>Use to select an item in list or deselect all items </li></ul>
    24. 24. <ul><li>A loop repeats a series of instructions </li></ul><ul><li>An iteration is a single execution of the statement(s) in the loop </li></ul><ul><li>Used when the exact number of iterations is unknown </li></ul><ul><li>A Do/Loop terminates based on condition change </li></ul><ul><ul><li>Execution of the loop continues while a condition is True or until a condition is True </li></ul></ul><ul><ul><li>The condition can be placed at the top or the bottom of the loop </li></ul></ul>
    25. 25. <ul><li>Pretest: test before enter loop </li></ul><ul><ul><li>loop may never be executed since test executes BEFORE entering loop </li></ul></ul><ul><ul><ul><li>Do While … Loop </li></ul></ul></ul><ul><ul><ul><li>Do Until … Loop </li></ul></ul></ul><ul><li>Posttest: test at end of loop </li></ul><ul><ul><li>loop will always be executed at least once </li></ul></ul><ul><ul><ul><li>Do … Loop While </li></ul></ul></ul><ul><ul><ul><li>Do … Loop Until </li></ul></ul></ul>
    26. 26. <ul><li>Used to repeat statements in a loop a specific number of times </li></ul><ul><li>Uses a numeric counter variable called Counter or Loop Index </li></ul><ul><ul><li>Counter is incremented at the bottom of the loop on each iteration </li></ul></ul><ul><li>Start value sets initial value for counter </li></ul><ul><li>End value sets final value for counter </li></ul><ul><li>Step value can be included to specify the incrementing amount </li></ul><ul><ul><li>Step can be a negative number </li></ul></ul>
    27. 27. <ul><li>Used to repeat statements for each member of a group </li></ul><ul><li>A reference variable is used to “point” to each item </li></ul><ul><ul><li>Must be the data type of each item in group </li></ul></ul>
    28. 28. <ul><li>In some situations you may need to exit the loop prematurely </li></ul><ul><li>Use the Exit For or Exit Do statement inside the loop structure </li></ul><ul><ul><li>Generally used within an If statement (something must be evaluated to determine whether or not to exit the loop) </li></ul></ul>