Showing posts with label c# Interview. Show all posts
Showing posts with label c# Interview. Show all posts

Wednesday, 27 August 2014

SOLID Design Principles

SOLID : Design Principles

Software design principles represent a set of guidelines that helps us to avoid having a bad design. The design principles are associated to Robert Martin who gathered them in "Agile Software Development: Principles, Patterns, and Practices". 
According to Robert Martin there are 3 important characteristics of a bad design that should be avoided:
  • Rigidity - It is hard to change because every change affects too many other parts of the system.
  • Fragility - When you make a change, unexpected parts of the system break.
  • Immobility - It is hard to reuse in another application because it cannot be disentangled from the current application.

Following 2 characters should be taken care during designing any software:
  • High Cohesion - How focused are the responsibilities of the modules you are designing.
  • Low Coupling - The degree to which modules rely on other modules.
Principles Of Object Oriented Class Design (the "SOLID" principles)
S => SRP Single responsibility principle - the notion that an object should have only a single responsibility.

O => OCP Open/closed principle the notion that “software entities … should be open for extension, but closed for modification”. 

L => LSP Liskov substitution principle the notion that “objects in a program should be replaceable with instances of their subtypes without altering the correctness of that program”. 

I=>  ISP Interface segregation principle the notion that “many client specific interfaces are better than one general purpose interface.” 

D => DIP Dependency inversion principle the notion that one should “Depend upon Abstractions. Do not depend upon concretions.” Dependency injection is one method of following this principle.

I think that these form the foundation of Object Oriented design that allows concise, modular, and ultimately maintainable code. This means code that you (or others) can understand and modify easily and without causing unintended consequences for the function of the application in which the code resides.

Although the above design principles are good and helpful, but they should be used intelligently otherwise this may lead to problems.

