+OOPS

+What is OOPS?

Object Oriented Programming

+What are the characteristics of OOPS?

  • Abstraction
  • Abstraction is "the process of identifying common patterns that have systematic variations; an abstraction represents the common pattern and provides a means for specifying which variation to use"

    An abstract class is a parent class that allows inheritance but can never be instantiated. Abstract classes contain one or more abstract methods that do not have implementation. Abstract classes allow specialization of inherited classes.

  • Interfaces
  • An interface is a collection of public methods and properties that are grouped together to encapsulate specific functionality. Once an interface is defined , you can implement in a class.

    Interface can not exist on theirown. You can not instantiate an interface. Inaddition interface can not contain any code to implement its members. It just defines members.

  • Inheritance
  • A sealed class is a class that does not allow inheritance. Some object model designs need to allow the creation of new instances but not inheritance, if this is the case, the class should be declared as sealed.

    To create a sealed class in VB.NET, the class declaration should be done as: NonInheritable Class Shape

  • Polymorphism
  • Polymorphism allows objects to be represented in multiple forms. Even though classes are derived or inherited from the same parent class, each derived class will have its own behavior. Polymorphism is a concept linked to inheritance and assures that derived classes have the same functions even though each derived class performs different operations.

    Virtual keyword : The virtual keyword allows polymorphism too.

    To create a virtual member in VB.NET, use the Overridable keyword: Public Overridable Function Draw()

  • Relationships between objects
  • Operator Overloading
  • Events
  • Reference verses value types

+Webservice

+What is Webservice?

Web services are server side programs that listen for messages from client applications and return specific information. This information may come from web service itself, from other componemts in the same domain, or from other web services.

A web service is a collection of protocols and standards used for exchanging data between applications or systems. Web services provide a standard means of communication among different software applications, running on a variety of platforms and/or frameworks. Software applications written in various programming languages and running on various platforms can use web services to exchange data over computer networks like the Internet in a manner similar to inter-process communication on a single computer. This interoperability (e.g., between Java and Python, or Windows and Linux applications) is due to the use of open standards. So it is hetrogeneous.

+Where webservice is used?

Because we need it

+SOAP and XML

SOAP once stood for 'Simple Object Access Protocol' but this acronym was dropped with Version 1.2 of the standard, as it was considered to be misleading

+ Data Base Questions

+ What is the difference between truncate and delete command?

To delete the rows stored within a table and free up the storage space that was occupied by these rows, use the Truncate Table command. While delete is used, storage space is not released.

  1. DELETE TABLE Logs the delete operation, making it slow. TRUNCATE TABLE does not log any information but it logs information about deallocation of data page of the table. So truncate table is faster as compared to delete table.
  2. DELETE TABLE can be rolled back while truncate can not be
  3. DELETE table can have criteria while truncate can not
  4. Truncate Table can not have triggers.

+ heading

section

+ heading

+ heading

section

+ heading

section

+ .NET Frame Work

+(B)What is a IL? / What is MSIL/ CIL

(IL)Intermediate Language is also known as MSIL (Microsoft Intermediate Language) or CIL (Common Intermediate Language). All .NET source code   is compiled to IL. This IL is then converted to machine code at the point where the software is installed, or at run-time by a Just-InTime (JIT) compiler.

+(B)What is a CLR?

Full form of  CLR   is   Common Language Runtime and it forms the heart of the .NET framework. All Languages have runtime and its the responsibility of the runtime to take care of the code execution of  the program. For example VC + + has MSCRT40.DLL, VB6 has MSVBVM60.DLL, Java has Java Virtual Machine etc. Similarly .NET has CLR. Following are the responsibilities of CLR

  1. Garbage Collection :- CLR automatically manages memory thus eliminating memory leakes. When objects are not referred GC automatically releases those memory thus providing efficient memory management.
  2. Code Access Security :- CAS grants rights to program depending on the security configuration of the machine. Example the program has rights to edit or   create  a new file but the security configuration of machine does not allow the program to delete a file. CAS will take care that the code runs under the environment of  machines security  configuration.
  3. Code Verification :- This ensures proper code execution and type safety while  the code runs. It prevents the source code to perform illegal operation such as  accessing invalid memory locations etc.
  4. IL( Intermediate language )-to-native translators and optimizer’s :- CLR uses  JIT and compiles the IL code to machine code and then executes. CLR also determines depending on platform what is optimized way of running the IL code.

+(B)What is a CTS?

