Programming Q's.txt

The flashcards below were created by user Anonymous on FreezingBlue Flashcards.

  1. Start Time: 7:30
    End Time:
  2. What is an enumerator?
    A distinct object type used to set a serious of constants.
  3. Give an example of an enumeration based on work week days
    enum WorkWeekDays { Monday, Tuesday, Wednesday, Thursday, Friday };
  4. What's the difference between a property and a field?
    Both are data variables in an object, when in an object internally (fields) and externally (properties)
  5. What are the three pillars of Object Oriented Programming (OOP)?
    (PIE) Polymorphism, Inheritance, and Encapsulation
  6. Define encapsulation:
    Ability to hide the data and behavior from others. This is done in OOP applications by making an object's methods or properties private. Considered one of the pillars of OOP design.
  7. Define inheritance:
    Ability of a class definition to acquire existing class definitions of another class, that is, to inherit characteristics of its predecessor. This forms a hierarchial relationship between the classes with the topmost class a superclass and the lower classes subclasses. Inheritance is one of the pillars of OOP design and it's achieved in C# using either an abstract class or an interface.
  8. Define polymorphism:
    Ability of an object instance to behave differently under different conditions. Two types exist: static [early binding/compile time polymorphism] and dynamic [late binding / run-time polymorphism]. Static polymorphism is achieve using (a) method overloading or (b) operator overloading. Dynamic polymorphism is achieved using (a) method overloading. Used to change the behavior of a parent class method from the child class WITHOUT changing the parent class nor the name of the method (i.e., PrintShape()). At runtime, the correct PrintShape() method for the object will be printed, dependant on its object type and state.
  9. What are the five (5) types of access modifiers?
    Private, public, protected, internal, protected internal
  10. Define private:
    Accessible only within the same class.
  11. Define public:
    Accessible to the same assembly or an assembly that references it.
  12. Define protected:
    Accessible only within the same class or in a derived class (inherited). It is considered BETWEEN private and public accessability.
  13. Define internal:
    Accessible to the same assembly only (not a referenced assembly); This means that NO external programs will be able to access this type.
  14. Define protected internal:
    Accessible to the same assembly OR by any derived class in another assembly (inherited). This is protected OR internal and not protected AND internal.
  15. What are static variables and why use them?
    A class variable and NOT an instance variable, that is, a variable accessible by all class members and NOT by the objects created by the class itself. In this way, before an object is created, the static variable can be called and used. It is also retained on the server until the application is complete, meaning, even though a page may be loaded and the class destroyed, the variable still exists in memory in case another class wants to use it. It is beneficial to use because it uses less memory (all subsequent calls simply get the original variable).
  16. What are the six (6) stages of development at DSH?
    Development, Testing, Staging, UAT, Pre-Production, and Production
  17. In the development life cycle, where is integration testing done?
    Typically done in Testing Environment, along with Unit Testing
  18. In the development life cycle, where is regression testing done?
    Typically done in the Staging Environment using Requirements Documentation.
  19. Write a function to reverse all the characters in a sentence (i.e., The Brown Cow becomes "woC nworB ehT):
    public static string ReverseCharacterString(string input) { string value = ""; for (int i = input.Length(); i <= 0; i--) { value += input[i];} return value;}
  20. Write a function to reverse all the words in a sentence (i.e., The Brown Cow becomes Cow Brown The)
    public static string ReverseWordString(string input) { String[] words = input.Split(' '); Array.Reverse(words); return value;}
  21. Write a function to reverse all the characters in a sentence using an array (i.e., The Brown Cow becomes "woC nworB ehT):
    public static string ReverseCharactersStringArray(string input) { Char[] arr = input.ToCharArray(); Array.Reverse(arr); return arr;}
  22. Write a function to reverse a string using StringBuilder in C#:
    StringBuilder builder = new StringBuilder(text.Length); for (int i = text.Length - 1; i >= 0; i--){ builder.Append(text[i]);}
  23. Declare an array of ten integers called tempArray:
    private int[] tempArray = new int[10];
  24. Declare an array of seven integers called tempArray AND initialize each (two methods):
    private int[] tempArray = new int[]{1,2,3,4,5,6,7}; Another method is done the same but without the "new int[]" in the declaration.
  25. Write a basic class called Employee with a name & age variables and accessors and one function called print:
    private class Employee { private string name = String.Empty; private int age = 0; public string Name {get;set} public int Age {get;set;} public void Print(object obj) { Console.WriteLn(obj.Age); }}
  26. What is an immutable string object?
    In C#, the basic string data type is immutable--meaning it can't be modified once create, rather, to change its content, the original is destroyed and a copy is recreated in its place. This is very inefficient so it is suggested to use StringBuilder instead, especially when dealing with loops. The problem with StringBuilder is that it uses high overhead for simple strings, so use with caution.
  27. What is an abstract class?
    A special type of class that can't be instantiated--so it is used specifically for inheritance. It contains implementation on at least one method and enforces various heirarchies for all subclasses. Only one base class can be used when inheriting from an abstract class (multiple inheritance doesn't exist in C#). Generally an abstract is considered better for version control since the content can be changed or overriden without affecting other classes.
  28. What is an interface?
    An interface is a contract stating that a particular class will have the elements it specifically declares--it is not a class itself and, like an abstract class, can't be instantiated itself. Unlike an abstract class, an interface has NO implementation but rather, contains a bunch of PUBLIC signatures only and no data properties. While multiple inheritance is not allowed in C#, some of the behavior associated with multiple inheritance can be mimicked by having the subclass inherit multiple interfaces (i.e., a Worker class can inherit both a Woman and Manager Class). Generally, the interface is considered bad
  29. What is the difference between a class and a struct?
    Both are basic customized data types in the .NET framework that encapsulate a set of data and behaviors that belong together in a single, logical unit. However, a class is a reference type wherein the struct is a value type--that is, the variable to which the struct is assigned hold the struct's actual data. Structs are typically used on smaller, less complex classes that rarely if ever get modified (i.e., a class that represents a point on a map); Classes are typically larger and more complex since sending them around takes little memory and they can be modified with ease.
  30. What is an object?
    An object is an instance of a class; that is, the class is the blueprint and the object is the item once it has been built (initialized). Each object contains its own data element values independent of other objects of the same type.
  31. What is a class?
    A class is a customized (typically) data type in the .NET framework that encapsulates a set of data and behaviors that belong together in a logical unit. A class is also a reference type in that the variable to which the object is assigned holds only a reference to that memory.
  32. Why is state management important in .NET applications?
    Because HTML is a stateless protocol--that is, once the server receives a request from a user, it process the request and sends the result back to the user (in the form of another page) and then deletes all information about the request on the server.
  33. What is an immutable object?
    An object that can't be changed. For example, the String data type is immutable, if we set the value uqual to "Cat" and then tried changing its contents to "Dog" then the value is copied into a new String data type and the original instance is destroyed. StringBuilder object is usefull in that it can be modified without destroying the original instance, hence, it is considered better than the String data type if the contents of the string are to changed frequently.
  34. What are the biggest downsides to object oriented programming?
    Several exist, but primary, are (a) high complexity of OOP programs, (b) long compile and load times, and (c) most importantly, much too large. Some have suggested that in order to create a banana in an OOP application, one creates the banana, the gorilla, and the entire jungle.
  35. What are the two groups of state management in .NET applications?
    Client-side and server-side state management.
  36. What are the five (5) types of client-side state management used in .NET applications?
    ViewState [dictionary of key/value pairs], Hidden fields, cookies, query strings, and control state [custom controls only]
  37. What are the two (2) types of server-side state management used in .NET applications?
    Application and session [both of which use dictionary key/value pairs].
  38. Compare the advantages of client-side state management as oppossed to server-side state management:
    Server-side state management possesses (a) better security and (b) reduces bandwidth of the network since items do not need to be send back across the network to the browser. Client-side state management can provide (a) better scalability, (b) support for multiple browsers, and (c) is considered faster since it is not necessary to go across the network.
  39. Define the Waterfall methodology of programming:
    A sequential programming style wherein one step of the cycle must be complete before beginning the next, and if a cycle fails, then the entire process from the beginning stage begins again. The basic stages are: requirements, design, implementation (coding), verification, maintenance. This methodology is considered older and inefficient--customers rarely know full specs before they begin and coding can't begin immediately, so this methodology was replaced by the Agile methodology.
  40. Define the Agile methodology of programming:
    Based on an iterative and incremental approach, it allows coding to begin almost immediately in small, incremental steps. Requirements and solutions evolve through a collaboration between self-organized, cross-functional teams which promotes adaptive planning and evolutionary development with a rapid and flexible response to requirement changes.
  41. What are the five (5) major steps of the Software Development Life Cycle (SDLC)?
    Requirements, Analysis/Design, Implementation, Verification, Maintenance
  42. What's the difference between Agile and Waterfall methodologies?
    Agile is considered much new and has become a major fixture compared to the older, more stringent waterfall method. Instead of the rigid straight-line approach of the waterfall method, the agile method allows a collaborative, iterative approach by many players without too much investment of resources.
  43. What is the difference between a field and a property?
    A field is a data value WITHIN a class or struct, also known as Members of their class. A property is a type of class member which provides the ability to read, write, or computer the value of a private field; properties are also known as special methods called accessors. For example: Public double Hours { get { return seconds / 3600; } set { seconds = value * 3600; } }
  44. What is a method?
    Code block that contains a series of statements. The Main methods is the entry point for every C# application and it is called by the common language runtime (CLR) when the program is first started.
  45. What is DLL Hell?
    Term used to describe the difficulty in Microsoft Operating Systems use of DLL's wherein adding or removing DLL's leads to conflicts between the various libraries. This problem has been largely avoided by use of the GAC in .NET systems.
  46. What is the GAC?
    Each computer where the common language runtime is installed has a machine-wide code cache called the global assembly cache. The global assembly cache stores assemblies specifically designated to be shared by several applications on the computer. Every assembly is checked prior to it being registered in the GAC and all assemblies must be have a strong name convention. This Global Assembly Cache is located at %windire%\Microsoft.NET\assembly
  47. What is the .NET Framework and its versions?
    A software framework created by Microsoft that includes its large library which provides language interoperability AND the Common Language Runtime engine (CLR) which is a virtual machine. Both of these items together constitute the .NET framework which has had versions 3.0, 3.5, 4.0, and 4.5.

    • What are the benefits of strong-named assemblies?
    • (a) guarantee name uniqueness, (b) protection of version assembly lineage, and (c) a strong entegrity check that makes sure each assembly ONLY uses other strongly-named assemblies, thereby making sure DLL hell does not creep into an application.
  48. What is the CLR?
    The Common Language Runtime (CLR) is the virtual machine component of Microsoft's .NET framework and is responsible for managing the execution of .NET programs written in different, supported languages. In a process known as just-in-time compilation, the compiled byte-code (CIL) is converted into machine instructions that, in turn, are executed by the computer's CPU. The CLR provides additional services including memory management, type safety and exception handling, garbage collection and thread management.
  49. Why are .NET applications compiled twice, once into bytecode and the second time into machine language at runtime?
    The conversion of various program languages by the CLR into bytecode occurs first and gives us the ability to use different languages and compile as much of the code as is reasonably possible. However, doing so again on the machine that houses the application, gives us an improved compilation since the CLR can determine number of CPU's, memory, storage, threat management and more, optimized on that specific machine.
  50. What is early binding?
    In C#, almost everything is early bound, meaning that at compile time, all object properties and methods are known to the compiler, allowing compile errors to be known before being deployed. In fact, with the help of IntelliSense, each object is known as you write the software code which is why almost everything in C# does early binding. Scripting languages like JavaScript or VBScipt uses late binding wherein modern applications such as C#, Visual Basic, or J# use early binding.
  51. What is late binding?
    Late binding occurs when code is compiled but the compiler doesn't know how to build the late-bound objects until actual run-time.
  52. Compare early vs late binding:
    With early binding: (a) compiler knows object structure at compile time, (b) errors known at compile time, (c) faster since items have already been created and checked. With late binding: (a) compiler needs to create objects, so it is slower, (b) errors
  53. What is an assembly?
    An assembly is a partially compiled code library containing the intermediate language (IL) placed into one or more .EXE or .DLL executable files used by the .NET application. After placing these .NET assemblies onto a website server, this code is further compiled into machine language at runtime by the CLR just-in-time compiler. Several different programming languages can be used to create an application, but each language IL would be created in different assembly files, which can then be placed on the server. The assembly library is used for deployment, versioning, and security. Two assembly types exists: private and global; private exists for the benefit of one application only wherein the global assembly can be used by multiple applications simultaneously and must be stored in the GAC.
  54. What is an event?
    Events enable a class or object to notify other classes or objects when something of interest occurs. The class that sends/raises the even is called the publisher and the receiving class is called a subscriber.
  55. What is a delegate?
    A delegate in C# is similar to a function pointer in C or C++. Using a delegate allows the programmer to encapsulate a reference to a method inside a delegate object. The delegate object can then be passed to code which can call the referenced method, without having to know at compile time which method will be invoked. Unlike function pointers in C or C++, delegates are object-oriented, type-safe, and secure. A delegate is type which holds a method(s) reference address and is similar to C++ function pointers, except in C#, they are type-safe and secure since they are declared with a signature.
  56. Declare a delegate called PostBack:
    public delegate void PostBack(Book book);
  57. Write code to add and remove a delegate from an existing PostBack delegate.
    PostBack += new Delegate(); PostBack -= new Delegate();
  58. What is a directive?
    Instructions to specify optional settings, such as registering a custom control and a page language.
  59. What are directives of the "Using" keyword in C#?
    (a) inclusion of namespaces, (b) as an alias, and (c) a using statement which ensures that IDisposable objects are discarded properly.
  60. What is a namespace?
    Namespaces are a way of organizing vast number of classes,structures,enumerations,delegates and interfaces that .NET Framework class library provides. Namespaces are hierarchial in nature. A namespace is a combination of naming convention and an assembly, which organizes collections of objects and prevents ambiguity in object references.
  61. A namespace is a combination of naming convention and an assembly, which organizes collections of objects and prevent ambiguity in object references.
  62. What is a constant?
    An immutable value which is known at compile time and does not change during the life of the program.
  63. What are destructors?
    (a) apply to classes and not struct's, (b) have no parameters, (c) can't be called, they are automatically invoked (d) only one exist per class, (e) cannot be inherited or overloaded (f) are call like such: ~Finalize() { */ Do Something /* }
  64. What is an indexer?
    An indexer allows a programmer to create a class that has the ability to act like an array in that it uses the [] array access operator. For example, to read a very large file in Byte format, an indexor can be created on the class that allows the developer to access each byte like it would an array, such as: ByteObject[i] += ByteObject[i] + 1;
  65. What is the abstract keyword used for in C#?
    Enables you to create a class or class member which is incomplete AND must be implemented in the derived class.
  66. What is the sealed keyword used for in C#?
    In a class, it is used to PREVENT other classes from inheriting from it. In a method or property, ???
  67. What is boxing and unboxing? [give an example of each]
    Boxing is the process of converting a specific data type (i.e., int, string, char) to the "object" data type whereas unboxing does just the opposite, converting an object type to a specific data type. Boxing: int i = 10; object o = i;. Unboxing: Object x = 33; int y = (int) x;
  68. What is the virtual keyword used for in C#?
    It is used by the base class to allow the subclass to override its method, property, indexer, or event in the derived class. By default, methods are non-virtual which means they cannot be overriden by the derived class. Vitual modifiers cannot be used on static, abstract, private, or override modifiers.
  69. What is the only difference between a static class and a non-static class?
    They are almost exactly the same, except that a static class cannot be instantiated (cannot use the new keyword to create a variable of the class type). An excellent example of this is libraries or utilities such as the Math() class which has some of the following function calls: Math.Abs(value); Math.Floor(value); Math.Round(value)
  70. What is the difference between decimal, double, and float data types?
    Both double and float data types are floating binary data types--that is, the binary number and location of the binary point are both encode within the value. This makes for inaccurate computations, such that 1.2 float isn't really 1.2 AND 1/3 can't accurately be computed by a machine, so these values use lots of rounding. Decimals, although slower, are MUCH more accurate and exact, 1.2 really means 1.2. Size and values are also relevant, Float (32 bit), Double (64 bit), and Decimal (128 bit).
  71. Why does the following expression produce a compilation error? float value = 3.5;
    Because the default value on the right side of the equation is a double and should be written as 3.5f;
  72. What is the best way to express money in C#?
    Barring creating your own class which would be ideal, the decimal value is the best for currency and it is because it is (a) very, very large, numerically speaking, and (b) it reduces rounding errors found in other data types. The downside is that decimal data types are MUCH slower than floating or double data types.
  73. Many .NET collection classes have been deprecated. What are five of the most useful, current collection classes?
    List, Dictionary, Queue, SortedList, and Stack which are all located in the System.Collections.Generic namespace
  74. What Visual Studio versions have you worked with?
    2005, 2008, and 2010, and 2012
  75. What SQL Server database versions have you worked with?
    2005, 2008(R2), 2010, 2012
  76. What is Visual Basic 6.0?
    An event-driven programming language and IDE from Microsoft, created in 1991 and derived from BASIC as an easy to use programming language for beginning developers
  77. What is Event-driven Programming?
    -Programming style where the flow of the program occurs as a result of various events such as a computer hover, click, or when a data value reaches a limit. This applications typically work on a main loop that listens for events, and when one occurs, it does a call-back. Event-driven programs can be written in any modern programming language with GUI, an OS, or similar user interface interaction, for example a video game. Examples include Visual Basic, JavaScript, and even Android applications.
  78. What is Procedure Driven Programming?
    -Progamming style wherein code is executed procedure by procedure...that is, it is structured and runs step-by-step. Focus of procedural programming is breaking down tasks into a collection of variables, data structures, routines wherein in object-oriented programming it it to do the same but by exposing behavior (methods) and data (attributes) using interfaces. The most important distinctions is that while procedural programming uses procedures to operate on data structures, OOP bundles the two together so that the "object" operates on its own data structures. Examples include C, C++, Fortran, Pascal, and BASIC.
  79. What is Object Oriented Programming?
    -Programming style wherein classes (blueprints) are created to create objects which contain both the data elements (attributes) and behavior (procedures) in a single entity, called an "instance" which operates on its own data elements and the behavior is managed only through an interface. Examples include C#, Java, C++, PHP, Ruby, and Visual Basic. Objects will correspond to real world items, for example, an online shopping system will have objects such as a shopping cart, customers, products, receipt, etc...and behaviors between the objects occur through an interface of the objects such as AddItemToCart, CreateReceipt, DetermineCustomerPurchases, etc. Classes are designed in a heirarchial fashion, for example, a parent product [name, price, taxable, etc] may be created which has subclasses (inheritance) which contain all the parent items plus their own distinct qualities such as software or hardware subclasses. Further, these
  80. Create an array of three (3) integers, called myArray and initialize its contents with 1, 2, 3:
    int[] myArray = new int[3]; myArray[0] = 1; myArray[1] = 2; myArray[2] = 3;
  81. How do you resize a 10 item array down to 3 items in C#?
    Array.Resize(ref myArray, 3);
  82. Write a foreach loop in an array in C#:
    foreach(int element in myArray) { Console.WriteLn(element); }
  83. What does the T in List refer to?
    It refers to the data type of the list, for example, if we wanted a list containing integers, we could write: List iList = new List();
  84. What methods can be used to loop through a list called iList?
    A foreach loop: foreach (int element in iList); Optionally, you could use an indexer, such as: for (int i = 0; i <= iList.Count; i++)
  85. How can you add an item to a list at a specific location (assume colors is the name of a string list)?
    colors.Insert(3, "Purple");
  86. Declare a dictionary called "dict" with a integer key and string values, then add two values:
    Dictionary dict = new Dictionary(); dict.Add(1, "Monday"); dict.Add(2, "Tuesday");
  87. Write a foreach loop for a dictionary containing of weekday values:
    foreach(KeyValuePair item in dict) { Console.WriteLn(item.key.ToString()) + ' ' + Console.WriteLn(item.Value.ToString()); }
  88. What's the difference between a dictionary and a hash table?
    Internally, both are hash tables, however, the dictionary is a generic type, meaning the contents are known when it is created and therefore it has type safety (HashTable does not). That is, when using a dictionary, you can't just assign any type of object into the dictionary but only the one declared when it was created.
  89. Why would you use a hash table over a dictionary?
    You wouldn't. A dictionary is a generic type, meaning it is type safe, so its structure is as small as possible plus items being pulled from the dictionary or inserted would not require casting. In a hash table, it is not generic and thus, not type safe.
  90. What is a hash table?
    A data structure used to implement an associative array using a key/value pair and a hash function. It is considered more efficient than search trees or table lookup structures in most situations and is therefore widely used.
  91. What are the differences and similarities between an abstract class and an interface?
    An interface has the following qualities: (a) class can inherit numberous interfaces, (b) has only signatures with no implementation, (c) all methods are public, (d) tend to be less homogenous, (e) slower, (f) bad a versioning, (g) no fields, constants, etc. Abstract classes: (a) only inherited once, (b) can contain implementation code, (c) tends to define homogoneous, similar behavior, (d) faster, (e) better versioning, (f) can have fields, properties, constants, etc.
  92. When approached with a problem you don't know the answer to, how do you overcome this?
    You can teach technical skills, but you can't teach personality. Generally people change only a little bit and over a long time frame. If they don't fit then they probably never will. You can learn how to write LINQ or determine the solution to a problem if you have personal or communication skills.
Card Set
Programming Q's.txt
Programming Questions
Show Answers