The other principle , that is of a great importance is YAGNI (You ain't gonna need it).

According to YAGNI:
  • The time spent is taken from adding, testing or improving necessary functionality.
  • The new features must be debugged, documented, and supported.
  • Any new feature imposes constraints on what can be done in the future, so an unnecessary feature now opens the possibility of conflicting with a necessary feature later.[clarification needed]
  • Until the feature is actually needed, it is difficult to fully define what it should do and to test it. If the new feature is not properly defined and tested, it may not work correctly, even if it eventually is needed.
  • It leads to code bloat; the software becomes larger and more complicated.
  • Unless there are specifications and some kind of revision control, the feature may not be known to programmers who could make use of it.
  • Adding the new feature may suggest other new features. If these new features are implemented as well, this may result in a snowball effect towards feature creep.



But then futuristic thinking is also a must while designing a software.
So, you should always take design decisions intelligently.

How to manage effective meetings?

I was recently listening to an interview with Jason Fried, founder of 37 signals and co-author of the book Rework, and it really got me thinking about meetings.  He pointed out that everyone hates meetings, from the lowest workers right up to the top managers, and yet we keep having them.  There are many reasons to hate meetings but here are some of the top ones that I run into.
  1. Interrupts my most productive hours
  2. Often meetings are not relevant to me or my job
  3. Meeting content is relevant but not important enough to warrant a meeting
  4. Meeting leader has no clear goal
  5. Meeting leader cannot manage participants who slow progress
  6. Too many people
So after listening to Jason, I’m convinced that the problem isn’t just about making time in meetings effective.  It is also about reducing the number of meetings.

How can one minimize the number of meetings?  Here are some suggestions.

  1. Use passive communication technologies (eg email, message boards, wikis) that allow team members to respond at their own convenience.
  2. Have scheduled time for not checking any of these passive messages.   For example, no email will be checked from 10:30 to 2:30.  Companies could even go so far as have the email servers not deliver messages during those hours.  But what about urgent messages?  Ok, it happens (which is why we have phones) but with email, everything is urgent…which seems to also mean nothing is urgent.  Having some dead hours will teach employees how to work on other tasks and schedule *urgent* tasks at times when people are able to effectively deal with them.
  3. Have a “no talking, no meetings” morning every week (or month, or whatever works for your company).
  4. Reduce the number of people required to attend meetings.   If too many people are involved in a decision, there can be too much debate and decisions are often worse  since no one really has to take responsibility.
  5. Delegate decisions Bosses have lots of meetings so they can effectively use their time to make many decisions.  The problem is that while the boss’s time may be more effective, everyone who is in the meeting is less effective.  If leaders can delegate decisions, fewer meetings will be required.
  6. Each time you call a meeting, consider if it is possible to resolve the meeting’s goal using some other method such as a short one-on-one chat (and a chat is definitely different from a scheduled meeting).
  7. Stand up meetings I’m ashamed to admit that I have not tried one of these yet but short stand up meetings seem like a great way to eliminate the long sitting meetings that eat up everyone’s time.
And how does this make meetings effective?
  1. When meetings are rare, everyone’s mindset changes a bit to understand that meetings are important.  Time in meetings becomes important.
  2. By reducing meeting participants, it becomes much easier to make decisions.

C# Framework Core

  • Memory 
  •  
  • What is the difference between a primitive type and a reference type?
  • What does the garbage collector do?
    • Handles memory de-allocation for objects
  • How is it implemented? A rough approximation is fine.
    • Basic algorithm
      • Model as a directed graph
      • Each object instance is a vertex
      • Each reference to an instance is an edge (So if one object references another, then there is a directed edge from one to the other)
      • Every so often, a depth first search occurs
        • All objects that are visited are considered “marked”
        • Therefore, unmarked objects are no longer referenced
      • Once the available memory is used, a “sweep” occurs where memory for all unmarked objects is released
      • The method described is called mark and sweep garbage collection.
  • What is generational garbage collection?
    • Some objects exist for longer times than other objects.  They do not need to be continuously checked in the mark and sweep algorithm described above
    • When a sweep occurs, marked objects get promoted to a different graph (a generation) that is not processed as frequently
    • C# has 3 generations
  • What is the difference between Finalize and Dispose?
    • Finalize is a destructor for an object and gets called when the garbage collector destroys the object.  The programmer does not determine when finalize gets called.
    • IDisposable, on the other hand, allows programmers to determine when an object can be destroyed by calling Dispose.  This allows programmatic release of resources like database connections. Note that the memory still is not released until the garbage collector reclaims it.
  • Why would someone want to implement IDisposable?
    • One common reason is to ensure efficient use of limited resources like database connections
    • Another use would be to wrap processes that have specific code that needs to be called at a start and finish point (ie, a database transaction block)
  • How could someone use the using statement to implement IDisposable?
    • using(MyObject obj = new MyObject()){ … }
    • When execution reaches the close }, MyObject’s Dispose method is called
  • What is a WeakReference?  Why would you use one?
    • A reference that doesn’t prevent garbage collection
    • An example use would be to maintain a cache
  • What is the difference between stack memory and heap memory?
    • Stack – contains memory for primitive types & pointers
    • Heap – used to allocate memory for objects that are created
  • What are the memory considerations when using recursion with many levels?

  • What is boxing and unboxing?
    • Boxing – the term use to describe the movement of values from the stack to the heap (so change a value type to a reference type)
    • Unboxing – from heap to stack

CLR

  • What is CLR?
  • What is CLI?
    • Common Language Infrastructure – a specification that .net languages are built on.  The CLR is an implementation of the CLI
  • What is CIL?
    • Common Intermediate Language – .net languages such as C# get compiled to CIL bytecode.  This format is understood by the CLR
  • What is JIT?
    • Just In Time compiler - CIL is compiled at runtime as needed into native code
    • It executes code by using a hybrid of interpreted and ahead-of-time approach.  Code is first interpreted and then the compilied commands are cached for later use.
  • How can JIT code be faster than ahead of time compiled code?
    • The JIT code is interpreted for an computer’s specific hardware configuration whereas ahead-of-time compilied code is written for a set of computers meeting a more general specification.  This means the JIT can take advantage of very specific hardware features.
  • Explain the path from C# source to native code
    • C# gets compiled to CIL
    • CIL is then executed by the CLR.  It does this using a JIT compiler which converts the CIL into native code

