Showing posts with label faq. Show all posts
Showing posts with label faq. Show all posts

Wednesday, 29 February 2012

SQL SERVER 2005 interview question answer


Operation must use an updateable query

Microsoft OLE DB Provider for ODBC Drivers error '80004005'
[Microsoft][ODBC Microsoft Access Driver] Operation must use an updateable query.
This error usually happens when you try to insert data into or update data in an Access database. It means that you don't have sufficient permissions to write to the Database.

If you are running the web server yourself then read the FAQ, Checking and Setting up the Correct Permissions on the Server.

If you are not running the server yourself you will need to contact your web space provider and ask them how to sort the problem out. You may need to use a special folder or they may have to setup a system DSN for you or change the permissions on the directory containing the database.

Cannot update. Database or object is read-only.

Microsoft OLE DB Provider for ODBC Drivers error '80004005'
[Microsoft][ODBC Microsoft Access Driver] Cannot update. Database or object is read-only.
This is the most common error that I'm asked about. This error usually happens when you try to insert data into or update data in an Access database. It means that you don't have sufficient permissions to write to the database.

If you are running the web server yourself then read the FAQ, Checking and Setting
up the Correct Permissions on the Server.

If you are not running the server yourself you will need to contact your web space provider and ask them how to sort the problem out. You may need to use a special folder or they may have to setup a system DSN for you or change the permissions on the directory containing the database.

AjaxControlToolkit is undefined OR Sys' is undefined error in ASP.NET AJAX

adding this under httpHandlers:

<add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
Turns out in the web.config nestled under <system.webServer> / <handlers>, I was missing this entry:

<add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />

When we get Error 'HTTP 502 Proxy Error' ?

We get this error when we execute ASP.NET Web pages in Visual Web Developer Web server, because the URL randomly select port number and proxy servers did not recognize the URL and return this error. To resolve this problem we have to change settings in Internet Explorer to bypass the proxy server for local addresses, so that the request is not sent to the proxy.

Operation must use an updateable query" error

Reason: Your database is in a folder where there is no write/change permission.
Resolution:
If using Windows 2000 - IIS5- the {Server}\ASPNET User Account must have Read, Write, and Change Control of the Folder where database resides
If using Windows 2003 - IIS6- the NETWORK SERVICE User Account must have Read, Write, and Change Control of the Folder where database residesGiving EVERYONE account full control will solve your problem too but Never do that as it will expose your system to external attacks within network.

Failed to load viewstate

cause
The exception occurs because the viewstate of the page must be restored to its previous state. This mean we need to re-load any control we loaded dynamically before the page load had being triggered.

Solution :
I was able to get it working by setting the PlaceHolder that I was dynamically adding the control to EnableViewState="False".
Set EnableViewStage=”false” in Page Directive

Deleting is not supported by data source 'SqlDataSource1' unless DeleteCommand is specified.

Solution:

if you need to pass parameters, then use the deleteparameters collection of the control.

get error message Validation of viewstate MAC failed

You have an ASP.NET web application running on a web-farm that does not use sticky sessions - so the requests for a session are not guaranteed to be served the same machine. Occasionally, the users get error message Validation of viewstate MAC failed. What could be one reason that is causing this error?
The most common reason for this error is that the machinekey value in machine.config is different for each server. As a result, viewstate encoded by one machine cannot be decoded by another. To rectify this, edit the machine.config file on each server in the web-farm to have the same value for machinekey.

What does the "Access is Denied" IE error mean?

The "Access Denied" error in any browser is due to the following reason.A javascript in one window or frame is tries to access another window or frame whose document's domain is different from the document containing the script.

Why innerText not working in Firefox

Use innerHTML instead of innerText

Cannot use a leading .. to exit above the top directory

When I do a server.mappath on ../../private, I get this error:Cannot use a leading .. to exit above the top directory.

try to use Server.MapPath("~/private"). It is more reliable. What willhappen when u add another subdirectory... Server.MapPath("~/private") willstill works.

Is there any way to get detailed error information for Win32 errors when using Platform Invoke?

Yes, you can use the FormatMessage Win32 API. Sample projects for C# and VB.NET are enclosed. This is how the declaration looks like:

[DllImport("Kernel32.dll")]

public static extern int FormatMessage(int flags, IntPtr source, int messageId, int languageId, StringBuilder buffer, int size, IntPtr arguments );

Called like so:

// You can call FormatMessage to get a descriptive error message

StringBuilder sbFormatMessage = new StringBuilder(1024);

retVal = Interop.FormatMessage(Interop.FORMAT_MESSAGE_FROM_SYSTEM, IntPtr.Zero, Marshal.GetLastWin32Error(), 0, sbFormatMessage,

sbFormatMessage.Capacity, IntPtr.Zero);

I get an error message "Property cannot be assigned to -- it is read only". How can I set this read only property?

When I try to set a particular font style, say italics, I get an error message "Property cannot be assigned to -- it is read only". How can I set this read only property?


Code such as

tabControl1.Font.Italic = true;

will not work. Instead, you have to create a new Font object, and set the property during its creation. This code
will work.

tabControl1.Font = new Font(tabControl1.Font, FontStyle.Italic);

I get a 'This would cause two bindings in the collection to bind to the same property' error message. What might cause this?

