0% found this document useful (0 votes)
57 views

Awt Demo

The document contains multiple choice questions about .NET concepts and technologies. It covers topics like data types, ASP.NET controls and components, web services, page lifecycle events, and exceptions. The second section asks about explaining UDDI, SOAP, and WSDL in relation to web services and the differences between web services and WCF. It also asks about explaining the ASP.NET page lifecycle with an example.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
57 views

Awt Demo

The document contains multiple choice questions about .NET concepts and technologies. It covers topics like data types, ASP.NET controls and components, web services, page lifecycle events, and exceptions. The second section asks about explaining UDDI, SOAP, and WSDL in relation to web services and the differences between web services and WCF. It also asks about explaining the ASP.NET page lifecycle with an example.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 18

SECTION-I

1. Sealed class does not allow to inherit from this class


Option A: Abstract
Option B: Base
Option C: partial
Option D: sealed

2. The UpdatePanel control helps to divide your Web page into parts, where each part
can be updated independently.
Option A: UpdateProgress
Option B: ScriptManagerProxy
Option C: UpdatePanel
Option D: Timer

3. Decimal data type from C# is specifically used for monetary values with precision
value of 28.
Option A: Boolean
Option B: Decimal
Option C: Integer
Option D: Float

4. In A, B, C of WCF service endpoint B is Bindings.


Option A: Base class
Option B: Bindings
Option C: Base address
Option D: Behaviors

5. ByDefault ASP.Net SessionID is stored in Cookies.


Option A: Application
Option B: Session
Option C: Cookies
Option D: ViewState

6. The Command ADO.Net object allows DataAdapters to read, add, update and delete
the records in a data source
Option A: Connection
Option B: Dataset
Option C: DataReader
Option D: Command

7. Generics are parameterized types


Option A: parameterized types
Option B: class
Option C: structure
Option D: interface

8. The Command object method Execute Scalar is used to Used when query returns
Single value
Option A: To retrieve array data
Option B: Used when query returns Single value
Option C: Used when more than one value is retrieved
Option D: Connection is not stable

9. All data base files are contained in App_Data folder in asp.net application
Option A: App_GlobalResources
Option B: App_Code
Option C: App_Data
Option D: App_Themes

10. Range Validator control checks the user’s input based upon a lower- and upperlevel
value of Numbers or characters:
Option A: RequiredField Validator
Option B: Compare Validator
Option C: Range Validator
Option D: Custom Validator

11. The File class provides static methods for working with files
Option A: File
Option B: FileStream
Option C: FileInfo
Option D: StreamReader

12. The acronym UDDI stands for Universal Description Discovery and Integration
Option A: Universal Description Discovery and Integration
Option B: Uniform Data Development Infrastructure
Option C: Unique Development & Design Integration
Option D: Unit Describing Discovery of Data

13. System.NullReferenceException Handles errors generated from referencing a null


object
Option A: System.NullReferenceException
Option B: System.InvalidCastException
Option C: System.IndexOutOfRangeException
Option D: System.OutOfMemoryException

14. System.Object is the root of the .NET type hierarchy


Option A: System.Object
Option B: System.Type
Option C: System.base
Option D: System.Root

15. Out-of-process session state maintains the state of the server in a separate worker
process Option A: In-Process
Option B: Out-of-process
Option C: SQL Server
Option D: SampleSpc

16. A delegate is a class that encapsulates methods


Option A: A means of passing arrays into methods
Option B: A class that encapsulates methods
Option C: A class that encapsulates methods
Option D: Passing method to parameter

17. Virtual and override keywords are used in c# to implement runtime polymorphism
Option A: virtual
Option B: virtual and override
Option C: new and virtual
Option D: override and new

18. AdRotator control in ASP.net is used to display advertisements on webpage


Option A: Imagemap
Option B: Adcontrol
Option C: AdRotator
Option D: Trigger

19. Asp.net AJAX uses XMLHttpRequest object to to exchange data asynchronously with
a server:
Option A: Request
Option B: XMLHttpRequest
Option C: Response
Option D: Reference

20. Preinit is the first event of ASP.NET page, when user requests a web page Option A:
PreLoad
Option B: Load
Option C: Preinit
Option D: Init
SECTION-II
1. Explain UDDI, SOAP, and WSDL with respect to web services. What is the
difference between Web Services and WCF?
UDDI:
 UDDI is an XML-based standard for describing, publishing, and finding web