Assemblies

  • What is the difference between a service and a standard exe?
  • What is the difference between an exe and a dll?
    • DLL is a library of useful code that can be used by other code when referenced
    • EXEs also have this ability as well.  However, they also offer an entry point that is able to start executing commands
  • What is DLL hell?
    • DLL hell refers to a set of problems caused by DLL sharing in applications before .net.  Multiple programs may share one dll.  When a new program is installed, it may overwrite a previously installed shared DLL with a newer version.  This version may not be backwards compatible breaking programs that were previously running correctly.
  • What is an assembly qualified name?
    • It is a way to ensure that a type is associated with the proper assembly binary
    • TopNamespace.SubNameSpace.ContainingClass+NestedClass, MyAssembly, Version=1.3.0.0, Culture=neutral, PublicKeyToken=b17a5c561934e089
  • What is the GAC? What does the GAC do?
    • The GAC is the global assembly cache.
    • It stores assemblies that are meant to be shared but avoids DLL mentioned above (by using assembly qualified names)
  • How do you add assemblies to the GAC?
    • The most common way is to use a windows installer
    • Using gacutil.exe is another method

Misc

  • What is reflection?
    • Reflection offers the ability to find information about types at runtime and use that information to dynamically create instances and call methods and properties
  • What are some examples of uses for reflection?
    • Custom serialization
    • Custom binding
    • ORM mapping
  • What is the difference between a.Equals(b) and a == b?
    • For value types, the expressions are the same
    • For reference types, a==b is true only when the objects have the same reference (pointer)
    • a.Equals(b), on the other hand, is true for reference types with different pointers provided they have the same value.  An example usage would be for a class that is mapped to a database table.  There could be two different instances of the class with an id of 5.  When using ==, the value would return false.  However, if Equals is appropriately overridden to compare the id, than a.Equals(b) should return true since they have the same id

Primitive Type implementations

Knowing details about primitive types is essential when dealing with many activities like efficiency, boundaries, and memory usage and is something senior developers should be able to at least approximate.  If you don’t know this table, you will never think about it.  However, once you know it, you will be surprised at how often you take these addition details into consideration when developing code.
Type Size Range (signed) Range (unsigned) Order Precision
boolean 8 bits 0 to 1


byte 8 bits -128 to 128 0 to 256 102
short 16 bits -32,768 to 32,767 0 to 65535 104
int 32 bits -2,147,483,648 to 2,147,483,647 0 to 4,294,967,295 109
long 64 bits -922337203685477508 to 922337203685477507 0 to 18446744073709551615 1019
float 32 bits -3.402823e38 to 3.402823e38
1038 7 digits
double 64 bits -1.79769313486232e308 to 1.79769313486232e308
10308 15-16 digits
decimal 128 bits ±1.0 × 10e−28 to ±7.9 × 10e28
1028 29 digits
char 16 bits
0 to 65535 104


How do the MVP, MVC, and MVVM patterns relate? When are they appropriate?

Those who know me know that I have a passion for software architecture and after developing projects using Model-View-ViewModel (MVVM), Model-View-Presenter (MVP), and Model-View-Controller (MVC),  I finally feel qualified to talk about the differences between these architectures.  The goal of this article is to clearly explain the differences between these 3 architectures.

First, the let’s define common elements.  All 3 of the architectures are designed to separate the view from the model.

Model

  • Domain entities & functionality
  • Knows only about itself and not about views, controllers, etc.
  • For some projects, it is simply a database and a simple DAO
  • For some projects, it could be a database/file system, a set of entities, and a number of classes/libraries that provide additional logic to the entities (such as performing calculations, managing state, etc)
Implementation: Create classes that describe your domain and handle functionality.  You probably should end up with a set of  domain objects and a set of classes that manipulate those objects.

View

  • Code that handles the display
  • Note that view related code in the codebehind is allowed (see final notes at the bottom for details)
Implementation:  HTML, WPF, WindowsForms, views created programmatically – basically code that deals with display only.

Differences between Presenters, ViewModels and Controllers

This is the tricky part.  Some things that Controllers, Presenters, and ViewModels have in common are:
  • Thin layers
  • They communicate with the model and the view
The features of each.

Presenter (Example: WinForms)

  • 2 way communication with the view
  • View Communication: The view communicates with the presenter by directly calling functions on an instance of the presenter.  The presenter communicates with the view by talking to an interface implemented by the view.
  • There is a single presenter for each view
