Saturday, January 28, 2012

.NET interview questions: - Elaborate interfaces in details with examples?

This is the basic and all time favorite .NET interview questions asked in the start or during the interview by the interviewer. So start with the definition & use an example to express the fundamental of the topic in more detail.

In real world interface allows two disparate/ different objects to communicate with each other. For instance a human is a very different object when compared to television object. But they can still use the remote control interface to communicate with each other. Same holds true for interfaces in software, it defines a communication vocabulary between objects. Interfaces have empty methods and we can not create an object of interface.

Figure: - Television interface

The other important thing is that interface brings in lot of uniformity in the project. They define common way of communication. Let’s consider a situation where you have multiple developers working on customer and supplier classes. You want that every developer should define the method name as ‘Update’ when these classes add the data to database. Developers are human’s so some would name it as update and some as add. You can tackle this situation by defining an interface with a method called as update. Now all the classes inherit from the same interface thus making update method constant through out the classes. You can also see how the client code methods are looking consistent in naming convention thus enforcing consistent communication interfaces across all classes.

Figure: - Interface fundamentals

Also see the OOPS fundamental video on polymorphism and its types as follows: -



Visit to get more stuff on Dotnet interview questions and answers

Regards,

Also visit for more author’s other blogs on Most asked Dotnet interview question

Wednesday, January 25, 2012

SQL Server interview questions: - What do you mean about Fragmentation in SQL Server?

This is the SQL Server interview questions which are asked during the interview not so frequent. But still go through it once before going for the interview.

Speed issues occur because of two major things
  • Fragmentation.
  • Splits.
Splits have been covered in the first questions. But one other big issue is fragmentation. When database grows it will lead to splits, but what happens when you delete something from the database…HeHeHe life has lot of turns right. Ok let’s say you have two extents and each have two pages with some data. Below is a graphical representation. Well actually that’s now how things are inside but for sake of clarity lot of things have been removed.


Figure: - Data Distribution in Initial Stages

Now over a period of time some Extent and Pages data undergo some delete. Here is the modified database scenario. Now one observation you can see is that some page’s are not removed even when they do not have data. Second If SQL server wants to fetch all “Females” it has to span across to two extent and multiple pages within them. This is called as “Fragmentation” i.e. to fetch data you span across lot of pages and extents. This is also termed as “Scattered Data”.


Figure: - Data Distribution after Deletes

What if the fragmentation is removed, you only have to search in two extent and two pages. Definitely, this will be faster as we are spanning across less entities


Figure: - Fragmentation removed

See the following video on calling a stored procedure using LINQ: -



Click for more SQL Server interview questions

Regards,

Visit for more author’s blog on SQL Server interview questions

Monday, January 23, 2012

Project management: .NET interview questions – Can you explain ROI?

This is a typical management type .NET interview questions asked by the interviewer to test the candidate’s skill on management. ROI is a measurement by which we can evaluate the financial value organization will gain from the project. ROI can also be used to measure returns from IT department to a company. In this book we will see ROI from the project perspective.

Below is a generic formula for ROI: -
ROI = (Expected profit in monetary terms / expected cost of the project) * 100
In one line ROI compares how much cost you will be incurring on the project to the total profit you will get out of the project.

Let's take a simple example of a software company who is developing a simple software accounting application. The following is a rough spending and forecast revenue on the accounting application year wise.

Year 2007:- In this year they will built the accounting application. Total rough estimate is 20,000 Dollars. They will be selling per installation of the accounting software for 1500 dollars. Company estimates that only 10 installation of the accounting software will happen in the first year.

Year 2008:- In the next year i.e. 2008 we need to only spend 1000$ on the traveling charges of the installation engineer. In this year they expect 13 to 15 installations. So forecasting from minimum sales we assume that only 13 installations will happen, i.e. a net profit of approximately 20,000 dollars.

Year 2009:- From year 2009 onwards company expects to have fixed installation of 5 to 6 because of competitors coming in. So the net profit is around 10,000 dollars.

Below figure ‘ROI’ shows how the ROI calculation with respect to the yearly view. In the below figure you can see we have the statistics and a graph drawn from the statistics. The ROI increases till 20 in 2008 and then again comes down to 10 in 2009.