In order that two language communicate smoothly CLR has CTS (Common Type System). Example in VB you have “Integer” and in C++ you have “long” these datatypes are not compatible so the interfacing between them is very complicated. In order that two different languages can communicate, Microsoft introduced Common Type System. So “Integer” datatype in VB6 and “int” datatype in C++ will convert it to System.int32 which is datatype of CTS. CLS is subset of CTS.

+(B)What is a CLS(Common Language Specification)?

This is a subset of the CTS which all .NET languages are expected to support. It was always a dream of microsoft to unite all different languages in to one umbrella and CLS is one step towards that. Microsoft has defined CLS which are nothing but guidelines that language to follow so that it can communicate with other .NET languages in a seamless manner.

+(B)What is a Managed Code?

Managed code runs inside the environment of CLR i.e. .NET runtime. In short all IL are managed code. But if you are using some third party software example VB6 or VC++ component they are unmanaged code as .NET runtime (CLR) does not have control over the source code execution of the language.

+B)What is a  Assembly ?

  • Assembly is unit of deployment like EXE or a DLL.
  • An assembly consists of one or more files (dlls, exe’s, html files etc.), and represents a group of resources, type definitions, and implementations of those types. An assembly  may also contain references to other assemblies. These resources, types and references are described in a block of data called a manifest. The manifest is part of the assembly, thus making the assembly self-describing.
  • An assembly is completely self-describing. An assembly contains metadata information, which is used by the CLR for everything from type checking and security to actually invoking the components methods. As all information is in assembly itself   it is independent of registry. This is the basic advantage as compared to COM where the version was stored in registry.
  • Multiple versions can be deployed side by side in different folders. These different versions can execute at the same time without interfering with each other. Assemblies can be private or shared. For private assembly deployment, the assembly is copied to the same directory as the client program that references it. No registration is needed, and no fancy installation program is required. When the component is removed, no registry cleanup is needed,and no uninstall program is required. Just delete it from the hard drive.
  • In shared assembly deployment, an assembly is installed in the Global Assembly Cache (or GAC). The GAC contains shared assemblies that are globally accessible to all .NET applications on the machine

+(A) What are different types of Assembly?

There are two types of assembly Private and Public assembly. 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. Crystal report classes which will be used by all application for Reports..

+(B) What is NameSpace?

Namespace has two basic functionality :-
  1. NameSpace Logically group types. Example System.Web.UI logically groups our UI related features.
  2. In Object Oriented world many times its possible that programmers will use the same class name. By qualifying NameSpace with classname this collision can be removed.

+ (B) What is Difference between NameSpace and Assembly?

Following are the differences between namespace and assembly :
  • Assembly is physical grouping of logical units. Namespace logically groups classes.
  • Namespace can span multiple assembly.

+(A)If you want to view a Assembly how to you go about it ? / What is ILDASM ?

When it comes to understanding of internals nothing can beat ILDASM. ILDASM basically converts the whole exe or dll in to IL code. To run ILDASM you have to go to "C:\Program Files\Microsoft Visual Studio .NET 2003\SDK\v1.1\Bin". Note that i had v1.1 you have to probably change it depending on the type of framework version you have.

If you run IDASM.EXE from the path you will be popped with the IDASM exe program as shown in figure ILDASM.Click on file and browse to the respective directory for the DLL whose assembly you want to view.After you select the DLL you will be popped with a tree view details of the DLL as shown in figure ILDASM.On double clicking on manifest you will be able to view details of assembly , internal   IL code etc as shown in Figure Manifest View.
Note : The version number are in the manifest itself which is defined with the DLL or EXE thus making deployment much easier as compared to COM where the information was stored in registry.Note the version information in Figure Manifest view.
You can expand the tree for detail information regarding the DLL like methods etc.

+(A) What is Manifest?

Assembly metadata is stored in Manifest. Manifest contains all the metadata needed to do the following things( See Figure Manifest View for more details) :
  1. Version of assembly
  2. Security identity
  3. Scope of the assembly
  4. Resolve references to resources and classes.
  5. The assembly manifest can be stored in either a PE file (an .exe or .dll) with Microsoft intermediate language (MSIL) code or in a stand-alone PE file that contains only assembly manifest information.

+(B)Where is version information stored of a assembly ?

Version information is stored in assembly in manifest.

+(I)Is versioning applicable to private assemblies?

Versioning concept is only applicable to global assembly cache (GAC) as private assembly lie in there individual folders.

+(B) What is GAC ? / What are situations when you register .NET assembly in GAC ?