Implementation:
  • Every view’s codebehind implements some sort of IView interface.  This interface has functions like displayErrorMessage(message:String), showCustomers(customers:IList<Customer>), etc.  When a function like showCustomers is called in the view, the appropriate items passed are added to the display.  The presenter corresponding to the view has a reference to this interface which is passed via the constructor.
  • In the view’s codebehind, an instance of the presenter is referenced.  It may be instantiated in the code behind or somewhere else.  Events are forwarded to the presenter  through the codebehind.  The view never passes view related code (such as controls, control event objects, etc) to the presenter.
A code example is shown below.
//the view interface that the presenter interacts with
public interface IUserView
{
    void ShowUser(User user);
    ...
}
 
//the view code behind
public partial class UserForm : Form, IUserView
{
    UserPresenter _presenter;
    public UserForm()
    {
        _presenter = new UserPresenter(this);
        InitializeComponent();
    }
 
    private void SaveUser_Click(object sender, EventArgs e)
    {
        //get user from form elements
        User user = ...;
        _presenter.SaveUser(user);
    }
 
    ...
}
 
public class UserPresenter
{
    IUserView _view;
    public UserPresenter(IUserView view){
        _view = view;
    }
 
    public void SaveUser(User user)
    {
 ...
    }
    ...
}

ViewModel (Example: WPF, Knockoutjs)

  • 2 way communication with the view
  • The ViewModel represents the view.  This means that fields in a view model usually match up more closely with the view than with the model.
  • View Communication:  There is no IView reference in the ViewModel.  Instead, the view binds directly to the ViewModel.  Because of the binding, changes in the view are automatically reflected in the ViewModel and changes in the ViewModel are automatically reflected in the view.
  • There is a single ViewModel for each view
Implementation:
  • The view’s datacontext is set to the ViewModel.  The controls in the view are bound to various members of the ViewModel.
  • Exposed ViewModel proproperties implement some sort of observable interface that can be used to automatically update the view (With WPF this is INotifyPropertyChanged; with knockoutjs this is done with the functions ko.observable() and ko.observrableCollection())

Controller (Example: ASP.NET MVC Website)

  • The controller determines which view is displayed
  • Events in the view trigger actions that the controller can use to modify the model or choose the next view.
  • There could be multiple views for each controller
  • View Communication:
    • The controller has a method that determines which view gets displayed
    • The view sends input events to the controller via a callback or registered handler.  In the case of a website, the view sends events to the controller via a url that gets routed to the appropriate controller and controller method.
    • The view receives updates directly from the model without having to go through the controller.
      • Note: In practice, I don’t think this particular feature of MVC is employed as often today as it was in the past.  Today, I think developers are opting for MVVM (or MVP) over MVC in most situations where this feature of MVC would have been used.  Websites are a situation where I think MVC is still a very practical solution.  However, the view is always disconnected from the server model and can only receive updates with a request that gets routed through the controller.  The view is not able to receive updates directly from the model.
Implementation (for web):
  • A class is required to interpret incoming requests and direct them to the appropriate controller.  This can be done by just parsing the url.  Asp.net MVC does it for you.
  • If required, the controller updates the model based on the request.
  • If required, the controller chooses the next view based on the request.  This means the controller needs to have access to some class that can be used to display the appropriate view.  Asp.net MVC provides a function to do this that is available in all controllers.  You just need to pass the appropriate view name and data model.
MVVM and MVP implementation seem pretty straightforward but MVC can be a little confusing.  The diagram below from Microsoft’s Smart Client Factory documentation does a great job at showing MVC communication.  Note that the controller chooses the view (ASP.NET MVC) which is not shown in this diagram.  MVVM interactions will look identical to MVP (replace Presenter with ViewModel).  The difference is that with MVP, those interactions are handled programmatically while with MVVM, they will be handled automatically by the data bindings.

General rules for when to use which?

MVP
  • Use in situations where binding via a datacontext is not possible.
  • Windows Forms is a perfect example of this.  In order to separate the view from the model, a presenter is needed.  Since the view cannot directly bind to the presenter, information must be passed to it view an interface (IView).
