244 test 1
Test information may change! Come to class to stay on top of details. READ the NOTES that are online and READ the assigned readings!
Test may NOT be "made up" without prior arrangements or VERIFIED EMERGENCY!

Make a CAP!
This guide is not a "promise" of what will be on the test, but is simply an outline of topics that MAY be on the test that I provide to be helpful to you. Other topics not listed may also sneak onto a test from time to time.

Understand that a test is a SAMPLING and can not possibly cover all information from class. The idea, however, is that you must study all the information since you don't know for certain what questions will show up. This is for your benefit as it motivates you to learn more!

Visual Studio IL is the same for all .Net languages. Managed Code & CLR JIT "The CLR JITS the IL that was generated by the compiler into binary code native to the processor." C# Code > C# Compiler > IL > CLR > JIT Compiler > Machinecode > Execution C# Projects and Solutions libraries & references windows forms programs console programs C# Language Basics: variables & types, casting & conversion reference vs. value conditions, relational & logical operators loops break continue for for each branching Methods parameters: ref, value, out return value class methods(static) instance methods - instantiate an object Library create in visual studio dll concept must create a reference to dll make methods independent of items in calling program pass needed elements as parameters use a dll from another source Arrays default values Length property indexing - 0 based using filling, finding looping Array concepts reference to an array stored on the stack 'new' allocates dynamic memory "heap" manged by CLR and OS copy a reference int[] x = new int[10]; int[] y = x; // creates a second reference to same memory Arrays as Parameters and return values passes the reference to the array return an array returns a reference 2d Arrays rectangular int[,] jagged (array of arrays) int[][] GetLength() nested loops used to navigate to manipulate Examples primes palindromes latin squares gol Array methods Copy Sort - ascending BinarySearch Arrays vs Collections Collections are part of .Net Arrays are prt of C# and (almost) ALL languages List<T> where T is a type List<decimal> prices = new List<decimal>(); Count property Capacity property Add() Clear() Insert() Remove() Compiling without the IDE Command line interface to OS stand-alone compiler create program with stand-alone editor use OS to execute program Class as a container for methods and data object is an instance of a class methods properties constructor encapsulation controls exposure of data items to other classes data hiding

Example Questions

A method, DoIt() has 3 parameters: int u, double v, char letter. There is nothing returned by DoIt(). The parameter 'u' should be copied from the caller. Alterations by DoIt() will have no direct effect in the calling method. The parameter 'v' should be defined so that a change in the value in the method changes the value in the calling method and vice versa. The parameter 'letter' should be defined so it can only be assigned in the DoIt() method and then read by the calling method upon return. Which of the following is the correct method signature? a. int DoIt ( int u, ref double v, out char letter ) b. void DoIt( int u, ref double v, out char letter ) c. void DoIt( int u, out double v, ref char letter ) d. int DoIt ( int u, out double v, ref char letter ) e. none of these int[,] alpha = new int[5,3]; int j,k; Which of the following statements correctly initializes all elements of alpha to 99? int n=99; (i) for(j = 0; j< 5; j++) for(k = 0; k< 3; k++) alpha[j,k] = n; (ii) for(k = 0; k< 3; k++) for(j = 0; j< 5; j++) alpha[j,k] = n; (iii) for(j = 4; j>= 0; j--) for(k = 0; k< 3; k++) alpha[j,k] = n; a. Only (i) b. Only (ii) c. Both(i) and (ii) d. All of these Consider if "= n" becomes "=n++" Explain the difference in the above code. Order of processing? Different outcome? Suppose you have the following C# declaration: int[] list = new int[100]; Which of the following ranges is valid for the index of the array nameList? (i) 1 through 100 (ii) 0 through 100 a. Only (i) b. Only (ii) c. Both (i) and (ii) d. None of these Write code to assign the even numbered(include 0) items in the array to be equal to their index: for(int i=0; i<list.Length; i+=2) list[i]=i; for(int i=0; i<list.Length; i++) if(i%2==0) list[i]=i; Write a method called 'Frequency' that accepts an array of ints and an int value. It should return the number of times the value occurs in the array. It should return the number of times the value does not occur in the array. Create a function, Found, that searches an unsorted int list and returns whether an item is in the list. 2 params: list, item Create a void function, Init, that will initialize a square 2-d array so that each element has a value equal to the sum of its indexes. The function has 1 parameters: the array. Create a method that accepts an array of indeterminate size of int values from 0-99. Create a methd that will return a count of how many of each number occurred in the array. (Three 1s, Five 2s, Sixty 3s, etc...)