GAC (Global Assembly Cache) is used where shared .NET assembly reside.GAC is used in the following situations :-
  1. If the application has to be shared among several application.
  2. If the assembly has some special security requirements like only administrators can remove the assembly. If the assembly is private then a simple delete of the assembly file will remove the assembly.
Note :- Registering .NET assembly in GAC can lead to the old problem of DLL hell. Where COM version was stored in central registry.So GAC should be used when absolutely necessary.

+(I) What is concept of strong names ?

Strong name is similar to GUID(It is supposed to be unique in space and time) in COM components.Strong Name is only needed when we need to deploy assembly in GAC.Strong Names helps GAC to differentiate between two versions.Strong names use public key cryptography (PKC) to ensure that no one can spoof it.PKC use public key and private key concept.

Following are the step to generate a strong name and sign a assembly :-
  • Go to “Visual Studio Command Prompt”. See below figure to “Visual studio Command Prompt”. Note the samples are compiled in 2005 but 2003 users do not have to worry about it. Same type of command prompt will be seen in 2003 also.
  • After you are in command prompt type sn.exe -k “c:\test.snk”.
  • After generation of the file you can view the SNK file in a simple notepad.
  • After the SNK file is generated its time to sign the project with this SNK file.
  • Click on project -properties and te browse the SNK file to the respective folder and compile the project.

+ How to add and remove a assembly from GAC?

There are two ways to install .NET assembly in GAC:-
  1. Using Microsoft installer package. You can get download of installer from http://www.microsoft.com
  2. Using Gacutil. Goto "Visual Studio Command prompt" and type " gacutil -i(assembly_name)". Where(assembly_name) is the DLL name of the project.

+(B) What is Delay signing?

During development process you will need strong name keys to be exposed to developer which will is not a good practice from security aspect point of view.In such situations you can assign the key later on and during development you an use delay signing Following is process to delay sign a assembly:
  • First obtain your string name keys using SN.EXE.
  • Annotate the source code for the assembly with two custom attributes from System.Reflection: AssemblyKeyFileAttribute, which passes the name of the file containing the public key as a parameter to its constructor. AssemblyDelaySignAttribute, which indicates that delay signing is being used by passing true as a parameter to its constructor. For example as shown below:

Visual Basic

[C#] [assembly:AssemblyKeyFileAttribute("myKey.snk")] [assembly:AssemblyDelaySignAttribute(true)] The compiler inserts the public key into the assembly manifest and reserves space in the PE file for the full strong name signature. The real public key must be stored while the assembly is built so that other assemblies that reference this assembly can obtain the key to store in their own assembly reference.

Because the assembly does not have a valid strong name signature, the verification of that signature must be turned off. You can do this by using the -Vr option with the Strong Name tool. The following example turns off verification for an assembly called myAssembly.dll. Sn -Vr myAssembly.dll

Just before shipping, you submit the assembly to your organization's signing authority for the actual strong name signing using the -R option with the Strong Name tool.The following example signs an assembly called myAssembly.dll with a strong name using the sgKey.snk key pair. Sn -R myAssembly.dll sgKey.snk

+(B)What is garbage collection?

Garbage collection is a CLR feature which automatically manages memory. Programmers forget to release the objects while coding ... .. laziness ( Remember in VB6 where one of the good practices is to set object to nothing). CLR automatically releases objects when they are no longer referenced and in use.CLR runs on non-deterministic to see the unused objects and cleans them. One side effect of this non-deterministic feature is that we cannot assume an object is destroyed when it goes out of the scope of a function. Therefore, we should not put code into a class destructor to release resources.

+(I) Can we force garbage collector to run ?

System.GC.Collect() forces garbage collector to run.This is not recommended but can be used if situations arises.

+(B)What is reflection?

All .NET assemblies have metadata information stored about the types defined in modules.This metadata information can be accessed by mechanism called as “Reflection”.System.Reflection can be used to browse through the metadata information.

Using reflection you can also dynamically invoke methods using System.Type.Invokemember. Below is sample source code

. Reflection

Reflection Box

Sample source code uses reflection to browse through “Button” class of  “Windows.Forms”. If you compile and run the program following is output as shown in “Sample Reflection Display”. Using reflection you can also dynamically invoke a method using “System.Type.InvokeMember”.

 

+(P)What are different type of JIT ?

JIT compiler is a part of the runtime execution environment. In Microsoft .NET there are three types of JIT compilers:

+Functions

Functions separate code that performs a single, well-defined task. This makes the code easier to read and allows you to reuse the code each time you need to perform the same task. A function is a self-contained module of code that prescribes a calling interface, performs some task, and optionally returns a result.

+ heading

section

end

Style Reference