Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
CUSTOMER_CODE SMUDE DIVISION_CODE SMUDE EVENT_CODE APR2016 ASSESSMENT_CODE MIT4021_APR2016 QUESTION_TYPE DESCRIPTIVE_QUESTION QUESTION_ID 37988 QUESTION_TEXT Explain the built in data types available in C# SCHEME OF EVALUATION 1. 2. 3. 4. Integer – 4 marks Real – 3 marks Boolean – 2 marks Characters – 1 mark QUESTION_T DESCRIPTIVE_QUESTION YPE QUESTION_ID 73727 QUESTION_T Explain one dimensional arrays with relevant examples. Describe regular EXT expressions in C#. One Dimensional Arrays: A list of items can be given one variable using only one subscript and such a variable is called a single subscript variable or a one dimensional array. Arrays are declared using the following syntax: < type > [] identifier ; In C# a single subscripted variable can be expressed as a: x[1], x[2], x[3] ………. x[4] The subscript can begin with number 0. That is x[0] is allowed. (2 Marks) For example, if we want to represent a set of five numbers, say (35, 40, 20, 57, 19) by an array variable number, then we may create the variable SCHEME OF number as follows: EVALUATION int [] number = new int [5] ; The initial value of the array is null. An array object is created using new: int [] store = new int [50] ; string [] names = new string [50] ; When the array is created, it initially contains the default value for the types that are in the array. For the store array, each element is an int with the value 0. For the names array, each element is a string with the value null. The values of the array can be assigned as follows: number[0] = 35 ; number[1] = 40 ; number[2] = 20 ; number[3] = 57 ; number[4] = 19 ; These elements may be used in programs just like any other C# variable. aNumber = number [0] + 10 ; number[4] = number[0] + number[2] ; number[2] = x[5] + y[10] ; value [6] = number [i] * 3 ; (2 Marks) Array Initialization: Arrays can be initialized at the same time as they are created. During initialization, the new int[x] can be omitted, and the computer will determine the size of the array allocate from the number of items in the initialization list: int [] store = { 0, 1, 2, 3, 10, 12 } ; The preceding line is equivalent to: int [] store = new int [6] { 0, 1, 2, 3, 10, 12 } ; (2 Marks) Regular Expressions: Regular expressions provide a powerful tool for searching and manipulating a large text. A regular expression may be applied to a text to accomplish texts such as: 1. To locate substring and return them. 2. To modify one or more substrings and return them. 3. To identify substrings that begin with or, end with a pattern of characters. 4. To find all words that begin with a group of characters and end with some other characters. 5. To find all the occurrences of a substring pattern A regular expression is a string containing two types of characters: Literals Metacharacters Literals are characters that we wish to search and match in the text. Metacharacters are special characters that give commands to the regular expression parser. (2 Marks) Example of Regular Expression: The table below shows sample regular expressions along with their meaning. In these expressions, \b, \B, \S* and | are metacharacters and m, er, X, space and comma are literals. (2 Marks) QUESTION_TYPE DESCRIPTIVE_QUESTION QUESTION_ID 118700 QUESTION_TEXT SCHEME OF EVALUATION Write a C# program to calculate the area of a rectangle using overloaded constructors. Ans: (10 marks, chapter 9, page 159,160) using System; class Rectangle { Public int length, width; public Rectangle(int x, int y) { length=x; width=y; } public Rectangle(int x) { length=width=x; } Public intRectArea() { int area=length*width; return area; } } Class RectArea {public static void Main() { Rectangle rect1=new Rectangle(15); Rectangle rect2=new Rectangle(15,10); int area1=rect1.RectArea(); int area2=rect2.RectArea(); Console.WriteLine(“Area1=”+area1); Console.WriteLine(“Area2=”+area2); Console.Read(); } } QUESTION_TYPE DESCRIPTIVE_QUESTION QUESTION_ID 118701 QUESTION_TEXT List the steps for creating a web based application. Explain any 2 of them Ans: The following are the steps to create a web based application SCHEME OF EVALUATION create the Default.aspx page add code for the Default.aspx page create the show.aspx page add code to the show.aspx page create the terms.aspx page (Listing carries 2 marks and explaining any 2 steps carry 4 marks each. hence 2*4=8 marks) QUESTION_TYPE DESCRIPTIVE_QUESTION QUESTION_ID 118702 QUESTION_TEXT Explain the steps involved in creating and using delegates with relevant examples. Ans: 4 steps: delegate declaration SCHEME OF EVALUATION delegate methods definition delegate instantiation delegate invocation (explaining each with examples carries 2.5 marks each hence 2.5*4=10 marks) QUESTION_TYPE DESCRIPTIVE_QUESTION QUESTION_ID 118704 Explain the user-defined reference types. QUESTION_TEXT 1. SCHEME OF EVALUATION 2. 3. Classes Delegates Arrays 4. Interfaces (2.5*4=10)