Questions and their Answers ...
------------------------------------
1)Is it possible to debug java-script in .NET IDE?
Ans : Yes, simply write "debugger" statement at the point where the breakpoint needs to be set within the javascript code and also enable javascript debugging in the browser property settings.
2) What’s the top .NET class that everything is derived from?
Ans : System.Object
3) Does C# support multiple-inheritance?
Ans : No
4) Is ASP.Net a language or technology?
Ans : technology.
5) What is default time for a session?
Ans : 20
6) Finally block executes every time ?
Ans : Yes
7) How can we sort an Array in decreasing order?
Ans : By calling Sort() and Reverse() methods
8) Which one of the following is Immutable?
Ans : Strings
9) What is the life span for items stored in ViewState
Ans : GC will remove items.
10) What are properties common to very Validation Control?
Ans : ControlToValidate Properties
Text Properties
ErrorMessage Properties
11) How can you provide an alternate color schema in a Repeater Control?
Ans : AlternatingItem Template.
12) Can Abstract Class be Inherited ?
Ans : Yes
13) Suppose you want a certain ASP.net function executed OnMouseOver for a certain button. Where do you add an Eventhandler ?
Ans : Button1.Attributes.Add("OnMouseOver","ClientScriptHere");
14) Where do you store the information about the user locale
Ans : System.Web.UI.Page.Culture.
15) What data type does the RangeValidator supports ?
Ans : Integer, String, Date.
16) As part of your weekly review meeting with your manager, he is testing your knowledge to the extreme! He wants you to put the following steps in the correct order relating to how IAS resolves a user name without a specified domain name.
A) IAS checks the default domain registry key. If one is specified, IAS authenticates the user against the domain specified in the registry key.
B) If the IAS server is not a member of a domain, IAS authenticates the user against the local Security Accounts Manager (SAM) database.
C) If the IAS server is a member of a domain, IAS authenticates the user against the domain to which it is joined.
Ans : A,C,B
17) As part of a group exercise all members of your network team have been asked to explain a concept of Windows Server 2003. Your manager has given you an extract describing a certain feature of Active Directory. He wants you to complete the missing word in the following paragraph:
In the Active Directory directory service, the _____ contains database files and processes that store and manage directory information for users, services, and applications. A copy of the _____ runs on each domain controller in the forest. The _____ provides access to directory information through a process called the Directory System Agent (DSA). The _____ holds directory information in a database file called Ntds.dit. The Active Directory _____ is often referred to as the directory
Ans : Data store
18) As the primary network administrator at your organization you have been tasked with logging UDP and TCP requests to the organizations DNS Server. How can you log User Datagram Protocol (UDP) and TCP DNS requests from host 10.2.3.99 to your DNS server with the least administrative effort?
Ans : Use the Debug Logging tab in the server’s properties dialog box
The correct answer is Use the Debug Logging tab in the server’s properties dialog box.This dialog allows you to define certain logging criteria including packet direction, content and type. You can also filter on IP address so in this case you could filter traffic coming from 10.2.3.99
19) You are working on configuring the Local Security Policies of individual computers in your organization. Your manager has recommended using one of the predefined security templates to save time by pre-populating most of the settings you will use.
Which one of the following security templates does NOT exist:
Ans : Extreme secure (extreme*.inf)
21) What is Default Authentication in ASP.NET.
Ans : Windows.
22) Expansion of CLI ?
Ans : Common Language Interface.
23) What does WSDL stand for?
Ans : Web Services Description Language
24) A Web service can only be written in .NET?
Ans : False
25) Expansion of SOAP?
Ans : Simple Object Access Protocol.
26) What is the transport protocol you use to call a Web service?
Ans : SOAP
21) Default modifier for Class?
Ans : private.
22) What is Interface default modifier ?
Ans : public
23) Specifies a search condition for a group or an aggregate
Ans : Having with Group by Clause.
24) PostBackUrl attribute is valid for
Ans : Button, Image, LinkButton
25) Which of the following is Navigation control?
Ans : Site Maps, Dynamic HTML menus, Tree View
26) Whether OleDbDataReader class is used to read a stream of records from a data source?
Ans : Yes
27) Whether ADO.NET is a part of the .NET Framework ?
Ans : Yes
28) What NameSpace we need to work with DataSet?
Ans : System.Data
29) The following controls are list controls which support data binding?
Ans : RadioButtonList, CheckBoxList, DropDownList, ListBox
30) Expansion of SDK?
Ans : Software Development Kit.
31) What's the maximum number of columns can a table have
in SQL Server 7.0?
Ans : 1024
32) Can you configure a .NET Remoting object via XML file?
Ans : Yes
33) How do you convert a value-type to a reference-type?
Ans : Using Boxing
34) What namespaces are necessary to create a localized application?
Ans: System.Globalization ,Sytem.Resources
35) What is the smallest unit of execution in .NET?
Ans : Assembly
36) What are the ways to deploy an assembly?
Ans : MSI Installer, a CAB archive, XCOPY command
37) What’s the difference between // comments, /* */ comments and /// comments? In XML -
Ans : Single line Comment, Multi-line Comment, XML documentation Comment.
38) Why can’t you specify the accessibility modifier for methods inside the interface?
Ans : By Default Public
39) What class is underneath the SortedList class?
Ans : A Sorted HashTable
40) What’s the .NET collection class that allows an element to be accessed using a unique key?
Ans : HashTable
41) What are the new caching features in ASP.NET 2.0?
Ans: SQL Cache Invalidation, Post-Cache Substitution ,Fragment Caching API,Cache Configuration
42) An application includes the following elements in the Page directive:
Debug=”True” and Trace="True".Which statement should be used when each page has to provide execution information in the Web browser immediately after the page’s normal display output
Ans: Trace.Write
43) You need to select a class that is optimized for key-based item retrieval from both small and large collections. Which class should you choose?
Ans : HybridDictionary Class
HybridDictionary: Implements IDictionary by using a ListDictionary while the collection is small
44) Which method is used to clear a Queue named q?
Ans : q.Clear();
45) Your application uses two threads.
How to prevent the execution of threadOne
until threadTwo completes execution?
Ans : Use a WaitCallback delegate to synchronize the threads.
46) Is it possible to have a static indexer in C#? allowed in C#.
Ans : No. static indexer are not.
47) Is it possible to inline assembly or IL in C# code?
Ans: No
48) What is the structure of the code
public Class A
{
private A instance;
{
private A(){}
public static A instance {
get{
if(A==null)
A=new A();
return instance;
}
}
}
Ans : Singleton
49) If a method is marked as protected internal who can access it?
Ans : Classes that are both in the samw assembly ans derived from the declaring class.
50) Which of the following is correctly declares a two dimensional array in C#?
Ans : int[,],arrayName.
51) The C# keyword 'int' maps to which .net type
Ans : System.Int32;
52) Which of the these string definition will prevent escaping on backslashes in c#?
Ans : string s=@”n test string”;
53) Which of the following condition is false ?
Ans : FormView is Editable, FormView allows paging, FormView allow to create new field all the options are false.
54) Can you store multiple data types in System.Array?
Ans : No
55) Are private class-level variables inherited?
Ans : yes
56) Where we save Assembly Version ?
Ans : Manifest
57) How can we get Current Version of the DataRow ?
Ans : By using DataRowVersion.Current
58) How many DataRow Version we have
Ans : 4
59) How many Executing Commands we have
Ans : 4
ExecuteNonQuery() ExecureReader() ExecuteScalar() ExecuteXmlReader()
60) How many CommandTypes we have
Ans : 3
CommandType.Text CommandType.StoredProcedure CommandType.TableDirect
61) Which one of the following is TRUE?
Ans : 1) There can be only one static constructor in class
2) The static constructor should be without parameter
3) It can be access the static members of the class
4) There should be no access modifier in static constructor definition
62) The partial modifier is not applicable for
Ans : delegates & enums
63) An Interface can contain the signature of
Ans : methods ,delegates ,events
64) Can a static class contain non static members?
Ans : No
65) Can you create an instance of a static class?
Ans : No
66) What is the thread?
Ans : is used to execute more than one program at a time.
67) What is use of Sealed Class?
Ans : Restrict Inheritance
68) In C#, class can be implemented or derived from multiple interfaces?
Ans : True
69) Which data structure is implemented in hash table?
Ans : Map
70) Which is the best method of sqlcommand to execute insert query?
Ans : ExecuteNonQuery()
71) Which one can be instantiated without using new operator?
Ans : Struct
72) Which of the following statement contains default instruction?
Ans : switch…case
73) Which OOPS concept allows to extend the behaviour of base class?
Ans : Polymorphism
74) Why should boxing should be avoided ? (Choose only One)
Ans : It adds overhead
75) What method stops a running thread ?
Ans : Thread.Abort
76) Expansion of RCW?
Ans : Runtime Callable Wrapper
77) Expansion of BLOB ?
Ans: Binary Large Object
78) Can you use single inheritance in .NET?
Ans : Yes
79) Is the ASP.NET AJAX Control Toolkit(AjaxControlToolkit.dll) installed in the Global Assembly Cache?
Ans : No
You must copy the AjaxControlToolkit.dll assembly to the /Bin folder in your application.
80) Can you nest UpdatePanel within each other?
Ans : Yes
you can do that. You would want to nest update panels to basically have more control over the Page Refresh.
81) Can we call Server-Side code (C# or VB.NET code) from javascript?
Ans : Yes
You can do so using PageMethods in ASP.NET AJAX or using webservices.
82) Is it possible to cancel an Asynchronous postback?
Ans : Yes.
83) Can we use multiple ScriptManager on a page?
Ans : No
You can use only one ScriptManager on a page.
84) What method do you use to explicitly kill a users session?
Ans : Session.Abandon().
85) Can you encrypt view state data of an aspx page?
Ans : Yes
you encrypt view state data of an aspx page by setting the page's ViewStateEncryptionMode property to true.
86) Is IIS Used to access asp.net web application?
Ans : Yes
87) Expansion of IIS?
Ans : Internet Information Server
88) Name some of the languages .Net support?
Ans : Visual Basic .Net,Visual C#, Visual C++
89) What are the different methods of Session maintenance in asp.net?
Ans : In process storage,Session State Services,Microsoft sql server
90) What are the types of authentications?
Ans : Windows,Forms,PassPort,Customs
91) How many types of Authentications?
Ans : 4
92) What are the Types of constructor?
Ans : public constructor, parameterized constructor
93) How many types of constructor?
Ans : 2
94) Is it Possible to Create Private Constructor?
Ans : Yes
95) Is Constructor Return any value?
Ans : No
96) What is constructor?
Ans : Same Name as the Class Name
97) Which of the following is not Value Type?
Ans : String
99) Which of the following is not Reference Type?
Ans : Char is not Reference Type
String,Delegate, arrays are Reference Type
100) What is the Main purpose of system.data.sqlclient?
Ans : Connect to SQL SERVER
Visual Studio is all about developer productivity. Microsoft Visual Studio is an Integrated Development Environment from Microsoft. It can be used to develop console and graphical user interface applications along with Windows Forms applications, web sites, web applications and much more..
Search This Blog
Friday, February 12, 2010
Visual Studio Key Combinations
Key Combination ............. use
CTRL+ALT+L ...................View Solution Explorer
CTRL+ALT+X ...................View ToolBox
CTRL+ALT+O ...................View Output
CTRL+\, then press E .......View Error List
CTRL+\, then press T .......View Task List
F4 .......View Property Window
CTRL+PgDn or CTRL+PgUp .......Design View to Source View and vice-versa
SHIFT+F7 .......Design View to Source View and vice-versa
F7 .....................Design or Source View to Code View
SHIFT+F7 .....................Code View to Design View
F5 .....................Start Debugging
CTRL+F5 .....................Start Without Debugging
F10 .....................Debug
F11 .....................Debug
SHIFT+F11 ....................Debug
CTRL+F10 ....................Debug
F9 ....................Toggle Breakpoint
CTRL+M, then press O .........Collapse to Definitions.
CTRL+K, then CTRL+C ........Comment selected Block
CTRL+K, then CTRL+U ........Uncomment selected block
CTRL+- .....................Go back to the previous location in the navigation history
F6 .....................Build Solution
SHIFT+F6 .....................Build Website
ATL+B, then R ........Rebuild Solution
CTRL+L .................Deletes Entire Line
CTRL+G .................GO to the Line Number
SHIFT+ATL+Enter ........Toggle Full Screen Mode
CTRL+Space ........Invoke the Intellisense List
CTRL+ALT+L ...................View Solution Explorer
CTRL+ALT+X ...................View ToolBox
CTRL+ALT+O ...................View Output
CTRL+\, then press E .......View Error List
CTRL+\, then press T .......View Task List
F4 .......View Property Window
CTRL+PgDn or CTRL+PgUp .......Design View to Source View and vice-versa
SHIFT+F7 .......Design View to Source View and vice-versa
F7 .....................Design or Source View to Code View
SHIFT+F7 .....................Code View to Design View
F5 .....................Start Debugging
CTRL+F5 .....................Start Without Debugging
F10 .....................Debug
F11 .....................Debug
SHIFT+F11 ....................Debug
CTRL+F10 ....................Debug
F9 ....................Toggle Breakpoint
CTRL+M, then press O .........Collapse to Definitions.
CTRL+K, then CTRL+C ........Comment selected Block
CTRL+K, then CTRL+U ........Uncomment selected block
CTRL+- .....................Go back to the previous location in the navigation history
F6 .....................Build Solution
SHIFT+F6 .....................Build Website
ATL+B, then R ........Rebuild Solution
CTRL+L .................Deletes Entire Line
CTRL+G .................GO to the Line Number
SHIFT+ATL+Enter ........Toggle Full Screen Mode
CTRL+Space ........Invoke the Intellisense List
Thursday, February 11, 2010
Interview Questions DotNet
1. What are the difference between Value Types and Reference types?
Ans: Value types are those that are created on the stack. Reference types are created on the heap. Value types are destroyed when the block creating them is exited. Reference types are garbage collected. Reference types are like pointers.
2. What is boxing and unboxing in .NET?
Ans: Boxing is wrapping a value type into an object, so it can be stored on the heap. Unboxing is the converse – recovering a value type from a reference type on the heap. Boxing works always. Unboxing a reference type would work only if the type was originally a value type that was boxed.
3. What are three to five important differences that you would find between COM/DCOM and .NET?
Ans:
(I) COM/DCOM uses the registry to store all information related to the component. And .NET stores the information within the component itself
(II) All COM/DCOM components must be installed. .NET components can simply be xcopied (even though shared assemblies would need to be installed with gacutil.exe)
(III) COM/DCOM components implement the interface IUnknown (that has the methods: AddRef(), Release() and QueryInterface()) All .NET components inherit from the CTS type System.Object
(IV) COM/DCOM is not type-independent. For example, all COM server methods in VB must accept or return variants. In .NET, since all languages share the same type library (CTS – Common Type System) - this overhead is removed.
(V) DCOM uses a proprietary mechanism to discover remote objects, marshall the parameters and return back values. .NET uses open standards like XML to do remoting.
(VI) COM/DCOM depends on reference counts to know if they are needed. In .NET, the garbage collector takes care of keeping object lifetimes and collecting them when no longer needed.
4. What is non-CLS compliant code?
Ans: Non CLS compliant code is code where the .NET cross-language standards are broken. For example: Having two C# methods that accept the same parameters but differ in case. This would be unusable from the VB.NET world.
5. What does Shared Assembly mean? Can you make any assembly a shared one?
Ans: Shared Assemblies are those that are installed in a special folder within the Windows installation (called Global Assembly Cache). They can be used by any .NET application that needs to be a client to the assembly's methods. To make an assembly into a shared one, you need to generate a strong name. For this you have SN.EXE that generates public and private keys that can be used to version and strongly name the assembly in the GAC. Unless this is done, any and every assembly cannot become shared.
6. Where is the metadata related to an assembly stored?
Ans: In a special area of the assembly header, called its manifest. This manifest contains file ownership details, culture, version numbers, types referenced, types exported and other media.
7. Can each file of an assembly have its own manifest?
Ans: No. Only one file in an assembly can have its manifest.
8. What are three to five differences you would state, between ASP and ASP.NET ?
Ans:
. In ASP all the page contents are in the same file (or in included files). In ASP.NET, you can split the page's content and code into separate files (the code-behind file)
2. ASP files end with .asp. ASP.NET files end with .aspx (this is dumb )
3. With ASP you had just two main languages to write code – VBScript and JScript. With ASP.NET you can write code in any language that has a .NET compiler installed on the IIS server
4. All ASP pages are interpreted. ASP.NET uses compilation of the code-behind and runs the binaries everytime the page is requested.
5. ASP.NET adds a lot of functionality to IIS – like server controls, user controls, improved session management, event driven programming etc.
6. ASP pages usually post their forms to other asp pages. ASP.NET pages post the forms back to the same page (by calling server methods)
9. What are delegates in .NET? Mention 2 places where they are majorly used
Ans: Delegates are objects representing function pointers. Whenever a delegate is created, it is given the name of a function of the type it is defined with (like void return, accepting an int). Invoking the delegate calls the method it was created with (sort of a callback mechanism). Two places where delegates are employed: Events and Threads.
10. What are multicast delegates?
Ans: Multicast delegates are delegates that can refer to multiple methods. They must return void. Whenever we create a delegate with void, .NET internally treats it as a multicast delegate. We can use the overloaded + operator to add void methods with the same signature to a multicast delegate. When this delegate is called, all the methods are called (not in sequence – do not trust sequence).
11. What is meant by ViewState in ASP.NET?
Ans: ViewState is a hidden form member created with each control in ASP.NET. Like, when we populate a dropdown list on a page – its members are stored with the viewstate. They help in persisting form content state and can be used in a scenario where we have multiple web servers (as in a server farm).
12. What are static constructors in C#?
Ans: Static constructors are constructors in a class, defined with the word static. They must not accept any parameter and must return nothing. They are called once - whenever the class is loaded by the CLR. Every class can have 0 or 1 static constructors.
13. Are you aware of a keyword called fixed in C#? What is it used for?
Ans: The fixed keyword is used with references defined in a class. Whenever the word fixed is encountered, the .NET runtime/CLR flags this particular object on the heap.So that the garbage collector will not move it when it compacts the heap. Using fixed allows you to perform pointer arithmetic on objects (unsafe code)
14. What is the meaning of the following keywords:
a. Internal
Ans: Internal flags a member as being accessible only within the current assembly
b. Override
Ans: override allows a derived class to create a method that specializes a base class virtual method.
c. Sealed
Sealed classes are those that cannot be inherited from. You can make objects from a sealed class, but you cannot subclass it.
15. What are hidden methods in C#/.NET
Ans: hidden methods in C# use the new keyword. They are methods in a derived class that have the same signature as a base class virtual method, but are not related in inheritance to it. In effect, the derived class hides the base class method.
16. Can you have a catch block with no parameters (no catch (Exception e) ?
Ans: Yes. When you define a catch block with no parameters, you are defining a block that will handle exceptional information from the non .NET world. This would take care of problems arising in method calls on COM components that don’t raise the System.Exception derived object.
17. What is stackalloc in C#?
Ans: stackalloc is used for creating C/C++ style stack arrays. When you desire a contiguous block of memory where you could perform pointer arithmetic with a set of data, you use stackalloc. This is unsafe/unmanaged code. By default, all .NET arrays are objects created on the heap – even with integer arrays (Recall, you have a length property for all arrays!) You have no length property for stack allocated arrays
18. How is threading done in .NET?
Ans: The System.Threading namespace defines a class called Thread. This thread is created with a ThreadStart delegate class object. This ThreadStart object must refer to a method that accepts and returns void. When the start method is called on the thread, it runs the delegate method parallel with the current thread of execution.
19. What is meant by strongly typed assemblies?
Ans: Strongly typed assemblies can be placed in the GAC. They are created with a strong name (public/private key, generated with sn.exe)
20. What is the mechanism used to peep inside an object and know about its methods, public members etc?
Ans: Reflection. It is possible as all types inherit from System.Object, that contains a method GetType that returns a Type structure, describing the object's type.
21. Can session information be shared between ASP and ASP.NET?
Ans: No. They are maintained differently and cannot be shared. Session info written by an ASP.NET page cannot be viewed in an ASP page linked to the former.
22. Can you have two files in the same assembly, created with different programming languages?
Ans: Yes. .NET allows this.
23. Can you have a page where the code behind uses two different .NET languages?
Ans: No. Every page or class in .NET must be created in the same language.
24. What is the concept of generations in objects, as related to garbage collection?
Ans: Every object has a generation counter that is set and used by the garbage collector. It is incremented every time the object skips the garbage collection mechanism as its reference is present with some place else on the heap. The GC compacts the heap and places all objects with the same generation count together.
25. What is meant by DNA programming, in the Windows world?
DNA is short for Distributed interNet Architecture. It envisages an n-tier design where the client has UI functionality, the middle tiers have business logic and process routing architecture and the back-end has the database logic. DNA architecture allows the same business tiers and back-ends to be used by multiple clients (web, application-based or device)
26. What are the means to implement security in ASP.NET?
Ans:
1. Integrated Windows Authentication: Where the user's information and roles are defined in the windows installation where the IIS instance is active
2. Config file-based: The web.config file for the website has XML tags to indicate which users must be allowed and those that must be denied access.
You can make the root web folder publicly accessible, while restricting access to subfolders or selected files
3. Web-Service based: Microsoft runs a Passport web service that has a single door entry to authenticate users. Web applications could utilize this service to identify and permit users to access the system.
27. What is the class DataSet – in the ADO.NET world.
Ans: DataSet is an in-memory image of a database. It contains a set of tables and relations between them, that can be used by applications.
28. Is this possible? I use a Connection object to retrieve a SqlDataReader. I iterate through the records in the DataReader, using
while (sqlDataReaderObject.Read())
Inside the while block, I connect to some webservice to retrieve a value corresponding to a particular column in the record. Can I update another table in the same database, using the above connection – or would I have to create another connection object for the update thing?
Ans: No. This is not possible, as the Connection is locked by the SqlDataReader object, as long as it is being read from. You must create a new instance of the connection object, with the same connection string
29. Can I write an ASP.NET page using Managed C++?
Ans: Yes. But the C++ language must be enabled in the IIS' configuration files and the compiler must be available. By default, only two languages are supported – C# and VB.NET. To enable Managed C++, the compiler must be available. Else, the answer is no.
30. What is the Monitor class in the threading world?
Ans: Monitor is used to synchronize access to a block of code between threads. When a certain operation is to be performed by only one thread at a time, it must obtain the monitor to that object. Once it has acquired the monitor, all other threads to that method must wait till the monitor is exited.
Ans: Value types are those that are created on the stack. Reference types are created on the heap. Value types are destroyed when the block creating them is exited. Reference types are garbage collected. Reference types are like pointers.
2. What is boxing and unboxing in .NET?
Ans: Boxing is wrapping a value type into an object, so it can be stored on the heap. Unboxing is the converse – recovering a value type from a reference type on the heap. Boxing works always. Unboxing a reference type would work only if the type was originally a value type that was boxed.
3. What are three to five important differences that you would find between COM/DCOM and .NET?
Ans:
(I) COM/DCOM uses the registry to store all information related to the component. And .NET stores the information within the component itself
(II) All COM/DCOM components must be installed. .NET components can simply be xcopied (even though shared assemblies would need to be installed with gacutil.exe)
(III) COM/DCOM components implement the interface IUnknown (that has the methods: AddRef(), Release() and QueryInterface()) All .NET components inherit from the CTS type System.Object
(IV) COM/DCOM is not type-independent. For example, all COM server methods in VB must accept or return variants. In .NET, since all languages share the same type library (CTS – Common Type System) - this overhead is removed.
(V) DCOM uses a proprietary mechanism to discover remote objects, marshall the parameters and return back values. .NET uses open standards like XML to do remoting.
(VI) COM/DCOM depends on reference counts to know if they are needed. In .NET, the garbage collector takes care of keeping object lifetimes and collecting them when no longer needed.
4. What is non-CLS compliant code?
Ans: Non CLS compliant code is code where the .NET cross-language standards are broken. For example: Having two C# methods that accept the same parameters but differ in case. This would be unusable from the VB.NET world.
5. What does Shared Assembly mean? Can you make any assembly a shared one?
Ans: Shared Assemblies are those that are installed in a special folder within the Windows installation (called Global Assembly Cache). They can be used by any .NET application that needs to be a client to the assembly's methods. To make an assembly into a shared one, you need to generate a strong name. For this you have SN.EXE that generates public and private keys that can be used to version and strongly name the assembly in the GAC. Unless this is done, any and every assembly cannot become shared.
6. Where is the metadata related to an assembly stored?
Ans: In a special area of the assembly header, called its manifest. This manifest contains file ownership details, culture, version numbers, types referenced, types exported and other media.
7. Can each file of an assembly have its own manifest?
Ans: No. Only one file in an assembly can have its manifest.
8. What are three to five differences you would state, between ASP and ASP.NET ?
Ans:
. In ASP all the page contents are in the same file (or in included files). In ASP.NET, you can split the page's content and code into separate files (the code-behind file)
2. ASP files end with .asp. ASP.NET files end with .aspx (this is dumb )
3. With ASP you had just two main languages to write code – VBScript and JScript. With ASP.NET you can write code in any language that has a .NET compiler installed on the IIS server
4. All ASP pages are interpreted. ASP.NET uses compilation of the code-behind and runs the binaries everytime the page is requested.
5. ASP.NET adds a lot of functionality to IIS – like server controls, user controls, improved session management, event driven programming etc.
6. ASP pages usually post their forms to other asp pages. ASP.NET pages post the forms back to the same page (by calling server methods)
9. What are delegates in .NET? Mention 2 places where they are majorly used
Ans: Delegates are objects representing function pointers. Whenever a delegate is created, it is given the name of a function of the type it is defined with (like void return, accepting an int). Invoking the delegate calls the method it was created with (sort of a callback mechanism). Two places where delegates are employed: Events and Threads.
10. What are multicast delegates?
Ans: Multicast delegates are delegates that can refer to multiple methods. They must return void. Whenever we create a delegate with void, .NET internally treats it as a multicast delegate. We can use the overloaded + operator to add void methods with the same signature to a multicast delegate. When this delegate is called, all the methods are called (not in sequence – do not trust sequence).
11. What is meant by ViewState in ASP.NET?
Ans: ViewState is a hidden form member created with each control in ASP.NET. Like, when we populate a dropdown list on a page – its members are stored with the viewstate. They help in persisting form content state and can be used in a scenario where we have multiple web servers (as in a server farm).
12. What are static constructors in C#?
Ans: Static constructors are constructors in a class, defined with the word static. They must not accept any parameter and must return nothing. They are called once - whenever the class is loaded by the CLR. Every class can have 0 or 1 static constructors.
13. Are you aware of a keyword called fixed in C#? What is it used for?
Ans: The fixed keyword is used with references defined in a class. Whenever the word fixed is encountered, the .NET runtime/CLR flags this particular object on the heap.So that the garbage collector will not move it when it compacts the heap. Using fixed allows you to perform pointer arithmetic on objects (unsafe code)
14. What is the meaning of the following keywords:
a. Internal
Ans: Internal flags a member as being accessible only within the current assembly
b. Override
Ans: override allows a derived class to create a method that specializes a base class virtual method.
c. Sealed
Sealed classes are those that cannot be inherited from. You can make objects from a sealed class, but you cannot subclass it.
15. What are hidden methods in C#/.NET
Ans: hidden methods in C# use the new keyword. They are methods in a derived class that have the same signature as a base class virtual method, but are not related in inheritance to it. In effect, the derived class hides the base class method.
16. Can you have a catch block with no parameters (no catch (Exception e) ?
Ans: Yes. When you define a catch block with no parameters, you are defining a block that will handle exceptional information from the non .NET world. This would take care of problems arising in method calls on COM components that don’t raise the System.Exception derived object.
17. What is stackalloc in C#?
Ans: stackalloc is used for creating C/C++ style stack arrays. When you desire a contiguous block of memory where you could perform pointer arithmetic with a set of data, you use stackalloc. This is unsafe/unmanaged code. By default, all .NET arrays are objects created on the heap – even with integer arrays (Recall, you have a length property for all arrays!) You have no length property for stack allocated arrays
18. How is threading done in .NET?
Ans: The System.Threading namespace defines a class called Thread. This thread is created with a ThreadStart delegate class object. This ThreadStart object must refer to a method that accepts and returns void. When the start method is called on the thread, it runs the delegate method parallel with the current thread of execution.
19. What is meant by strongly typed assemblies?
Ans: Strongly typed assemblies can be placed in the GAC. They are created with a strong name (public/private key, generated with sn.exe)
20. What is the mechanism used to peep inside an object and know about its methods, public members etc?
Ans: Reflection. It is possible as all types inherit from System.Object, that contains a method GetType that returns a Type structure, describing the object's type.
21. Can session information be shared between ASP and ASP.NET?
Ans: No. They are maintained differently and cannot be shared. Session info written by an ASP.NET page cannot be viewed in an ASP page linked to the former.
22. Can you have two files in the same assembly, created with different programming languages?
Ans: Yes. .NET allows this.
23. Can you have a page where the code behind uses two different .NET languages?
Ans: No. Every page or class in .NET must be created in the same language.
24. What is the concept of generations in objects, as related to garbage collection?
Ans: Every object has a generation counter that is set and used by the garbage collector. It is incremented every time the object skips the garbage collection mechanism as its reference is present with some place else on the heap. The GC compacts the heap and places all objects with the same generation count together.
25. What is meant by DNA programming, in the Windows world?
DNA is short for Distributed interNet Architecture. It envisages an n-tier design where the client has UI functionality, the middle tiers have business logic and process routing architecture and the back-end has the database logic. DNA architecture allows the same business tiers and back-ends to be used by multiple clients (web, application-based or device)
26. What are the means to implement security in ASP.NET?
Ans:
1. Integrated Windows Authentication: Where the user's information and roles are defined in the windows installation where the IIS instance is active
2. Config file-based: The web.config file for the website has XML tags to indicate which users must be allowed and those that must be denied access.
You can make the root web folder publicly accessible, while restricting access to subfolders or selected files
3. Web-Service based: Microsoft runs a Passport web service that has a single door entry to authenticate users. Web applications could utilize this service to identify and permit users to access the system.
27. What is the class DataSet – in the ADO.NET world.
Ans: DataSet is an in-memory image of a database. It contains a set of tables and relations between them, that can be used by applications.
28. Is this possible? I use a Connection object to retrieve a SqlDataReader. I iterate through the records in the DataReader, using
while (sqlDataReaderObject.Read())
Inside the while block, I connect to some webservice to retrieve a value corresponding to a particular column in the record. Can I update another table in the same database, using the above connection – or would I have to create another connection object for the update thing?
Ans: No. This is not possible, as the Connection is locked by the SqlDataReader object, as long as it is being read from. You must create a new instance of the connection object, with the same connection string
29. Can I write an ASP.NET page using Managed C++?
Ans: Yes. But the C++ language must be enabled in the IIS' configuration files and the compiler must be available. By default, only two languages are supported – C# and VB.NET. To enable Managed C++, the compiler must be available. Else, the answer is no.
30. What is the Monitor class in the threading world?
Ans: Monitor is used to synchronize access to a block of code between threads. When a certain operation is to be performed by only one thread at a time, it must obtain the monitor to that object. Once it has acquired the monitor, all other threads to that method must wait till the monitor is exited.
Subscribe to:
Comments (Atom)