Figure: - ROI

Get to see one of the technical questions on .NET of OOPS topic as follows: -



Click and see more interview questions and answers for Dotnet

Regards,

Also see from author’s blog for management based topics on Most asked Dotnet interview question

Thursday, January 19, 2012

SQL Server interview questions: - Explain two types of indexes?

This is the SQL Server interview questions most asked during the interview so do revise before you go for the interview.
There are basically two types of indexes:-
  • Clustered Indexes.
  • Non-Clustered Indexes.
Every thing is same for both the indexes i.e. it uses “B-TREE” for searching data. However, the main difference is the way it stores physical data
In clustered index, the non-leaf level actually points to the actual data.



Figure: - Clustered Index Architecture

In Non-Clustered index the leaf nodes point to pointers (they are rowid’s) which then point to actual data.


Figure: - Non-Clustered Index has pointers

So here is what the main difference is in clustered and non-clustered, in clustered when we reach the leaf nodes we are on the actual data. In non-clustered indexes, we get a pointer, which then points to the actual data.

Therefore, after the above fundamentals following are the basic differences between them:-
  • indexes as we have pointers, which is logical arrangement we do need this compulsion. Also, note in clustered index actual data as to be sorted in same way as the clustered indexes are. While in non-clustered
  • So we can have only one clustered index on a table as we can have only one physical order while we can have more than one non-clustered indexes.
Also see the following video calling a stored procedure using LINQ: -



Click for more SQL Server interview questions

Regards,

Visit for more author’s blog on SQL Server interview questions

Monday, January 16, 2012

.NET interview questions: - Elaborate project life cycle?

This is basic of .NET interview questions which are mostly asked to 1 year experience and above candidates.

So here is a simplified answer we have put in front with a diagram so that you can learn in a more easier manner.

Figure: - Life cycle of a project

There are five stages of any project initiating, planning, executing, controlling, and closeout. These are general phases and change according to domain. Example when writing a book we will have the following mappings initiating (contacting publishers, getting copy right etc), planning (Table of contents of book, Number of chapters, tool to use, chapter wise deadlines etc), executing (Actually writing the book), controlling (proof reading, language checks, page alignments etc), and closeout (Finally printing and on the shelf for sale). Therefore, this classification is at very broader level, for software development the above figure shows the mapping.

During Software project management interview, expected answer is requirement phase, design phase, coding phase, testing phase, and project closure. But you can just impress the answer by giving a general answer and then showing the mapping.

Also see a question for differences between Abstraction and Encapsulation based on OOPS as follows: -



Learn more on Dotnet interview questions and answers

Regards,

From more on author’s blog related to important .NET interview questions click and visit.

Friday, January 13, 2012

4 real time use of Partial classes and partial methods

Introduction
Fundamentals of partial classes
Fundamentals of partial methods
Use number 2:- LINQ and Entity framework
Use number 3:- Better maintenance by compacting large classes
Use number 4:- Multiple people working on the same class


Introduction

Recently I was hunting about partial classes and the real time use of the same. Many of those postings found on google talked about the concept of partial classes and partial methods, but in what scenarios to use them very few highlighted.

In this article we will first start with fundamentals of partial classes and methods and then discuss the 4 real time use of the same.

I have also created a video of the same here where I have discussed about partial classes and shown the real time use of the same.



Fundamentals of partial classes

A partial class allows a single class to be divided in to two separate physical files. During compile time these files get compiled in to single class. For instance you can see in the below figure we have the customer class divided in to two different files “customer1.cs” and “customer2.cs”.

During compilation these files gets compiled in to single class internally. So when you create an object of the customer class you will be able to see methods lying in both the physical files. For instance you can see “Add” method belongs to “customer1.cs” and “Delete” method belongs to “customer2.cs” , but when the customer object is created we can see both “Add” and “Delete” methods.



Fundamentals of partial methods

There is one more important concept in partial classes called as partial methods. Partial methods helps us to define a method definition in one of the physical files and we can implement that method in the other physical files as shown in the below figure.