services.

 UDDI stands for Universal Description, Discovery, and Integration.


 UDDI is a specification for a distributed registry of web services.
 UDDI is platform independent, open framework.
 UDDI can communicate via SOAP, CORBA, and Java RMI Protocol.
 UDDI uses WSDL to describe interfaces to web services.
 UDDI is seen with SOAP and WSDL as one of the three foundation
standards of web services.
 UDDI is an open industry initiative enabling businesses to discover each
other and define how they interact over the Internet.
SOAP:
 SOAP is an XML-based protocol for exchanging information between
computers.
 SOAP is a communication protocol.
 SOAP is for communication between applications.
 SOAP is a format for sending messages.
 SOAP is designed to communicate via Internet.
 SOAP is platform independent.
 SOAP is language independent.
 SOAP is simple and extensible.
 SOAP allows you to get around firewalls.
 SOAP will be developed as a W3C standard.
WSDL:
 WSDL is an XML-based language for describing web services and how to
access them.
 WSDL stands for Web Services Description Language.
 WSDL was developed jointly by Microsoft and IBM.
 WSDL is an XML based protocol for information exchange in
decentralized and distributed environments.
 WSDL is the standard format for describing a web service.
 WSDL definition describes how to access a web service and what
operations it will perform.
 WSDL is a language for describing how to interface with XML-based
services.
 WSDL is an integral part of UDDI, an XML-based worldwide business
registry.
 WSDL is the language that UDDI uses.
DIFFERENCE BETWEEN WEB SERVICES AND WCF:

Field Web Service WCF

Attributes a web service is defined WCF service is defined by


by WebService and ServiceContract and
WebMethod attributes. OperationContract attributes

Protocols a web service only WCF supports a range of


supports HTTP protocol. protocols, i.e., HTTP, Named
Pipes, TCP, and MSMQ, 

Hosting a web service is hosted Various activation


Mechanisms only by IIS. mechanisms are there for
WCF hosting, i.e., IIS
(Internet Information
Service), WAS (Windows
Activation Service), Self-
hosting and Windows
Service

Services web service only WCF supports a robust


supports security security, trustworthy
services. messaging, transaction and
interoperability,

Serializer  web service supports WCF Supports DataContract


XML serializer by making serializer by employing
use of System.Runtime.Serialization
System.Xml.Serialization.

Tools WSDL.EXE tool is used ServiceMetadata tool


for client generation for (svcutil.exe) is used for client
a web service. generation for a WCF service
Exception unhandled exceptions In WCF, unhandled
Handling do not return to the exceptions are handled in a
client like in a web better way by making use of
service as SOAP faults. FaultContract.

Hash Table It is not possible to It is possible to serialize a


serialize a Hash Table in Hash Table in WCF
web service

Multithreading this is not supported in a WCF supports


web service. multithreading by using the
ServiceBehavior Class

2. What is Page Event? Explain the Page Life Cycle of ASP.NET page with an
example.
Page Event:
At each stage of the page life cycle, the page raises some events, which could be
coded. An event handler is basically a function or subroutine, bound to the
event, using declarative attributes such as Onclick or handle.
Following are the page life cycle events:

 PreInit - PreInit is the first event in page life cycle. It checks the
IsPostBack property and determines whether the page is a postback. It
sets the themes and master pages, creates dynamic controls, and gets
and sets profile property values. This event can be handled by
overloading the OnPreInit method or creating a Page_PreInit handler.
 Init - Init event initializes the control property and the control tree is
built. This event can be handled by overloading the OnInit method or
creating a Page_Init handler.
 InitComplete - InitComplete event allows tracking of view state. All the
controls turn on view-state tracking.
 LoadViewState - LoadViewState event allows loading view state
information into the controls.
 LoadPostData - During this phase, the contents of all the input fields are
defined with the <form> tag are processed.
 LoadPostData - During this phase, the contents of all the input fields are
defined with the <form> tag are processed.
 Load - The Load event is raised for the page first and then recursively for
all child controls. The controls in the control tree are created. This event
can be handled by overloading the OnLoad method or creating a
Page_Load handler.
 LoadComplete - The loading process is completed, control event
handlers are run, and page validation takes place. This event can be
handled by overloading the OnLoadComplete method or creating a
Page_LoadComplete handler
 PreRender - The PreRender event occurs just before the output is
rendered. By handling this event, pages and controls can perform any
updates before the output is rendered.
 PreRenderComplete - As the PreRender event is recursively fired for all
