You are on page 1of 21

Microsoft .

Net success Kit

• Success Kit

• C# Questions?

• What is a class?
• Blue print of an object. It is programmer defined datatype.It can be
public, private, protected.
• What is object?
• It is a specific instance of a class, we are using “new” keyword when we
create an object Ex. car c=new car ();
• What is static member variable and methods?
• It means belongs to a class rather than to an object.
• What are the Oops features?
• a).Encapsulation: Hiding some features from outside world. We are
using excess modified like Private, Public, and Protected.
• b).Pollymorphism: many forms of methods/classes.
• Ex. Overloaded method.
• Here we can assign subclass object to a super class object.
• c).Inheritance: It is process by which sub class inherits member
variable & methods from super class.
• d).Abstraction: It is hiding, providing the interface to the user.
• Ex. Object.
• What Is Value Type?
• Just values in the memory are stored in a class
• Ex.int, char & struct.
• What is Reference Type?
• Contain the address of the object are stored in attack.
• Ex. Class, interfaces, array & strings.
• What is constructor?
• ->It helps in creating an instance of a class?
• ->Have no return type, not even void.
• ->Can be private, public/procted.
• ->Can be overloaded.
• Access Modifier.
• Private->It access within the class.
• Protected->it access within the class & any subclass of that class.
• Public->It excess by all.
• Abstract Method.
• Abstract method is a keyword, which contain abstract method of
abstract class.
• Abstract class:-Which contain abstract methods.

By: Er.Gopabandhu Behera i


Microsoft .Net success Kit

• ->abstract class can not be instantied.


• ->Wee using abstract keyword, when we declare a abstract class.
• Ex.Public abstract class car
• {

• }
• What is Method Overloading?
• It means same method name & different signature.
• ->
• They can be in the same class/different class.
• ->Public class Adding numbers
• {Public int add (int a, int b)
• {
• Return a+b;
• }
• Public int Add (int a, int b,int c)
• {
• Return a+b+c;
• }
• }
• What is method overriding?
• It means same method name & same signature.
• ->They can not be in the same class.
• ->It has to be in the subclass.
• ->Static method can not be overridden.
• ->Exception can be same or more.
• ->Excess modified can be same or more.
• ->Method overriding is done by the ‘virtual’ keyword.
• What is Boxing & unboxing?
• Boxing->When storing value type in the form of object type in the heap
memory(value type into reference type)
• UnBoxing->When you are converting object type in the form of value
type(reference type into value type).

• What is an Interface?
• An interface is just like class but not a class, which contains any
abstract method & member variable, should be final/static. It is an
entity that is defined by the word Interface. An interface has
• No implementation; it only has the signature or in other words, just the
definition of the
• Methods without the body. As one of the similarities to abstract class, it
is a contract that is
• Used to define hierarchies for all subclasses or it defines specific set of
methods and their

By: Er.Gopabandhu Behera ii


Microsoft .Net success Kit

• Arguments. The main difference between them is that a class can


implement more than one
• Interface but can only inherit from one abstract class. Since C# doesn’t
support multiple
• Inheritance, interfaces are used to implement multiple inheritance.
• How do you turn off cookies for one page in your site?
• Use the Cookie. Discard Property which Gets or sets the discard flag set
by the server. When
• true, this property instructs the client application
• not to save the Cookie on the users hard disk when a session ends.
• Or
• it can be turned off by mentioning cookie state= false in web.config file
• 16.What is the difference between Convert.ToInt32(string) and
Int32.Parse(string)?
• The two give identical results, except where the string is null.
Convert.ToInt32(null) returns zero, whereas Int32.Parse(null) throws an
ArgumentNullException.
• 17.What are Destructors?
• A destructor is opposite to s constructor. It is called when an object is
no more required. The name of the destructor is the same as the class
name and is preceded by a tilde(~) sign. Like constructors, a destructor
has no return type.

• C# manages the memory dynamically and uses a garbage collector,


running on a separate thread, to execute all destructors on exit. The
process of calling a destructor when an object is reclaimed by the
garbage collector is called finalization.
• Note: Destructor takes no arguments.

• 18. How u can create XML file?