In the below figure you can see we have defined “Validate” method in “Customer1.cs” and this validate method is implemented in “Customer2.cs”. Please note the partial keywords attached to both of these methods.


Use number 1:- ASP.NET auto generated code

The biggest use of partial classes is in technologies where there is code generation. Microsoft team themselves use partial classes in ASP.NET, LINQ and EF code generation. For instance when we look at ASP.NET there are two parts one is the auto generated code of a page and the other is behind code where you write your custom logic.

The custom logic is written in the “.aspx.cs” file while the auto generated logic is in “.aspx.designer.cs” file as shown in the below figure.


As a developer you would like the auto generated code to do his work i.e. generate code when you drag and drop a button the ASP.NET designer.


Below is how the code snippet of the auto generated code looks like.

public partial class WebForm1 {
        
        /// 
        /// form1 control.
        /// 
        /// 
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// 
        protected global::System.Web.UI.HtmlControls.HtmlForm form1;
        
        /// 
        /// Button1 control.
        /// 
        /// 
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// 
        protected global::System.Web.UI.WebControls.Button Button1;
        
        /// 
        /// Label1 control.
        /// 
        /// 
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// 
        protected global::System.Web.UI.WebControls.Label Label1;
    }


At the same time you would also like to customize the code in some other file so that the auto generation part is not disturbed. For the same ASP.NET provides the “.aspx.cs” file which is a partial class where in you can go put your own custom logic.

public partial class WebForm1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            // Your custom logic
        }
    }


This is only possible when the class is split in two physical files but united via the partial keyword. So if you see any ASP.NET behind code class files it’s marked by the word partial.
So by using the partial keyword in ASP.NET the Microsoft team has made VS and developer work side by side thus not fiddling with each other’s code and thus increasing productivity.


Use number 2:- LINQ and Entity framework

LINQ and EF also use partial classes and methods heavily because of the auto generation nature of these technologies. So when you drag tables in these framework they create auto generated classes as shown in the below figure.

In the below figure you can see how the auto generated code has partial classes and partial methods.




The partial methods later can be extended to put custom logic. For instance you can see in the below code for the above autogenerated class “tblCustomer” we have used partial methods to override the “OnCustomerCodeChanged” event to ensure that customer code is not more than 8 length.

public partial class tblCustomer
    {
        partial void OnCustomerCodeChanged()
        {
            if (_CustomerCode.Length > 8)
            {
                throw new Exception("Customer code can not be greater than 8");
            }
        }
    }

So by using partial classes and partial methods, LINQ and EF framework keep auto generating classes and by using partial methods we can customize the class with our own logic. 

Use number 3:- Better maintenance by compacting large classes

The other important use of partial classes is for better maintenance of the project. If you have large classes with lots of methods as shown in the below figure , it’s a bit pain to maintain those classes.


By using partial classes you can split them in to physical files as shown in the below figure thus making your project better and easy to maintain.


Use number 4:- Multiple people working on the same class


The last and final real time I see of partial classes is when we want simultaneously two developers to work in the same class. I agree this can be a very rare use as there are better options like using a version control software like TFS or Sub version, but in case you want something quick and local this option is not bad at all.

You can also watch my 500 videos on different technologies like .NET, C#, Silverlight, Azure, VSTS, WCF, WPF, WWF, Share Point, design patterns, UML and lots more.

For other author's blog on important .NET interview questions articles.

Monday, January 9, 2012

C# interview question: - Explain partial methods in partial classes of C# and .NET?

Partial methods are important components of partial classes. Read and click on the following link in case you are new to partial classes.

Partial methods helps us to define a method definition in one of the physical files and we can implement that method in the other physical files as shown in the below figure.

In the below figure you can see we have defined “Validate” method in “Customer1.cs” and this validate method is implemented in “Customer2.cs”. Please note the partial keywords attached to both of these methods.

Figure: -
Also see the following video on Partial methods: -



Click for more learning stuffs on c# interview questions and answers

Regards,

Click it for author’s more training stuffs on Most asked c# interview questions

Saturday, January 7, 2012

C# interview questions: - Show partial classes in C# and .NET?