MVVM
  • Use in situations where binding via a datacontext is possible.  Why?  The various IView interfaces for each view are removed which means less code to maintain.
  • Some examples where MVVM is possible include WPF and javascript projects using Knockout.
MVC
  • Use in situations where the connection between the view and the rest of the program is not always available (and you can’t effectively employ MVVM or MVP).
  • This clearly describes the situation where a web API is separated from the data sent to the client browsers.  Microsoft’s ASP.NET MVC is a great tool for managing such situations and provides a very clear MVC framework.

Final notes

  • Don’t get stuck on semantics.  Many times, one of your systems will not be purely MVP or MVVM or MVC.  Don’t worry about it.  Your goal is not to make an MVP, MVVM, or MVC system.  Your goal is to separate the view, the model, and the logic that governs both of them. It doesn’t matter if your view binds to your ‘Presenter’, or if you have a pure Presenter mixed in with a bunch of ViewModels.  The goal of a maintainable project is still achieved.
  • Some evangelists will say that your ViewModels (and Presenters) must not make your model entities directly available for binding to the view.   There are definitely situations where this is a bad thing.  However, don’t avoid this for the sake of avoiding it.  Otherwise, you will have to constantly be copying data between your model and ViewModel.  Usually this is a pointless waste of time that results in much more code to maintain.
  • In line with the last point, if using WPF it makes sense to implement INotifyPropertyChanged in your model entities.  Yes, this does break POCO but when considering that INotifyPropertyChanged adds a lot of functionality with very little maintenance overhead , it is an easy decision to make.
  • Don’t worry about “bending the rules” a bit so long as the main goal of a maintainable program is achieved
  • Views
    • When there is markup available for creating views (Xaml, HTML, etc), some evangelists may try to convince developers that views must be written entirely in markup with no code behind.  However, there are perfectly acceptable reasons to use the code behind in a view if it is dealing with view related logic.  In fact, it is the ideal way to keep view code out of your controllers, view models, and  presenters.  Examples of situations where you might use the code behind include:
      • Formatting a display field
      • Showing only certain details depending on state
      • Managing view animations
    • Examples of code that should not be in the view
      • Sending an entity to the database to be saved
      • Business logic
Happy coding.

Monday, 11 August 2014

Difference between Object and Var and Dynamic type in C#

C# is rich in data type. It provides three types Object, Var and Dynamic to store data of any type. In this article, I am trying to explore the differences among these three.

Difference between Object, Var and Dynamic type

Object
1.       Object was introduced with C# 1.0
2.       It can store any kind of value, because object is the base class of all type in .NET framework.
3.       Compiler has little information about the type.
4.       Object type can be passed as method argument and method also can return object type.
5.       Need to cast object variable to original type to use it and performing desired operations.
6.       Cause the problem at run time if the stored value is not getting converted to underlying data type.
7.       Useful when we don’t have more information about the data type.

Var
1.       Var was introduced with C# 3.0
2.       It can store any type of value but It is mandatory to initialize var types at the time of declaration.
3.       It is type safe i.e. Compiler has all information about the stored value, so that it doesn't cause any issue at run-time.
4.       Var type cannot be passed as method argument and method cannot return object type. Var type work in the scope where it defined.
5.       No need to cast because compiler has all information to perform operations.
6.       Doesn't cause problem because compiler has all information about stored value.
7.       Useful when we don’t know actual type i.e. type is anonymous.

Dynamic
1.       Dynamic was introduced with C# 4.0
2.       It can store any type of the variable, similar to old VB language variable.
3.       It is not type safe i.e. Compiler doesn't have any information about the type of variable.
4.       Dynamic type can be passed as method argument and method also can return dynamic type.
5.       Casting is not required but you need to know the properties and methods related to stored type.
6.       Cause problem if the wrong properties or methods are accessed because all the information about stored value is get resolve only at run time.
7.                  7           Useful when we need to code using reflection or dynamic languages or with the COM objects, because             you need to write less code.

Tuesday, 16 October 2012

What is the difference between new and override?