child controls, this event ensures the completion of the pre-rendering
phase.
 SaveStateComplete - State of control on the page is saved.
Personalization, control state and view state information is saved. The
HTML markup is generated. This stage can be handled by overriding the
Render method or creating a Page_Render handler.
 UnLoad - The UnLoad phase is the last phase of the page life cycle. It
raises the UnLoad event for all controls recursively and lastly for the page
itself. Final cleanup is done and all resources and references, such as
database connections, are freed. This event can be handled by modifying
the OnUnLoad method or creating a Page_UnLoad handler.
Page Life Cycle of ASP.NET page
 Page request - When ASP.NET gets a page request, it decides whether to
parse and compile the page, or there would be a cached version of the
page; accordingly the response is sent.
 Starting of page life cycle - At this stage, the Request and Response
objects are set. If the request is an old request or post back, the
IsPostBack property of the page is set to true. The UICulture property of
the page is also set.
 Page initialization - At this stage, the controls on the page are assigned
unique ID by setting the UniqueID property and the themes are applied.
For a new request, postback data is loaded and the control properties are
restored to the view-state values.
 Page load - At this stage, control properties are set using the view state
and control state values.
 Validation - Validate method of the validation control is called and on its
successful execution, the IsValid property of the page is set to true.
 Postback event handling - If the request is a postback (old request), the
related event handler is invoked.
 Page rendering - At this stage, view state for the page and all controls are
saved. The page calls the Render method for each control and the output
of rendering is written to the OutputStream class of the Response
property of page.
 Unload - The rendered page is sent to the client and page properties,
such as Response and Request, are unloaded and all cleanup done.

3. What is state management? Explain different ways to handle at client and Server
side in ASP.NET?
State Management:
State management maintains and stores the information of any user till the end
of the user session.
ASP.NET State management is a preserve state control and object in an
application because ASP.NET web applications are stateless. A new instance of
the Web page class is created each time the page is posted to the server. If a user
enters information into a web application, that information would be lost in the
round trip from the browser.
Different ways to handle at client and Server side in ASP.NET:
Server side
Session
Session is a very important technique to maintain state. Normally session is used
to store information and identity. The server stores information using Sessionid.
Set User Session

1. protected void btnSubmit_Click(object sender, EventArgs e)  
2. {  
3.    Session["UserName"] = txtName.Text;  
4.   
5.    Response.Redirect("Home.aspx");  
6. }  

Session Event
Session event can be seen in project Global.asax file.
Two types of Session Events
Session_Start
The Session_start event is raised every time a new user requests without a
session ID.

1. void Session_Start(object sender, EventArgs e)  
2. {  
3.    Session["master"] = "~/Master.master";  
4. }  

Session_End
The Session_End event is raised when session is ended by a user or a time out
using Session end method.

1. void Session_End(object sender, EventArgs e)  
2. {  
3.    Response.Write("Session_End");  
4. }  

The session is stored in the following for ways in ASP.NET.

 InProcMode
It is a default session mode and a value store in web server memory (IIS).
In this the session value stored with server start and it ends when the
server is restarted.
 State Server Mode
In this mode session data is stored in separate server.
 SQL Server Mode
In this session is stored in the database. It is a secure mode.
 Custom Mode
Generally under session data is stored in InProc, Sql Server, State server,
etc. If you store session data with other new techniques then provide
ASP.NET. 

Application
Application State is a server side management state. It is also called application
level state management. In this mainly store user activity in server memory and
application event shown in Global.asax file.
There are three types of applications in ASP.NET.
Application_Start
This event begins with domain start.

1. Void Application_Start(object sender, EventArgs e)  
2. {  
3.    Application["AppstartMessage"] = "Welcome to CSharp Corner Develop
er Communtiy";  
4. }  

Application_Error

In this section manage unhandled exception error.

1. void Application_Error(object sender, EventArgs e)   
2. {   
3.    // Write an unhandled error code exception  
4. }  

Application_ End

This ends with domain or restarts IIS.

1. Void Application_End(object sender, EventArgs e)  
2. {  
3.    Application["AppEndMessage"] = "Application Closed";  
4. }  

Cache
Cache is stored on server side. It implements Page Caching and data caching.
Cache is use to set expiration polices

Response.Cache.SetExpiresTime(DateTime.Now.AddDays(1));

Client Side
state management has the following four important parts available on the client
side:
Cookie
Cookie is a small and an important part of ASP.NET. In this store user
information, session and application. It can be created constant and temporary
and they work with browser request. Cookies are store on client side. The server
can read cookies and abstract data.
Two types of cookies are available,
Persistence
This type of cookie works with Date and time.