A partial class allows a single class to be divided in to two separate physical files. During compile time these files get compiled in to single class. For instance you can see in the below figure we have the customer class divided in to two different files “customer1.cs” and “customer2.cs”.

During compilation these files gets compiled in to single class internally. So when you create an object of the customer class you will be able to see methods lying in both the physical files. For instance you can see “Add” method belongs to “customer1.cs” and “Delete” method belongs to “customer2.cs” , but when the customer object is created we can see both “Add” and “Delete” methods.


Figure: -
Also want to see in the form of video to understand in better form see the following video on partial class: -



Visit for more interview questions and answers for c#

Regards,

For more author's blog on Most asked c# interview questions

Thursday, January 5, 2012

.NET interview questions: -Explain V-model and its working in testing?

If you are senior software professional this .NET interview questions may come across to check your skills on testing. If you new to this question then just go through it before the interview and if you are aware of it just revise it.

This type of model was developed by testers to emphasis the importance of early testing. In this model testers are involved from requirement stage itself. So below is the diagram which shows how for every stage some testing activity is done to ensure that the project is moving as planned.

For instance,

  • In requirement stage we have acceptance test documents created by the testers. Acceptance test document outlines that if these test pass then customer will accept the software.
  • In specification stage testers create the system test document. In the coming section system testing is explained in more elaborate fashion.
  • In design stage we have integration documents created by the testers. Integration test documents define testing steps of how the components should work when integrated. For instance you develop a customer class and product class. You have tested the customer class and the product class individually. But in practical scenario the customer class will interact with the product class. So you also need to test is the customer class interacting with product class properly.
  • In implement stage we have unit documents created by the programmers or testers.
Lets try to understand every of this testing phase in more detail.

Unit Testing
Starting from the bottom the first test level is "Unit Testing". It involves checking that each feature specified in the "Component Design" has been implemented in the component. In theory an independent tester should do this, but in practice the developer usually does it, as they are the only people who understand how a component works. The problem with a component is that it performs only a small part of the functionality of a system, and it relies on co-operating with other parts of the system, which may not have been built yet. To overcome this, the developer either builds, or uses special software to trick the component into believe it is working in a fully functional system.

Integration Testing
As the components are constructed and tested they are then linked together to check if they work with each other. It is a fact that two components that have passed all their tests, when connected to each other produce one new component full of faults. These tests can be done by specialists, or by the developers.

Integration Testing is not focused on what the components are doing but on how they communicate with each other, as specified in the "System Design". The "System Design" defines relationships between components.

The tests are organized to check all the interfaces, until all the components have been built and interfaced to each other producing the whole system.

System Testing
Once the entire system has been built then it has to be tested against the "System Specification" to check if it delivers the features required. It is still developer focused, although specialist developers known as systems testers are normally employed to do it.
In essence System Testing is not about checking the individual parts of the design, but about checking the system as a whole. In fact it is one giant component.
System testing can involve a number of specialist types of test to see if all the functional and non-functional requirements have been met. In addition to functional requirements these may include the following types of testing for the non-functional requirements:
  • Performance - Are the performance criteria met?
  • Volume - Can large volumes of information be handled?
  • Stress - Can peak volumes of information be handled?
  • Documentation - Is the documentation usable for the system?
  • Robustness - Does the system remain stable under adverse circumstances?
There are many others, the need for which is dictated by how the system is supposed to perform.

Acceptance Testing
Acceptance Testing checks the system against the "Requirements". It is similar to systems testing in that the whole system is checked but the important difference is the change in focus:
Systems testing checks that the system that was specified has been delivered. Acceptance Testing checks that the system will deliver what was requested.
The customer should always do acceptance testing and not the developer. The customer knows what is required from the system to achieve value in the business and is the only person qualified to make that judgment. This testing is more of getting the answer for whether is the software delivered as defined by the customer. It’s like getting a green flag from the customer that the software is up to the expectation and ready to be used.


Figure: - V model cycle flow

Also get a glance on the following video on Unit testing: -



Click for more learning stuffs on important Dotnet interview questions

Regards,

Click it for author’s more training stuffs on Most asked Dotnet interview question