As the message suggests, the code is calling Control.DataBindings.Add twice with what amounts to the same parameters.One way this might happen is if you call the same code more than once in your program to reload your datasource for some reason, and in this code, you have lines such as:

Me.TextBox1.DataBindings.Add("Text", myDataTable, "Col1Name")
Me.TextBox2.DataBindings.Add("Text", myDataTable, "Col2Name")
Me.TextBox3.DataBindings.Add("Text", myDataTable, "Col3Name")

On the second call, this would attempt to add a duplicate binding to the DataBindings collection. One solution is to Clear the DataBindings collection before you add your new binding.

Me.TextBox1.DataBindings.Clear();
Me.TextBox1.DataBindings.Add("Text", myDataTable, "Col1Name")
Me.TextBox2.DataBindings.Clear();
Me.TextBox2.DataBindings.Add("Text", myDataTable, "Col2Name")
Me.TextBox3.DataBindings.Clear();
Me.TextBox3.DataBindings.Add("Text", myDataTable, "Col

When I try to update a dataset I get an error that the system is unable to find "Table"?

Are you calling Update on the dataset like this without specifying the name of the table that you are updating. The problem is that when table names are not given the system assumes a table name of 'Table'. This of course causes the update to fail.

this.dataAdapter.Update(this.dataSet);

If so just change this line to

this.dataAdapter.Update(this.dataSet, "Customers");

// replace 'Customers' with the table that you have

In C++, the code "MyClass ht;" creates an object ht on the stack frame. But in C#, this same code compiles, but gives a runtime error. Why?

MyClass ht; does not create any object. Instead, it creates a variable (a reference) of type MyClass, and sets its value to null. No object is created. To create an object, you need to explicitly call the class contructor with a new.

MyClass ht = new MyClass();

You can also use ht to refer to an instance of MyClass that has been created (with a new) at some other point in your code.

MyClass myClass = new MyClass();

MyClass ht;

ht = myClass; // both ht and myClass are references to the same object...

How can I get rid of the error icon that appears when there is an editing error?

DataTable dt = (DataTable)dataGrid1.DataSource;

foreach(DataRow row in dt.GetErrors())

{

row.RowError = "";

foreach(DataColumn col in dt.Columns)

row.SetColumnError(col, "");

}

session does not working in Web Service

The EnableSession property of the WebMethod attribute enables session state for an XML Web service method. Once enabled, the XML Web service can access the session state collection directly from HttpContext.Current.Session or with the WebService.Session property.

in VB.NET

_

in C#

[System.Web.Services.WebMethod(EnableSession=true)]

Parse error: parse error, unexpected T_STRING

Cause of Error
The problem is the syntax of your code, perhaps you forgot a semi-colon on one of the lines.

How to Fix Them
If you notice that you forgot a simple semi-colon, then insert it and you'll be on your way.

 

Internet Explorer cannot download MyPage.aspx from MyWebSite.com

Why do I get error message "Internet Explorer cannot download MyPage.aspx from MyWebSite.com ..."?

This happens for example, whe you try to export data to excel from a datagrid.
The problem occurs if the server is using Secure Sockets Layer (SSL) and has added one or both of the following HTTP headers to the response message:

Pragma: no-cache
Cache-control: no-cache,max-age=0,must-revalidate

Unable to find script libruary 'WebUIValidation.js'

Why do I get the "Unable to find script libruary 'WebUIValidation.js'" error ?

When you install the .Net framework on your web server, it installs some script files (including the above) under the root folder (usually "C:\inetput\wwwroot" if you do a default installation) . You can then find the above file at "C:\Inetpub\wwwroot\aspnet_client\system_web\1_1_4322", for example.

The above problem could happen if you reconfigured your web root directory to be a different one after you installed ASP.Net in your web server. If that is the case, then run 'aspnet_regiis -c' (utility is under %windir%\Microsoft.NET\Framework\v1.1.4322, for example) or copy over manually the above script files into a similar sub-directory below your current web root directory. Also, if you look at the error message in detail, you will notice where the file is supposed to be.


Why do I get error message "Error creating assembly manifest: Error reading key file 'key.snk' -- The system cannot find the file specified"?

Check the location of the key.snk file relative to the assembly file. Provide an explicit path or a relative path.

Assembly: AssemblyKeyFileAttribute("Drive:\key.snk")

Compiler Error Message: BC30289

My ASP code gives an error "Compiler Error Message: BC30289: Statement cannot appear within a method body. End of method assumed" when changed to .aspx?

Use a script runat=server block instead of the Delimeter syntax to define Subs.Make sure you have proper events associated with the code and have start and end of procedure or function wirtten properly.

How to catch the 404 error in my web application and provide more useful information?

In the global.asax Application_error Event write the following code

VB.NET

Dim ex As Exception = Server.GetLastError().GetBaseException()
If TypeOf ex Is System.IO.FileNotFoundException Then
'your code
'Response.Redirect("err404.aspx")
Else
'your code
End If

C#

Exception ex = Server.GetLastError().GetBaseException();
If (ex.GetType() == typeof(System.IO.FileNotFoundException))
{
//your code
Response.Redirect ("err404.aspx");
}
else
{
//your code
}

Why do I get the "Unable to find script libruary 'WebUIValidation.js'" error ?

When you install the .Net framework on your web server, it installs some script files (including the above) under the root folder (usually "C:\inetput\wwwroot" if you do a default installation) .

You can then find the above file at "C:\Inetpub\wwwroot\aspnet_client\system_web\1_1_4322", for example.

The above problem could happen if you reconfigured your web root directory to be a different one after you installed ASP.Net in your web server. If that is the case, then run 'aspnet_regiis -c' (utility is under %windir%\Microsoft.NET\Framework\v1.1.4322, for example) or copy over manually the above script files into a similar sub-directory below your current web root directory. Also, if you look at the error message in detail, you will notice where the file is supposed to be.

Server Application Unavailable

Why do I get the error message "Server Application Unavailable The web application you are attempting to access on this web server is currently unavailable. Please hit the "Refresh" button in your web browser to retry your request."?

By default, ASP.NET runs its worker process (Aspnet_wp.exe) with a weak account (the local machine account, which is named ASPNET) to provide a more secure environment. On a domain controller or on a backup domain controller, all user accounts are domain accounts and are not local machine accounts. Therefore, Aspnet_wp.exe fails to start because it cannot find a local account named "localmachinename\ASPNET". To provide a valid user account on the domain controller, you must specify an explicit account in the section of the Machine.config file, or you must use the SYSTEM account.

Why do I get "HTTP 500" error (or "(DLL) initialization routine failed") in my browser?

This is because if you have the /3GB boot switch enabled, the ASP.NET worker process (Aspnet_wp.exe) does not start. To create and set the "ASPNETENABLE3GB" environment variable as mentioned in the above article, right click MyComputer ->Properties->Advanced > Environment Variables > System variables > New. Add the variable name in the top text box and the value in the lower textbox.

Invalid postback or callback argument

Try adding this into the system.web section of your web.config file:
pages enableEventValidation="false"

@ Page Language="C#" MasterPageFile="~/Admin/MasterPage_Admin.master" AutoEventWireup="true" CodeFile="CategoryManagement.aspx.cs" Inherits="Admin_CategoryManagement" Title="Untitled Page" EnableEventValidation="false"
You can also benefit from those features by leaving it enabled then register your control for event validation. Simply add the following call in the PreRender or Render page life cycle then your control should work without having to turn off eventValidation:Page.ClientScript.RegisterForEventValidation(this.UniqueID);

Sys.WebForms.PageRequestManagerParserErrorException

Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed. Common causes for this error are when the response is modified by calls to Response.Write(), response filters, HttpModules, or server trace is enabled.

If your Response.Redirect doesn’t work under UpdatePanel’s callback, then you definitely missing ScriptModule in the web.config:
in httpmodules tag
add type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" name="ScriptModule"
close tag httpmodules

error that says the BIOS limit has been exceeded

When I try to run pages on a remote computer using the ASP.NET Development Server, I get an error that says the BIOS limit has been exceeded. What is the problem?

You might see this error if the remote computer is running Windows 2000 or Windows XP. If the remote computer is running Windows 2000, you can follow the instructions in Microsoft KnowledgeBase article 810886 to set the maximum number of concurrent connections to a higher number. If you are running Windows XP, you might be able to avoid this error by closing existing shared resources, including terminal server sessions, on the remote computer. (Windows XP is configured with a fixed number of maximum concurrent network requests.)

error "The page cannot be displayed" and an HTTP 502 Proxy Error

When I run a page, I get the error "The page cannot be displayed" and an HTTP 502 Proxy Error. Why?

This error can occur if you are running ASP.NET Web pages using the Visual Web Developer Web server, because the URL includes a randomly selected port number. Proxy servers do not recognize the URL and return this error. To get around the problem, change your settings in Internet Explorer to bypass the proxy server for local addresses, so that the request is not sent to the proxy. In Internet Explorer, you can make this change in Tools > Internet Options. In the Connections
tab, click LAN Settings and then select Bypass proxy server for local addresses.

There was an error reflecting MyClass

XmlSerializer is throwing a generic "There was an error reflecting MyClass" error. How do I find out what the problem is?

Look at the InnerException property of the exception that is thrown to get a more specific error message.

Why do I get errors when I try to serialize a Hashtable?

XmlSerializer will refuse to serialize instances of any class that implements IDictionary, e.g. Hashtable. SoapFormatter and BinaryFormatter do not have this restriction.

I'm having some trouble with CAS. How can I troubleshoot the problem?

Caspol has a couple of options that might help. First, you can ask caspol to tell you what code group an assembly belongs to, using caspol -rsg. Similarly, you can ask what permissions are being applied to a particular assembly using caspol -rsp.

get the error System.__ComObject

I get the error System.__ComObject when using recordset?

This error occurs if you are trying to fetch the recordset value as follows

rs.Fields("productname")

To avoid this error try

VB.NET

rs.Fields("productname").Value.ToString()

C#

rs.Fields["productname").Value.ToString() ;

Why do I get error "A generic error occurred in GDI+." when trying to save the bitmap file?

May be the path of the file you are giving is wrong or you do not have write permissions on the specific folder.

My ASP code gives an error "Compiler Error Message: BC30289: Statement cannot appear within a method body. End of method assumed" when changed to aspx

Use a script runat="server" block instead of the <% %> syntax to define Subs.Make sure you have proper events associated with the code and have start and end of procedure or function wirtten properly.

Why do I get error message "Error creating assembly manifest: Error reading key file 'key.snk' -- The system cannot find the file specified"?

Check the location of the key.snk file relative to the assembly file. Provide an explicit path or a relative path.



Why do I get the "Unable to find script libruary 'WebUIValidation.js'" error ?

When you install the .Net framework on your web server, it installs some script files (including the above) under the root folder (usually "C:\inetput\wwwroot" if you do a default installation) . You can then find the above file at "C:\Inetpub\wwwroot\aspnet_client\system_web\1_1_4322", for example.

The above problem could happen if you reconfigured your web root directory to be a different one after you installed ASP.Net in your web server. If that is the case, then run 'aspnet_regiis -c' (utility is under %windir%\Microsoft.NET\Framework\v1.1.4322, for example) or copy over manually the above script files into a similar sub-directory below your current web root directory. Also, if you look at the error message in detail, you will notice where the file is supposed to be.

error message "It is already opened exclusively by another user, or you need permission to view its data." when I try to open Access mdb?

The ASPNET worker process doesn't have the correct permissions to connect to or write to the Access database. Either enable impersonation for users or configure the ASP.NET worker process to run under the SYSTEM account. You can also grant read and write permissions for the "Everyone" group on the database and the database folder.

Why do I get the Error Message "System.OutOfMemoryException: Exception of type System.OutOfMemoryException was thrown."?

It means that the server is out of available memory. You probably have an infinite loop somewhere that's frantically creating large objects, or you forgot to dispose of disposable objects and memory slowly leaked.

"Login failed for user '(null)'. Reason: Not associated with a trusted SQL Server connection"?

This error usually indicates that SQLServer (or MSDE) is configured to use Windows Authentication. If you want to use a SQL login, you will need to enable SQL Authentication (mixed mode authentication).

What is Stored Procedure?

A stored procedure is a named group of SQL statements that have been previously created and stored in the server database. Stored procedures accept input parameters so that a single procedure can be used over the network by several clients using different input data. And when the procedure is modified, all clients automatically get the new version. Stored procedures reduce network traffic and improve performance. Stored procedures can be used to help ensure the integrity of the database. e.g. sp_helpdb, sp_renamedb, sp_depends etc.

What are different normalization forms?

1NF: Eliminate Repeating Groups
Make a separate table for each set of related attributes, and give each table a primary key. Each field contains at most one value from its attribute domain.
2NF: Eliminate Redundant Data
If an attribute depends on only part of a multi-valued key, remove it to a separate table.
3NF: Eliminate Columns Not Dependent On Key
If attributes do not contribute to a description of the key, remove them to a separate table. All
attributes must be directly dependent on the primary key
BCNF: Boyce-Codd Normal Form
If there are non-trivial dependencies between candidate key attributes, separate them out into distinct tables.
4NF: Isolate Independent Multiple Relationships
No table may contain two or more 1:n or n:m relationships that are not directly related.
5NF: Isolate Semantically Related Multiple Relationships
There may be practical constrains on information that justify separating logically related many-to-many relationships.
ONF: Optimal Normal Form
A model limited to only simple (elemental) facts, as expressed in Object Role Model notation.
DKNF: Domain-Key Normal Form
A model free from all modification anomalies.
Remember, these normalization guidelines are cumulative. For a database to be in 3NF, it must first fulfill all the criteria of a 2NF and 1NF database.

What is normalization?

Database normalization is a data design and organization process applied to data structures based on rules that help build relational databases. In relational database design, the process of organizing data to minimize redundancy. Normalization usually involves dividing a database into two or more tables and defining relationships between the tables. The objective is to isolate data so that additions, deletions,and modifications of a field can be made in just one table and then propagated through the rest of the database via the defined relationships.

What is RDBMS?

Relational Data Base Management Systems (RDBMS) are database management systems that maintain data records and indices in tables. Relationships may be created and maintained across and among the data and tables. In a relational database, relationships between data items are expressed by means of tables. Interdependencies among these tables are expressed by data values rather than by pointers.
This allows a high degree of data independence. An RDBMS has the capability to recombine the data items from different files, providing powerful tools for data usage.

Before a user can build reports using Report Builder in Reporting Services 2005, which one of the following steps must be done first?

Build and deploy a modelReport Builder requires a model and that model cannot be defined using Report Builder. The advantage of using models is that users do not need to understand SQL statements to build a report (but they will still benefit from a basic understanding of the relationships between various bits of data)

Where are Notification Services event messages logged in SQL Server 2005?

In the Windows Application Log
Event messages are logged in the Windows Application log.

The TRUSTWORTHY database property is by default?

Off
The correct answer is off – The TRUSTWORTHY database property indicates whether the installed instance of SQL Server trusts the database such that it can reach out and perform actions outside the database. By default it is OFF such that the database to reduce certain threats that can result from attaching a database that contains potentially harmful code

In the SQL Server 2005 thesaurus XML configuration file, what is the expansion set?

Expansion sets are synonyms for the search term and returned as results if they appear along with the search term.
The expansion set is the group of values that are synonyms and can be substituted for the search term. For example, an expansion set can be "SS2K5", "SQL Server 2005", "SQL2K5". In this case, fields with any of these 3 values would be returned as a result for searches on "SQL Server 2005".

Native Web Services require what type of endpoint in SQL Server 2005?

HTTP endpoints
Native XML Web Services in SQL Server 2005 require HTTP endpoints to communicate with clients.

In Reporting Services 2005, how is Report Builder typically deployed to end users?

One click deployment launched from a menu on the Report Manager home page
One click deployment is fast and easy, users click the menu on the Report Manager page. It is not a web application, but rather a .Net Winform application.

trigger assigned to it?

Yes
An event can have multiple triggers assigned to it.

Out of the box Report Builder supports two report level fields that can be shown on a report. Which option below has those two options?

The current filter and the number of rows that matched that filterBy default, the current filter definition and the number of rows that matched the filter are added to the end of the report. They can be removed and added back as needed.

Which utility is used to administer SQL Server 2005 Notification Services instances?

nscontrol.exe
The nscontrol application can be used with various parameters to administer a SQL Server 2005 Notification Services instance.

You have noticed in both your SQL Server 2000 and 2005 instances that when a database grows in SQL Server, there is a delay in the database response.

Once the file is grown, zeros are written to the new space, causing a delay.When a database file grows, unless instant file initialization is turned on, the server must allocate disk space and then write 0s into all that space. This zero-ing out of the file creates the delay.

Using Reporting Services 2005, it is true or false that subreports execute a query against the datasource once for every detail row in the report?

True
True. Subreports can be used for a master-detail relationship, or the subreport can be a separate item, but in either case RS will query to get the data for the report once for each detail row. If end users are going to only occasionally look at the data you're displaying in the subreport or only view it for a few rows, a better option is to create a link to the other report.

On which platforms can you use Instant File Initialization to improve database growth performance in SQL Server 2005?

Windows 2003 and XP Pro
Both Windows 2003 Server and later as well as Windows XP Professional support Instant
File Initialization.

Which RAID levels store parity information?

RAID 5
Only RAID 5 (of those listed) contains parity information.

True or false, Report Builder supports using the LIKE function inside filters?

False
There is no LIKE support, the next best thing is the CONTAINS function which works as if you specified both a leading and trailing wild card.

Using Report Builder, which of the following statements is correct about formatting numbers?

Users can pick from a small number of predefined formats and they have the option to specify a custom format
There are give built in formats; general, currency, percentage, two place decimal, and exponent. Users can also define a custom format using a .Net format string.

Which of the following choices show the three report formats supported by Report Builder ?

Table, Matrix, Chart
Report Builder can build a report formatted as a table, chart, or matrix (cross tab), but only ONE can be used in any given report.


C++/OOPS Programming language



Question - 1) What is a class?