1. Response.Cookies["CookieName"].Value = "Test Cookies";  
2. //set expire time   
3. Response.Cookies["CookieName"].Expires = DateTime.Today.AddHours(1
);  

Non-Persistence
This is a temporary cookie. It is created with access application and discards the
close application.

1. Response.Cookies["CookieName"].Value = "Test Cookies";  

Control state
Control state technique is developed to maintain data work properly in order.
We can use view state but suppose view state is disabled by the user, the control
will not work as expected. For expected results of the control we have to use
Control State. In application, the Viewstate is by default true. Sometimes we
need to use custom control to manage application properly.

1. if (!IsPostBack)  
2. {  
3.    lblmsg1.Text = "Welcome to C# corner";  
4.    lblmsg2.Text = "Welcome to C# corner community";  
5. }   

When two messages are displayed on a Postback event, then control which one
is displayed by using customized control state.
 
Hidden Field

Hidden fields are used to store value to client side. Hidden field is not displayed
on the browser, but it works on a request.

1. if (HiddenField1.Value != null)  
2. {  
3.    int val = Convert.ToInt32(HiddenField1.Value) + 1;  
4.    HiddenField1.Value = val.ToString();  
5.    Label1.Text = val.ToString();  
6. }  

Viewstate

Viewstate is a very useful client side property. It is used for page level state
management. Viewstate stores any type of data and used for sending and
receiving information,
Example: Set/Get user

1. if (ViewState["UserName"] != null)  
2. lblName.Text = ViewState["UserName"].ToString();  

OR,

1. ViewState["UserName"] = txtUserName.Text;  

Viewstate is easy to apply and does not need access to any server resources. In a
Viewstate, only store small values. Viewstate enables and disables on page level
control. It also supports Encryption and Decryption and data/value is stored in
hashed format. So we are not storing important data such as password, account
information, etc. When more data is stored in this, then the page becomes
heavy.
 
Query String
Query string stores the value in URL.
Response.Redirect("ShowStringValue.aspx?Username=" + txtUsername.Text);

4. Write a short note on: (Answer any 4 )


a. CLR
 CLR (Common Language Runtime) is the basic and Virtual Machine
component of the .NET Framework.
 It is the run-time enviornment in the .NET Framework that runs the
codes and helps in making the development process easier by
providing the various services.
 It is responsible for managing the execution of .NET
programs regardless of any .NET programming language.
 The code that runs under the Common Language Runtime is termed
as the Managed Code.
 CLR provides a managed execution enviornment for
the .NET programs by improving the security, including the cross
language integration and a rich set of class libraries etc. CLR is
present in every .NET framework verison.
Main components of CLR:
 Common Language Specification (CLS)
It is responsible for converting the different .NET programming
language syntactical rules and regulations into CLR understandable
format.
 Common Type System (CTS)
CTS is responsible for understanding all the data type systems of
.NET programming languages and converting them into CLR
understandable format which will be a common format.
 Garbage Collection (GC)
It is used to provide the Automatic Memory Management feature.
 Just In – Time Compiler (JIT)
It is responsible for converting the CIL(Common Intermediate
Language) into machine code or native code using the Common
Language Runtime environment.

b. Static members and methods


A static class can only contain static data members, static methods, and a
static constructor. It is not allowed to create objects of the static class.
Static classes are sealed, means you cannot inherit a static class from
another class.
Syntax:
static class Class_Name
{
// static data members
// static method
}
In C#, the static class contains two types of static members as follows:
 Static Data Members: As static class always contains static data
members, so static data members are declared using static
keyword and they are directly accessed by using the class name.
The memory of static data members is allocating individually
without any relation with the object.
Synatx:
static class Class_name
{
public static nameofdatamember;
}
 Static Methods: As static class always contains static methods, so
static methods are declared using static keyword. These methods
only access static data members, they can not access non-static
data members.
Synatx:
static class Class_name {
public static nameofmethod()
{
// code
}
}

c. FileInfo Class
The FileInfo class is used to deal with file and its operations in C#. It provides
properties and methods that are used to create, delete and read file. It uses
StreamWriter class to write data to the file. It is a part of System.IO
namespace.

FileInfo Constructors

FileInfo(String It is used to initialize a new instance


) of the FileInfo class which acts as a
wrapper for a file path.