The differences between the two C# keywords is due to polymorphism. When a virtual method is called on a reference, the actual type of the object to which the reference refers is used to determine which method implementation should be used. When a method of a base class is overridden in a derived class (subclass), the version defined in the derived class is used. This is so even should the calling application be unaware that the object is an instance of the derived class.

The following example illustrates the override keyword:
public class BaseClass
{
    public virtual void AMethod()
    {
    }
}
 
public class DerivedClass : BaseClass
{
    public override void AMethod()
    {
    }
}
 
// ...
 
BaseClass baseClass = new DerivedClass();
baseClass.AMethod();

In the preceding example, DerivedClass.AMethod will be called; because, it overrides BaseClass.AMethod.

If the new keyword were used instead of the override keyword, then the method in the derived class would not override the base class method, but would hide it instead. The following is an example illustrating the new keyword:

public class BaseClass
{
    public virtual void AMethod()
    {
    }
}
 
public class DerivedClass : BaseClass
{
    public new void AMethod()
    {
    }
}
 
// ...
 
BaseClass baseClass = new DerivedClass();
baseClass.AMethod();
 
DerivedClass derivedClass = new DerivedClass();
derivedClass.AMethod();
 
The preceding example will call BaseClass.AMethod first, followed by DerivedClass.AMethod. Effectively, the two methods are unrelated except for the fact that they have the same name.

If neither the new nor overrides keyword is specified, the result is the same as if the new were specified. However, a compiler warning will be generated to ensure that the programmer is aware that a method in the base class is being hidden.

What is the difference between const and static readonly?

The value of a static readonly field is set at runtime; therefore, the value can be modified by the containing class. On the other hand, the value of a const field is set to a compile-time constant.

In the case of static readonly, the containing class is allowed to modify the value only:
  • in the variable declaration (via a variable initializer)
  • in the static constructor (or instance constructors for non-static)
Typically, static readonly is used either when the value is unknown at compile time or if the type of the field is not allowed in a const declaration.
Also, instance readonly fields are allowed.

Note: for reference types, in both cases—static and instance—the readonly modifier only prevents assignment of a new reference to the field. It does not specifically make the object pointed to by the reference immutable.
 
class TestProgram
{
   public static readonly Test test = new Test();
 
   static void Main (string[] args)
   {
      test.Name = "Application";
      test = new Test();  
      // Error: A static readonly field cannot
      // be assigned to (except in a static constructor
      // or a variable initializer).  
    }
}
 
class Test
{
   public string Name;
}
 
On the other hand, if Test were a value type, then assignment to test.Name would be an error.

Sunday, 25 March 2012

Test Number:6-Topic Name: ADO.NET


.Net Framework and C# Basics - Test No : 01 

 Test Number:2 Topics :Assembly, Event, Delegates_exceptions

Test 04 - Reflection, Custom Attributes, Threading, Windows Service

Test No : 05 -Remoting ,Webservices


Topic Name: ADO.NET


_______ is namespace for  the SQL Server provider classes.
a) Sysytem.Data.Oracle
b)  System.Data.SqlClient
c) System.Data.Sql
d) System.Data.Odbc

_________ contains SQL Server data types.
a)System.Data.SqlserverTypes
b) System.Data.Oralce.Types
c) System.Data.OdbcTypes
d)System.Data.SqlTypes

______ Used as wrappers for SQL statements or stored procedure calls.
a)SqlCommand
b)OracleCommand
c)OleDbCommand and ODBCCommand
d) All the above

A syntax for connection string
a)"Server;datbasename=;uid=id;pwd=pwd"
b)“Server=servername;database=dbName;uid=id;pwd=pwd”
c)"add name=con1 ;databasename=db1 ;connectionstring=con1;uid=id;pwd=pwd"
d) None of the above

Can we directly assign a datareader to a gridview
a)Yes
b)No
d) None of above

________is describes the database instance to connect to; each SQL Server process can
 expose several database instances
a) integrated security = SSPI
b) server=(local)
c) None of above
d) database=Northwind( Any database name) 
______________is Executes the command but does not return any output
a) ExecuteNonQuery()
b) ExecuteScalar()
c) ExecuteReader()
d) None of above
____________is Executes the command and returns a typed IDataReader
a) ExecuteNonQuery()
b) ExecuteReader()
c) ExecuteScalar
d)None of above
______________is Executes the command and returns a single value
a) ExecuteNonQuery()
b) ExecuteReader()
c) ExecuteScalar()
d) None of above