• To write Dataset Contents out to disk as an XML file use:
• MyDataset.WriteXML (server.MapPath ("MyXMLFile.xml"))
• 19. What is CLR?
• CLR is .NET equivalent of Java Virtual Machine (JVM). It is the runtime
that converts a MSIL code
• into the host machine language code, which is then executed
appropriately. The CLR is the
• execution engine for .NET Framework applications. It provides a number
of services, including:
• Code management (loading and execution)
• Application memory isolation
• Verification of type safety
• Conversion of IL to native code.
• Access to metadata (enhanced type information)
• Managing memory for managed objects
• Enforcement of code access security

By: Er.Gopabandhu Behera iii


Microsoft .Net success Kit

• Exception handling, including cross-language exceptions


• Interoperation between managed code, COM objects, and pre-existing
DLL's (unmanaged code
• And data)
• Automation of object layout
• Support for developer
• Services (profiling, debugging, and so on).
• 20. Which two properties are on every validation control?
• Control to validate & Error Message.
• 21. What Is The Difference Between View State and Session
State?
• View State persist the values of controls of particular page in the client
(browser) when post
• Back operation done. When user requests another page previous page
data no longer available.
• Session State persist the data of particular user in the server. This data
available till user close
• the browser or session time completes.
• 22. What is CTS and CLS?
• =>cls stands for common language specification where as
• cts stands for common type system. =>CLS : cls is a standard for .net .
cls is small set of specification to make all languages as a .net
• compliant languages. cls make a use of cts and clr. if my languages
(c#,vb.net,j#,vc++) wants to
• be compliant language it has to follow cls standard.
• =>CTS : Common Type System is also a standard like cls. If two
languages (c# or vb.net or j# or
• vc++) wants to communicate with each other, they have to convert into
some common type (i.e.in clr common language runtime). In c# we use
int which is converted to Int32 of CLR to
• Communicate with vb.net which uses Integer or vice versa.
• 23. in .NET Compact Framework, can I free memory explicitly
without waiting for garbage
• Collector to free the memory?
• Yes you can clear the memory using gc.collect method but it is
recommended that u should not
• call this coz we don’t know the exact time when the gc will be called
automatic.
• 24. What is "Common Type System" (CTS)?
• CTS define all of the basic types that can be used in the .NET
Framework and the operations
• Performed on those types. All this time we have been talking about
language interoperability,
• and .NET Class Framework. None of this is possible without all the
language sharing the same

By: Er.Gopabandhu Behera iv


Microsoft .Net success Kit

• data types. What this means is that an int should mean the same in VB,
VC++, C# and all other
• .NET compliant languages. This is achieved through introduction of
Common Type System (CTS).
• 25. How do you create a permanent cookie?
• By setting the expiry date of the cookie to a later time (like 10 years
later.)
• 26. Why is catch(Exception) almost always a bad idea?
• Well, if at that point you know that an error has occurred, then why not
write the proper code
• to handle that error instead of passing a new Exception object to the
catch block? Throwing
• your own exceptions signifies some design flaws in the project.
• 27. What is the difference between thread and process?
• Thread - is used to execute more than one program at a time.
• process - executes single programA thread is a path of execution that
run on CPU, a process is a collection of threads that share
• the same virtual memory. A process has at least one thread of
execution, and a thread always
• run in a process context.
• 28. How do you turn off cookies for one page in your site?
• By setting the Cookie. Discard property false.
• 29. How to get the column count of a report?
• SY-LINSZ system variable gives the column count (line size) and SY-
LINCT for line count.
• 30. What is Full Trust?
• Your code is allowed to do anything in the framework, meaning that all
(.Net) permissions are
• granted. The GAC has Full Trust because it’s on the local HD, and that
has Full Trust by default,
• you can change that using caspol .
• 31. How can I read .doc document in ASP.Net?
• You can read from a text file like this.
• private void Button12_Click(object sender, System.EventArgs e)
• {
• string path="C:Inetpub ew1.txt";
• using(StreamReader reader=new StreamReader(path))
• {
• string line;
• while ((line=reader.ReadLine())!=null)
• {
• Label2.Text+="<br>"+line;
• }
• }
• }
• from .doc file try yourself

By: Er.Gopabandhu Behera v


Microsoft .Net success Kit

• 32. How does the Xml Serializer work? What ACL permissions
does a process using it require?
• Xml Serializer requires write permission to the system’s TEMP directory.
• 33. What exactly is being serialized when you perform
serialization?
• Serialization is the process of converting an object into stream of bytes.
We perform it at the
• time of trans port an object in remoting.
• 34. Briefly explain how server form post-back works ?
• Post Back: The process in which a Web page sends data back to the
same page on the server.
• View State: View State is the mechanism ASP.NET uses to keep track of
server control state
• values that don't otherwise post back as part of the HTTP form.
• View State Maintains the UI State of a Page View State is base64-
encoded. It is not encrypted
• but it can be encrypted by setting Enable View Stat MAC="true" &
setting the machine Key
• validation type to 3DES. If you want to NOT maintain the View State,
include the directive < %@
• Page Enable View State="false" % > at the top of an .aspx page or add
the attribute Enable View
• State="false" to any control.
• 35. What is the transport protocol you use to call a Web service
SOAP?
• Http is preferred for Soap while tcp for binary i.e. HTTP is used in web
services and tcp works
• well in remoting.
• 36. Can you explain what inheritance is and an example of when
you might use it?
• The process of deriving a new class from an existing class is called
Inheritance. The old class is
• called the base class and the new class is called derived class. The
derived class inherits some or
• everything of the base class. In Visual Basic we use the Inherits
keyword to inherit one class
• from other.
• Ex:
• Public Class Base
• ---
• ---
• End Class
• Public Class Derived
• Inherits Base
• ---
• End Class
• 37. Differences between Datagrid, Datalist and Repeater?

By: Er.Gopabandhu Behera vi


Microsoft .Net success Kit

• Datagrid has paging while Datalist doesnt.


• Datalist has a property called repeat. Direction = vertical/horizontal.
(This is of great help in
• designing layouts). This is not there in Datagrid.
• A repeater is used when more intimate control over html generation is
required.
• When only checkboxes/radiobuttons are repeatedly served then a
checkboxlist or
• radiobuttonlist are used as they involve fewer overheads than a
Datagrid.
• The Repeater repeats a chunk of HTML you write, it has the least
functionality of the three.
• DataList is the next step up from a Repeater; accept you have very little
control over the HTML
• that the control renders. DataList is the first of the three controls that
allow you Repeat-
• Columns horizontally or vertically. Finally, the DataGrid is
• the motherload. However, instead of working on a row-by-row basis,
you’re working on a
• column-by-column basis. DataGrid caters to sorting and has basic
paging for your disposal. Again
• you have little contro, over the HTML. NOTE: DataList and DataGrid both
render as HTML tables
• by default. Out of the 3 controls, I use the Repeater the most due to its
flexibility w/ HTML.
• Creating a Pagination scheme isn't that hard, so I rarely if ever use a
DataGrid.
• Occasionally I like using a DataList because it allows me to easily list out
my records in rows of
• three for instance.
• 38. How different are interface and abstract class in .Net?
• Abstract classes can not be instantiated it can have or cannot have
abstract method basically
• known as mustinherit as the methods are static in nature
• where interfaces are the declaration and r defined where they are called
used for dynamic
• methods
• 39. Briefly explain what user controls are and what server
controls are and the differences
• between the two.
• An ASP.NET control (sometimes called a server control) is a server-side
component that is
• shipped with .NET Framework. A server control is a compiled DLL file
and cannot be edited. It
• can, however, be manipulated through its public properties at design-
time or runtime. It is
• possible to build a custom server control (sometimes called a custom
control or composite

By: Er.Gopabandhu Behera vii


Microsoft .Net success Kit

• control). (We will build these in part 2 of this article.)


• In contrast, a user control will consist of previously built server controls
(called constituent
• controls when used within a user control). It has an interface that can
be completely edited and
• changed. It can be manipulated at design-time and runtime via
properties that you are
• responsible for creating. While there will be a multitude of controls for
every possible function
• built by third-party vendors for ASP.NET, they will exist in the form of
compiled server controls,
• as mentioned above. Custom server controls may be the .NET answer to
ActiveX Web controls.
• 40. What is serialization, how it works in .NET?
• Serialization is when you persist the state of an object to a storage
medium so an exact copy can
• be re-created at a later stage.
• Serialization is used to save session state in ASP.NET.
• Serialization is to copy objects to the Clipboard in Windows Forms
• Serialization is used by remoting to pass objects by value from one
application domain to
• another.
• 41. Explain how Viewstate is being formed and how it is stored
on client.
• The type of ViewState is System.Web.UI.StateBag, which is a dictionary
that stores name/value
• pairs. ViewState is persisted to a string variable by the ASP.NET page
framework and sent to the
• client and back as a hidden variable. Upon postback, the page
framework parses the input string
• from the hidden variable and populates the ViewState property of each
control. If a control uses
• ViewState for property data instead of a private field, that property
automatically will be
• persisted across round trips to the client. (If a property is not persisted
in ViewState, it is good
• practice to return its default value on postback.)
• 42. What is the root class in .Net ?
• Object
• 45. What is Delegation?
• A delegate acts like a strongly type function pointer. Delegates can
invoke the methods that
• they reference without making explicit calls to those methods.
• Delegate is an entity that is entrusted with the task of representation,
assign or passing on
• information. In code sense, it means a Delegate is entrusted with a
Method to report

By: Er.Gopabandhu Behera viii


Microsoft .Net success Kit

• information back to it when a certain task (which the Method expects) is


accomplished outside
• the Method's class.
• 46. What is Reflection?
• It extends the benefits of metadata by allowing developers to inspect
and use it at runtime. For
• example, dynamically determine all the classes contained in a given
assembly and invoke their
• methods.
• Reflection provides objects that encapsulate assemblies, modules, and
types. You can use
• reflection to dynamically create an instance of a type, bind the type to
an existing object, or get
• the type from an existing object. You can then invoke the type's
methods or access its fields and
• properties.
• Namespace: System.Reflection
• 47. Describe session handling in a web farm, how does it work
and what are the limits ?
• In ASP.NET there are three ways to manage session objects. one
support the in-proc mechanism
• and other two's support the out-proc mechanism.
o In-Proc (By Default)
o SQL-Server (Out-proc) - Using SQL server or any other database
for storing sessions regarding
• current logged in user.
o State-Server (Out-Proc) - Using State Server, as one dedicated
server for managing sessions.
• State Server will run as service on web server having dotnet installed.
• 48. Can you give an example of when it would be appropriate to
use a web service as opposed
• to a non-serviced .NET component?
• A web service has the following characteristics:
• It communicates using open protocols like HTTP
• Processes XML messages framed using SOAP
• May be described using WSDL
• Can be discovered using UDDI
• Any application which is supposed to reach a wide customer base should
be written as a web
• service, as opposed to customized applications for specific customers.
• For example, services which help in stock trading by providing analysis
of market trends could
• best be implemented as a web service. The reasons are
• Such a web service would be easily discovered by potential customers
when they need it.
• It will require minimal setup on the client machines

By: Er.Gopabandhu Behera ix


Microsoft .Net success Kit

• The updates to the system will be automatically available to all its


consumers, without any
• need to deploy the updates on their machines.
• 49. Why The JavaScript Validation Not Run on the Asp.Net?
• The Asp.Net Button Is post backed on the server & not yet Submit &
when It goes to the server
• its states is lost So if we r using JavaScript in our application so we
always use the Input Button
• in the asp Button.
• 50. What are the authentication methods in .NET?
• 1.WINDOWS AUTHENTICATION
• 2.FORMS AUTHENTICATION
• 3.PASSPORT AUTHENTICATION
• 4.NONE/CUSTOM AUTHENTICATION
• The authentication option for the ASP.NET application is specified by
using the tag in the
• Web.config file, as shown below:
• other authentication options
• WINDOWS AUTHENTICATION Schemes
o Integrated Windows authentication
o Basic and basic with SSL authentication
o Digest authentication
o Client Certificate authentication
• FORMS AUTHENTICATION
• You, as a Web application developer, are supposed to develop the Web
page and authenticate
• the user by checking the provided user ID and password against some
user database
• 3.PASSPORT AUTHENTICATION
• A centralized service provided by Microsoft, offers a single logon point
for clients.
• Unauthenticated users are redirected to the Passport site
• 4 NONE/CUSTOM AUTHENTICATION:
• If we don?t want ASP.NET to perform any authentication, we can set the
authentication mode
• to ?none?.
• The reason behind this decision could be: We don?t want to authenticate
our users, and our
• Web site is open for all to use. We want to provide our own custom
authentication.
• 51. What is ASP.NET Authentication Providers and IIS Security?
• ASP.NET implements authentication using authentication providers,
which are code modules
• that verify credentials and implement other security functionality such
as cookie generation.
• ASP.NET supports the following three authentication providers:

By: Er.Gopabandhu Behera x


Microsoft .Net success Kit

• Forms Authentication: Using this provider causes unauthenticated


requests to be redirected to a
• specified HTML form using client side redirection. The user can then
supply logon credentials,
• and post the form back to the server. If the application authenticates
the request (using
• application-specific logic), ASP.NET issues a cookie that
• contains the credentials or a key for reacquiring the client identity.
Subsequent requests are
• issued with the cookie in the request headers, which means that
subsequent authentications
• are unnecessary.
• Passport Authentication: This is a centralized authentication service
provided by Microsoft that
• offers a single logon facility and membership services for participating
sites. ASP.NET, in
• conjunction with the Microsoft? Passport software development kit
(SDK), provides similar
• functionality as Forms Authentication to Passport users.
• 52. How many types of assemblies are there , wat are they?
• Private, Public/Shared, Satellite. A private assembly is normally used by
a single application, and
• is stored in the application's directory. A shared assembly is normally
stored in the global
• assembly cache, which is a repository of assemblies maintained by the
.NET runtime. Satellite
• assemblies are often used to deploy language-specific resources for an
application. These
• language-specific assemblies work in side-by-side execution because the
application has a
• separate product ID for each language and installs satellite assemblies
in a language-specific
• subdirectory for each language.
• 53. What are Attributes?
• Attributes are declarative tags in code that insert additional metadata
into an assembly. There
• exist two types of attributes in the .NET Framework: Predefined
attributes such as Assembly
• Version, which already exist and are accessed through the Runtime
Classes; and custom
• attributes, which you write yourself by extending the
• System. Attribute class.
• 54. Can you give an example of when it would be appropriate to
use a web service as opposed
• to a non-serviced .NET component?
• Webservice:
• Appropriate, when exposing the functionalitiss across different Platforms

By: Er.Gopabandhu Behera xi


Microsoft .Net success Kit

• (windows/Linux/Solaris..etc.,) or.NET to J2EE.


• .NET Component:
• Appropriate, when exposing the functionalities within propritory
O/S(.Net-.Net, or Java-Java
• platform)

• 55.How to set a cookie?


• HttpCookie myCookie = new HttpCookie("myWebSiteName");
• myCookie.Value = "http://www.faqpanel.com/";
• myCookie.Expires = DateTime.Now.AddMonths(6);
• Response.Cookies.Add(myWebSiteName);

• 56.How to get a cookie?


• if (Request.Cookies["myWebSiteName"] != null)
• {
• string myWebSiteUrl = Request.Cookies["myWebSiteName"].Value;
• }

• 57.What is difference between ExecuteReader, ExecuteNonQuery


and ExecuteScalar?
• ExecuteReader : Use for accessing data. It provides a forward-only,
read-only, connected recordset.
• ExecuteNonQuery : Use for data manipulation, such as Insert, Update,
Delete.
• ExecuteScalar : Use for retriving 1 row 1 col. value., i.e. Single value.
eg: for retriving aggregate function. It is faster than other ways of
retriving a single value from DB.

• 58.What is Strongly Typed Dataset Object?

• Strongly typed Dataset object allows you to create early-bound data


retrieval expression.

• Advantage of Strongly Typed dataset


• It is faster than late-bound data retrieval expression.
• Its column name is shown in intellisense as you type code.
• 59.What is Hashtable in ASP.Net?
• The Hashtable object contains items in key/value pairs. The keys are
used as indexes, and very quick searches can be made for values by
searching through their keys.

• Items are added to the Hashtable with the Add() method.

• 60.What is Repeater Control in ASP.Net?


• The Repeater control is used to display a repeated list of items that are
bound to the control. The Repeater control may be bound to a database
table, an XML file, or another list of items.

By: Er.Gopabandhu Behera xii


Microsoft .Net success Kit

• 61.What is DataList Control in ASP.Net?


• The DataList control is, like the Repeater control, used to display a
repeated list of items that are bound to the control. However, the
DataList control adds a table around the data items by default. The
DataList control may be bound to a database table, an XML file, or
another list of items.

• 62.What is the "Window Service"?


• On Microsoft Windows operating systems, a Windows Service is a long-
running executable that performs specific functions and which is
designed not to require user intervention. Windows services can be
configured to start when the operating system is booted and run in the
background as long as Windows is running, or they can be started
manually when required.

• Once a service is installed, it can be managed by launching "Services"


from the Windows Control Panel -> Administrative Tools or typing
"Services.msc" in the Run command on Start menu. The "Services"
management console provides a brief description of the service
functions and displays the path to the service executable, its current
status, startup type, dependencies and the account under which the
service is running. It enables users to:

• Start, stop, pause or restart services.


• Specify service parameters.
• Change the startup type which includes Automatic, Manual and
Disabled.

• Note: Windows Services is new name for NT Services you used to


develop in previous versions of Visual Studio.

• 63.What is Cross Page Posting? How is it done?


• By default, ASP.Net submits a form to the same page. In cross-page
posting, the form is submitted to a different page. This is done by
setting the PostBackUrl property of the button(that causes postback) to
the desired page. In the code-behind of the page to which the form has
been posted, use the FindControl method of the PreviousPage property
to reference the data of the control in the first page.

• 64.What is typed dataset?


• A typed dataset is very much similar to a normal dataset. But the only
difference is that the sehema is already present for the same. Hence
any mismatch in the column will generate compile time errors rather

By: Er.Gopabandhu Behera xiii


Microsoft .Net success Kit

than runtime error as in the case of normal dataset. Also accessing the
column value is much easier than the normal dataset as the column
definition will be available in the schema.
• 65.What is System.Web.Mail?
• System.Web.Mail (SWM) is the .Net namespace used to send email in
.Net Framework applications. SWM contains three classes:

• MailMessage - used for creating and manipulating the mail message


contents.
• MailAttachments - used for creating a mail attachment to be added to
the mail message.
• SmtpMail - used for sending email to the relay mail server.

• More information on the System.Web.Mail Namespace can be found on


MSDN here:

• 66.Why does the SessionID changes in every request?


• This may happen if your application has never stored anything in the
session state. In this case, a new session state (with a new ID) is
created in every request, but is never saved because it contains
nothing.

• However, there are two exceptions to this same session ID behavior:


• If the user has used the same browser instance to request another page
that uses the session state, you will get the same session ID every time.
• If the Session_OnStart event is used, ASP.NET will save the session
state even when it is empty.

• 67.In Session_End, do I have a valid HttpSessionState object


and HttpContext object?
• You will have the HttpSessionState object available. Just use Session to
access it. For HttpContext, it is not available because this event is not
associated with any request.

• 68.How come Response.Redirect and Server.Transfer is not


working in Session_End?
• Session_End is fired internally by the server, based on an internal timer.
And thus there is no HttpRequest associted when that happens. That is
why Response.Redirect or Server.Transferdoes not make sense and will
not work.

• 69. What does WSDL stand for?


• WSDL stands for Web Services Description Language. It is an XML
representation of the web

By: Er.Gopabandhu Behera xiv


Microsoft .Net success Kit

• service interface.
• There are two types of the operations specified in the WSDL file, as
represented by the
• <soap:binding> attribute of the file.
• Document oriented operations -- are the ones which contain XML
documents as input and
• output
• Result oriented operations -- are the ones which contain input
parameters as the input
• message and result as the output message
• 70. How can you provide an alternating color scheme in a
Repeater control?
• AlternatingItemTemplate Like the ItemTemplate element, but rendered
for every otherrow
• (alternating items) in the Repeater control. You can specify a different
appearancefor the
• AlternatingItemTemplate element by setting its style properties.
• 71. What are the features of ADO.Net ?
• ADO.NET features:
• Disconnected Data Architecture
• Data cached in Datasets
• Data transfer
• in XML format
• Interaction with the database is done through data commands
• 72. What is an interface and what is an abstract class? Please,
expand by examples of using
• both. Explain why?
• Abstract classes are closely related to interfaces. They are classes that
cannot be instantiated,
• and are frequently either partially implemented, or not at all
implemented. One key difference
• between abstract classes and interfaces is that a class may implement
an unlimited number of
• interfaces, but may inherit from only one abstract (or any other kind of)
class. A class that is
• derived from an abstract class may still implement interfaces. Abstract
classes are useful when
• creating components because they allow you specify an invariant level
of functionality in some
• methods, but leave the implementation of other methods until a specific
implementation of
• that class is needed. They also version well, because if additional
functionality is needed in
• derived classes, it can be added to the base class without breaking
code.
• 73 .What is reflection?

By: Er.Gopabandhu Behera xv


Microsoft .Net success Kit

• All .NET compilers produce metadata about the types defined in the
modules they produce. This metadata is packaged along with the
module (modules in turn are packaged together in assemblies), and can
be accessed by a mechanism called reflection. The System.Reflection
namespace contains classes that can be used to interrogate the types
for a module/assembly.
• Using reflection to access .NET metadata is very similar to using
ITypeLib/ITypeInfo to access type library data in COM, and it is used for
similar purposes - e.g. determining data type sizes for marshaling data
across context/process/machine boundaries.
• Reflection can also be used to dynamically invoke methods (see
System.Type.InvokeMember), or even create types dynamically at
run-time (see System.Reflection.Emit.TypeBuilder).
• 74. What is the difference between a private assembly and a
shared assembly?
• Location and visibility: A private assembly is normally used by a single
application, and is stored in the application's directory, or a sub-
directory beneath. A shared assembly is normally stored in the global
assembly cache, which is a repository of assemblies maintained by the
.NET runtime. Shared assemblies are usually libraries of code which
many applications will find useful, e.g. the .NET framework classes.

• Versioning: The runtime enforces versioning constraints only on shared


assemblies, not on private assemblies.
• 75. What is serialization?
• Serialization is the process of converting an object into a stream of
bytes. Deserialization is the opposite process of creating an object from
a stream of bytes. Serialization/Deserialization is mostly used to
transport objects (e.g. during remoting), or to persist objects (e.g. to a
file or database).
• 76 .Does the .NET Framework have in-built support for
serialization?
• There are two separate mechanisms provided by the .NET class library -
XmlSerializer and SoapFormatter/BinaryFormatter. Microsoft uses
XmlSerializer for Web Services, and uses
SoapFormatter/BinaryFormatter for remoting. Both are available for use
in your own code.
• 77. Why is XmlSerializer so slow?
• There is a once-per-process-per-type overhead with XmlSerializer. So
the first time you serialize or deserialize an object of a given type in an
application, there is a significant delay. This normally doesn't matter, but
it may mean, for example, that XmlSerializer is a poor choice for loading
configuration settings during startup of a GUI application.
• 78. Why do I get errors when I try to serialize a Hashtable?
• XmlSerializer will refuse to serialize instances of any class that
implements IDictionary, e.g. Hashtable. SoapFormatter and
BinaryFormatter do not have this restriction.

By: Er.Gopabandhu Behera xvi


Microsoft .Net success Kit

• 79. XmlSerializer is throwing a generic "There was an error


reflecting MyClass" error. How do I find out what the problem
is?
• Look at the InnerException property of the exception that is thrown to
get a more specific error message.

By: Er.Gopabandhu Behera xvii


Microsoft .Net success Kit

• SQl Server 2005

• 1.How many Columns per SELECT statement is possible in SQL


Server?
• 4096
• 2.What is the difference between a primary key and a unique
key?
• Both primary key and unique enforce uniqueness of the column on
which they are defined. But by default primary key creates a clustered
index on the column, where are unique key creates a non-clustered
index by default. Another major difference is that, primary key does not
allow NULLs, but unique key allows one NULL only.
• 3.Write a SQL Query to find first week day of the month?
• SELECT DATENAME(dw, DATEADD(dd, - DATEPART(dd, GETDATE()) + 1,
GETDATE())) AS FirstWeekDayofMonth
• 4.How to find nth highest salary from Employee table in SQL
Server?SELECT TOP 1 salary FROM (SELECT DISTINCT TOP n salary
FROM employee ORDER BY salary DESC) a ORDER BY salary.
• 5.What is the Referential Integrity in SQL Server?
• Referential integrity refers to the consistency that must be maintained
between primary and foreign keys, i.e. every foreign key value must
have a corresponding primary key value
• 6.What is the row size in SQL Server 2000?
• 8060 bytes.
• 7.What is the use of DESC in SQL Server Query?
• DESC has two purposes. It is used to describe a schema as well as to
retrieve rows from table in descending order.

By: Er.Gopabandhu Behera xviii


Microsoft .Net success Kit

• 8.Which function is used in SQL Server to find the largest integer


less than or equal to a specific value?
• FLOOR.
• 9.Which system table contains information on constraints on all
the tables created in SQL Server?
• USER_CONSTRAINTS table.
• 10.TRUNCATE TABLE EMP;, DELETE FROM EMP; -What Will the
outputs of the above two commands (Queries) in SQL Server?
• Both the statement delete all row from the table EMP, First one can not
be rolled back but second one will be rolled back.
• 11.What command is used to create a table by copying the
structure of another table in SQL Server?
• CREATE TABLE NEWTABLE AS SELECT command
• 12.To copy only the structure, the WHERE clause of the SELECT
command should contain a FALSE statement as in the following.
• CREATE TABLE NEWTABLE AS SELECT * FROM EXISTINGTABLE WHERE
1=2;
• If the WHERE condition is true, then all the rows or rows satisfying the
condition will be copied to the new table.
• 13.What is a constraint in SQL Server?
• A constraint is an object that exists only within confines of a table.
Constraints are much like they sound, i.e. - Rules which are enforced on
data being entered, and prevents the users from entering invalid data
into tables are called constraints. Thus, constraints super control data
being entered in tables for permanent storage.

• 14.What is a View in SQL Server?


• A View is something like a virtual table in SQL Server. A view is used
just like a table, except that it does not contains any data of its own.
Instead, a view is merely a preplanned mapping and representations of
the data stored in tables. The plan is stored in the database in the form
of query. This query calls for data from some, but not necessarily all,
columns to be retrieved from one or more tables.
• 15.The reason why views are created in SQL Server?
• When data security is required.
• When data redundancy is to be kept to the minimum while maintaining
data security.
• 16.What are the Stored procedures (sprocs) in SQL Server?
• Stored Procedures are logically grouped set of transect-SQL statement
bundled up into a single unit that perform a specific task. They allow for
variables and parameters as well as selection and looping constructs.
• 17.What is difference between function and stored procedure in
sql server?
• Stored Procedures may return multiple values, while functions returns
only one value at a time.
• 18.Stored Procedures can have input, output parameters for it
whereas functions can have only input parameters.

By: Er.Gopabandhu Behera xix


Microsoft .Net success Kit

• Stored Procedure allows select as well as DML statement in it whereas


function allows only select statement in it.

• Functions can be called from Stored Procedure whereas Stored


Procedures cannot be called from function.

• Exception can be handled by try-catch block in a Stored Procedure


whereas try-catch block cannot be used in a function.

• Stored Procedures can not be utilized in a select statement whereas


function can be embedded in a select statement.

• Stored Procedures are called independently, using the EXEC command,


while functions are called from within another SQL statement.
• 19.What are the benefits of using Stored Procedures in SQL
Server?
• OR
• Why should we use Stored Procedures?
• Precompiled execution. SQL Server compiles each stored procedure
once and then reutilizes the execution plan. This results in tremendous
performance boosts when stored procedures are called repeatedly.

• Reduced client/server traffic. If network bandwidth is a concern in your


environment, you will be happy to learn that stored procedures can
reduce long SQL queries to a single line that is transmitted over the
wire.

• Efficient reuse of code and programming abstraction. Stored procedures


can be used by multiple users and client programs. If you utilize them in
a planned manner, you will find the development cycle takes less time.

• Enhanced security controls. You can grant users permission to execute a


stored procedure independently of underlying table permissions.

• 20.Which function is used to find the smallest integer greater


than or equal to a specific value in sql server?
• CEILING.

• 21.Which join gives the Cartesian product of two tables in sql


server?
• Cross Join.
• 22.Explain an outer join?
• An outer join includes rows from tables when there are no matching
values in the tables.
• 23.What is the difference between group by and order by?
• Group by controls the presentation of the rows, order by controls the
presentation of the columns for the results of the SELECT statement.

By: Er.Gopabandhu Behera xx


Microsoft .Net success Kit

• 24.What keyword does an SQL SELECT statement use for a string


search?
• The LIKE keyword allows for string searches. The % and _ sign is used
as a wildcard.
• 25.What is the DEADLOCK ?
• A deadlock is a situation in which two transactions conflict with each
other and the only resolution is to cancel one transaction.
• 26.What is a Subquery ?
• A Subquery is a normal T-SQL query that is nested inside another query.
They are created using parentheses when you have a SELECT statement
that serve as the basis for the either part of the data or the condition in
another query.
• Subqueries are generally used to fill one of couple of needs -
• Break a query up into a series of a logical steps.
• Provide a listing to be the target of a WHERE clause together with [IN|
ESISTS|ANY|ALL].
• TO provide a lookup driven by each individual record in a parent query.
• Eg.
• SELECT SelectList FROM SomeTable WHERE SomeColumn = (SELECT
SingleColumn FROM SomeTable WHERE Condition that results in only
one row returned)

By: Er.Gopabandhu Behera xxi

You might also like