OOP's

Object Oriented Concepts - Object Code

Question: What do u mean by Function Overloading ?
Answer: When more than one function is created with the same name, but different is of there arguments . In other words, function names can be overloaded. A function may also have the same name as an attribute. In the case that there is an ambiguity between a function on a complex type and an attribute of the complex type, the attribute will always be used.

Question: What Is OOPS ?
Answer: OOPs is an Object Oriented Programming language,which is the extension of Procedure Oriented programming language.OOPS reduce the code of the program because of the extensive feature of Polymorphism. OOPS have many properties such as Data-Hiding,Inheritence,Data Absraction,Data Encapsulation and many moreEverything in the world is an object. The type of the object may vary. In OOPS, we get the power to create objects of our own, as & when required.

Question: what is Class ?
Answer:A group of objects that share a common definition and that therefore share common properties, operations, and behavior. A user-defined type that is defined with the class-key 'class,' 'struct,' or 'union.' Objects of a class type consist of zero or more members and base class objects.Classes can be defined hierarchically, allowing one class to be an expansion of another, and classes can restrict access to their members.

Question: What is Constructor?
Answer:When we create instance of class a special method of that class, called that is constructor. Similarly, when the class is destroyed, the destructor method is called. These are general terms and usually not the actual member names in most object-oriented languages. It is initialized using the keyword New, and is destroyed using the keyword Finalize.

Question: What is Abstract Class ?
Answer:Classes that cannot be instantiated. We cannot create an object from such a class for use in our program. We can use an abstract class as a base class, creating new classes that will inherit from it. Creating an abstract class with a certain minimum required level of functionality gives us a defined starting point from which we can derive non-abstract classes. An abstract class may contain abstract methods & non-abstract methods. When a class is derived from an abstract class, the derived class must implement all the abstract methods declared in the base class. We may use accessibility modifiers in an abstract class.An abstract class can inherit from a non-abstract class. In C++, this concept is known as pure virtual method.

Question: What is ValueType?
Answer:Value Types - Value types are primitive types. Like Int32 maps to System.Int32, double maps to System.double.All value types are stored on stack and all the value types are derived from System.ValueType. All structures and enumerated types that are derived from System.ValueType are created on stack, hence known as ValueType.In value type we create a copy of object and uses there value its not the original one.

Question: What is diff. between abstract class and an interface?
Answer: An abstract class and Interface both have method only but not have body of method.The difference between Abstract class and An Interface is that if u call Ablstract class then u have to call all method of that particular Abstract class but if u call an Interface then it is not necessary that u call all method of that particular interface.Method OverLoading:-Return type, Parameter type, parameter and body of method number may be different.Method Overriding:- Return type, Parameter type, Parameter Number all must be same . Only body of method can change.

Question:-How ADO.NET come into existence ?
Answer: DAO (data access model) is the first Data Access Model that is created for local databases which contains built-in Jet engine which overcome with some problem like performance and functionality issues. After this RDO (Remote Data Object) and ADO (Active Data Object) comes in market which basically designed for Client Server applications but soon ADO is more comfort then RDO. ADO a good architecture. ADO contained all the data in a recordset object which creates problems when implemented on the network where firewalls exist. Because ADO was a connected data access, which make connection open until the application is closed. This creates issue like database security and network traffic. Because open database connections use system resources to a maximum extent making the system performance less effective. This helps in developing of ADO.NET.

Question: What is Asynchronous Database Commands ?
Answer:- When we execute any database. Thread that executing the command waits before the command get fully executing before executing any additional code. Thread is blocked for another process. But Asynchronous Database Commands solve this problem when database command is executing the current thread can continue on other process.Thread can execute a no of database command. There are two benefits of using Asynchronous Database Commands.
1) Executing Multiple Databse Commands simultaneously improve performance.
2) Because ASP.Net framework uses a limited pool service for request. Whenany request for a page is comes its assign a thread to handle the request. If framework is out of thread then job is in gueses we get error 503. But if we are using asynchronous database command then current thread is release back to current thread pool.

