Interview Questions for freshers part -2



Q1)difference between array and stack
Ans)
There are two main differences between an array and a stack. Firstly, an array can be multi-dimensional, while a stack is strictly one-dimensional. Secondly, an array allows direct access to any of its elements, whereas with a stack, only the 'top' element is directly accessible; to access other elements of a stack, you must go through them in order, until you get to the one you want
------------------------------------------
Q2)Suppose you have a DataTable having 100,000 rows and 50 columns. Now you've create array of perticular column values, how will you do that?
Ans)
It's simple.
for C#
object[] arr = Array.ConvertAll(dataTable.Select(), (DataRow r) => r[]);
for VB
dim arr as Object() = Array.ConvertAll(Of DataRow, Object)(dataTable.Select(), Function(r as DataRow) r());
------------------------------------------------------------
Q3)Can we assign values to read only variables?if yes then how?
Ans)
yes, we can assign values to read only variables either at a time of declaration or in constructors
-------------------------------------------------------------------
4)Difference between Abstract class and interface?
Ans)
1.Through the abstract class we cannot achieve the multiple inheritance in c-sharp. while by interface we can.
2. We can declare the access modifier in abstract class but not in interface. Because by default everything in interface is public
-----------------------------------------------------------------------
5)You can derive an abstract class from another abstract class. In that case, in the child class it is optional to make the implementation of the abstract methods of the parent class....!
Ans)
Select from following answers:
True
False
No Idea
True
If the derived class is also an abstract class then it is not mandatory to implement the abstract method of the parent class.
-------------------------------------------------------------------------------
6)Can you prevent a class from overriding ?
Ans)Yes you can prevent a class from overriding if you define a class as "Sealed " then you can not inherit the class any further.
------------------------------------------------------------------
7)What is the difference between N-layer and N-tier architecture?
Ans)
N-layers of application may reside on the same physical computor(same tier) and the components in each layer communicates with the components of other layer by well defined interfaces.Layered architecture focuses on the grouping of related functionality within an application into distinct layers that are stacked vertically on top of each other.Communication between layers is explicit and loosely coupled.With strict layering, components in one layer can interact only with componentsin the same layer or with components from the layer directly below it.
The main benefits of the layered architectural style are:
Abstraction,Isolation, Manageability, Performance, Reusability, Testability.
N-tiers architectue usually have atleast three separate logical parts,each located on separate physical server.Each tier is responsible with specific functionality.Each tier is completely independent from all other tier, except for those immediately above and below it.Communication between tiers is typically asynchronous in order to support better scalability.
The main benifit of tier achitecture styles are
1.Maintainability. Because each tier is independent of the other tiers, updates or changes can be carried out without affecting the application as a whole.
2.Scalability. Because tiers are based on the deployment of layers, scaling out an application is reasonably straightforward.
3.Flexibility. Because each tier can be managed or scaled independently, flexibility is increased.
4.Availability. Applications can exploit the modular architecture of enabling systems using easily scalable components, which increases availability.