A class is a group of objects, i.e. data members or member-functions that share common properties and relationships. It represents a group of similar objects.


Question - 2) What is an object?

An object is an identifiable entity with some characteristics and behavior. It represents an entity that can store data and its associated functions.


Question - 3) List the advantages of object oriented programming?

Object oriented programming has many advantages:
  • Re-usability of code.
  • Ease of comprehension.
  • Ease of fabrication and maintenance.
  • Easy redesign and extension.


Question - 4) What is meant by ‘call by value’?

In C++, structures can be passed to functions by two methods namely ‘by value’ and ‘by reference’. In ‘call by value’ method, the called function copies the passed structure on to its own work copy; the original structure then remains unaffected.


Question - 5) What is meant by ‘call by reference’?

In ‘call by reference’ method of calling functions, the called function declares a reference for the passed structure and refers to the original structure elements through its reference.


Question - 6) What is a reference variable ? What is its use ?

A reference variable is an alias name for a previously declared variable. The use of it is that is that the same data object can be referred to by two names and these names can be used interchangeably.


Question - 7) What are inline functions ? What is the advantage of using them ? How are they declared ?

An inline function is a function upon which the C++ compiler is asked to perform inline expansion, i.e. the compiler is requested to replace every function call with the complete body of the function, rather than generating the function code at each and every position of the function call.