____________is  Executes the command and returns an XmlReader object, which can
be used to traverse the XML fragment returned from the database
a) ExecuteNonQuery()
b) Executescalar()
c) ExecuteXmlReader()
d) None of above

Can we get a XML presentation of a table from Dataset?
a)Yes
b)NO

____________class consists of a set of data tables, each of which will have a set of data columns and data rows
a) Data Adapter
b) DataTable
c)  DataSet
d) DataRow

Data adapter includes _______________command objects
a) Select command
b) insert command
c) update command, delete command
d) All of above
A ___________is very similar to a physical database table — it consists of a set of columns with particular
 properties, and might have zero or more rows of data
a)  dataset
b) data table
c) datacoloumn
d) All of above 

________,______________,_____________ and ________________.Used to generate SQL
 commands (such as INSERT, UPDATE, and DELETE statements) from a SELECT statement
a) SqlCommandBuilder
b) OleDbCommandBuilder,   ODBCCommandBuilder
c) OracleCommandBuilder
d) All of above

  where we should  write a connection string
a) in web.config
b)in App.config file
c) Machine Config
d)all of the above

If we use a DataAdapter, we don’t need to open or close database connection explicitly.
a)Yes
b)No

_________________,________________,__________,________________  Used as a forward only,
 connected data reader
a) OleDbDataReader
b) OracleDataReader
c) SqlDataReader
d)  All of the above

 Which method is used to return the database table in XML format?
a)Serialization format
b) Binary format
c)ReadXML
d)Soap Format
What object is used to generate the commands automatically for a specific SqlDataAdapter?
a) sqlConnection
b) sqlCommandBulider
c) dataset
d) sqlDataReader

Which method  of DataTable can copy all the content from DataReader to DataTable.?
a)Copy
b)Load
c)Unload
d)all of the above
__________ object is designed for disconnected use and can contain a set of DataTables
 and include relationships between these tables
a) Data Adapter
b) system.Data
c) Constraint
d) DataSet 

___________a container of data that consists of one or more DataColumns and, when populated,
will have one or more DataRows containing data
a) DataSet
b) DataTable
c) Datacoloumn
d) DataRow

____________class which represent a number of values, akin to a row from a database table,
 or a row from a spreadsheet
a) DataRow
b) DataColoumn
c) DataAdapter
d) DataTable
______________ object contains the definition of a column, such as the name and data type.
a) DataColoumnMapping
b) DataColumn
c) DataTable
d) DataSet 

_______________a link between two DataTable classes within a DataSet class. Used for foreign
 key and master/detail relationships
a) DataAdapter
b) DataSet
c) Constraint
d) DataRelation
_______________class defines a rule for a DataColumn class (or set of data columns),
such as unique values
a) DataRow
b) Constraint
c) DataTable
d) DataSet 



__________________Maps the name of a column from the database with the name of a
 column within a DataTable.
a) DataTableMapping
b) DataColumnMapping
c) Constraint
d) DataAdapter
______________________ Maps a table name from the database to a DataTable within a DataSet
a) DataColoumnMapping
b) DataTableMapping
c) DataSet
d) DataRow
Namespaces expose the ____________________  used in OLE DB .NET data access.
a) Sqlprovider classes
b) Oracleprovider classes
c) ODBCprovider classes
d)  OLE DB provider classes
________________denotes the database server to connect to. SQL Server permits a number
 of separate database server instances to be running on the same machine, and here you're
connecting to the default SQL Server instance
a) database=Northwind (lets say)
b) integrated security=SSPI 
c) server=(local)
d) None of above

________________ uses Windows Authentication to connect to the database, which is highly
recommended over using a username and password within the source code
a) database=Northwind (lets say)
b) integrated security=SSPI 
c) server=(local)
d) None of above
   Which namespace contains following classes: DataSet, DataTable, DataColumn, and DataRow?
a)System.Data.SqlserverTypes
b)System.data.sqlclient
c) system.data
d)system.configuration