Question:-What is Concurrency and its types?
Answer: When two or more people try to update same type of data then Concurrency helps how to handle this situation there are two types of concurrency
Pessimistic:-When one user try to change the data with pessimistic concurrency a lock is placed on the data so that another user cannot change that one after one another can change.
Optimistic:-In this if two user works on the same data and one change that data first then second user cannot change that same data becasue the which he have using is allready changed so he cannot do the change becasue change apply to another data that is changed by first user.

Question: How to start Outlook,NotePad file in AsP.NET with code ?
Answer: Here is the syntax to open outlook or notepad file in ASP.NET VB.NET Process.Start("Notepad.exe") Process.Start("msimn.exe"); C#.NET System.Diagnostics.Process.Start("msimn.exe"); System.Diagnostics.Process.Start("Notepad.exe");v

Question: How to get result from two table in SqlDataReader ?
Answer: string str="Select * from table1;Select * from table2"; cmd.commandtext=str; dr=cmd.executereader();

Question: What is Ref Cursor in .NET and how it is link with ExecuteReader ?
Answer: Ref cursor play its role when doing with the oracle database these comes in ODP.NET. Ref Cursors are objects that link to Oracle server-side cursors.These Ref Cursor can be converted in oracle datareader with this Ref cursor we can get result with query written to pl/sql and the result can be get in .net.Now the question arise why we use Ref Cursor when we have an option of ExceuteReader reson is simple when we need more query in pl/sql means our work is done in pl/sql then we need this ref cursor for getting result set because doennot have direct connection to that table.Becasue advantage of pl/sql we can take two opertion in one query.

Question: Define tool Manage Statistics in SQL Serevr 2000 query ?
Answer: SQL Server creates internal statistics on the rows in all of our tables that is used by the Query Optimizer to select the optimal execution plan for our query. And Query Optimizer helps in doing this.Soome time when statistics isnot maintains then this is done by tool Manage Statistics.We can add,edit or delete for statistics that is maintained by SQL Server.We can experiment with different sets of statistics and see how it affects the query otimizer execution plans.

Question: Some important instruction regarding ADO.NET connection string ?
Answer: When we are making connection string always use Server's IP address not the DNS name if we use IP address it will reduce the time taken for connection to establish.Becasue server IP address is used to get a default or named instance of Sql Server that ls running. if we are running the cluster we have to use the Virtual SQL Server IP address.

Question: How to get database schema information when connection object is establish in ADO.NET ?
Answer: There is a method that helps in getting schema information that is GetSchema() and this method is called in three different ways first way when we call this method without any parameter its return the metadata(table, view, stored procedure.indexes etc).When method is called by passing metadata collection name and filter criteria returns the items from the collection after applying the filter criteria and last way is when we called by passing a metadata collection name returns information about items found in the specified collection.

Question: Which one is better WebService and Remoting ?
Answer: Both of these have little difference WebService helpfull where the user who is using WebService doesnot have the .NET plateform. On the otherside for remoting we need .Net plateform on the both side so from both of this remoting is faster then webservice.So keep in mind which of these are you using if you have .net plateform or other.

Question:-What is DataGrid wheater its a Server Control or something else ?
Answer:DataGrid is Web server control a powerful tool for displaying information from a data source. we can display editable data in a professional-looking grid by setting only a few properties. The grid has a sophisticated object model that provides you with great flexibility in how you display the data.

Question:-Define different execute methods of ADO.NET command object ?
Answer: ExecuteScalar:- This method returns a single value from the first row and first column of the result get from the execution of SQL query.
ExecuteNonQuery:- This method executes the DML SQL query just like insert, delete or update and then returns the number of rows affected by the action.
ExecuteReader:- This method returns DataReader object which is a forward-only resultset.
ExecuteXMLReader:- This method is available for SQL Server 2000 or later. Upon execution it builds XMLReader object from standard SQL query.


Question:-What DataReader class do in ADO.NET ?
Answer:To get read-only and forward only access to data we use DataReader .the DataReader object reduces the system overhead because one row at a time is taken into memory so it is quite lightweight. To get second object connection is reconnected. We can create a DataReader object by execute Execute readre() method. There are two Data Reader class one is SqlDataReader and other is OleDbDataReader.