The major advantage of inline functions is that it saves on the overhead of a function call. Since the function is not invoked, but its code is replaced in the program, it saves the compiler time and improves efficiency.

The format to declare an inline function is:

inline datatype function_name(parameters)
{
function content;
}


Question - 8) What are the defining traits of an object-oriented language ?

The defining traits of an object oriented programming language are the following:

Data abstraction.
Data encapsulation.
Inheritance.
Polymorphism.
Modularity.


Question - 9) What is the purpose of the scope resolution operator ?

In C++, the scope resolution operator (::) is used to qualify hidden file names so that
they can be used. Further, the scope resolution operator can also be used to qualify
class names or class member names.


Question - 10) What are the differences between type casting and automatic type conversion ?

Type casting or explicit type conversion is user-defined forced conversion. It is done with the help of casting operator ().

Automatic type conversion or implicit type conversion is a data type conversion performed by compiler on its own. It occurs whenever an expression has different types.
Question - 11) Why ‘char’ is often considered as an integer data type?

The memory implementation of char data type is in terms of the number code, which is an integer. Therefore, it is said to be another integer data type.


Question - 12) What is the difference between structure and class in C++?

A structure is a collection of data while the class is a collection of data and functions. Further, all members are public by default in a structure while all members are private by default in class. Class has greater data security than structure.