FileInfo Properties

The following table contains some properties of the FileInfo class.


Attributes It is used to get or set the attributes
for the current file or directory.

CreationTime It is used to get or set the creation


time of the current file or directory.

Directory It is used to get an instance of the


parent directory.

FileInfo Methods

The following table contains some methods of the FileInfo class.

AppendText() It is used to create a StreamWriter


that appends text to the file
represented by this instance of the
FileInfo.

CopyTo(String It is used to copy an existing file to a


) new file.

Create() It is used to create a file.

FileInfo Example: Creating a File


using System;  
using System.IO;  
namespace CSharpProgram  
{  
    class Program  
    {  
        static void Main(string[] args)  
        {  
            try  
            {  
                // Specifying file location  
                string loc = "F:\\abc.txt";  
                // Creating FileInfo instance  
                FileInfo file = new FileInfo(loc);  
                // Creating an empty file  
                file.Create();  
                Console.WriteLine("File is created Successfuly");  
            }catch(IOException e)  
            {  
                Console.WriteLine("Something went wrong: "+e);  
            }  
        }  
    }  
}  

d. Generics
Generics allow you to define the specification of the data type of
programming elements in a class or a method, until it is actually used in the
program. In other words, generics allow you to write a class or method that
can work with any data type.

Features of Generics

Generics is a technique that enriches your programs in the following ways −


 It helps you to maximize code reuse, type safety, and performance.
 You can create generic collection classes. The .NET Framework class
library contains several new generic collection classes in
the System.Collections.Generic namespace. You may use these
generic collection classes instead of the collection classes in
the System.Collections namespace.
 You can create your own generic interfaces, classes, methods, events,
and delegates.
 You may create generic classes constrained to enable access to
methods on particular data types.
 You may get information on the types used in a generic data type at
run-time by means of reflection.
Generic class example
using System;  
namespace CSharpProgram  
{  
    class GenericClass<T>  
    {  
        public GenericClass(T msg)  
        {  
            Console.WriteLine(msg);  
        }  
    }  
    class Program  
    {  
        static void Main(string[] args)  
        {  
            GenericClass<string> gen   = new GenericClass<string> ("This is
generic class");  
            GenericClass<int>    genI  = new GenericClass<int>(101);  
            GenericClass<char>   getCh = new GenericClass<char>('I');  
        }  
    }  
}  

Output:

This is generic class


101
I

C# allows us to create generic methods also. In the following example, we are


creating generic method that can be called by passing any type of argument.

Generic Method Example


using System;  
namespace CSharpProgram  
{  
    class GenericClass  
    {  
        public void Show<T>(T msg)  
        {  
            Console.WriteLine(msg);  
        }  
    }  
    class Program  
    {  
        static void Main(string[] args)  
        {  
            GenericClass genC = new GenericClass();  
            genC.Show("This is generic method");  
            genC.Show(101);  
            genC.Show('I');  
        }  
    }  
}  

Output:

This is generic method


101
I

e. Disconnected Architecture of ADO.net

The architecture of ADO.net in which data retrieved from database can be


accessed even when connection to database was closed is called as
disconnected architecture.
Disconnected architecture of ADO.net was built on classes connection,
dataadapter, commandbuilder and dataset and dataview.
Disconnected architecture is a method of retrieving a record set from the
database and storing it giving you the ability to do many CRUD (Create, Read,
Update and Delete) operations on the data in memory, then it can be re-
synchronized with the database when reconnecting.
A method of using disconnected architecture is using a Dataset.

f. Master Pages
Master pages allow you to create a consistent look and behavior for all the
pages (or group of pages) in your web application.
A master page provides a template for other pages, with shared layout and
functionality. The master page defines placeholders for the content, which
can be overridden by content pages. The output result is a combination of
the master page and the content page.
The content pages contain the content you want to display.
When users request the content page, ASP.NET merges the pages to produce
output that combines the layout of the master page with the content of the
content page.
Master Page Example
<%a Master %>
<html>
<body>
<h1>Standard Header From Masterpage</h1>
<asp:ContentPlaceHolder id=”CPH1” runat=”server”>
</asp:ContentPlaceHolder>
</body>
</html>

The master page above is a normal HTML page designed as a template for
other pages.
The @ Master directive defines it as a master page.
The master page contains a placeholder tag <asp:ContentPlaceHolder> for
individual content.
The id="CPH1" attribute identifies the placeholder, allowing many
placeholders in the same master page.

You might also like