Question:-Why is ADO.NET serialization slower than ADO ?
Answer: ADO uses binary serialization while ADO.NET uses text based serialization. Since the text takes more space, it takes longer to write it out.
Question:-Is XML is a component of ADO.NET ?
Answer: The answer of this question is always Yes because XML is an important component of ADO.NET architecture .ADO.NET use XML to store and transfer data.We not have to convert data to XML format.Datasets helps XML to integrate with ADO.NET. XML schema plays a role to get table definition,column,datatypes and constraints helps DataSet.

Question:- How to check if the Dataset has records ?
Answer:
if ds.Tables(0).Rows.Count= 0 then
'No record
else
'record found

Question:- What is the significance of CommandBehavior.CloseConnection ?
Answer: To avoid having to explicitly close the connection associated with the command used to create either a SqlDataReader or and OleDbDataReader, pass the CommandBehavior.CloseConnection argument to the ExecuteReader method of the Connection.

dr= cmd.ExecuteReader(CommandBehavior.CloseConnection);

The associated connection will be closed automatically when the Close method of the Datareader is called. This makes it all the more important to always remember to call Close on your datareaders.

Question:-Which method do you invoke on the DataAdapter control to load your generated dataset with data?
Answer: The Fill() method.

Question:-What is Dataset and Diffgram?
Answer: When sending and retrieving a DataSet from an XML Web service, the DiffGram format is implicitly used. Additionally, when loading the contents of a DataSet from XML using the ReadXml method, or when writing the contents of a DataSet in XML using the WriteXml method, you can select that the contents be read or written as a DiffGram. For more information, see Loading a DataSet from XML and Writing a DataSet as XML Data. While the DiffGram format is primarily used by the .NET Framework as a serialization format for the contents of a DataSet, you can also use DiffGrams to modify data in tables in a Microsoft SQL Server™ 2000 database.

Question:-What is typed dataset ?
Answer: A typed dataset is very much similar to a normal dataset. But the only difference is that the sehema is already present for the same. Hence any mismatch in the column will generate compile time errors rather than runtime error as in the case of normal dataset. Also accessing the column value is much easier than the normal dataset as the column definition will be available in the schema.

Question:-How can you provide an alternating color scheme in a Repeater control?
Answer: AlternatingItemTemplate Like the ItemTemplate element, but rendered for every other row (alternating items) in the Repeater control. You can specify a different appearance for the AlternatingItemTemplate element by setting its style properties.

Question:-What are good ADO.NET object(s) to replace the ADO Recordset object?
Answer: There are alot...but the base once are SqlConnection, OleDbConnection, etc...

Question:-Can you explain the difference between an ADO.NET Dataset and an ADO Recordset?
Answer:Valid answers are:
• A DataSet can represent an entire relational database in memory, complete with tables, relations, and views.
• A DataSet is designed to work without any continuing connection to the original data source.
• Data in a DataSet is bulk-loaded, rather than being loaded on demand.
• There's no concept of cursor types in a DataSet.
• DataSets have no current record pointer You can use For Each loops to move through the data.
• You can store many edits in a DataSet, and write them to the original data source in a single operation.
• Though the DataSet is universal, other objects in ADO.NET come in different versions for different data sources.

Question:-What are the differences between Datalist DataGrid and datarepeater ?
Answer:DataList
• Has table appearence by default
• Has no autoformat option
• has no default paging & sorting options
• can define separators between elements using template
DataGrid
• Has a grid appearence by default
• has a autoformat option
• has default paging and sorting
• has no separator between elements
DataRepeater
• simple,read-only output, has no built in support for selecting or editing items, has no DEFAULT APPEARENCE, has no default paging.


What is an Interface?
An interface is a contract & defines the requisite behavior of generalization of types.
An interface mandates a set of behavior, but not the implementation. Interface must be inherited. We can't create an instance of an interface.
An interface is an array of related function that must be implemented in derived type. Members of an interface are implicitly public & abstract.
An interface can inherit from another interface.

What is Sealed modifiers?
Sealed types cannot be inherited & are concrete.
Sealed modifiers can also be applied to instance methods, properties, events & indexes. It can't be applied to static members.Sealed members are allowed in sealed and non-sealed classes.

What is Abstract Class?
Abstract class exists extensively for inheritance. We can't create an instance of an abstract class. Abstract type must be inherited.Static, Value Types & interface doesn't support abstract modifiers.Static members cannot be abstract. Classes with abstract member must also be abstract.