Question - 13) What is the purpose of ios:app?

The function of ios::app is to retain the previous contents of a file and to append to the end of the existing file contents, rather than truncating them.


Question -14) What is the purpose of ios::ate?

The purpose of ios::ate is to place file pointer at the end of the file, but you can write data anywhere in the file.


Question - 15) How is random access of data achieved in C++?

In C++, random access is achieved by manipulating seekg( ), seekp( ), tellg( ) and tellp( ) functions. The seekg() and tellg() functions allow you to set and examine the get_pointer, and the seekp() and tellp() functions perform these operations on the put_pointer.

Question - 16) Which header file is required for creating and manipulating data files in C++?

fstream.h


Question - 17) What is an access specifier?

An access specifier is a way to specify the scope and accessibility of members of a class. Access specifiers can be either private or protected or public.


Question - 18) How is memory allocated to a class and its objects?

When a class is defined, memory is allocated for its member functions and they are stored in the memory. When an object is created, separate memory space is allocated for its data members. All objects work with the one copy of member functions shared by all.


Question - 19) What is the difference between an object and a class ?

An object is an identifiable entity with some characteristics and behavior. It represents an entity that can store data and its associated functions.
A class is a group of objects that share common properties and relationships. It represents a group of similar objects.


Question - 20) Differentiate between data hiding and encapsulation ?

