Solution Set of AWP Solution Set November-2018 1. Attempt Any Three of the Following: A. What Is Namespace? Explain with the Help of an Example
Total Page:16
File Type:pdf, Size:1020Kb
Solution Set of AWP solution set November-2018 1. Attempt any three of the following: a. What is namespace? Explain with the help of an example. A namespace is designed for providing a way to keep one set of names separate from another. The class names declared in one namespace does not conflict with the same class names declared in another. Defining a Namespace A namespace definition begins with the keyword namespace followed by the namespace name as follows − namespace namespace_name { // code declarations } To call the namespace-enabled version of either function or variable, prepend the namespace name as follows − namespace_name.item_name; (2 marks) Any example demo (3 marks) b. Explain jagged array with example. A Jagged array is an array of arrays. You can declare a jagged array named scores of type int as int [][] scores; Declaring an array, does not create the array in memory. To create the above array − int[][] scores = new int[5][]; for (int i = 0; i < scores.Length; i++) { scores[i] = new int[4]; } You can initialize a jagged array as − int[][] scores = new int[2][]{new int[]{92,93,94},new int[]{85,66,87,88}}; Where, scores is an array of two arrays of integers - scores[0] is an array of 3 integers and scores[1] is an array of 4 integers. (2marks) Any example (3 marks) c. What is .NET Framework? Explain its architecture in brief. The .NET Framework is a new and revolutionary platform created by Microsoft for developing applications • It is a platform for application developers • It is a Framework that supports Multiple Language and Cross languageintegration. • IT has IDE (Integrated Development Environment). • Framework is a set of utilities or can say building blocks of your application system. • .NET Framework provides GUI in a GUI manner. • .NET is a platform independent but with help of Mono Compilation System (MCS). MCS is a middle level interface. Page 1 of 21 • .NET Framework provides interoperability between languages i.e. Common Type System (CTS) . • .NET Framework also includes the .NET Common Language Runtime (CLR), which is responsible for maintaining the execution of all applications developed using the .NET library. • The .NET Framework consists primarily of a gigantic library of code. (2 marks) Components of the .Net Framework with diagram (3 marks) d. Write a program in C# to demonstrate multiple inheritance using interfaces. Multiple Inheritance in C# C# does not support multiple inheritance. However, you can use interfaces to implement multiple inheritance. The following program demonstrates this − Any 1 example (5 marks) e. Explain various Types of Constructors in C# What is a constructor? Constructor is a method which gets executed automatically when we create or instantiate object of that class having constructor. Types of Constructors in C# There are 5 types of constructor in C# as listed below Default Constructor Parameterized Constructor Copy Constructor Page 2 of 21 Static Constructor Default Constructor A constructor without any parameters is called as default constructor means a constructor which does not have any input parameter is known as default constructor. Example of Default Constructor (1 mark) Parameterized Constructor A constructor having one or more parameters is called as parameterized constructor means a constructor which is having single input parameter or multiple input parameters of same data types or different data types are known as parameterized constructor. Example of Parameterized Constructor (1 mark) Copy Constructor A constructor that contains a parameter of same class type is called as copy constructor. C# does not provide a copy constructor. A copy constructor enables you to copy the data stored in the member variables of an object of the class into another new object means it helps to copy data stored in one object into another new object of the same instance. Example of Copy Constructor (1 mark) Static Constructor Static constructor should be parameter less means it should not contain any input parameter. Program will not execute if static constructor is having any input parameter. Static constructor can be invoked once for any number instances are created and it is invoked only during the first initialization of instance. It is used to initialize static fields of the class Static constructor is created using a static keyword as shown below. Example of Static Constructor (1 mark) f. What is delegate? Explain multicast delegate with an example. A delegate is like a pointer to a function. It is a reference type data type and it holds the reference of a method. All the delegates are implicitly derived from System.Delegate class. A delegate can be declared using delegate keyword followed by a function signature as shown below. Delegate Syntax: <access modifier> delegate <return type> <delegate_name>(<parameters>) (2 marks) Multicast Delegate The delegate can points to multiple methods. A delegate that points multiple methods is called a multicast delegate. The "+" operator adds a function to the delegate object and the "-" operator removes an existing function from a delegate object. Example: Multicast delegate (3 marks) 2. Attempt any three of the following: 15 a. What is the difference between List Box and Drop-Down Lists? List and explain any three common properties of these controls. Page 3 of 21 Common properties of list box and drop-down Lists: Property Description The collection of ListItem objects that represents the items in the Items control. This property returns an object of type ListItemCollection. Specifies the number of items displayed in the box. If actual list Rows contains more rows than displayed then a scroll bar is added. The index of the currently selected item. If more than one item is SelectedIndex selected, then the index of the first selected item. If no item is selected, the value of this property is -1. The value of the currently selected item. If more than one item is SelectedValue selected, then the value of the first selected item. If no item is selected, the value of this property is an empty string (""). Indicates whether a list box allows single selections or multiple SelectionMode selections. b. Explain Adrotator control with example in ASP.NET Page 4 of 21 The AdRotator control randomly selects banner graphics from a list, which is specified in an external XML schedule file. This external XML schedule file is called the advertisement file. The AdRotator control allows you to specify the advertisement file and the type of window that the link should follow in the AdvertisementFile and the Target property respectively. The basic syntax of adding an AdRotator is as follows: <asp:AdRotator runat = "server" AdvertisementFile = "adfile.xml" Target = "_blank" /> The advertisement file is an XML file, which contains the information about the advertisements to be displayed. [2 marks] Any 1 Example of AdRotator Control [3 marks] c. List and explain any four types of validation controls used in asp.net ASP.NET validation controls validate the user input data to ensure that useless, unauthenticated, or contradictory data don't get stored. ASP.NET provides the following validation controls: • RequiredFieldValidator • RangeValidator • CompareValidator • RegularExpressionValidator • CustomValidator • ValidationSummary [1 mark ] Explaination of any four controls with syntax and properties or example [1 mark each] d. Explain Calendar control with example in ASP.NET The calendar control is a functionally rich web control, which provides the following capabilities: • Displaying one month at a time • Selecting a day, a week or a month • Selecting a range of days • Moving from month to month • Controlling the display of the days programmatically The basic syntax of a calendar control is: <asp:Calender ID = "Calendar1" runat = "server"> </asp:Calender> [1 mark] Any 1 example [4 marks] Page 5 of 21 e. Short note on Page class. f. Explain SiteMapPath control in ASP.NET • The SiteMapPath control basically is used to access web pages of the website from one webpage to another. It is a navigation control and displays the map of the site related to its web pages. • This map includes the pages in the particular website and displays the name of those pages. We can click on that particular page in the Site Map to navigate to that page. We can say that the SiteMapPath control displays links for connecting to URLs of other pages. • The SiteMapPath control uses a property called SiteMapProvider for accessing data from databases and it stores the information in a data source. [1 mark ] Any 1 example or Syntax and Properties description [4 marks] 3. Attempt any three of the following: 15 a. What is user-defined exception? Explain with example. We have seen built-in exception classes however, we often like to raise an exception when the business rule of our application gets violated. So, for this we can create a custom exception class by deriving Exception or ApplicationException class. [1 mark] Page 6 of 21 Any 1 example [4 marks] b. What is debugging. Explain the process of debugging in detail. Debugging allows the developers to see how the code works in a step-by-step manner, how the values of the variables change, how the objects are created and destroyed, etc. When the site is executed for the first time, Visual Studio displays a prompt asking whether it should be enabled for debugging: When debugging is enabled, the following lines of codes are shown in the web.config: <system.web> <compilation debug="true"> <assemblies> .............. </assemblies> </compilation> </system.web> The Debug toolbar provides all the tools available for debugging: Breakpoints Breakpoints specifies the runtime to run a specific line of code and then stop execution so that the code could be examined and perform various debugging jobs such as, changing the value of the variables, step through the codes, moving in and out of functions and methods etc.