Which object can point to the parameter in stored procedure?
a) parametirsed
b)AddParameter
c)ConnectionParameter
d)Parameter
__________ method executes the command and returns a typed data reader object, depending
 on the provider in use
a) ExecuteNonQuery()
b) ExecuteXmlReader()
c) ExecuteReader()
d) None of Above

______________method is commonly used for UPDATE, INSERT, or DELETE statements,
where the only returned value is the number of records affected
a) ExecuteNonQuery()
b) ExecuteScalar()
c) ExecuteReader()
d) None of Above

In many times, it is necessary to return a single result from a SQL statement, such as the count
 of records in a given table than _________ method is used
a) ExecuteNonQuery()
b) ExecuteScalar()
c) ExecuteReader()
d) None of Above

A ___________ is the simplest and fastest way of selecting some data from a data source,
 but also the least capable
a) Datarecorder
b) Datareader
c) XMLReader
d) All the above

The_______________has been designed as an offline container of data. It has no notion of
 database connections
a)  DataSet class
b) DataAdapter
c) DataTable
d) All of above

A ___________ consists of a set of data tables, each of which will have a set of data columns
 and data rows
a)  DataSet class
b) DataAdapter
c) DataTable
d) All of above
________________property of  DataColumnObject  is true, permits the column to be set to DBNull
a) AllowNull
b) AllowDBNull
c) Null
d) None of above
________________ property of DataColumnObject  defines that this column value is automatically
generated as an incre- menting number
a) AllowIncrement
b) AutoIncrement
c) Increment
d) All of above

________________property of DataColumnObject  defines the initial seed value for an AutoIncrement column
a) None of below
b)  AllowIncrement
c) IncrementSeed
d) AutoIncrementSeed

________________property of  DataColumnObject   defines the step between automatically generated
 column values, with a default of one
a) AllowIncrement
b) AutoIncrement
c) AutoIncrementSeed
d) AutoIncrementStep
________________ property of DataColumnObject can be used for displaying the name of the
 column on screen.
a) ColumnName
b) ColumnMapping
c) Caption
d) All of above
________________property of DataColumnObject can define a default value for a column
a) DefaultValue
b) DataType
c) Current
d) Default
Can we add one SQL Server table and another Oracle table inside a single DataSet?
a)Yes
b)NO
_____________________is datarowstate which indicates that the row has not been changed
 since the last call to AcceptChanges().
a) Original
b) Modified
c) Expression
d) Proposed
_____________________ is datarowstate which  indicates that the row has not been changed
since the last call to AcceptChanges().
a) Added
b) Deleted
c) Depatched
d) Unchanged
_____________________ is datarowstate state which indicates that the row has been newly
added to a DataTable's Rows collection
a) Added
b) Deleted
c) Depatched
d) Unchanged
________________returns an integer representing how many table rows were affected by the query
a) ExecuteNonQuery()
b) ExecuteScalar()
c) ExecuteReader()
d) None of Above
__________- these are the extreamly useful controls to output the data on the web pages
a) All of below
b) Repeater
c) DetailsView, FormView
d) GridView, DataList

All data-bindable controls support  the top- level  ________________ method.
a) Eval()
b) Bind()
c) DataBind()
d) All of above
Changes made to the DataSet need to save on Server, which method helps to do this?
a)Updation
b)Update
c)Updatemethod()
d)update()
The _____________ expression is identical but allows to insert data into attributes of server controls
a) Eval()
b) Bind()
c) DataBind()
d) All of above

Which is a set of operations that must either succeed or fail as a unit?
a)Triggers
b)Sql query
c) Transaction
d)function

What are the 2 methods of DataAdapter, when the connection is open?
a)open connection
b)fill,update
c)fill,open
d)sql connection.open

If we are specifying windows authentication in connection string what element we should add?
a)pool=false;
b)intial integrated=db1;
c)IntegratedSecurity= true
d)None of the above

Which class can be used to implement relationship on client side?
a)Dataset
b)DataRelation
c)DataAdpter
d)DataReader

Which object is used to point location of database?
 a) ConnectionSQlstring
b)ConnectionString
c)ConnectionParameter
d)Connection