Data hiding is the property whereby the internal data structure of an object is hidden from the rest of the program.

Data encapsulation is the mechanism by which the data and associated functions are bound together within an object definition in such a way so that only relevant information is exposed and rest remains hidden. Thus, data encapsulation implements data hiding.

Question - 21) What is polymorphism? Explain with an example ?

Polymorphism is the property by which the same message can be sent to different objects of several different classes, and eah object can respond to it in a different way depending upon its class. In C++, polymorphism is implemented through overloading.

A function name having several definitions that are differentiable by the number of types of their arguments is known as function overloading. For example,

float area (float a)
{
return a * a;
}
float area (float a, float b)
{
return a * b;
}


Question - 22) What is public, protected and private ?

Public, protected and private are access labels in a class. A class provides three access labels namely private, protected and public.

A member declared as public is made available to the outside world. That is, it can be accessed by any function, any expression in the program but only by using an object of the same class type.

A member declared as private or protected remains hidden from outside world and it can only be accessed by the member functions and friend functions of a class.


Question - 23) What is the significance of the protected access specifier ?

The members having protected accessibility are hidden from outside world, like private members, but when inherited, they remain visible in the derived class unlike private members.


Question -24) Do 'derivation' and 'friendship' mean the same ?

No. ‘Friendship’ gets the access privilege for private and protected members of a class. However, ‘derivation’ from that class gets access privilege only for protected members of the class.


Question - 25) Enlist some advantages of object oriented programming ?

The major advantages of object oriented programming are:
  • Re-usability of code.
  • Ease of comprehension.
  • Ease of fabrication and maintenance.
  • Easy redesign and extension.

Question - 26) Is prototyping mandatory in C++? Why?

Yes, prototyping is mandatory in C++. C++ makes it mandatory to ensure proper invocation of functions and prompt error reporting.


Question -27) When should a function be made inline?

A function is made inline when:
  • The function is small.
  • The function is not returning any value and contains no return statement.
  • The function does not contain a loop or a switch or a goto.
  • The function does not contain static variables.
  • The function is not recursive.

Question - 28) How is a static variable different from a static function?

A static variable has a function scope but the global life time. A static function has a file scope instead of program scope.


Question - 29) What is meant by macro?

A macro is a #define function, whose every occurrence is the program is replaced prior to compilation as per its definition.


Question - 30) What do you mean by inline function?

An inline function is that which is not invoked at the time of function call rather its code is replaced in the program at the time of function call. Thus, inline functions save the overheads of a function call.

31) What is a constructor? Why would I ever use one?

A constructor is a member function with the same name as that of its class. Constructors are automatically invoked when an object of the same class is created. The constructor has the same name as that of the class.
A constructor is used often to initialize the objects of that class type with a legal initial value.


32) What are destructors really for? Why would I ever use them?

A destructor is a member function with the same name as that of its class but is preceded by a tilde (~). Destructors are really for the purpose of de-initializing an object before it goes out of scope.


33) Is a default constructor equivalent to a constructor having default arguments?

Yes, a default constructors is equivalent to a constructor having default arguments because when no initial values are provided for an object at the time of its declaration, the constructor having default argument values is invoked same way as the default constructor is invoked. Therefore, these two are considered equivalent.


34) Why is a destructor function required in a class?

During construction of an object by a constructor, resources are allocated for use. These resources must be de-allocated before the object is destroyed. A destructor achieves this function and performs all clean-up jobs.


35) What is a parameterized constructor?

A constructor that receives arguments or parameters is called a parameterized constructor.

36) What is a copy constructor?

A constructor that initializes an object using values of another object passed to it as parameter is called copy constructor. It creates the copy of the passed object. The format of declaration is:
classname (classname &)


37) What is a default constructor? What is its role?

A default constructor is the one that takes no arguments. It is automatically invoked when an object is created without providing any initial values. In case, the programmer has not defined a default constructor, the compiler automatically generates it.


38) What is meant by constructor overloading?

Constructor overloading refers to a class having multiple constructor definitions, each having a different signature.


39) What is operator overloading?

Operator overloading is a specific case of polymorphism in C++. In operator overloading, different operators have different implementations, depending on their arguments.


40) What operators can/cannot be overloaded?

Most can be overloaded. The only C++ operators that can't be are . and ?: (and sizeof, which is technically an operator). C++ adds a few of its own operators, most of which can be overloaded except :: and .*.

41) How is operator overloading implemented successfully in C++?