What is New modifiers?
The new modifiers hides a member of the base class. C# supports only hide by signature.

What is Virtual keyword?
This keyword indicates that a member can be overridden in a child class. It can be applied to methods, properties, indexes and events.

What is Inheritance?
It provides a convenient way to reuse existing fully tested code in different context thereby saving lot of coding.Inheritance of classes in C# is always implementation Inheritance.

What is Static Method?
It is possible to declare a method as Static provided that they don't attempt to access any instance data or other instance methods.

What is Static field?
To indicate that a field should only be stored once no matter how many instance of the class we create.

What is Class?
A Class is the generic definition of what an object is a template.
The keyword class in C# indicates that we are going to define a new class (type of object)

What is Object?
Object is anything that is identifiable as a single material item.

Can Struct be inherited?
No, Struct can't be inherited as this is implicitly sealed.

What is Virtual method?
Virtual Method has implementation & provide the derived class with the option to override it.

What is Abstract method?
Posted by: Raja | Show/Hide Answer
Abstract method doesn't provide the implementation & forces the derived class to override the method.

What is Polymorphisms?
Posted by: Raja | Show/Hide Answer
Polymorphism means one interface and many forms. Polymorphism is a characteristics of being able to assign a different meaning or usage to something in different contexts specifically to allow an entity such as a variable, a function or an object to have more than one form.

There are two types of Polymorphism.
Compile time: function or operator overloading
Runtime: Inheritence & virtual functions
1. Write a simple Windows Forms MessageBox statement.
System.Windows.Forms.MessageBox.Show("Hello, Windows Forms");
2. Can you write a class without specifying namespace? Which namespace does it belong to by default??
Yes, you can, then the class belongs to global namespace which has no name. For commercial products, naturally, you wouldn’t want global namespace.
3. You are designing a GUI application with a window and several widgets on it. The user then resizes the app window and sees a lot of grey space, while the widgets stay in place. What’s the problem? One should use anchoring for correct resizing. Otherwise the default property of a widget on a form is top-left, so it stays at the same location when resized.
4. How can you save the desired properties of Windows Forms application? .config files in .NET are supported through the API to allow storing and retrieving information. They are nothing more than simple XML files, sort of like what .ini files were before for Win32 apps.
5. So how do you retrieve the customized properties of a .NET application from XML .config file? Initialize an instance of AppSettingsReader class. Call the GetValue method of AppSettingsReader class, passing in the name of the property and the type expected. Assign the result to the appropriate variable.
6. Can you automate this process? In Visual Studio yes, use Dynamic Properties for automatic .config creation, storage and retrieval.
7. My progress bar freezes up and dialog window shows blank, when an intensive background process takes over. Yes, you should’ve multi-threaded your GUI, with taskbar and main form being one thread, and the background process being the other.
8. What’s the safest way to deploy a Windows Forms app? Web deployment: the user always downloads the latest version of the code; the program runs within security sandbox, properly written app will not require additional security privileges.
9. Why is it not a good idea to insert code into InitializeComponent method when working with Visual Studio? The designer will likely throw it away; most of the code inside InitializeComponent is auto-generated.
10. What’s the difference between WindowsDefaultLocation and WindowsDefaultBounds? WindowsDefaultLocation tells the form to start up at a location selected by OS, but with internally specified size. WindowsDefaultBounds delegates both size and starting position choices to the OS.
11. What’s the difference between Move and LocationChanged? Resize and SizeChanged? Both methods do the same, Move and Resize are the names adopted from VB to ease migration to C#.
12. How would you create a non-rectangular window, let’s say an ellipse? Create a rectangular form, set the TransparencyKey property to the same value as BackColor, which will effectively make the background of the form transparent. Then set the FormBorderStyle to FormBorderStyle.None, which will remove the contour and contents of the form.
13. How do you create a separator in the Menu Designer? A hyphen ‘-’ would do it. Also, an ampersand ‘&\’ would underline the next letter.
14. How’s anchoring different from docking? Anchoring treats the component as having the absolute size and adjusts its location relative to the parent form. Docking treats the component location as absolute and disregards the component size. So if a status bar must always be at the bottom no matter what, use docking. If a button should be on the top right, but change its position with the form being resized, use anchoring.