In C++, operator overloading follows the same procedure of functioning as function overloading. The implementation of operator overloading depends upon the situation where the operator is used. For example, the ‘-‘sign, when used with a number, like -20, is read by the compiler to be a negative number. At the same time, when the ‘-‘ sign is associated with two numbers, like 8-5, then the compiler identifies it to be the subtraction operation.


42) What is abstract class?

Abstract class is a class that defines an interface, but does not necessarily provide implementations for all its member functions. No objects of an abstract class exist, i.e, it cannot be instantiated.


43) What is concrete class?

A concrete class is a derived class of an abstract class that implements all the missing functionality. A concrete class can be instantiated. i.e, its objects can be created.


44) What is function overloading and operator overloading?

A function name having several definitions that are differentiable by the number or types of their arguments is known as function overloading.

Operator overloading is a specific case of polymorphism in C++. In operator overloading, different operators have different implementations, depending on their arguments.


45) What is a ‘friend’ function?

A friend function in C++ is a function which allows access to private or protected data in a class from outside. Friend functions are declared using the ‘friend’ keyword.

46) Do ‘friends’ violate encapsulation?

The friend lessens the value of encapsulation of separate classes in object oriented programming. Hence, too many external functions or friend functions are not advisable for use in object oriented programs.


47) What are some advantages/disadvantages of using friends?

The major advantage of the friend function is that it allows a great degree of freedom in the interface design option. This function is useful when a class needs to hide certain components from the users and use it elsewhere. Friend function efficiently keeps the data details private and secure from the outside-class area.

The major disadvantage of friend function is that it requires an extra line of code while using dynamic binding.


48) What do you mean by the friend function and friend class?

A friend function is a non-member function that is granted access to a class’s private and protected members.
A friend class is a class whose member functions can access another class’s private and protected members.


49) Why should I use `new' instead of trustworthy old malloc()?

It is necessary to use ‘new’ instead of the old ‘malloc’ to ensure efficiency of the program. Unlike malloc, new calls the specific constructor. Further, the value returned by new is type safe and the new operator can be overridden.


50) How do I allocate / unallocate an array of things?

An array of things is allocated or unallocated using the new and delete operators.

51) What if I forget the `[ ]' when `delete'ing array allocated via `new X[n]'?

Basically, it is the duty of the programmer, and not the compiler, to get the connection between the ‘new X[n]’ and the ‘[]’. If the programmer fails in this, the compiler will not generate a runtime error or compile-time error but will result in a heap corruption. Otherwise, the program will die.


52) What are free store operators?

Operators that facilitate dynamic memory allocation, i.e., allocation new and de-allocation delete operators are called free store operators.


53) What do you mean by free storage list or AVAIL list?

A list keeping account of available free memory is called an AVAIL list or free storage list.


54) What is meant by static memory allocation?

When the amount of memory to be allocated is known beforehand and the memory is allocated during compilation itself, it is referred to as static memory allocation.


55) What is dynamic memory allocation?

Allocation of memory at runtime is referred to as dynamic memory allocation.

56) Define free store ?

It is a pool of unallocated heap memory given to a program that is used by the program for dynamic allocation during execution.


57) What do you mean by a self referential structure?

A structure having a member element that refers to the structure itself is called a self-referential structure.


58) What is inheritance? What the types of inheritance?

Inheritance is the capability of one class to inherit properties from another class. The class from which properties are inherited is called a base class and the class inheriting properties is called the derived class.


59) What are the different types of inheritances?

Inheritances are of many types namely single inheritance, multiple inheritance, multilevel inheritance, hierarchical inheritance and hybrid inheritance.


60) What is the difference between a virtual base class and a normal base class?

The major and only difference between a virtual base class and a normal one is when an object inherits the base more than once. If virtual base classes are used, then only one base class is present in the object. Otherwise, multiple copies will be found.
61) What is meant by a visibility mode?

The public, private or protected specifier that controls the visibility and availability of a member in a class is called a visibility mode.


62) What's the difference between `public:', `private:', and `protected:' visibility modes?

The differences between the `public:', `private:', and `protected:' visibility modes lie in the ways in which members and functions can be accessed within a class.

In the publicly derived class, the public and protected members of the base class become public and protected members of the derived class.

In the privately derived class, the public and protected members of the base class become private members of the derived class.

In the protectedly derived class, the public and protected members of the base class become protected members of the derived class.


63) When should you use inheritances?

Inheritance finds wide applications in C++ due to the following reasons.

  • Inheritance has the capability to express the inheritance relationships which makes it ensure the closeness with the real-world models.
  • Another reason is the idea of re-usability. Inheritance helps in addition of additional features to an existing class without modifying it.
  • Inheritance possesses a transitive nature.



64) How do you express `private inheritance'?

The private derivation means, the derived class can access the public and private members f the base class privately. Here, the inherited members can be accessed only through member functions of the derived class.

Private inheritance is expressed as :
class derived-class-name : visibility-mode base-class name
{
;
}


65) What are the access rules with `private' and `protected' inheritance?

In private derivation, though the derived class inherits all the public and protected members of the base class become private members of the derived class, the objects of the derived class cannot access them directly. Here, the public and protected members of the base class are directly accessible by the member functions and friends of the derived class as if they were the private members of the derived class.
66) What is meant by inheritance hierarchy ?

The relationship between a base and derived class is referred to as a derivation or inheritance hierarchy. The derivation from multiple base classes is referred to as a derivation or inheritance graph.


67) Differentiate between multiple and multilevel inheritances ?

Multiple inheritance is the inheritance hierarchy wherein one derived class inherits from multiple base classes.

Multilevel inheritance is the inheritance hierarchy wherein a subclass acts as a base class for other classes.


68) What is an ABC (`Abstract Base Class') ?

A class serving only as a base class for other classes and no objects of which are created is known as an abstract base class.


69) What is a `virtual destructor' ?

A virtual destructor is a destructor which is essential in C++ programming. The virtual destructor is important for a C++ base class to ensure that the destructor from the most called function is chosen.


70) What is a dangling pointer or wild pointers ?

Dangling pointers or wild pointers are pointers in computer programming, which do not point to a valid object of the appropriate type. They are special variations of memory safety violations.

71) What is abstraction?

Data abstraction refers to the act of representing essential features without including the background details or explanations. Data abstraction is an important characteristic of object oriented programming.


72) How is abstraction and encapsulation interrelated?

Encapsulation wraps up data and functions under a single unit and ensures that only essential features get represented without representing the background details which is nothing but abstraction. Therefore, encapsulation is a way of implementing abstraction.


73) What is an adaptor class or Wrapper class?

A wrapper class or an adaptor class refers to the method by which classes wrap their primitive values in a class and offers access to them through objects. A few of the primitive wrapper data types are:
Byte, short, int, long, float, double, char, Boolean.


74) What is a container class? What are the types of container classes?

Two classes such that the objects of a class are enclosed within the other class are called container classes and the property is called containership, nesting or composition.


75) What is polymorphism?

Polymorphism is the ability for a message or data to be processed in more than one form. Function overloading, operator overloading etc are all components of polymorphism.
76) What do you mean by a static data member and a static member function?

A static data member is a class data member common to all the objects of a class. A static member function is a member function that can access only the static data members.


77) What is modularity in C++?

Modularity is the property of a system that has been decomposed into a set of cohesive and loosely coupled modules. In other words, modularity is the act of partitioning a program into individual components is called modularity.


78) What do you mean by data abstraction?

Data abstraction is the act of representing essential features without including the background details.


79) What is a pointer? How will you define a pointer to an integer and a pointer to a character?

A pointer is a variable which holds a memory address which is usually the location of another variable in memory.

A pointer, say ptr, to integer is declared as int *ptr; and a pointer, say cptr, is declared to a character as char *cptr.


80) How does a pointer variable differ from a simple variable?

A simple variable stores a data value whereas a pointer variable stores a memory address of another variable in the memory.
81) What is a nested structure ?

A nested structure is a structure having another structure as its member element. It finds a wide range of applications in C++ components like linked lists.


82) How are arrays and structures related to each other ?

Arrays bring together a group of items of the same data type whereas structures bring together a group of related data items of any data type.


83) How are structures and classes related to each other ?
                                             OR
What is the difference between structure and class?

Structure is actually a class in C++ declared with keyword struct. By default, all members are public in a structure, while on the other hand, all members are private by default in classes.


84) What is the difference between get and getline member functions ?

The get() and getline() functions are virtually identical to one another. But the difference between the two of them is that getline() reads and removes the newline character from the input stream if its is encountered, which is not done by the get() function.


85) Differentiate between ifstream class and ofstream class?

The ifstream class is an input stream class, which provides input operations for file. The ofstream class is an output stream class, which provides output operations for a file. Both ifstream and ofstream classes are defined under the header file iostream.h.
86) Name the streams generally used for file operations.

Ifstream, ofstream and fstream.


87) What do you mean by ‘this’ pointer?

The ‘this’ pointer is an already created object pointer that points to currently calling object.


88) What is a data structure?

A named group of data of different data types which can be processed as a single unit is referred to as a data structure.


89) List four major operations associated with linear data structures.

Four major operations performed on data structures are searching, sorting, traversing and inserting.


90) What are trees in C++?

Trees are non-linear data structures having a hierarchical relationship between various elements called nodes. Topmost node is called the root of the tree and the bottommost nodes are called leaves of the tree.

91) State conditions under which binary search is applicable.

For binary search,
  • The list must be sorted.
  • Lower bound and upper bound of the list must be known.



92) What is a linked list?

A linked list is a collection of data elements, called nodes pointing to the next nodes by means of pointers.


93) Differentiate between functions read() and write().

The read() function lest one read a unit of information from a file and the write() function lets one write a unit of information to a file.


94) What is a null pointer?

A pointer that does not point to any data object is called a null pointer, In C++, the null pointer can be represented by the constant 0.


95) What is a memory leak?

A situation in which there lie so many orphaned memory-blocks that are still allocated but no pointers are referencing to them, are referred to as a memory leak.

96) What is a stack?

The memory area that stores the return address of the functions, arguments passed to functions, and local variables of functions is called a stack.


97) What is meant by overflow in C++?

If one tries to insert a node into a linked list, when there is no memory available, it is called ‘Overflow’.


98) What is an infix expression?

An expression in which operators are placed in between the operands is called an infix expression.


99) What do you mean by static binding?

Static binding or early binding is the process of selection of a particular function for a particular call at the compile time.


100) What do you mean by a node?

A part of a linked list storing information of an element as well as having a pointer to the next node is called a node.