Transcript

Interview

VB------------1 What is the difference between activeX Exe and ActiveX DLL2 Late Binding Vs Early Binding3 Inheritense - Type of inheritense4 Version Compatibility5 Error handling6 How to compile code in VB7 Can we use events in VB how to declare it With Events key words8 What is marshelling9 what is DLL Hell10 Can we validate a control by default11 What is a collection How to use it12 What are class instancing properties(Private PublicNotCreatable MultiUse GlobalMultiUse for dll)(SingleUse and Global Single use for activeX exe)13 What are access modifier14 When an access modifier friend is used15 What kind of threading model is used in VB16 What is unattened Execution17 Can we provide any command line agruements to vb program18 Can we do conditional compilation in VB

COM---------------1 What is com3 What is IUNKnown Interface (Addref release queryinterface) 2 What is QueryInterface4 What is polymorphism Can we implement polymorphism in VB5 COM components implements which interface for automation IDispatch What are IDispatch methods6 What is dual interface how it is different to Idispatch interface

DCOM----------------1 What is DCOM2 What is the difference between DCOM and Webservices3 What is stub and proxy4

ASP-------------1 What are different objects in ASP2 What are the different modes to pass data from one page to another3 How to know which user has logged into the system Logon_User4 How to abandon the session5 How to include a file in ASP6 How to make variable declaration mandatory in ASP7 What is dictionary object in aSP8 What is responsebuffer property9 What is responseflush property10 How to lock the application before making any update through application object

11 Error handling in ASP12 How to open a text file using ASP13 What are different authentication types in IIS

ADO----------------1 What are different object in ADO2 what are different locks type3 What are different cursor types What is cursor location property4 How can we execute the stored procedure5 How to get a recordset from stored procedure oraclesql server6 Error handling in ADO

XML----------------------------------1 What is XML2 When to use XML and when to use Database3 Can we query an XML How4 How to validate an XML5 what is object navigator 7 Fatest way to read XML in net 8 Storing foreign language characters in XMl like jap russsian chinese 9

SourceSafe------------------1 What is source safe2 Can multiple users can simultaniouly checkout the same file3 How a ascii file and binary files are stored in the VSS

Javascript---------------------

NET----------------1 What is differene between VBNETCnet2 What is Web service3 What are the building blocks of Webservice4 What is difference between ASPCOM based architecture and NET architecture5 What is an Assembly what is GAC6 what is CLR7 What is type safety8 What is namespace9 What are NET enterprise servers10What are muticast delegates when are they used 11 What are reflections what is Type object 12 Boxing and Unboxing and when are they done 13 Event handlings and custom events in Dotnet 14 How do you ActiveXExe equivalent in Dotnet 15 how does inner keyword affect classvisibility

16 Public and private keys concept When and how do you use it17 How is that the assembly is preserved using key pairs 18 What is binding policy How do u dynamically load dlls 17 what is codebase property in the app config file How do use it dynamically download an assembly 18 what is native image generator 19 Difference btwn GAC and Native image storing 20 Explain app config file 21 Relation between namespace and assemblies 22 what are sealed classes 23 Architecture of Net remoting 24 Remoting types 25 Explain singleton singlecall client activated objects Their merits and demerits 26 configuration of remoting using app config file 27 Ways to Hosting of Remote objects 28 How do convert remote object to resceptive webservice 29 How do you handle concurrency in Remote objects30 What is attribute programming Example 31 WHat is Distributed transtaction coordinator How is it in net 32 Different kinds of formatter available How is serialize and deserialize33 What is a context in a application ow do explain it with Marshalbyref 34 what is marshalbyVal 35 How do you bind webservices dynamically 36 Async reading of websewrvice 37 Explain multithreaded app and sync concept 38 what are windows services how is configure them in Net 39 how is object poooling achieved in net 40 Explain store and forward pattern and how do u implement the same in net

ADONet 1WHy datasets what is commandbuilder 2Dynamic generations of update insert commands for dataadapters3How do u build relations in dataset 4Explain xml support for dataset 5 How do generate typed datasets

webservies

GDI programming

COM+ Interop

soapsuds tools installuitl snk install regsrvr32 wsdlproxygenerator console admintools gtnet config wizard

ASPNET1 What is server control2 What is validation control3 What are different type of caching(Page Fragment data)4 what is XMLHTTP5 Different kinds of session management 6 Types of caching dependency7 Dynamic caching 8 Role based authetication using Principals and Identity objects

VBNET1 What is alising

COMDCOM

1 What is COM

COM provides a group of conventions and supporting libraries that allow interaction between different pieces of software in a consistent object-oriented way

COM is a binary standard for component interoperability It helps to build language neutral components

2 What is dual interface

An interface that supports both IDispatch and VTBL binding COM Dlls developed in VB automatically inherits IdispatchImpl interface and

thus dual interface

3 Have you ever worked on DCOM If yes explain the architecture of any one of the application

ltlt Need to explain typical application architecture here gtgt

4 What are the various services provided by the MTSCOM+ system

Manage server process pools and thread pools Ultimately rather than dedicating a thread to work on behalf of a single client servers need to manage thread pools for servicing multiple client requests

Synchronize access to shared data and resources across concurrent requests from clients This requires sophisticated locking protocols that must account for deadlocks race conditions starvation and other performance issues

Manage client context including database connections and per-user data structures (or objects)

Cache state on the client for improved latency across slow networks Implement security to ensure that business functions and objects are only

available to those authorized to use them Implement management and configuration tools to allow remote installation

and administration of the servers

5 What are AdvantagesDisadvantages of ActiveX controls over DLL

Look for an answer similar to points mentioned in the table below

ActiveX DLLEncapsulates the whole aspects of the object

Encapsulates only functional aspect of the object

Pretty complicated for implementation and usage

Much easier to implement and use

Binary compatibility specification (may be used in different platforms)

Implemented only for Win32 platform

6 What is IUnknown What methods provided by IUnknown

It is generally good idea to have an answer for this question if you claim you know COM in your resume Otherwise you may consider your interview failed at this point

IUnknown is the base interface of COM All other interfaces must derive directly or indirectly from IUnknown There are three methods in that interface AddRef Release and QueryInterface

7 What are the purposes of AddRef Release and QueryInterface functions

AddRef increments reference count of the object Release decrements reference counter of the object and QueryInterface obtains a pointer to the requested interface

8 What is aggregation How can we get an interface of the aggregated object

Aggregation is the reuse mechanism in which the outer object exposes interfaces from the inner object as if they were implemented on the outer object itself This is useful when the outer object would always delegate every call to one of its interfaces to the same interface in the inner object Aggregation is actually a specialized case of containmentdelegation and is available as a convenience to avoid extra implementation overhead in the outer object in these cases We can get a pointer to the inner interface calling QueryInterface of the outer object with IID of the inner interface

9 C is aggregated by B which in turn aggregated by A Our client requested C What will happen

QueryInterface to A will delegate request to B which in turn will delegate request for the interface to C This pointer will be returned to the client

10 Whats the difference if any between OLE and COM

OLE is build on top of COM The question is not strict because OLE was built over COM for years while COM as a technology was presented by Microsoft a few years ago You may mention also that COM is a specification while OLE is a particular implementation of this specification which in todays world is not exactly true as well because what people call COM today is likely implementation of COM spec by Microsoft

11 Whats the difference between COM and DCOM

Again the question does not require strict answer Any DCOM object is yet a COM object (DCOM extends COM) and any COM object may participate in DCOM transactions

DCOM introduced several improvementsoptimizations for distributed environment such as MULTI_QI (multiple QueryInterface()) security contexts etc DCOM demonstrated importance of surrogate process (you cannot run in-proc server on a remote machine You need a surrogate process to do that) DCOM introduced a load balancing

12 What is a dual interface

Dual interface is one that supports both - IDispatch interface and vtbl-based interface Therefore it might be used in scripting environment like VBScript and yet to use power and speed of vtbl-based interface for non-scripting environment Discussion then may easily transform into analyzing of dual interface problems - be prepared to this twist

13 What is a multi-threaded apartment (MTA) and what is a Single-threaded apartment (STA)

This is pretty difficult question to describe shortly

Anyway apartments were introduced by Microsoft in NT 351 and late Windows 95 to isolate the problem of running legacy non-thread safe code into multithreaded environment Each thread was encapsulated into so called single-threaded apartment The reason to create an object in apartment is thread-safety

COM is the responsible synchronized way to access an object even if the object inside the apartment is not thread-safe Multithreaded apartments (MTA or free threading apartment) were introduced in NT 40 Idea behind MTA is that COM is

not responsible to synchronize object calls between threads In MTA the developer is responsible for that

ltlt See Professional DCOM Programming of Dr Grimes et al or Essential COM of Don Box for the further discussion on this topic gtgt

14 Lets assume we have object B and aggregated object C (in-proc server) created by B Can you access any interface of B from C Whats the difference between aggregated and contained objects

Yes you can This is fundamental postulate of COM If you can get there from here you can get there from anywhere ie QIing for IUnknown you may proceed and to get a pointer to any other interface supported by the object Aggregated object exposes its interface directly without visible intervention of the object container Contained object is created within the object container and its interfaces might be altered or filtered by the object container

15 Is there a way to register in-proc server without regsvr32exe

Yes Call DllRegisterServer() from the client Do not forget to call DLLUnregisterServer() from the same client You may also use Registrar object for the same purpose or use direct manipulation of the windows registry

16 What is VARIANT Why and where would you use it

VARIANT is a huge union containing automation type This allows easy conversion of one automation type to another The biggest disadvantage of VARIANT is size of the union

17 What is __declspec(novtable) Why would you need this

__declspec(novtable) is a Microsofts compiler optimization The main idea of this optimization is to strip the vtable initialization code from abstract class (for abstract class the vtable is empty while it is initialized in contructor) MSDN has an excellent article on this topic (search for ATL Virtual Functions and vtables)

18 What is an IDL

IDL stands for Interface Definition Language IDL is the language to describe COM interfaces

19 What is In-proc

In-proc is in-process COM object ie COM object that implemented as DLL and supposed to be hosted by a container When you have to instantiate the in-proc object remotely you may use DLLHostexe application that was design specially for this purpose

20 What is OLE

OLE is an object and embedding first implementation of COM spec available from MS before COM was officially named COM

21 Give examples of OLE usage

The most famous examples are probably drag and drop and structured storage implementations

22 What are 2 storage types for composite document

The two storage types are Storage and Stream

23 Is doc document a compound document Is it a structured storage

Compound document is a document that contains information about other documents hosted in this document All office documents may or may not be compound documents Word documents from version 60 and up are stored as structured storage

Non-VB COMDCOM

1 What should QueryInterface functions do if requested object was not found

Return E_NOINTERFACE and nullify its out parameter

2 How would you create an instance of the object in COM

ltlt Well it all depends on your project Start your answer from CoCreateInstance or CoCreateInstanceEx explain the difference between them If interviewer is still not satisfied youll have to explain the whole kitchen behind the scenes including a difference between local server and inproc server meaning and mechanism of class factory etc You may also mention other methods of object creation like CoGetInstanceFromFile but discussion will likely turn to discussion of monikers then gtgt

3 What happens when client calls CoCreateInstance

ltlt Again all depends on the level of detail and expertise of interviewer Start with simple explanation of class object and class factory mechanism Further details would depend on a specific situation gtgt

4 What are the limitations of CoCreateInstance

Well a major problem with CoCreateInstance is that it is only able to create one object and only on local system To create a remote object or to get several objects based on single CLSID at the same time one should use CoCreateInstanceEx

5 What is a moniker

It is an object that implements the IMoniker interface A moniker acts as a name that uniquely identifies a COM object In the same way that a path identifies a file in the file system a moniker identifies a COM object in the directory namespace

6 Can you have two dual interfaces in one class

Yes You may have two dual interfaces in one class but only one of them may be default The bottom line is that you cannot work with two dual interfaces at the same time due to nature of dual interfaceTo support two dual interfaces in VB you would write something like

dim d1 as IDualInterface1 dim d2 as IDualInterface2

set d1 = new MyClassWithTwoDualsset d2 = d1

In ATLs class you would have to use macro COM_INTERFACE_ENTRY2(IDispatch IDualInterface1) to distinguish between different dual interfaces

7 What is a marshalling by value

Some objects can essentially be considered static regardless of which methods are called the state of the object does not change Instead of accessing such an object remotely it is possible to copy the static state of the object and create a new object with the same state information on the caller side The caller wont be able to notice the difference but calls will be more efficient because they do not involve network round trips This is called marshaling by value

8 What is ROT What is GIT Give pros and cons of both

By definition running object table (ROT) is a globally accessible table on each computer that keeps track of all COM objects in the running state that can be identified by a moniker Moniker providers register an object in the table which increments the objects reference count Before the object can be destroyed its moniker must be released from the tableGlobal Interface Table (GIT) allows any apartment (either single- or multi-threaded) in a process to get access to an interface implemented on an object in any other apartment in the process

9 If you have an object with two interfaces can you custom marshal one of them

No The decision to use custom marshaling is an all-or-nothing decision an object has to custom marshal all its interfaces or none of them

10 How can you guarantee that only a remote server is ever created by a client

Create an object (call CoCreateObjectEx()) with CLSCTX_REMOTE_SERVER flag

Visual Basic

1 What are the properties and methods of ObjectControl interface

Activate Deactivate CanBePooled

2 How will you implement transaction in a visual basic ActiveX dll

Set the MTSTransactionMode property of the class modules Use the ObjectContextSetcomplete SetAbort methods to commitrollback

the transactions

3 How to execute a stored proc from VB using ADO

A stored proc can be executed using the command object

4 What are the objects in ADO

These are Connection Command Recordset Record Parameter and stream

Visual Basic UI

1 How to access a member variable in one form from another

Set the access modifier of the member variable as Public Create a property procedure

2 What is the listindex property of a list box control

Listindex is the index of the currently selected item in the control

3 Have you worked on grid controls

ltlt Answer should be Yes or No gtgt

ASP

1 How will you describe a session

Session object in ASP provides dynamic associative array that a script can use to store information

ASP Sessions Are Cookie-based

2 What are the different methods to pass an argument from one page to another

Using Query string Using Hidden controls

NET

1 How NET My Services work

From the developers perspective NET My Services is a set of XML Web services accessed by sending and receiving SOAP messages sent though the HTTP or DIME protocols and using the NET Passport system for authentication NET My Services consists of three things Authentication which will be provided by NET Passport when NET My Services goes live SOAP the communication protocol XML following the rules and schemas set out in the XMI Reference which provides the data formatting and organization

2 What are Web Services

Web Services are applications delivered as a service on the Web Web services allow for programmatic access of business logic over the Web Web services typically rely on XML-based protocols messages and interface descriptions for communication and access Web services are designed to be used by other programs or applications rather than directly by end user Programs invoking a Web service are called clients SOAP over HTTP is the most commonly used protocol for invoking Web services

3 How do I use a proxy server when invoking a Web service

If you are using the SOAP Toolkit you need to set some connector properties to use a proxy server Dim soap As SoapClient Set soap=New SoapClient soapConnectorProperty(ProxyServer) = ldquoproxyservernamerdquo soapConnectorProperty(ProxyPort) = ldquo8080rdquo soapConnectorProperty(UseProxy) = True While with NET you just need to create a SystemNetWebProxy object and use it to set the Proxy property Dim webs As localhostMyService() websProxy=New SystemNetWebProxy(ldquohttpproxyserver8080rdquo)

4 What is Simple Object Access Protocol (SOAP)

SOAP is an XML-based messaging framework specifically designed for exchanging formatted data across the Internet for example using request and reply messages or sending entire documents SOAP is simple easy to use and completely neutral with respect to operating system programming language or

distributed computing platform

5 What is Web Services Description Language (WSDL)

After SOAP became available as a mechanism for exchanging XML messages among enterprises (or among disparate applications within the same enterprise) a better way was needed to describe the messages and how they are exchanged The Web Services Description Language (WSDL) is a particular form of an XML Schema developed by Microsoft and IBM for the purpose of defining the XML message operation and protocol mapping of a web service accessed using SOAP or other XML protocol WSDL defines web services in terms of endpoints that operate on XML messages The WSDL syntax allows both the messages and the operations on the messages to be defined abstractly so they can be mapped to multiple physical implementations The current WSDL spec describes how to map messages and operations to SOAP 11 HTTP GETPOST and MIME WSDL creates web service definitions by mapping a group of endpoints into a logical sequence of operations on XML messages The same XML message can be mapped to multiple operations (or services) and bound to one or more communications protocols (using ports)

6 What is Universal Description Discovery and Integration (UDDI)

The Universal Description Discovery and Integration (UDDI) framework defines a data model (in XML) and SOAP APIs for registration and searches on business information including the web services a business exposes to the Internet UDDI is an independent consortium of vendors founded by Microsoft IBM and Ariba for the purpose of developing an Internet standard for web service description registration and discovery Microsoft IBM and Ariba also are hosting the initial deployment of a UDDI service which is conceptually patterned after DNS (the Internet service that translates URLs into TCP addresses) UDDI uses a private agreement profile of SOAP (ie UDDI doesnt use the SOAP serialization format because its not well suited to passing complete XML documents (its aimed at RPC style interactions) The main idea is that businesses use the SOAP APIs to register themselves with UDDI and other businesses search UDDI when they want to discover a trading partner for example someone from whom they wish to procure sheet metal bolts or transistors The information in UDDI is categorized according to industry type and geographical location allowing UDDI consumers to search through lists of potentially matching businesses to find the specific one they want to contact Once a specific business is chosen another call to UDDI is made to obtain the specific contact information for that business The contact information includes a pointer to the target businesss WSDL or other XML schema file describing the web service that the target business publishes

The interviewer should be well versed in NET to ask these questions The interview should know the answers

Execution cycle of an assembly How does CLR comes into picture- Platform independence

Managed unmanaged code Information about GAC How does GAC help in maintaining different versions of an assembly if

changes are made to an assembly and the new version does not support some of functionality that previous version supported how will the runtime handle ito What is the sequence of steps followed by the runtime to look for the

references like first to bin then GAC etco How to add assemblies in GAC

How do we use MTS capabilities in NET assemblies Different type of data persistence in NET

o Caching Data caching Output caching

o Serialization Xml Bin

Usercontrols vc Custom Controls ndash Composite controls Datareader vs Dataset Sorting in Datagrid adding custom controls in datagrid columns Use of view state in ASPX pages How to improve performance of the pages in web environment Is it possible to have both client side and server side functionality on aspx

server controls In the page execution life cycle when is the page_init called What is AutoEventWireUp attribute used for What are delegates used for Webservices

o How do you deploy web services Reflections Remoting

o What is client activated objects and what are server activated objectso What are channels used for

Interopo How does a NET component call a primitive one What are the steps taken

General Scripting Questions

1 How do you add a quotation mark to VB script string

The first method uses two quotation marks in a row to create a single quotation mark The second method uses the ASCII value of the quotation mark character

2 How do you break a single VBScript Statement into multiple lines

A single VBScript Statement can be broken into multiple lines by using the _underscore character

3 What is the proper method of comparing strings in VBScript

The first method uses VBScript function with the vbTextCompare constant The second method forces both strings into uppercase

4 How do you re-enable errors after using ON ERROR RESUME NEXT

ltlt Need an answer gtgt

5 How do you prevent My Script from timing out

You can extend the amount of time a script is allowed to run by using the ScriptTimeout property of the Server object

6 When do you need to explicitly convert a variable to a particular data type

If you are comparing numbers or dates and there is a danger that VBScript might interpret the values as strings one of the VBScript conversion functions should be used

7 When should one pass a variable by value and when by reference

When you pass a variable by value to a subordinate or function a new instance of the variable is created Any changes made to the value of the variable do not affect the value of the original variable On the other hand whne you pass a variable by reference changes made to the variable do affect the value of the original variable

8 How can you add a space between the output of two variables

ltlt Need an answer gtgt

9 Does ASP support dynamic includes

It does not support

10 How do you use the option Explicit statement in an ASP

It must be used before nay other VBScript statement or HTML content in a script else it will generate and error

Session and Application Variable Questions

1 Why do session variables sometimes fail to work

Session variables depend on browser cookies If a browser does not support cookies or a user has turned off cookies or the userrsquos cookie file is corrupted Session variables will not work

2 How do you remove an application variable

ltlt Need an answer gtgt

3 How do you detect whether a File exists

I can detect by using the FileExists method of the FileSystemObject

4 How do you automatically display a list of the Files in a directory

By using a list of files in a folder by using the FileSystemObject and the Folder object

Image Questions

1 How do you store an image in a database table

Although you can store an image in a SQL Server BLOB column it is almost always better to store the URL of an image in a database table rather than the image itself

2 How do you dynamically generate a graph or image in an ASP

Several third-party ASP components enable you to dynamically create custom images

Browser Questions

1 How do you detect the type of browser a person is using to visit your web site

The User-Agent header indicates the type of browser

2 How do you detect a page from which a person originated

The Referer header contains the URL of the last page the person visited This header can be retrieved from the ServerVariables collection

ActiveX Data Objects Questions

1 Why do you sometimes receive an error when using the Connection Object to execute a SQL string

ltlt Need an answer gtgt

2 How do you retrieve a Text filed in an ASP

If you do not take special precautions when retrieving a Text field from a database table the value of the Text field might be truncated If you are using a forward-only cursor type you should use the Text field as the very last field in your select list Alternatively consider using a richer cursor type when opening a Recordset that contains a Text field

3 Why does the RecordCount always return the Value-1

The RecordCount property returns the number of rows in a Recordset after it has been opened you cannot use this property with a forward-only cursor when using SQL Server (it will always return ndash1)

4 Why do you receive an error whenever you try to update the value of a filed in a recordset

By default when you open a Recordset it is opened with a forward-only cursor and read-only lock type To update a Recordset you must open a Recordset that is not read-only

5 How do you limit the number of rows returned by a Database Query

If using SQL 70 or Access you can use the SQL Top keyword to limit the number of records returned Otherwise if you are using SQL 65 use the MaxRecords property of the Recordset object

ltlt What about SQL 2000 gtgt

6 How do you retrieve the value from a SQL Statement that uses Count() Max Min or Identity

There are two methods that you can use to retrieve the value from a SQL function or a SQL global variable You can either use an alias for the value or refer to the value by its ordinal position in the Recordset

7 How do you retrieve an output parameter from a SQL stored procedure within an ASPScript

You must use the ADO Command nad parameter objects

Form and Query String Questions

1 How do you accept file uploads in an HTML form

ltlt Need an answer gtgt

2 What causes the value of a form field to become truncated

HTML uses quotation marks to mark the beginning and end of a value So If a variable contains question marks in its values the value of the variablewill be truncated when displayed

3 How do you include spaces or other special characters in a query string

URL encode the query string

C++ Questions

1 What is an object in C++

An object is a package that contains related data and instructions The data relates to what the object represents while the instructions define how this object relates to other objects and itself

2 What is a message

A message is a signal from one object to another requesting that a computation take place It is roughly equivalent to a function call in other languages

3 What is a class

A class defines the characteristics of a certain type of object It defines what its members will remember the messages to which they will respond and what form the response will take

4 What is an instance

It is an individual object that is a member of some class

5 What is a super-class

Given a class a super-class is the basis of the class under consideration The given class is defined as a subset (in some respects) of the super-class All objects of the given class potentially posses all the characteristics belonging to objects of the super-class

6 What is inheritance

Inheritance is property such that a parent (or super) class passes the characteristics of itself to children (or sub) classes that are derived from it The sub-class has the option of modifying these characteristics in order to make a different but fundamentally related class from the super-class

7 To what does message protocol refer

An objects message protocol is the exact form of the set of messages to which the object can respond

8 What is polymorphism

Polymorphism refers to the ability of an object to respond in a logically identical fashion to messages of the same protocol containing differing types of objects Consider 1 + 5 and 1 + 51 In the former the message + 5 is sent to an object of class integer (1) In the later the message + 51 is sent to the same integer object The form of the message (its protocol) is identical in both cases What differs is the type of object on the right-hand side of these messages The former is an integer object (5) while the later is a floating point object (51) The receiver (1) appears (to other objects) to respond in the same way to both messages Internally however it knows that it must treat the two types of objects differently in order to obtain the same overall response

9 What are instance variables

These represent an objects private memory They are defined in an objects class

18 What is a virtual member function

A virtual function allows derived classes to replace the implementation provided by the base class The compiler makes sure the replacement is always called whenever the object in question is actually of the derived class even if the object is accessed by a base pointer rather than a derived pointer This allows algorithms in the base class to be replaced in the derived class even if users dont know about the derived class

The derived class can either fully replace (override) the base class member function or the derived class can partially replace (augment) the base class member function The latter is accomplished by having the derived class member function call the base class member function if desired

19 How can C++ achieve dynamic binding yet also static typing

When you have a pointer to an object the object may actually be of a class that is derived from the class of the pointer (eg a Vehicle that is actually pointing to a Car object) Thus there are two types the (static) type of the pointer (Vehicle in this case) and the (dynamic) type of the pointed-to object (Car in this case)

Static typing means that the legality of a member function invocation is checked at the earliest possible moment by the compiler at compile time The compiler uses the static type of the pointer to determine whether the member function invocation is legal If the type of the pointer can handle the member function certainly the pointed-to object can handle it as well Eg if Vehicle has a certain member function certainly Car also has that member function since Car is a kind-of Vehicle

Dynamic binding means that the address of the code in a member function invocation is determined at the last possible moment based on the dynamic type of the object at run time It is called dynamic binding because the binding to the code that actually gets called is accomplished dynamically (at run time) Dynamic binding is a result of virtual functions

20 Whats the difference between how virtual and non-virtual member functions are called

Non-virtual member functions are resolved statically That is the member function is selected statically (at compile-time) based on the type of the pointer (or reference) to the object

In contrast virtual member functions are resolved dynamically (at run-time) That is the member function is selected dynamically (at run-time) based on the type of the object not the type of the pointerreference to that object This is called dynamic binding Most compilers use some variant of the following technique

if the object has one or more virtual functions the compiler puts a hidden pointer in the object called a virtual-pointer or v-pointer This v-pointer points to a global table called the virtual-table or v-table

The compiler creates a v-table for each class that has at least one virtual function For example if class Circle has virtual functions for draw() and move() and resize() there would be exactly one v-table associated with class Circle even if there were a gazillion Circle objects and the v-pointer of each of those Circle objects would point to the Circle v-table The v-table itself has pointers to each of the virtual functions in the class For example the Circle v-table would have three pointers a pointer to Circledraw() a pointer to Circlemove() and a pointer to Circleresize()

During a dispatch of a virtual function the run-time system follows the objects v-pointer to the classs v-table then follows the appropriate slot in the v-table to the method code

The space-cost overhead of the above technique is nominal an extra pointer per object (but only for objects that will need to do dynamic binding) plus an extra pointer per method (but only for virtual methods) The time-cost overhead is also fairly nominal compared to a normal function call a virtual function call requires two extra fetches (one to get the value of the v-pointer a second to get the address of the method) None of this runtime activity happens with non-virtual functions since the compiler resolves non-virtual functions exclusively at compile-time based on the type of the pointer

21 When should my destructor be virtual

When you may delete a derived object via a base pointer

virtual functions bind to the code associated with the class of the object rather than with the class of the pointerreference When you say delete basePtr and the base class has a virtual destructor the destructor that gets invoked is the one associated with the type of the object basePtr rather than the one associated with the type of the pointer This is generally A Good Thing

TECHNO-GEEK WARNING PUT YOUR PROPELLER HAT ON Technically speaking you need a base classs destructor to be virtual if and only if you intend to allow someone to invoke an objects destructor via a base class pointer (this is normally done implicitly via delete) and the object being destructed is of a derived class that has a non-trivial destructor A class has a non-trivial destructor if it either has an explicit destructor or if it has a member object or a base class that has a non-trivial destructor (note that this is a recursive definition (eg a class has a non-trivial destructor if it has a member object (which has a base class (which has a member object (which has a base class (which has an explicit destructor)))))) END TECHNO-GEEK WARNING REMOVE YOUR PROPELLER HAT

If you had a hard grokking the previous rule try this (over)simplified one on for size A class should have a virtual destructor unless that class has no virtual functions Rationale if you have any virtual functions at all youre probably going to be doing stuff to derived objects via a base pointer and some of the stuff you may do may include invoking a destructor (normally done implicitly via delete) Plus once youve put the first virtual function into a class youve already paid all the per-object space cost that youll ever pay (one pointer per object note that this is theoretically compiler-specific in practice everyone does it pretty much the same way) so making the destructor virtual wont generally cost you anything extra

22 What is a virtual constructor

An idiom that allows you to do something that C++ doesnt directly support

You can get the effect of a virtual constructor by a virtual clone() member function (for copy constructing) or a virtual create() member function (for the default constructor)

class Shape public virtual ~Shape() A virtual destructor virtual void draw() = 0 A pure virtual function virtual void move() = 0 virtual Shape clone() const = 0 Uses the copy constructor virtual Shape create() const = 0 Uses the default constructor class Circle public Shape public Circle clone() const return new Circle(this) Circle create() const return new Circle()

In the clone() member function the new Circle(this) code calls Circles copy constructor to copy the state of this into the newly created Circle object In the create() member function the new Circle() code calls Circles default constructor

Users use these as if they were virtual constructors

void userCode(Shapeamp s) Shape s2 = sclone() Shape s3 = screate() delete s2 You probably need a virtual destructor here

delete s3

23 How do you link a C++ program to C functions

By using the extern C linkage specification around the C function declarations

24 Explain the scope resolution operator

The scope resolution operator permits a program to reference an identifier in the global scope that has been hidden by another identifier with the same name in the local scope

25 What are the differences between a C++ struct and C++ class

The default member and base class access specifiers are different

26 How many ways are there to initialize an int with a constant

Two

27 How does throwing and catching exceptions differ from using setjmp and longjmp

The throw operation calls the destructors for automatic objects instantiated since entry to the try block

28 How does throwing and catching exceptions differ from using setjmp and longjmp

The throw operation calls the destructors for automatic objects instantiated since entry to the try block

29 What is a default constructor

A constructor that has no arguments or one where all the arguments have default argument values

If you dont code a default constructor the compiler provides one if there are no other constructors If you are going to instantiate an array of objects of the class the class must have a default constructor

30 What is a conversion constructor

It is a constructor that accepts one argument of a different type

The compiler uses this idiom as one way to infer conversion rules for a class A constructor with more than one argument and with default argument values can be interpreted by the compiler as a conversion constructor when the compiler is looking for an object of the type and sees an object of the type of the constructors first argument

31 What is the difference between a copy constructor and an overloaded assignment operator

A copy constructor constructs a new object by using the content of the argument object An overloaded assignment operator assigns the contents of an existing object to another existing object of the same class

First you must know that a copy constructor is one that has only one argument which is a reference to the same type as the constructor The compiler invokes a copy constructor wherever it needs to make a copy of the object for example to pass an argument by value If you do not provide a copy constructor the compiler creates a member-by-member copy constructor for you

You can write overloaded assignment operators that take arguments of other classes but that behavior is usually implemented with implicit conversion constructors If you do not provide an overloaded assignment operator for the class the compiler creates a default member-by-member assignment operator

This discussion is a good place to get into why classes need copy constructors and overloaded assignment operators By discussing the requirements with respect to data member pointers that point to dynamically allocated resources you demonstrate a good grasp of the problem

32 When should you use multiple inheritance

There are three acceptable answers Never Rarely and When the problem domain cannot be accurately modeled any other way

33 What is a virtual destructor

The simple answer is that a virtual destructor is one that is declared with the virtual attribute

The behavior of a virtual destructor is what is important If you destroy an object through a pointer or reference to a base class and the base-class destructor is not virtual the derived-class destructors are not executed and the destruction might not be complete

34 Explain the ISA and HASA class relationships How would you implement each in a class design

A specialized class is a specialization of another class and therefore has the ISA relationship with the other class An Employee ISA Person This relationship is best implemented with inheritance Employee is derived from Person A class may have an instance of another class For example an Employee has a Salary therefore the Employee class has the HASA relationship with the Salary class This relationship is best implemented by embedding an object of the Salary class in the Employee class

The answer to this question reveals whether you have an understanding of the fundamentals of object-oriented design which is important to reliable class design

There are other relationships The USESA relationship is when one class uses the services of another The Employee class uses an object (cout) of the ostream class to display the employees name onscreen for example But if you get ISA and HASA right you usually dont need to go any further

35 When is a template a better solution than a base class

When you are designing a generic class to contain or otherwise manage objects of other types when the format and behavior of those other types are unimportant to their containment or management and particularly when those other types are unknown (thus the genericity) to the designer of the container or manager class

Prior to templates you had to use inheritance your design might include a generic List container class and an application-specific Employee class To put employees in a list a ListedEmployee class is multiply derived (contrived) from the Employee and List classes These solutions were unwieldy and error-prone Templates solved that problem

Questions for ANSI-Knowledgeable Applicants

There are six questions for those who profess knowledge of the progress of the ANSI committee If you claim to have that much interest in the language you should know the answers to all these questions

1 What is a mutable member

A mutable member is one that can be modified by the class even when the object of the class or the member function doing the modification is const

Understanding this requirement implies an understanding of C++ const which many programmers do not have I have seen large class designs that do not employ the const qualifier anywhere Some of those designs are my own early C++ efforts One author suggests that some programmers find const to be such a bother that it is easier to ignore const than to try to use it meaningfully No

wonder many programmers dont understand the power and implications of const Someone who claims to have enough interest in the language and its evolution to keep pace with the ANSI deliberations should not be ignorant of const however

2 What is an explicit constructor

A conversion constructor declared with the explicit keyword The compiler does not use an explicit constructor to implement an implied conversion of types Its purpose is reserved explicitly for construction

3 What is the Standard Template Library

It is a library of container templates approved by the ANSI committee for inclusion in the standard C++ specification

4 Describe run-time type identification

It is the ability to determine at run time the type of an object by using the typeid operator or the dynamic_cast operator

5 What problem does the namespace feature solve

Multiple providers of libraries might use common global identifiers causing a name collision when an application tries to link with two or more such libraries The name-space feature surrounds a librarys external declarations with a unique namespace that eliminates the potential for those collisions

This solution assumes that two library vendors dont use the same namespace of course

6 Are there any new intrinsic (built-in) data types

Yes The ANSI committee added the bool intrinsic type and its true and false value keywords and the wchar_t data type to support character sets wider than eight bits

SQL Server

1 What is a foreign key

A foreign key is a column or combination of columns used to establish and enforce a link (referential integrity) between the data in two tables A link is created between two tables by adding the column or columns that hold one tablersquos primary key values to the other table This column becomes a foreign key in the second table

2 What is the difference between a primary key and unique key

There can be only one primary key constrain on a table but there can be many unique key constraints in a table

Primary key doesnrsquot allow null values but Unique allows 1 Null value

3 What is an index

Indexes are database objects which provides faster data access The index provides pointers to the data values stored in specified columns of

the table and then orders those pointers according to the sort order you specify

Different types of indexes are unique index clustered index and non-clustered index

4 How to return multiple result set from a stored proc and capture it in ADO

Use multiple Select statements to return multiple result sets Use ADOrsquos GetNextRecordset() method to get the second recordset during the

execution of the stored proc

  • COMDCOM
  • Visual Basic
  • General Scripting Questions
  • Session and Application Variable Questions
    • Image Questions
    • Browser Questions
    • ActiveX Data Objects Questions
    • Form and Query String Questions
      • 18 What is a virtual member function
      • 19 How can C++ achieve dynamic binding yet also static typing
      • 20 Whats the difference between how virtual and non-virtual member functions are called
      • 21 When should my destructor be virtual
      • 22 What is a virtual constructor
      • Questions for ANSI-Knowledgeable Applicants

    11 Error handling in ASP12 How to open a text file using ASP13 What are different authentication types in IIS

    ADO----------------1 What are different object in ADO2 what are different locks type3 What are different cursor types What is cursor location property4 How can we execute the stored procedure5 How to get a recordset from stored procedure oraclesql server6 Error handling in ADO

    XML----------------------------------1 What is XML2 When to use XML and when to use Database3 Can we query an XML How4 How to validate an XML5 what is object navigator 7 Fatest way to read XML in net 8 Storing foreign language characters in XMl like jap russsian chinese 9

    SourceSafe------------------1 What is source safe2 Can multiple users can simultaniouly checkout the same file3 How a ascii file and binary files are stored in the VSS

    Javascript---------------------

    NET----------------1 What is differene between VBNETCnet2 What is Web service3 What are the building blocks of Webservice4 What is difference between ASPCOM based architecture and NET architecture5 What is an Assembly what is GAC6 what is CLR7 What is type safety8 What is namespace9 What are NET enterprise servers10What are muticast delegates when are they used 11 What are reflections what is Type object 12 Boxing and Unboxing and when are they done 13 Event handlings and custom events in Dotnet 14 How do you ActiveXExe equivalent in Dotnet 15 how does inner keyword affect classvisibility

    16 Public and private keys concept When and how do you use it17 How is that the assembly is preserved using key pairs 18 What is binding policy How do u dynamically load dlls 17 what is codebase property in the app config file How do use it dynamically download an assembly 18 what is native image generator 19 Difference btwn GAC and Native image storing 20 Explain app config file 21 Relation between namespace and assemblies 22 what are sealed classes 23 Architecture of Net remoting 24 Remoting types 25 Explain singleton singlecall client activated objects Their merits and demerits 26 configuration of remoting using app config file 27 Ways to Hosting of Remote objects 28 How do convert remote object to resceptive webservice 29 How do you handle concurrency in Remote objects30 What is attribute programming Example 31 WHat is Distributed transtaction coordinator How is it in net 32 Different kinds of formatter available How is serialize and deserialize33 What is a context in a application ow do explain it with Marshalbyref 34 what is marshalbyVal 35 How do you bind webservices dynamically 36 Async reading of websewrvice 37 Explain multithreaded app and sync concept 38 what are windows services how is configure them in Net 39 how is object poooling achieved in net 40 Explain store and forward pattern and how do u implement the same in net

    ADONet 1WHy datasets what is commandbuilder 2Dynamic generations of update insert commands for dataadapters3How do u build relations in dataset 4Explain xml support for dataset 5 How do generate typed datasets

    webservies

    GDI programming

    COM+ Interop

    soapsuds tools installuitl snk install regsrvr32 wsdlproxygenerator console admintools gtnet config wizard

    ASPNET1 What is server control2 What is validation control3 What are different type of caching(Page Fragment data)4 what is XMLHTTP5 Different kinds of session management 6 Types of caching dependency7 Dynamic caching 8 Role based authetication using Principals and Identity objects

    VBNET1 What is alising

    COMDCOM

    1 What is COM

    COM provides a group of conventions and supporting libraries that allow interaction between different pieces of software in a consistent object-oriented way

    COM is a binary standard for component interoperability It helps to build language neutral components

    2 What is dual interface

    An interface that supports both IDispatch and VTBL binding COM Dlls developed in VB automatically inherits IdispatchImpl interface and

    thus dual interface

    3 Have you ever worked on DCOM If yes explain the architecture of any one of the application

    ltlt Need to explain typical application architecture here gtgt

    4 What are the various services provided by the MTSCOM+ system

    Manage server process pools and thread pools Ultimately rather than dedicating a thread to work on behalf of a single client servers need to manage thread pools for servicing multiple client requests

    Synchronize access to shared data and resources across concurrent requests from clients This requires sophisticated locking protocols that must account for deadlocks race conditions starvation and other performance issues

    Manage client context including database connections and per-user data structures (or objects)

    Cache state on the client for improved latency across slow networks Implement security to ensure that business functions and objects are only

    available to those authorized to use them Implement management and configuration tools to allow remote installation

    and administration of the servers

    5 What are AdvantagesDisadvantages of ActiveX controls over DLL

    Look for an answer similar to points mentioned in the table below

    ActiveX DLLEncapsulates the whole aspects of the object

    Encapsulates only functional aspect of the object

    Pretty complicated for implementation and usage

    Much easier to implement and use

    Binary compatibility specification (may be used in different platforms)

    Implemented only for Win32 platform

    6 What is IUnknown What methods provided by IUnknown

    It is generally good idea to have an answer for this question if you claim you know COM in your resume Otherwise you may consider your interview failed at this point

    IUnknown is the base interface of COM All other interfaces must derive directly or indirectly from IUnknown There are three methods in that interface AddRef Release and QueryInterface

    7 What are the purposes of AddRef Release and QueryInterface functions

    AddRef increments reference count of the object Release decrements reference counter of the object and QueryInterface obtains a pointer to the requested interface

    8 What is aggregation How can we get an interface of the aggregated object

    Aggregation is the reuse mechanism in which the outer object exposes interfaces from the inner object as if they were implemented on the outer object itself This is useful when the outer object would always delegate every call to one of its interfaces to the same interface in the inner object Aggregation is actually a specialized case of containmentdelegation and is available as a convenience to avoid extra implementation overhead in the outer object in these cases We can get a pointer to the inner interface calling QueryInterface of the outer object with IID of the inner interface

    9 C is aggregated by B which in turn aggregated by A Our client requested C What will happen

    QueryInterface to A will delegate request to B which in turn will delegate request for the interface to C This pointer will be returned to the client

    10 Whats the difference if any between OLE and COM

    OLE is build on top of COM The question is not strict because OLE was built over COM for years while COM as a technology was presented by Microsoft a few years ago You may mention also that COM is a specification while OLE is a particular implementation of this specification which in todays world is not exactly true as well because what people call COM today is likely implementation of COM spec by Microsoft

    11 Whats the difference between COM and DCOM

    Again the question does not require strict answer Any DCOM object is yet a COM object (DCOM extends COM) and any COM object may participate in DCOM transactions

    DCOM introduced several improvementsoptimizations for distributed environment such as MULTI_QI (multiple QueryInterface()) security contexts etc DCOM demonstrated importance of surrogate process (you cannot run in-proc server on a remote machine You need a surrogate process to do that) DCOM introduced a load balancing

    12 What is a dual interface

    Dual interface is one that supports both - IDispatch interface and vtbl-based interface Therefore it might be used in scripting environment like VBScript and yet to use power and speed of vtbl-based interface for non-scripting environment Discussion then may easily transform into analyzing of dual interface problems - be prepared to this twist

    13 What is a multi-threaded apartment (MTA) and what is a Single-threaded apartment (STA)

    This is pretty difficult question to describe shortly

    Anyway apartments were introduced by Microsoft in NT 351 and late Windows 95 to isolate the problem of running legacy non-thread safe code into multithreaded environment Each thread was encapsulated into so called single-threaded apartment The reason to create an object in apartment is thread-safety

    COM is the responsible synchronized way to access an object even if the object inside the apartment is not thread-safe Multithreaded apartments (MTA or free threading apartment) were introduced in NT 40 Idea behind MTA is that COM is

    not responsible to synchronize object calls between threads In MTA the developer is responsible for that

    ltlt See Professional DCOM Programming of Dr Grimes et al or Essential COM of Don Box for the further discussion on this topic gtgt

    14 Lets assume we have object B and aggregated object C (in-proc server) created by B Can you access any interface of B from C Whats the difference between aggregated and contained objects

    Yes you can This is fundamental postulate of COM If you can get there from here you can get there from anywhere ie QIing for IUnknown you may proceed and to get a pointer to any other interface supported by the object Aggregated object exposes its interface directly without visible intervention of the object container Contained object is created within the object container and its interfaces might be altered or filtered by the object container

    15 Is there a way to register in-proc server without regsvr32exe

    Yes Call DllRegisterServer() from the client Do not forget to call DLLUnregisterServer() from the same client You may also use Registrar object for the same purpose or use direct manipulation of the windows registry

    16 What is VARIANT Why and where would you use it

    VARIANT is a huge union containing automation type This allows easy conversion of one automation type to another The biggest disadvantage of VARIANT is size of the union

    17 What is __declspec(novtable) Why would you need this

    __declspec(novtable) is a Microsofts compiler optimization The main idea of this optimization is to strip the vtable initialization code from abstract class (for abstract class the vtable is empty while it is initialized in contructor) MSDN has an excellent article on this topic (search for ATL Virtual Functions and vtables)

    18 What is an IDL

    IDL stands for Interface Definition Language IDL is the language to describe COM interfaces

    19 What is In-proc

    In-proc is in-process COM object ie COM object that implemented as DLL and supposed to be hosted by a container When you have to instantiate the in-proc object remotely you may use DLLHostexe application that was design specially for this purpose

    20 What is OLE

    OLE is an object and embedding first implementation of COM spec available from MS before COM was officially named COM

    21 Give examples of OLE usage

    The most famous examples are probably drag and drop and structured storage implementations

    22 What are 2 storage types for composite document

    The two storage types are Storage and Stream

    23 Is doc document a compound document Is it a structured storage

    Compound document is a document that contains information about other documents hosted in this document All office documents may or may not be compound documents Word documents from version 60 and up are stored as structured storage

    Non-VB COMDCOM

    1 What should QueryInterface functions do if requested object was not found

    Return E_NOINTERFACE and nullify its out parameter

    2 How would you create an instance of the object in COM

    ltlt Well it all depends on your project Start your answer from CoCreateInstance or CoCreateInstanceEx explain the difference between them If interviewer is still not satisfied youll have to explain the whole kitchen behind the scenes including a difference between local server and inproc server meaning and mechanism of class factory etc You may also mention other methods of object creation like CoGetInstanceFromFile but discussion will likely turn to discussion of monikers then gtgt

    3 What happens when client calls CoCreateInstance

    ltlt Again all depends on the level of detail and expertise of interviewer Start with simple explanation of class object and class factory mechanism Further details would depend on a specific situation gtgt

    4 What are the limitations of CoCreateInstance

    Well a major problem with CoCreateInstance is that it is only able to create one object and only on local system To create a remote object or to get several objects based on single CLSID at the same time one should use CoCreateInstanceEx

    5 What is a moniker

    It is an object that implements the IMoniker interface A moniker acts as a name that uniquely identifies a COM object In the same way that a path identifies a file in the file system a moniker identifies a COM object in the directory namespace

    6 Can you have two dual interfaces in one class

    Yes You may have two dual interfaces in one class but only one of them may be default The bottom line is that you cannot work with two dual interfaces at the same time due to nature of dual interfaceTo support two dual interfaces in VB you would write something like

    dim d1 as IDualInterface1 dim d2 as IDualInterface2

    set d1 = new MyClassWithTwoDualsset d2 = d1

    In ATLs class you would have to use macro COM_INTERFACE_ENTRY2(IDispatch IDualInterface1) to distinguish between different dual interfaces

    7 What is a marshalling by value

    Some objects can essentially be considered static regardless of which methods are called the state of the object does not change Instead of accessing such an object remotely it is possible to copy the static state of the object and create a new object with the same state information on the caller side The caller wont be able to notice the difference but calls will be more efficient because they do not involve network round trips This is called marshaling by value

    8 What is ROT What is GIT Give pros and cons of both

    By definition running object table (ROT) is a globally accessible table on each computer that keeps track of all COM objects in the running state that can be identified by a moniker Moniker providers register an object in the table which increments the objects reference count Before the object can be destroyed its moniker must be released from the tableGlobal Interface Table (GIT) allows any apartment (either single- or multi-threaded) in a process to get access to an interface implemented on an object in any other apartment in the process

    9 If you have an object with two interfaces can you custom marshal one of them

    No The decision to use custom marshaling is an all-or-nothing decision an object has to custom marshal all its interfaces or none of them

    10 How can you guarantee that only a remote server is ever created by a client

    Create an object (call CoCreateObjectEx()) with CLSCTX_REMOTE_SERVER flag

    Visual Basic

    1 What are the properties and methods of ObjectControl interface

    Activate Deactivate CanBePooled

    2 How will you implement transaction in a visual basic ActiveX dll

    Set the MTSTransactionMode property of the class modules Use the ObjectContextSetcomplete SetAbort methods to commitrollback

    the transactions

    3 How to execute a stored proc from VB using ADO

    A stored proc can be executed using the command object

    4 What are the objects in ADO

    These are Connection Command Recordset Record Parameter and stream

    Visual Basic UI

    1 How to access a member variable in one form from another

    Set the access modifier of the member variable as Public Create a property procedure

    2 What is the listindex property of a list box control

    Listindex is the index of the currently selected item in the control

    3 Have you worked on grid controls

    ltlt Answer should be Yes or No gtgt

    ASP

    1 How will you describe a session

    Session object in ASP provides dynamic associative array that a script can use to store information

    ASP Sessions Are Cookie-based

    2 What are the different methods to pass an argument from one page to another

    Using Query string Using Hidden controls

    NET

    1 How NET My Services work

    From the developers perspective NET My Services is a set of XML Web services accessed by sending and receiving SOAP messages sent though the HTTP or DIME protocols and using the NET Passport system for authentication NET My Services consists of three things Authentication which will be provided by NET Passport when NET My Services goes live SOAP the communication protocol XML following the rules and schemas set out in the XMI Reference which provides the data formatting and organization

    2 What are Web Services

    Web Services are applications delivered as a service on the Web Web services allow for programmatic access of business logic over the Web Web services typically rely on XML-based protocols messages and interface descriptions for communication and access Web services are designed to be used by other programs or applications rather than directly by end user Programs invoking a Web service are called clients SOAP over HTTP is the most commonly used protocol for invoking Web services

    3 How do I use a proxy server when invoking a Web service

    If you are using the SOAP Toolkit you need to set some connector properties to use a proxy server Dim soap As SoapClient Set soap=New SoapClient soapConnectorProperty(ProxyServer) = ldquoproxyservernamerdquo soapConnectorProperty(ProxyPort) = ldquo8080rdquo soapConnectorProperty(UseProxy) = True While with NET you just need to create a SystemNetWebProxy object and use it to set the Proxy property Dim webs As localhostMyService() websProxy=New SystemNetWebProxy(ldquohttpproxyserver8080rdquo)

    4 What is Simple Object Access Protocol (SOAP)

    SOAP is an XML-based messaging framework specifically designed for exchanging formatted data across the Internet for example using request and reply messages or sending entire documents SOAP is simple easy to use and completely neutral with respect to operating system programming language or

    distributed computing platform

    5 What is Web Services Description Language (WSDL)

    After SOAP became available as a mechanism for exchanging XML messages among enterprises (or among disparate applications within the same enterprise) a better way was needed to describe the messages and how they are exchanged The Web Services Description Language (WSDL) is a particular form of an XML Schema developed by Microsoft and IBM for the purpose of defining the XML message operation and protocol mapping of a web service accessed using SOAP or other XML protocol WSDL defines web services in terms of endpoints that operate on XML messages The WSDL syntax allows both the messages and the operations on the messages to be defined abstractly so they can be mapped to multiple physical implementations The current WSDL spec describes how to map messages and operations to SOAP 11 HTTP GETPOST and MIME WSDL creates web service definitions by mapping a group of endpoints into a logical sequence of operations on XML messages The same XML message can be mapped to multiple operations (or services) and bound to one or more communications protocols (using ports)

    6 What is Universal Description Discovery and Integration (UDDI)

    The Universal Description Discovery and Integration (UDDI) framework defines a data model (in XML) and SOAP APIs for registration and searches on business information including the web services a business exposes to the Internet UDDI is an independent consortium of vendors founded by Microsoft IBM and Ariba for the purpose of developing an Internet standard for web service description registration and discovery Microsoft IBM and Ariba also are hosting the initial deployment of a UDDI service which is conceptually patterned after DNS (the Internet service that translates URLs into TCP addresses) UDDI uses a private agreement profile of SOAP (ie UDDI doesnt use the SOAP serialization format because its not well suited to passing complete XML documents (its aimed at RPC style interactions) The main idea is that businesses use the SOAP APIs to register themselves with UDDI and other businesses search UDDI when they want to discover a trading partner for example someone from whom they wish to procure sheet metal bolts or transistors The information in UDDI is categorized according to industry type and geographical location allowing UDDI consumers to search through lists of potentially matching businesses to find the specific one they want to contact Once a specific business is chosen another call to UDDI is made to obtain the specific contact information for that business The contact information includes a pointer to the target businesss WSDL or other XML schema file describing the web service that the target business publishes

    The interviewer should be well versed in NET to ask these questions The interview should know the answers

    Execution cycle of an assembly How does CLR comes into picture- Platform independence

    Managed unmanaged code Information about GAC How does GAC help in maintaining different versions of an assembly if

    changes are made to an assembly and the new version does not support some of functionality that previous version supported how will the runtime handle ito What is the sequence of steps followed by the runtime to look for the

    references like first to bin then GAC etco How to add assemblies in GAC

    How do we use MTS capabilities in NET assemblies Different type of data persistence in NET

    o Caching Data caching Output caching

    o Serialization Xml Bin

    Usercontrols vc Custom Controls ndash Composite controls Datareader vs Dataset Sorting in Datagrid adding custom controls in datagrid columns Use of view state in ASPX pages How to improve performance of the pages in web environment Is it possible to have both client side and server side functionality on aspx

    server controls In the page execution life cycle when is the page_init called What is AutoEventWireUp attribute used for What are delegates used for Webservices

    o How do you deploy web services Reflections Remoting

    o What is client activated objects and what are server activated objectso What are channels used for

    Interopo How does a NET component call a primitive one What are the steps taken

    General Scripting Questions

    1 How do you add a quotation mark to VB script string

    The first method uses two quotation marks in a row to create a single quotation mark The second method uses the ASCII value of the quotation mark character

    2 How do you break a single VBScript Statement into multiple lines

    A single VBScript Statement can be broken into multiple lines by using the _underscore character

    3 What is the proper method of comparing strings in VBScript

    The first method uses VBScript function with the vbTextCompare constant The second method forces both strings into uppercase

    4 How do you re-enable errors after using ON ERROR RESUME NEXT

    ltlt Need an answer gtgt

    5 How do you prevent My Script from timing out

    You can extend the amount of time a script is allowed to run by using the ScriptTimeout property of the Server object

    6 When do you need to explicitly convert a variable to a particular data type

    If you are comparing numbers or dates and there is a danger that VBScript might interpret the values as strings one of the VBScript conversion functions should be used

    7 When should one pass a variable by value and when by reference

    When you pass a variable by value to a subordinate or function a new instance of the variable is created Any changes made to the value of the variable do not affect the value of the original variable On the other hand whne you pass a variable by reference changes made to the variable do affect the value of the original variable

    8 How can you add a space between the output of two variables

    ltlt Need an answer gtgt

    9 Does ASP support dynamic includes

    It does not support

    10 How do you use the option Explicit statement in an ASP

    It must be used before nay other VBScript statement or HTML content in a script else it will generate and error

    Session and Application Variable Questions

    1 Why do session variables sometimes fail to work

    Session variables depend on browser cookies If a browser does not support cookies or a user has turned off cookies or the userrsquos cookie file is corrupted Session variables will not work

    2 How do you remove an application variable

    ltlt Need an answer gtgt

    3 How do you detect whether a File exists

    I can detect by using the FileExists method of the FileSystemObject

    4 How do you automatically display a list of the Files in a directory

    By using a list of files in a folder by using the FileSystemObject and the Folder object

    Image Questions

    1 How do you store an image in a database table

    Although you can store an image in a SQL Server BLOB column it is almost always better to store the URL of an image in a database table rather than the image itself

    2 How do you dynamically generate a graph or image in an ASP

    Several third-party ASP components enable you to dynamically create custom images

    Browser Questions

    1 How do you detect the type of browser a person is using to visit your web site

    The User-Agent header indicates the type of browser

    2 How do you detect a page from which a person originated

    The Referer header contains the URL of the last page the person visited This header can be retrieved from the ServerVariables collection

    ActiveX Data Objects Questions

    1 Why do you sometimes receive an error when using the Connection Object to execute a SQL string

    ltlt Need an answer gtgt

    2 How do you retrieve a Text filed in an ASP

    If you do not take special precautions when retrieving a Text field from a database table the value of the Text field might be truncated If you are using a forward-only cursor type you should use the Text field as the very last field in your select list Alternatively consider using a richer cursor type when opening a Recordset that contains a Text field

    3 Why does the RecordCount always return the Value-1

    The RecordCount property returns the number of rows in a Recordset after it has been opened you cannot use this property with a forward-only cursor when using SQL Server (it will always return ndash1)

    4 Why do you receive an error whenever you try to update the value of a filed in a recordset

    By default when you open a Recordset it is opened with a forward-only cursor and read-only lock type To update a Recordset you must open a Recordset that is not read-only

    5 How do you limit the number of rows returned by a Database Query

    If using SQL 70 or Access you can use the SQL Top keyword to limit the number of records returned Otherwise if you are using SQL 65 use the MaxRecords property of the Recordset object

    ltlt What about SQL 2000 gtgt

    6 How do you retrieve the value from a SQL Statement that uses Count() Max Min or Identity

    There are two methods that you can use to retrieve the value from a SQL function or a SQL global variable You can either use an alias for the value or refer to the value by its ordinal position in the Recordset

    7 How do you retrieve an output parameter from a SQL stored procedure within an ASPScript

    You must use the ADO Command nad parameter objects

    Form and Query String Questions

    1 How do you accept file uploads in an HTML form

    ltlt Need an answer gtgt

    2 What causes the value of a form field to become truncated

    HTML uses quotation marks to mark the beginning and end of a value So If a variable contains question marks in its values the value of the variablewill be truncated when displayed

    3 How do you include spaces or other special characters in a query string

    URL encode the query string

    C++ Questions

    1 What is an object in C++

    An object is a package that contains related data and instructions The data relates to what the object represents while the instructions define how this object relates to other objects and itself

    2 What is a message

    A message is a signal from one object to another requesting that a computation take place It is roughly equivalent to a function call in other languages

    3 What is a class

    A class defines the characteristics of a certain type of object It defines what its members will remember the messages to which they will respond and what form the response will take

    4 What is an instance

    It is an individual object that is a member of some class

    5 What is a super-class

    Given a class a super-class is the basis of the class under consideration The given class is defined as a subset (in some respects) of the super-class All objects of the given class potentially posses all the characteristics belonging to objects of the super-class

    6 What is inheritance

    Inheritance is property such that a parent (or super) class passes the characteristics of itself to children (or sub) classes that are derived from it The sub-class has the option of modifying these characteristics in order to make a different but fundamentally related class from the super-class

    7 To what does message protocol refer

    An objects message protocol is the exact form of the set of messages to which the object can respond

    8 What is polymorphism

    Polymorphism refers to the ability of an object to respond in a logically identical fashion to messages of the same protocol containing differing types of objects Consider 1 + 5 and 1 + 51 In the former the message + 5 is sent to an object of class integer (1) In the later the message + 51 is sent to the same integer object The form of the message (its protocol) is identical in both cases What differs is the type of object on the right-hand side of these messages The former is an integer object (5) while the later is a floating point object (51) The receiver (1) appears (to other objects) to respond in the same way to both messages Internally however it knows that it must treat the two types of objects differently in order to obtain the same overall response

    9 What are instance variables

    These represent an objects private memory They are defined in an objects class

    18 What is a virtual member function

    A virtual function allows derived classes to replace the implementation provided by the base class The compiler makes sure the replacement is always called whenever the object in question is actually of the derived class even if the object is accessed by a base pointer rather than a derived pointer This allows algorithms in the base class to be replaced in the derived class even if users dont know about the derived class

    The derived class can either fully replace (override) the base class member function or the derived class can partially replace (augment) the base class member function The latter is accomplished by having the derived class member function call the base class member function if desired

    19 How can C++ achieve dynamic binding yet also static typing

    When you have a pointer to an object the object may actually be of a class that is derived from the class of the pointer (eg a Vehicle that is actually pointing to a Car object) Thus there are two types the (static) type of the pointer (Vehicle in this case) and the (dynamic) type of the pointed-to object (Car in this case)

    Static typing means that the legality of a member function invocation is checked at the earliest possible moment by the compiler at compile time The compiler uses the static type of the pointer to determine whether the member function invocation is legal If the type of the pointer can handle the member function certainly the pointed-to object can handle it as well Eg if Vehicle has a certain member function certainly Car also has that member function since Car is a kind-of Vehicle

    Dynamic binding means that the address of the code in a member function invocation is determined at the last possible moment based on the dynamic type of the object at run time It is called dynamic binding because the binding to the code that actually gets called is accomplished dynamically (at run time) Dynamic binding is a result of virtual functions

    20 Whats the difference between how virtual and non-virtual member functions are called

    Non-virtual member functions are resolved statically That is the member function is selected statically (at compile-time) based on the type of the pointer (or reference) to the object

    In contrast virtual member functions are resolved dynamically (at run-time) That is the member function is selected dynamically (at run-time) based on the type of the object not the type of the pointerreference to that object This is called dynamic binding Most compilers use some variant of the following technique

    if the object has one or more virtual functions the compiler puts a hidden pointer in the object called a virtual-pointer or v-pointer This v-pointer points to a global table called the virtual-table or v-table

    The compiler creates a v-table for each class that has at least one virtual function For example if class Circle has virtual functions for draw() and move() and resize() there would be exactly one v-table associated with class Circle even if there were a gazillion Circle objects and the v-pointer of each of those Circle objects would point to the Circle v-table The v-table itself has pointers to each of the virtual functions in the class For example the Circle v-table would have three pointers a pointer to Circledraw() a pointer to Circlemove() and a pointer to Circleresize()

    During a dispatch of a virtual function the run-time system follows the objects v-pointer to the classs v-table then follows the appropriate slot in the v-table to the method code

    The space-cost overhead of the above technique is nominal an extra pointer per object (but only for objects that will need to do dynamic binding) plus an extra pointer per method (but only for virtual methods) The time-cost overhead is also fairly nominal compared to a normal function call a virtual function call requires two extra fetches (one to get the value of the v-pointer a second to get the address of the method) None of this runtime activity happens with non-virtual functions since the compiler resolves non-virtual functions exclusively at compile-time based on the type of the pointer

    21 When should my destructor be virtual

    When you may delete a derived object via a base pointer

    virtual functions bind to the code associated with the class of the object rather than with the class of the pointerreference When you say delete basePtr and the base class has a virtual destructor the destructor that gets invoked is the one associated with the type of the object basePtr rather than the one associated with the type of the pointer This is generally A Good Thing

    TECHNO-GEEK WARNING PUT YOUR PROPELLER HAT ON Technically speaking you need a base classs destructor to be virtual if and only if you intend to allow someone to invoke an objects destructor via a base class pointer (this is normally done implicitly via delete) and the object being destructed is of a derived class that has a non-trivial destructor A class has a non-trivial destructor if it either has an explicit destructor or if it has a member object or a base class that has a non-trivial destructor (note that this is a recursive definition (eg a class has a non-trivial destructor if it has a member object (which has a base class (which has a member object (which has a base class (which has an explicit destructor)))))) END TECHNO-GEEK WARNING REMOVE YOUR PROPELLER HAT

    If you had a hard grokking the previous rule try this (over)simplified one on for size A class should have a virtual destructor unless that class has no virtual functions Rationale if you have any virtual functions at all youre probably going to be doing stuff to derived objects via a base pointer and some of the stuff you may do may include invoking a destructor (normally done implicitly via delete) Plus once youve put the first virtual function into a class youve already paid all the per-object space cost that youll ever pay (one pointer per object note that this is theoretically compiler-specific in practice everyone does it pretty much the same way) so making the destructor virtual wont generally cost you anything extra

    22 What is a virtual constructor

    An idiom that allows you to do something that C++ doesnt directly support

    You can get the effect of a virtual constructor by a virtual clone() member function (for copy constructing) or a virtual create() member function (for the default constructor)

    class Shape public virtual ~Shape() A virtual destructor virtual void draw() = 0 A pure virtual function virtual void move() = 0 virtual Shape clone() const = 0 Uses the copy constructor virtual Shape create() const = 0 Uses the default constructor class Circle public Shape public Circle clone() const return new Circle(this) Circle create() const return new Circle()

    In the clone() member function the new Circle(this) code calls Circles copy constructor to copy the state of this into the newly created Circle object In the create() member function the new Circle() code calls Circles default constructor

    Users use these as if they were virtual constructors

    void userCode(Shapeamp s) Shape s2 = sclone() Shape s3 = screate() delete s2 You probably need a virtual destructor here

    delete s3

    23 How do you link a C++ program to C functions

    By using the extern C linkage specification around the C function declarations

    24 Explain the scope resolution operator

    The scope resolution operator permits a program to reference an identifier in the global scope that has been hidden by another identifier with the same name in the local scope

    25 What are the differences between a C++ struct and C++ class

    The default member and base class access specifiers are different

    26 How many ways are there to initialize an int with a constant

    Two

    27 How does throwing and catching exceptions differ from using setjmp and longjmp

    The throw operation calls the destructors for automatic objects instantiated since entry to the try block

    28 How does throwing and catching exceptions differ from using setjmp and longjmp

    The throw operation calls the destructors for automatic objects instantiated since entry to the try block

    29 What is a default constructor

    A constructor that has no arguments or one where all the arguments have default argument values

    If you dont code a default constructor the compiler provides one if there are no other constructors If you are going to instantiate an array of objects of the class the class must have a default constructor

    30 What is a conversion constructor

    It is a constructor that accepts one argument of a different type

    The compiler uses this idiom as one way to infer conversion rules for a class A constructor with more than one argument and with default argument values can be interpreted by the compiler as a conversion constructor when the compiler is looking for an object of the type and sees an object of the type of the constructors first argument

    31 What is the difference between a copy constructor and an overloaded assignment operator

    A copy constructor constructs a new object by using the content of the argument object An overloaded assignment operator assigns the contents of an existing object to another existing object of the same class

    First you must know that a copy constructor is one that has only one argument which is a reference to the same type as the constructor The compiler invokes a copy constructor wherever it needs to make a copy of the object for example to pass an argument by value If you do not provide a copy constructor the compiler creates a member-by-member copy constructor for you

    You can write overloaded assignment operators that take arguments of other classes but that behavior is usually implemented with implicit conversion constructors If you do not provide an overloaded assignment operator for the class the compiler creates a default member-by-member assignment operator

    This discussion is a good place to get into why classes need copy constructors and overloaded assignment operators By discussing the requirements with respect to data member pointers that point to dynamically allocated resources you demonstrate a good grasp of the problem

    32 When should you use multiple inheritance

    There are three acceptable answers Never Rarely and When the problem domain cannot be accurately modeled any other way

    33 What is a virtual destructor

    The simple answer is that a virtual destructor is one that is declared with the virtual attribute

    The behavior of a virtual destructor is what is important If you destroy an object through a pointer or reference to a base class and the base-class destructor is not virtual the derived-class destructors are not executed and the destruction might not be complete

    34 Explain the ISA and HASA class relationships How would you implement each in a class design

    A specialized class is a specialization of another class and therefore has the ISA relationship with the other class An Employee ISA Person This relationship is best implemented with inheritance Employee is derived from Person A class may have an instance of another class For example an Employee has a Salary therefore the Employee class has the HASA relationship with the Salary class This relationship is best implemented by embedding an object of the Salary class in the Employee class

    The answer to this question reveals whether you have an understanding of the fundamentals of object-oriented design which is important to reliable class design

    There are other relationships The USESA relationship is when one class uses the services of another The Employee class uses an object (cout) of the ostream class to display the employees name onscreen for example But if you get ISA and HASA right you usually dont need to go any further

    35 When is a template a better solution than a base class

    When you are designing a generic class to contain or otherwise manage objects of other types when the format and behavior of those other types are unimportant to their containment or management and particularly when those other types are unknown (thus the genericity) to the designer of the container or manager class

    Prior to templates you had to use inheritance your design might include a generic List container class and an application-specific Employee class To put employees in a list a ListedEmployee class is multiply derived (contrived) from the Employee and List classes These solutions were unwieldy and error-prone Templates solved that problem

    Questions for ANSI-Knowledgeable Applicants

    There are six questions for those who profess knowledge of the progress of the ANSI committee If you claim to have that much interest in the language you should know the answers to all these questions

    1 What is a mutable member

    A mutable member is one that can be modified by the class even when the object of the class or the member function doing the modification is const

    Understanding this requirement implies an understanding of C++ const which many programmers do not have I have seen large class designs that do not employ the const qualifier anywhere Some of those designs are my own early C++ efforts One author suggests that some programmers find const to be such a bother that it is easier to ignore const than to try to use it meaningfully No

    wonder many programmers dont understand the power and implications of const Someone who claims to have enough interest in the language and its evolution to keep pace with the ANSI deliberations should not be ignorant of const however

    2 What is an explicit constructor

    A conversion constructor declared with the explicit keyword The compiler does not use an explicit constructor to implement an implied conversion of types Its purpose is reserved explicitly for construction

    3 What is the Standard Template Library

    It is a library of container templates approved by the ANSI committee for inclusion in the standard C++ specification

    4 Describe run-time type identification

    It is the ability to determine at run time the type of an object by using the typeid operator or the dynamic_cast operator

    5 What problem does the namespace feature solve

    Multiple providers of libraries might use common global identifiers causing a name collision when an application tries to link with two or more such libraries The name-space feature surrounds a librarys external declarations with a unique namespace that eliminates the potential for those collisions

    This solution assumes that two library vendors dont use the same namespace of course

    6 Are there any new intrinsic (built-in) data types

    Yes The ANSI committee added the bool intrinsic type and its true and false value keywords and the wchar_t data type to support character sets wider than eight bits

    SQL Server

    1 What is a foreign key

    A foreign key is a column or combination of columns used to establish and enforce a link (referential integrity) between the data in two tables A link is created between two tables by adding the column or columns that hold one tablersquos primary key values to the other table This column becomes a foreign key in the second table

    2 What is the difference between a primary key and unique key

    There can be only one primary key constrain on a table but there can be many unique key constraints in a table

    Primary key doesnrsquot allow null values but Unique allows 1 Null value

    3 What is an index

    Indexes are database objects which provides faster data access The index provides pointers to the data values stored in specified columns of

    the table and then orders those pointers according to the sort order you specify

    Different types of indexes are unique index clustered index and non-clustered index

    4 How to return multiple result set from a stored proc and capture it in ADO

    Use multiple Select statements to return multiple result sets Use ADOrsquos GetNextRecordset() method to get the second recordset during the

    execution of the stored proc

    • COMDCOM
    • Visual Basic
    • General Scripting Questions
    • Session and Application Variable Questions
      • Image Questions
      • Browser Questions
      • ActiveX Data Objects Questions
      • Form and Query String Questions
        • 18 What is a virtual member function
        • 19 How can C++ achieve dynamic binding yet also static typing
        • 20 Whats the difference between how virtual and non-virtual member functions are called
        • 21 When should my destructor be virtual
        • 22 What is a virtual constructor
        • Questions for ANSI-Knowledgeable Applicants

      16 Public and private keys concept When and how do you use it17 How is that the assembly is preserved using key pairs 18 What is binding policy How do u dynamically load dlls 17 what is codebase property in the app config file How do use it dynamically download an assembly 18 what is native image generator 19 Difference btwn GAC and Native image storing 20 Explain app config file 21 Relation between namespace and assemblies 22 what are sealed classes 23 Architecture of Net remoting 24 Remoting types 25 Explain singleton singlecall client activated objects Their merits and demerits 26 configuration of remoting using app config file 27 Ways to Hosting of Remote objects 28 How do convert remote object to resceptive webservice 29 How do you handle concurrency in Remote objects30 What is attribute programming Example 31 WHat is Distributed transtaction coordinator How is it in net 32 Different kinds of formatter available How is serialize and deserialize33 What is a context in a application ow do explain it with Marshalbyref 34 what is marshalbyVal 35 How do you bind webservices dynamically 36 Async reading of websewrvice 37 Explain multithreaded app and sync concept 38 what are windows services how is configure them in Net 39 how is object poooling achieved in net 40 Explain store and forward pattern and how do u implement the same in net

      ADONet 1WHy datasets what is commandbuilder 2Dynamic generations of update insert commands for dataadapters3How do u build relations in dataset 4Explain xml support for dataset 5 How do generate typed datasets

      webservies

      GDI programming

      COM+ Interop

      soapsuds tools installuitl snk install regsrvr32 wsdlproxygenerator console admintools gtnet config wizard

      ASPNET1 What is server control2 What is validation control3 What are different type of caching(Page Fragment data)4 what is XMLHTTP5 Different kinds of session management 6 Types of caching dependency7 Dynamic caching 8 Role based authetication using Principals and Identity objects

      VBNET1 What is alising

      COMDCOM

      1 What is COM

      COM provides a group of conventions and supporting libraries that allow interaction between different pieces of software in a consistent object-oriented way

      COM is a binary standard for component interoperability It helps to build language neutral components

      2 What is dual interface

      An interface that supports both IDispatch and VTBL binding COM Dlls developed in VB automatically inherits IdispatchImpl interface and

      thus dual interface

      3 Have you ever worked on DCOM If yes explain the architecture of any one of the application

      ltlt Need to explain typical application architecture here gtgt

      4 What are the various services provided by the MTSCOM+ system

      Manage server process pools and thread pools Ultimately rather than dedicating a thread to work on behalf of a single client servers need to manage thread pools for servicing multiple client requests

      Synchronize access to shared data and resources across concurrent requests from clients This requires sophisticated locking protocols that must account for deadlocks race conditions starvation and other performance issues

      Manage client context including database connections and per-user data structures (or objects)

      Cache state on the client for improved latency across slow networks Implement security to ensure that business functions and objects are only

      available to those authorized to use them Implement management and configuration tools to allow remote installation

      and administration of the servers

      5 What are AdvantagesDisadvantages of ActiveX controls over DLL

      Look for an answer similar to points mentioned in the table below

      ActiveX DLLEncapsulates the whole aspects of the object

      Encapsulates only functional aspect of the object

      Pretty complicated for implementation and usage

      Much easier to implement and use

      Binary compatibility specification (may be used in different platforms)

      Implemented only for Win32 platform

      6 What is IUnknown What methods provided by IUnknown

      It is generally good idea to have an answer for this question if you claim you know COM in your resume Otherwise you may consider your interview failed at this point

      IUnknown is the base interface of COM All other interfaces must derive directly or indirectly from IUnknown There are three methods in that interface AddRef Release and QueryInterface

      7 What are the purposes of AddRef Release and QueryInterface functions

      AddRef increments reference count of the object Release decrements reference counter of the object and QueryInterface obtains a pointer to the requested interface

      8 What is aggregation How can we get an interface of the aggregated object

      Aggregation is the reuse mechanism in which the outer object exposes interfaces from the inner object as if they were implemented on the outer object itself This is useful when the outer object would always delegate every call to one of its interfaces to the same interface in the inner object Aggregation is actually a specialized case of containmentdelegation and is available as a convenience to avoid extra implementation overhead in the outer object in these cases We can get a pointer to the inner interface calling QueryInterface of the outer object with IID of the inner interface

      9 C is aggregated by B which in turn aggregated by A Our client requested C What will happen

      QueryInterface to A will delegate request to B which in turn will delegate request for the interface to C This pointer will be returned to the client

      10 Whats the difference if any between OLE and COM

      OLE is build on top of COM The question is not strict because OLE was built over COM for years while COM as a technology was presented by Microsoft a few years ago You may mention also that COM is a specification while OLE is a particular implementation of this specification which in todays world is not exactly true as well because what people call COM today is likely implementation of COM spec by Microsoft

      11 Whats the difference between COM and DCOM

      Again the question does not require strict answer Any DCOM object is yet a COM object (DCOM extends COM) and any COM object may participate in DCOM transactions

      DCOM introduced several improvementsoptimizations for distributed environment such as MULTI_QI (multiple QueryInterface()) security contexts etc DCOM demonstrated importance of surrogate process (you cannot run in-proc server on a remote machine You need a surrogate process to do that) DCOM introduced a load balancing

      12 What is a dual interface

      Dual interface is one that supports both - IDispatch interface and vtbl-based interface Therefore it might be used in scripting environment like VBScript and yet to use power and speed of vtbl-based interface for non-scripting environment Discussion then may easily transform into analyzing of dual interface problems - be prepared to this twist

      13 What is a multi-threaded apartment (MTA) and what is a Single-threaded apartment (STA)

      This is pretty difficult question to describe shortly

      Anyway apartments were introduced by Microsoft in NT 351 and late Windows 95 to isolate the problem of running legacy non-thread safe code into multithreaded environment Each thread was encapsulated into so called single-threaded apartment The reason to create an object in apartment is thread-safety

      COM is the responsible synchronized way to access an object even if the object inside the apartment is not thread-safe Multithreaded apartments (MTA or free threading apartment) were introduced in NT 40 Idea behind MTA is that COM is

      not responsible to synchronize object calls between threads In MTA the developer is responsible for that

      ltlt See Professional DCOM Programming of Dr Grimes et al or Essential COM of Don Box for the further discussion on this topic gtgt

      14 Lets assume we have object B and aggregated object C (in-proc server) created by B Can you access any interface of B from C Whats the difference between aggregated and contained objects

      Yes you can This is fundamental postulate of COM If you can get there from here you can get there from anywhere ie QIing for IUnknown you may proceed and to get a pointer to any other interface supported by the object Aggregated object exposes its interface directly without visible intervention of the object container Contained object is created within the object container and its interfaces might be altered or filtered by the object container

      15 Is there a way to register in-proc server without regsvr32exe

      Yes Call DllRegisterServer() from the client Do not forget to call DLLUnregisterServer() from the same client You may also use Registrar object for the same purpose or use direct manipulation of the windows registry

      16 What is VARIANT Why and where would you use it

      VARIANT is a huge union containing automation type This allows easy conversion of one automation type to another The biggest disadvantage of VARIANT is size of the union

      17 What is __declspec(novtable) Why would you need this

      __declspec(novtable) is a Microsofts compiler optimization The main idea of this optimization is to strip the vtable initialization code from abstract class (for abstract class the vtable is empty while it is initialized in contructor) MSDN has an excellent article on this topic (search for ATL Virtual Functions and vtables)

      18 What is an IDL

      IDL stands for Interface Definition Language IDL is the language to describe COM interfaces

      19 What is In-proc

      In-proc is in-process COM object ie COM object that implemented as DLL and supposed to be hosted by a container When you have to instantiate the in-proc object remotely you may use DLLHostexe application that was design specially for this purpose

      20 What is OLE

      OLE is an object and embedding first implementation of COM spec available from MS before COM was officially named COM

      21 Give examples of OLE usage

      The most famous examples are probably drag and drop and structured storage implementations

      22 What are 2 storage types for composite document

      The two storage types are Storage and Stream

      23 Is doc document a compound document Is it a structured storage

      Compound document is a document that contains information about other documents hosted in this document All office documents may or may not be compound documents Word documents from version 60 and up are stored as structured storage

      Non-VB COMDCOM

      1 What should QueryInterface functions do if requested object was not found

      Return E_NOINTERFACE and nullify its out parameter

      2 How would you create an instance of the object in COM

      ltlt Well it all depends on your project Start your answer from CoCreateInstance or CoCreateInstanceEx explain the difference between them If interviewer is still not satisfied youll have to explain the whole kitchen behind the scenes including a difference between local server and inproc server meaning and mechanism of class factory etc You may also mention other methods of object creation like CoGetInstanceFromFile but discussion will likely turn to discussion of monikers then gtgt

      3 What happens when client calls CoCreateInstance

      ltlt Again all depends on the level of detail and expertise of interviewer Start with simple explanation of class object and class factory mechanism Further details would depend on a specific situation gtgt

      4 What are the limitations of CoCreateInstance

      Well a major problem with CoCreateInstance is that it is only able to create one object and only on local system To create a remote object or to get several objects based on single CLSID at the same time one should use CoCreateInstanceEx

      5 What is a moniker

      It is an object that implements the IMoniker interface A moniker acts as a name that uniquely identifies a COM object In the same way that a path identifies a file in the file system a moniker identifies a COM object in the directory namespace

      6 Can you have two dual interfaces in one class

      Yes You may have two dual interfaces in one class but only one of them may be default The bottom line is that you cannot work with two dual interfaces at the same time due to nature of dual interfaceTo support two dual interfaces in VB you would write something like

      dim d1 as IDualInterface1 dim d2 as IDualInterface2

      set d1 = new MyClassWithTwoDualsset d2 = d1

      In ATLs class you would have to use macro COM_INTERFACE_ENTRY2(IDispatch IDualInterface1) to distinguish between different dual interfaces

      7 What is a marshalling by value

      Some objects can essentially be considered static regardless of which methods are called the state of the object does not change Instead of accessing such an object remotely it is possible to copy the static state of the object and create a new object with the same state information on the caller side The caller wont be able to notice the difference but calls will be more efficient because they do not involve network round trips This is called marshaling by value

      8 What is ROT What is GIT Give pros and cons of both

      By definition running object table (ROT) is a globally accessible table on each computer that keeps track of all COM objects in the running state that can be identified by a moniker Moniker providers register an object in the table which increments the objects reference count Before the object can be destroyed its moniker must be released from the tableGlobal Interface Table (GIT) allows any apartment (either single- or multi-threaded) in a process to get access to an interface implemented on an object in any other apartment in the process

      9 If you have an object with two interfaces can you custom marshal one of them

      No The decision to use custom marshaling is an all-or-nothing decision an object has to custom marshal all its interfaces or none of them

      10 How can you guarantee that only a remote server is ever created by a client

      Create an object (call CoCreateObjectEx()) with CLSCTX_REMOTE_SERVER flag

      Visual Basic

      1 What are the properties and methods of ObjectControl interface

      Activate Deactivate CanBePooled

      2 How will you implement transaction in a visual basic ActiveX dll

      Set the MTSTransactionMode property of the class modules Use the ObjectContextSetcomplete SetAbort methods to commitrollback

      the transactions

      3 How to execute a stored proc from VB using ADO

      A stored proc can be executed using the command object

      4 What are the objects in ADO

      These are Connection Command Recordset Record Parameter and stream

      Visual Basic UI

      1 How to access a member variable in one form from another

      Set the access modifier of the member variable as Public Create a property procedure

      2 What is the listindex property of a list box control

      Listindex is the index of the currently selected item in the control

      3 Have you worked on grid controls

      ltlt Answer should be Yes or No gtgt

      ASP

      1 How will you describe a session

      Session object in ASP provides dynamic associative array that a script can use to store information

      ASP Sessions Are Cookie-based

      2 What are the different methods to pass an argument from one page to another

      Using Query string Using Hidden controls

      NET

      1 How NET My Services work

      From the developers perspective NET My Services is a set of XML Web services accessed by sending and receiving SOAP messages sent though the HTTP or DIME protocols and using the NET Passport system for authentication NET My Services consists of three things Authentication which will be provided by NET Passport when NET My Services goes live SOAP the communication protocol XML following the rules and schemas set out in the XMI Reference which provides the data formatting and organization

      2 What are Web Services

      Web Services are applications delivered as a service on the Web Web services allow for programmatic access of business logic over the Web Web services typically rely on XML-based protocols messages and interface descriptions for communication and access Web services are designed to be used by other programs or applications rather than directly by end user Programs invoking a Web service are called clients SOAP over HTTP is the most commonly used protocol for invoking Web services

      3 How do I use a proxy server when invoking a Web service

      If you are using the SOAP Toolkit you need to set some connector properties to use a proxy server Dim soap As SoapClient Set soap=New SoapClient soapConnectorProperty(ProxyServer) = ldquoproxyservernamerdquo soapConnectorProperty(ProxyPort) = ldquo8080rdquo soapConnectorProperty(UseProxy) = True While with NET you just need to create a SystemNetWebProxy object and use it to set the Proxy property Dim webs As localhostMyService() websProxy=New SystemNetWebProxy(ldquohttpproxyserver8080rdquo)

      4 What is Simple Object Access Protocol (SOAP)

      SOAP is an XML-based messaging framework specifically designed for exchanging formatted data across the Internet for example using request and reply messages or sending entire documents SOAP is simple easy to use and completely neutral with respect to operating system programming language or

      distributed computing platform

      5 What is Web Services Description Language (WSDL)

      After SOAP became available as a mechanism for exchanging XML messages among enterprises (or among disparate applications within the same enterprise) a better way was needed to describe the messages and how they are exchanged The Web Services Description Language (WSDL) is a particular form of an XML Schema developed by Microsoft and IBM for the purpose of defining the XML message operation and protocol mapping of a web service accessed using SOAP or other XML protocol WSDL defines web services in terms of endpoints that operate on XML messages The WSDL syntax allows both the messages and the operations on the messages to be defined abstractly so they can be mapped to multiple physical implementations The current WSDL spec describes how to map messages and operations to SOAP 11 HTTP GETPOST and MIME WSDL creates web service definitions by mapping a group of endpoints into a logical sequence of operations on XML messages The same XML message can be mapped to multiple operations (or services) and bound to one or more communications protocols (using ports)

      6 What is Universal Description Discovery and Integration (UDDI)

      The Universal Description Discovery and Integration (UDDI) framework defines a data model (in XML) and SOAP APIs for registration and searches on business information including the web services a business exposes to the Internet UDDI is an independent consortium of vendors founded by Microsoft IBM and Ariba for the purpose of developing an Internet standard for web service description registration and discovery Microsoft IBM and Ariba also are hosting the initial deployment of a UDDI service which is conceptually patterned after DNS (the Internet service that translates URLs into TCP addresses) UDDI uses a private agreement profile of SOAP (ie UDDI doesnt use the SOAP serialization format because its not well suited to passing complete XML documents (its aimed at RPC style interactions) The main idea is that businesses use the SOAP APIs to register themselves with UDDI and other businesses search UDDI when they want to discover a trading partner for example someone from whom they wish to procure sheet metal bolts or transistors The information in UDDI is categorized according to industry type and geographical location allowing UDDI consumers to search through lists of potentially matching businesses to find the specific one they want to contact Once a specific business is chosen another call to UDDI is made to obtain the specific contact information for that business The contact information includes a pointer to the target businesss WSDL or other XML schema file describing the web service that the target business publishes

      The interviewer should be well versed in NET to ask these questions The interview should know the answers

      Execution cycle of an assembly How does CLR comes into picture- Platform independence

      Managed unmanaged code Information about GAC How does GAC help in maintaining different versions of an assembly if

      changes are made to an assembly and the new version does not support some of functionality that previous version supported how will the runtime handle ito What is the sequence of steps followed by the runtime to look for the

      references like first to bin then GAC etco How to add assemblies in GAC

      How do we use MTS capabilities in NET assemblies Different type of data persistence in NET

      o Caching Data caching Output caching

      o Serialization Xml Bin

      Usercontrols vc Custom Controls ndash Composite controls Datareader vs Dataset Sorting in Datagrid adding custom controls in datagrid columns Use of view state in ASPX pages How to improve performance of the pages in web environment Is it possible to have both client side and server side functionality on aspx

      server controls In the page execution life cycle when is the page_init called What is AutoEventWireUp attribute used for What are delegates used for Webservices

      o How do you deploy web services Reflections Remoting

      o What is client activated objects and what are server activated objectso What are channels used for

      Interopo How does a NET component call a primitive one What are the steps taken

      General Scripting Questions

      1 How do you add a quotation mark to VB script string

      The first method uses two quotation marks in a row to create a single quotation mark The second method uses the ASCII value of the quotation mark character

      2 How do you break a single VBScript Statement into multiple lines

      A single VBScript Statement can be broken into multiple lines by using the _underscore character

      3 What is the proper method of comparing strings in VBScript

      The first method uses VBScript function with the vbTextCompare constant The second method forces both strings into uppercase

      4 How do you re-enable errors after using ON ERROR RESUME NEXT

      ltlt Need an answer gtgt

      5 How do you prevent My Script from timing out

      You can extend the amount of time a script is allowed to run by using the ScriptTimeout property of the Server object

      6 When do you need to explicitly convert a variable to a particular data type

      If you are comparing numbers or dates and there is a danger that VBScript might interpret the values as strings one of the VBScript conversion functions should be used

      7 When should one pass a variable by value and when by reference

      When you pass a variable by value to a subordinate or function a new instance of the variable is created Any changes made to the value of the variable do not affect the value of the original variable On the other hand whne you pass a variable by reference changes made to the variable do affect the value of the original variable

      8 How can you add a space between the output of two variables

      ltlt Need an answer gtgt

      9 Does ASP support dynamic includes

      It does not support

      10 How do you use the option Explicit statement in an ASP

      It must be used before nay other VBScript statement or HTML content in a script else it will generate and error

      Session and Application Variable Questions

      1 Why do session variables sometimes fail to work

      Session variables depend on browser cookies If a browser does not support cookies or a user has turned off cookies or the userrsquos cookie file is corrupted Session variables will not work

      2 How do you remove an application variable

      ltlt Need an answer gtgt

      3 How do you detect whether a File exists

      I can detect by using the FileExists method of the FileSystemObject

      4 How do you automatically display a list of the Files in a directory

      By using a list of files in a folder by using the FileSystemObject and the Folder object

      Image Questions

      1 How do you store an image in a database table

      Although you can store an image in a SQL Server BLOB column it is almost always better to store the URL of an image in a database table rather than the image itself

      2 How do you dynamically generate a graph or image in an ASP

      Several third-party ASP components enable you to dynamically create custom images

      Browser Questions

      1 How do you detect the type of browser a person is using to visit your web site

      The User-Agent header indicates the type of browser

      2 How do you detect a page from which a person originated

      The Referer header contains the URL of the last page the person visited This header can be retrieved from the ServerVariables collection

      ActiveX Data Objects Questions

      1 Why do you sometimes receive an error when using the Connection Object to execute a SQL string

      ltlt Need an answer gtgt

      2 How do you retrieve a Text filed in an ASP

      If you do not take special precautions when retrieving a Text field from a database table the value of the Text field might be truncated If you are using a forward-only cursor type you should use the Text field as the very last field in your select list Alternatively consider using a richer cursor type when opening a Recordset that contains a Text field

      3 Why does the RecordCount always return the Value-1

      The RecordCount property returns the number of rows in a Recordset after it has been opened you cannot use this property with a forward-only cursor when using SQL Server (it will always return ndash1)

      4 Why do you receive an error whenever you try to update the value of a filed in a recordset

      By default when you open a Recordset it is opened with a forward-only cursor and read-only lock type To update a Recordset you must open a Recordset that is not read-only

      5 How do you limit the number of rows returned by a Database Query

      If using SQL 70 or Access you can use the SQL Top keyword to limit the number of records returned Otherwise if you are using SQL 65 use the MaxRecords property of the Recordset object

      ltlt What about SQL 2000 gtgt

      6 How do you retrieve the value from a SQL Statement that uses Count() Max Min or Identity

      There are two methods that you can use to retrieve the value from a SQL function or a SQL global variable You can either use an alias for the value or refer to the value by its ordinal position in the Recordset

      7 How do you retrieve an output parameter from a SQL stored procedure within an ASPScript

      You must use the ADO Command nad parameter objects

      Form and Query String Questions

      1 How do you accept file uploads in an HTML form

      ltlt Need an answer gtgt

      2 What causes the value of a form field to become truncated

      HTML uses quotation marks to mark the beginning and end of a value So If a variable contains question marks in its values the value of the variablewill be truncated when displayed

      3 How do you include spaces or other special characters in a query string

      URL encode the query string

      C++ Questions

      1 What is an object in C++

      An object is a package that contains related data and instructions The data relates to what the object represents while the instructions define how this object relates to other objects and itself

      2 What is a message

      A message is a signal from one object to another requesting that a computation take place It is roughly equivalent to a function call in other languages

      3 What is a class

      A class defines the characteristics of a certain type of object It defines what its members will remember the messages to which they will respond and what form the response will take

      4 What is an instance

      It is an individual object that is a member of some class

      5 What is a super-class

      Given a class a super-class is the basis of the class under consideration The given class is defined as a subset (in some respects) of the super-class All objects of the given class potentially posses all the characteristics belonging to objects of the super-class

      6 What is inheritance

      Inheritance is property such that a parent (or super) class passes the characteristics of itself to children (or sub) classes that are derived from it The sub-class has the option of modifying these characteristics in order to make a different but fundamentally related class from the super-class

      7 To what does message protocol refer

      An objects message protocol is the exact form of the set of messages to which the object can respond

      8 What is polymorphism

      Polymorphism refers to the ability of an object to respond in a logically identical fashion to messages of the same protocol containing differing types of objects Consider 1 + 5 and 1 + 51 In the former the message + 5 is sent to an object of class integer (1) In the later the message + 51 is sent to the same integer object The form of the message (its protocol) is identical in both cases What differs is the type of object on the right-hand side of these messages The former is an integer object (5) while the later is a floating point object (51) The receiver (1) appears (to other objects) to respond in the same way to both messages Internally however it knows that it must treat the two types of objects differently in order to obtain the same overall response

      9 What are instance variables

      These represent an objects private memory They are defined in an objects class

      18 What is a virtual member function

      A virtual function allows derived classes to replace the implementation provided by the base class The compiler makes sure the replacement is always called whenever the object in question is actually of the derived class even if the object is accessed by a base pointer rather than a derived pointer This allows algorithms in the base class to be replaced in the derived class even if users dont know about the derived class

      The derived class can either fully replace (override) the base class member function or the derived class can partially replace (augment) the base class member function The latter is accomplished by having the derived class member function call the base class member function if desired

      19 How can C++ achieve dynamic binding yet also static typing

      When you have a pointer to an object the object may actually be of a class that is derived from the class of the pointer (eg a Vehicle that is actually pointing to a Car object) Thus there are two types the (static) type of the pointer (Vehicle in this case) and the (dynamic) type of the pointed-to object (Car in this case)

      Static typing means that the legality of a member function invocation is checked at the earliest possible moment by the compiler at compile time The compiler uses the static type of the pointer to determine whether the member function invocation is legal If the type of the pointer can handle the member function certainly the pointed-to object can handle it as well Eg if Vehicle has a certain member function certainly Car also has that member function since Car is a kind-of Vehicle

      Dynamic binding means that the address of the code in a member function invocation is determined at the last possible moment based on the dynamic type of the object at run time It is called dynamic binding because the binding to the code that actually gets called is accomplished dynamically (at run time) Dynamic binding is a result of virtual functions

      20 Whats the difference between how virtual and non-virtual member functions are called

      Non-virtual member functions are resolved statically That is the member function is selected statically (at compile-time) based on the type of the pointer (or reference) to the object

      In contrast virtual member functions are resolved dynamically (at run-time) That is the member function is selected dynamically (at run-time) based on the type of the object not the type of the pointerreference to that object This is called dynamic binding Most compilers use some variant of the following technique

      if the object has one or more virtual functions the compiler puts a hidden pointer in the object called a virtual-pointer or v-pointer This v-pointer points to a global table called the virtual-table or v-table

      The compiler creates a v-table for each class that has at least one virtual function For example if class Circle has virtual functions for draw() and move() and resize() there would be exactly one v-table associated with class Circle even if there were a gazillion Circle objects and the v-pointer of each of those Circle objects would point to the Circle v-table The v-table itself has pointers to each of the virtual functions in the class For example the Circle v-table would have three pointers a pointer to Circledraw() a pointer to Circlemove() and a pointer to Circleresize()

      During a dispatch of a virtual function the run-time system follows the objects v-pointer to the classs v-table then follows the appropriate slot in the v-table to the method code

      The space-cost overhead of the above technique is nominal an extra pointer per object (but only for objects that will need to do dynamic binding) plus an extra pointer per method (but only for virtual methods) The time-cost overhead is also fairly nominal compared to a normal function call a virtual function call requires two extra fetches (one to get the value of the v-pointer a second to get the address of the method) None of this runtime activity happens with non-virtual functions since the compiler resolves non-virtual functions exclusively at compile-time based on the type of the pointer

      21 When should my destructor be virtual

      When you may delete a derived object via a base pointer

      virtual functions bind to the code associated with the class of the object rather than with the class of the pointerreference When you say delete basePtr and the base class has a virtual destructor the destructor that gets invoked is the one associated with the type of the object basePtr rather than the one associated with the type of the pointer This is generally A Good Thing

      TECHNO-GEEK WARNING PUT YOUR PROPELLER HAT ON Technically speaking you need a base classs destructor to be virtual if and only if you intend to allow someone to invoke an objects destructor via a base class pointer (this is normally done implicitly via delete) and the object being destructed is of a derived class that has a non-trivial destructor A class has a non-trivial destructor if it either has an explicit destructor or if it has a member object or a base class that has a non-trivial destructor (note that this is a recursive definition (eg a class has a non-trivial destructor if it has a member object (which has a base class (which has a member object (which has a base class (which has an explicit destructor)))))) END TECHNO-GEEK WARNING REMOVE YOUR PROPELLER HAT

      If you had a hard grokking the previous rule try this (over)simplified one on for size A class should have a virtual destructor unless that class has no virtual functions Rationale if you have any virtual functions at all youre probably going to be doing stuff to derived objects via a base pointer and some of the stuff you may do may include invoking a destructor (normally done implicitly via delete) Plus once youve put the first virtual function into a class youve already paid all the per-object space cost that youll ever pay (one pointer per object note that this is theoretically compiler-specific in practice everyone does it pretty much the same way) so making the destructor virtual wont generally cost you anything extra

      22 What is a virtual constructor

      An idiom that allows you to do something that C++ doesnt directly support

      You can get the effect of a virtual constructor by a virtual clone() member function (for copy constructing) or a virtual create() member function (for the default constructor)

      class Shape public virtual ~Shape() A virtual destructor virtual void draw() = 0 A pure virtual function virtual void move() = 0 virtual Shape clone() const = 0 Uses the copy constructor virtual Shape create() const = 0 Uses the default constructor class Circle public Shape public Circle clone() const return new Circle(this) Circle create() const return new Circle()

      In the clone() member function the new Circle(this) code calls Circles copy constructor to copy the state of this into the newly created Circle object In the create() member function the new Circle() code calls Circles default constructor

      Users use these as if they were virtual constructors

      void userCode(Shapeamp s) Shape s2 = sclone() Shape s3 = screate() delete s2 You probably need a virtual destructor here

      delete s3

      23 How do you link a C++ program to C functions

      By using the extern C linkage specification around the C function declarations

      24 Explain the scope resolution operator

      The scope resolution operator permits a program to reference an identifier in the global scope that has been hidden by another identifier with the same name in the local scope

      25 What are the differences between a C++ struct and C++ class

      The default member and base class access specifiers are different

      26 How many ways are there to initialize an int with a constant

      Two

      27 How does throwing and catching exceptions differ from using setjmp and longjmp

      The throw operation calls the destructors for automatic objects instantiated since entry to the try block

      28 How does throwing and catching exceptions differ from using setjmp and longjmp

      The throw operation calls the destructors for automatic objects instantiated since entry to the try block

      29 What is a default constructor

      A constructor that has no arguments or one where all the arguments have default argument values

      If you dont code a default constructor the compiler provides one if there are no other constructors If you are going to instantiate an array of objects of the class the class must have a default constructor

      30 What is a conversion constructor

      It is a constructor that accepts one argument of a different type

      The compiler uses this idiom as one way to infer conversion rules for a class A constructor with more than one argument and with default argument values can be interpreted by the compiler as a conversion constructor when the compiler is looking for an object of the type and sees an object of the type of the constructors first argument

      31 What is the difference between a copy constructor and an overloaded assignment operator

      A copy constructor constructs a new object by using the content of the argument object An overloaded assignment operator assigns the contents of an existing object to another existing object of the same class

      First you must know that a copy constructor is one that has only one argument which is a reference to the same type as the constructor The compiler invokes a copy constructor wherever it needs to make a copy of the object for example to pass an argument by value If you do not provide a copy constructor the compiler creates a member-by-member copy constructor for you

      You can write overloaded assignment operators that take arguments of other classes but that behavior is usually implemented with implicit conversion constructors If you do not provide an overloaded assignment operator for the class the compiler creates a default member-by-member assignment operator

      This discussion is a good place to get into why classes need copy constructors and overloaded assignment operators By discussing the requirements with respect to data member pointers that point to dynamically allocated resources you demonstrate a good grasp of the problem

      32 When should you use multiple inheritance

      There are three acceptable answers Never Rarely and When the problem domain cannot be accurately modeled any other way

      33 What is a virtual destructor

      The simple answer is that a virtual destructor is one that is declared with the virtual attribute

      The behavior of a virtual destructor is what is important If you destroy an object through a pointer or reference to a base class and the base-class destructor is not virtual the derived-class destructors are not executed and the destruction might not be complete

      34 Explain the ISA and HASA class relationships How would you implement each in a class design

      A specialized class is a specialization of another class and therefore has the ISA relationship with the other class An Employee ISA Person This relationship is best implemented with inheritance Employee is derived from Person A class may have an instance of another class For example an Employee has a Salary therefore the Employee class has the HASA relationship with the Salary class This relationship is best implemented by embedding an object of the Salary class in the Employee class

      The answer to this question reveals whether you have an understanding of the fundamentals of object-oriented design which is important to reliable class design

      There are other relationships The USESA relationship is when one class uses the services of another The Employee class uses an object (cout) of the ostream class to display the employees name onscreen for example But if you get ISA and HASA right you usually dont need to go any further

      35 When is a template a better solution than a base class

      When you are designing a generic class to contain or otherwise manage objects of other types when the format and behavior of those other types are unimportant to their containment or management and particularly when those other types are unknown (thus the genericity) to the designer of the container or manager class

      Prior to templates you had to use inheritance your design might include a generic List container class and an application-specific Employee class To put employees in a list a ListedEmployee class is multiply derived (contrived) from the Employee and List classes These solutions were unwieldy and error-prone Templates solved that problem

      Questions for ANSI-Knowledgeable Applicants

      There are six questions for those who profess knowledge of the progress of the ANSI committee If you claim to have that much interest in the language you should know the answers to all these questions

      1 What is a mutable member

      A mutable member is one that can be modified by the class even when the object of the class or the member function doing the modification is const

      Understanding this requirement implies an understanding of C++ const which many programmers do not have I have seen large class designs that do not employ the const qualifier anywhere Some of those designs are my own early C++ efforts One author suggests that some programmers find const to be such a bother that it is easier to ignore const than to try to use it meaningfully No

      wonder many programmers dont understand the power and implications of const Someone who claims to have enough interest in the language and its evolution to keep pace with the ANSI deliberations should not be ignorant of const however

      2 What is an explicit constructor

      A conversion constructor declared with the explicit keyword The compiler does not use an explicit constructor to implement an implied conversion of types Its purpose is reserved explicitly for construction

      3 What is the Standard Template Library

      It is a library of container templates approved by the ANSI committee for inclusion in the standard C++ specification

      4 Describe run-time type identification

      It is the ability to determine at run time the type of an object by using the typeid operator or the dynamic_cast operator

      5 What problem does the namespace feature solve

      Multiple providers of libraries might use common global identifiers causing a name collision when an application tries to link with two or more such libraries The name-space feature surrounds a librarys external declarations with a unique namespace that eliminates the potential for those collisions

      This solution assumes that two library vendors dont use the same namespace of course

      6 Are there any new intrinsic (built-in) data types

      Yes The ANSI committee added the bool intrinsic type and its true and false value keywords and the wchar_t data type to support character sets wider than eight bits

      SQL Server

      1 What is a foreign key

      A foreign key is a column or combination of columns used to establish and enforce a link (referential integrity) between the data in two tables A link is created between two tables by adding the column or columns that hold one tablersquos primary key values to the other table This column becomes a foreign key in the second table

      2 What is the difference between a primary key and unique key

      There can be only one primary key constrain on a table but there can be many unique key constraints in a table

      Primary key doesnrsquot allow null values but Unique allows 1 Null value

      3 What is an index

      Indexes are database objects which provides faster data access The index provides pointers to the data values stored in specified columns of

      the table and then orders those pointers according to the sort order you specify

      Different types of indexes are unique index clustered index and non-clustered index

      4 How to return multiple result set from a stored proc and capture it in ADO

      Use multiple Select statements to return multiple result sets Use ADOrsquos GetNextRecordset() method to get the second recordset during the

      execution of the stored proc

      • COMDCOM
      • Visual Basic
      • General Scripting Questions
      • Session and Application Variable Questions
        • Image Questions
        • Browser Questions
        • ActiveX Data Objects Questions
        • Form and Query String Questions
          • 18 What is a virtual member function
          • 19 How can C++ achieve dynamic binding yet also static typing
          • 20 Whats the difference between how virtual and non-virtual member functions are called
          • 21 When should my destructor be virtual
          • 22 What is a virtual constructor
          • Questions for ANSI-Knowledgeable Applicants

        ASPNET1 What is server control2 What is validation control3 What are different type of caching(Page Fragment data)4 what is XMLHTTP5 Different kinds of session management 6 Types of caching dependency7 Dynamic caching 8 Role based authetication using Principals and Identity objects

        VBNET1 What is alising

        COMDCOM

        1 What is COM

        COM provides a group of conventions and supporting libraries that allow interaction between different pieces of software in a consistent object-oriented way

        COM is a binary standard for component interoperability It helps to build language neutral components

        2 What is dual interface

        An interface that supports both IDispatch and VTBL binding COM Dlls developed in VB automatically inherits IdispatchImpl interface and

        thus dual interface

        3 Have you ever worked on DCOM If yes explain the architecture of any one of the application

        ltlt Need to explain typical application architecture here gtgt

        4 What are the various services provided by the MTSCOM+ system

        Manage server process pools and thread pools Ultimately rather than dedicating a thread to work on behalf of a single client servers need to manage thread pools for servicing multiple client requests

        Synchronize access to shared data and resources across concurrent requests from clients This requires sophisticated locking protocols that must account for deadlocks race conditions starvation and other performance issues

        Manage client context including database connections and per-user data structures (or objects)

        Cache state on the client for improved latency across slow networks Implement security to ensure that business functions and objects are only

        available to those authorized to use them Implement management and configuration tools to allow remote installation

        and administration of the servers

        5 What are AdvantagesDisadvantages of ActiveX controls over DLL

        Look for an answer similar to points mentioned in the table below

        ActiveX DLLEncapsulates the whole aspects of the object

        Encapsulates only functional aspect of the object

        Pretty complicated for implementation and usage

        Much easier to implement and use

        Binary compatibility specification (may be used in different platforms)

        Implemented only for Win32 platform

        6 What is IUnknown What methods provided by IUnknown

        It is generally good idea to have an answer for this question if you claim you know COM in your resume Otherwise you may consider your interview failed at this point

        IUnknown is the base interface of COM All other interfaces must derive directly or indirectly from IUnknown There are three methods in that interface AddRef Release and QueryInterface

        7 What are the purposes of AddRef Release and QueryInterface functions

        AddRef increments reference count of the object Release decrements reference counter of the object and QueryInterface obtains a pointer to the requested interface

        8 What is aggregation How can we get an interface of the aggregated object

        Aggregation is the reuse mechanism in which the outer object exposes interfaces from the inner object as if they were implemented on the outer object itself This is useful when the outer object would always delegate every call to one of its interfaces to the same interface in the inner object Aggregation is actually a specialized case of containmentdelegation and is available as a convenience to avoid extra implementation overhead in the outer object in these cases We can get a pointer to the inner interface calling QueryInterface of the outer object with IID of the inner interface

        9 C is aggregated by B which in turn aggregated by A Our client requested C What will happen

        QueryInterface to A will delegate request to B which in turn will delegate request for the interface to C This pointer will be returned to the client

        10 Whats the difference if any between OLE and COM

        OLE is build on top of COM The question is not strict because OLE was built over COM for years while COM as a technology was presented by Microsoft a few years ago You may mention also that COM is a specification while OLE is a particular implementation of this specification which in todays world is not exactly true as well because what people call COM today is likely implementation of COM spec by Microsoft

        11 Whats the difference between COM and DCOM

        Again the question does not require strict answer Any DCOM object is yet a COM object (DCOM extends COM) and any COM object may participate in DCOM transactions

        DCOM introduced several improvementsoptimizations for distributed environment such as MULTI_QI (multiple QueryInterface()) security contexts etc DCOM demonstrated importance of surrogate process (you cannot run in-proc server on a remote machine You need a surrogate process to do that) DCOM introduced a load balancing

        12 What is a dual interface

        Dual interface is one that supports both - IDispatch interface and vtbl-based interface Therefore it might be used in scripting environment like VBScript and yet to use power and speed of vtbl-based interface for non-scripting environment Discussion then may easily transform into analyzing of dual interface problems - be prepared to this twist

        13 What is a multi-threaded apartment (MTA) and what is a Single-threaded apartment (STA)

        This is pretty difficult question to describe shortly

        Anyway apartments were introduced by Microsoft in NT 351 and late Windows 95 to isolate the problem of running legacy non-thread safe code into multithreaded environment Each thread was encapsulated into so called single-threaded apartment The reason to create an object in apartment is thread-safety

        COM is the responsible synchronized way to access an object even if the object inside the apartment is not thread-safe Multithreaded apartments (MTA or free threading apartment) were introduced in NT 40 Idea behind MTA is that COM is

        not responsible to synchronize object calls between threads In MTA the developer is responsible for that

        ltlt See Professional DCOM Programming of Dr Grimes et al or Essential COM of Don Box for the further discussion on this topic gtgt

        14 Lets assume we have object B and aggregated object C (in-proc server) created by B Can you access any interface of B from C Whats the difference between aggregated and contained objects

        Yes you can This is fundamental postulate of COM If you can get there from here you can get there from anywhere ie QIing for IUnknown you may proceed and to get a pointer to any other interface supported by the object Aggregated object exposes its interface directly without visible intervention of the object container Contained object is created within the object container and its interfaces might be altered or filtered by the object container

        15 Is there a way to register in-proc server without regsvr32exe

        Yes Call DllRegisterServer() from the client Do not forget to call DLLUnregisterServer() from the same client You may also use Registrar object for the same purpose or use direct manipulation of the windows registry

        16 What is VARIANT Why and where would you use it

        VARIANT is a huge union containing automation type This allows easy conversion of one automation type to another The biggest disadvantage of VARIANT is size of the union

        17 What is __declspec(novtable) Why would you need this

        __declspec(novtable) is a Microsofts compiler optimization The main idea of this optimization is to strip the vtable initialization code from abstract class (for abstract class the vtable is empty while it is initialized in contructor) MSDN has an excellent article on this topic (search for ATL Virtual Functions and vtables)

        18 What is an IDL

        IDL stands for Interface Definition Language IDL is the language to describe COM interfaces

        19 What is In-proc

        In-proc is in-process COM object ie COM object that implemented as DLL and supposed to be hosted by a container When you have to instantiate the in-proc object remotely you may use DLLHostexe application that was design specially for this purpose

        20 What is OLE

        OLE is an object and embedding first implementation of COM spec available from MS before COM was officially named COM

        21 Give examples of OLE usage

        The most famous examples are probably drag and drop and structured storage implementations

        22 What are 2 storage types for composite document

        The two storage types are Storage and Stream

        23 Is doc document a compound document Is it a structured storage

        Compound document is a document that contains information about other documents hosted in this document All office documents may or may not be compound documents Word documents from version 60 and up are stored as structured storage

        Non-VB COMDCOM

        1 What should QueryInterface functions do if requested object was not found

        Return E_NOINTERFACE and nullify its out parameter

        2 How would you create an instance of the object in COM

        ltlt Well it all depends on your project Start your answer from CoCreateInstance or CoCreateInstanceEx explain the difference between them If interviewer is still not satisfied youll have to explain the whole kitchen behind the scenes including a difference between local server and inproc server meaning and mechanism of class factory etc You may also mention other methods of object creation like CoGetInstanceFromFile but discussion will likely turn to discussion of monikers then gtgt

        3 What happens when client calls CoCreateInstance

        ltlt Again all depends on the level of detail and expertise of interviewer Start with simple explanation of class object and class factory mechanism Further details would depend on a specific situation gtgt

        4 What are the limitations of CoCreateInstance

        Well a major problem with CoCreateInstance is that it is only able to create one object and only on local system To create a remote object or to get several objects based on single CLSID at the same time one should use CoCreateInstanceEx

        5 What is a moniker

        It is an object that implements the IMoniker interface A moniker acts as a name that uniquely identifies a COM object In the same way that a path identifies a file in the file system a moniker identifies a COM object in the directory namespace

        6 Can you have two dual interfaces in one class

        Yes You may have two dual interfaces in one class but only one of them may be default The bottom line is that you cannot work with two dual interfaces at the same time due to nature of dual interfaceTo support two dual interfaces in VB you would write something like

        dim d1 as IDualInterface1 dim d2 as IDualInterface2

        set d1 = new MyClassWithTwoDualsset d2 = d1

        In ATLs class you would have to use macro COM_INTERFACE_ENTRY2(IDispatch IDualInterface1) to distinguish between different dual interfaces

        7 What is a marshalling by value

        Some objects can essentially be considered static regardless of which methods are called the state of the object does not change Instead of accessing such an object remotely it is possible to copy the static state of the object and create a new object with the same state information on the caller side The caller wont be able to notice the difference but calls will be more efficient because they do not involve network round trips This is called marshaling by value

        8 What is ROT What is GIT Give pros and cons of both

        By definition running object table (ROT) is a globally accessible table on each computer that keeps track of all COM objects in the running state that can be identified by a moniker Moniker providers register an object in the table which increments the objects reference count Before the object can be destroyed its moniker must be released from the tableGlobal Interface Table (GIT) allows any apartment (either single- or multi-threaded) in a process to get access to an interface implemented on an object in any other apartment in the process

        9 If you have an object with two interfaces can you custom marshal one of them

        No The decision to use custom marshaling is an all-or-nothing decision an object has to custom marshal all its interfaces or none of them

        10 How can you guarantee that only a remote server is ever created by a client

        Create an object (call CoCreateObjectEx()) with CLSCTX_REMOTE_SERVER flag

        Visual Basic

        1 What are the properties and methods of ObjectControl interface

        Activate Deactivate CanBePooled

        2 How will you implement transaction in a visual basic ActiveX dll

        Set the MTSTransactionMode property of the class modules Use the ObjectContextSetcomplete SetAbort methods to commitrollback

        the transactions

        3 How to execute a stored proc from VB using ADO

        A stored proc can be executed using the command object

        4 What are the objects in ADO

        These are Connection Command Recordset Record Parameter and stream

        Visual Basic UI

        1 How to access a member variable in one form from another

        Set the access modifier of the member variable as Public Create a property procedure

        2 What is the listindex property of a list box control

        Listindex is the index of the currently selected item in the control

        3 Have you worked on grid controls

        ltlt Answer should be Yes or No gtgt

        ASP

        1 How will you describe a session

        Session object in ASP provides dynamic associative array that a script can use to store information

        ASP Sessions Are Cookie-based

        2 What are the different methods to pass an argument from one page to another

        Using Query string Using Hidden controls

        NET

        1 How NET My Services work

        From the developers perspective NET My Services is a set of XML Web services accessed by sending and receiving SOAP messages sent though the HTTP or DIME protocols and using the NET Passport system for authentication NET My Services consists of three things Authentication which will be provided by NET Passport when NET My Services goes live SOAP the communication protocol XML following the rules and schemas set out in the XMI Reference which provides the data formatting and organization

        2 What are Web Services

        Web Services are applications delivered as a service on the Web Web services allow for programmatic access of business logic over the Web Web services typically rely on XML-based protocols messages and interface descriptions for communication and access Web services are designed to be used by other programs or applications rather than directly by end user Programs invoking a Web service are called clients SOAP over HTTP is the most commonly used protocol for invoking Web services

        3 How do I use a proxy server when invoking a Web service

        If you are using the SOAP Toolkit you need to set some connector properties to use a proxy server Dim soap As SoapClient Set soap=New SoapClient soapConnectorProperty(ProxyServer) = ldquoproxyservernamerdquo soapConnectorProperty(ProxyPort) = ldquo8080rdquo soapConnectorProperty(UseProxy) = True While with NET you just need to create a SystemNetWebProxy object and use it to set the Proxy property Dim webs As localhostMyService() websProxy=New SystemNetWebProxy(ldquohttpproxyserver8080rdquo)

        4 What is Simple Object Access Protocol (SOAP)

        SOAP is an XML-based messaging framework specifically designed for exchanging formatted data across the Internet for example using request and reply messages or sending entire documents SOAP is simple easy to use and completely neutral with respect to operating system programming language or

        distributed computing platform

        5 What is Web Services Description Language (WSDL)

        After SOAP became available as a mechanism for exchanging XML messages among enterprises (or among disparate applications within the same enterprise) a better way was needed to describe the messages and how they are exchanged The Web Services Description Language (WSDL) is a particular form of an XML Schema developed by Microsoft and IBM for the purpose of defining the XML message operation and protocol mapping of a web service accessed using SOAP or other XML protocol WSDL defines web services in terms of endpoints that operate on XML messages The WSDL syntax allows both the messages and the operations on the messages to be defined abstractly so they can be mapped to multiple physical implementations The current WSDL spec describes how to map messages and operations to SOAP 11 HTTP GETPOST and MIME WSDL creates web service definitions by mapping a group of endpoints into a logical sequence of operations on XML messages The same XML message can be mapped to multiple operations (or services) and bound to one or more communications protocols (using ports)

        6 What is Universal Description Discovery and Integration (UDDI)

        The Universal Description Discovery and Integration (UDDI) framework defines a data model (in XML) and SOAP APIs for registration and searches on business information including the web services a business exposes to the Internet UDDI is an independent consortium of vendors founded by Microsoft IBM and Ariba for the purpose of developing an Internet standard for web service description registration and discovery Microsoft IBM and Ariba also are hosting the initial deployment of a UDDI service which is conceptually patterned after DNS (the Internet service that translates URLs into TCP addresses) UDDI uses a private agreement profile of SOAP (ie UDDI doesnt use the SOAP serialization format because its not well suited to passing complete XML documents (its aimed at RPC style interactions) The main idea is that businesses use the SOAP APIs to register themselves with UDDI and other businesses search UDDI when they want to discover a trading partner for example someone from whom they wish to procure sheet metal bolts or transistors The information in UDDI is categorized according to industry type and geographical location allowing UDDI consumers to search through lists of potentially matching businesses to find the specific one they want to contact Once a specific business is chosen another call to UDDI is made to obtain the specific contact information for that business The contact information includes a pointer to the target businesss WSDL or other XML schema file describing the web service that the target business publishes

        The interviewer should be well versed in NET to ask these questions The interview should know the answers

        Execution cycle of an assembly How does CLR comes into picture- Platform independence

        Managed unmanaged code Information about GAC How does GAC help in maintaining different versions of an assembly if

        changes are made to an assembly and the new version does not support some of functionality that previous version supported how will the runtime handle ito What is the sequence of steps followed by the runtime to look for the

        references like first to bin then GAC etco How to add assemblies in GAC

        How do we use MTS capabilities in NET assemblies Different type of data persistence in NET

        o Caching Data caching Output caching

        o Serialization Xml Bin

        Usercontrols vc Custom Controls ndash Composite controls Datareader vs Dataset Sorting in Datagrid adding custom controls in datagrid columns Use of view state in ASPX pages How to improve performance of the pages in web environment Is it possible to have both client side and server side functionality on aspx

        server controls In the page execution life cycle when is the page_init called What is AutoEventWireUp attribute used for What are delegates used for Webservices

        o How do you deploy web services Reflections Remoting

        o What is client activated objects and what are server activated objectso What are channels used for

        Interopo How does a NET component call a primitive one What are the steps taken

        General Scripting Questions

        1 How do you add a quotation mark to VB script string

        The first method uses two quotation marks in a row to create a single quotation mark The second method uses the ASCII value of the quotation mark character

        2 How do you break a single VBScript Statement into multiple lines

        A single VBScript Statement can be broken into multiple lines by using the _underscore character

        3 What is the proper method of comparing strings in VBScript

        The first method uses VBScript function with the vbTextCompare constant The second method forces both strings into uppercase

        4 How do you re-enable errors after using ON ERROR RESUME NEXT

        ltlt Need an answer gtgt

        5 How do you prevent My Script from timing out

        You can extend the amount of time a script is allowed to run by using the ScriptTimeout property of the Server object

        6 When do you need to explicitly convert a variable to a particular data type

        If you are comparing numbers or dates and there is a danger that VBScript might interpret the values as strings one of the VBScript conversion functions should be used

        7 When should one pass a variable by value and when by reference

        When you pass a variable by value to a subordinate or function a new instance of the variable is created Any changes made to the value of the variable do not affect the value of the original variable On the other hand whne you pass a variable by reference changes made to the variable do affect the value of the original variable

        8 How can you add a space between the output of two variables

        ltlt Need an answer gtgt

        9 Does ASP support dynamic includes

        It does not support

        10 How do you use the option Explicit statement in an ASP

        It must be used before nay other VBScript statement or HTML content in a script else it will generate and error

        Session and Application Variable Questions

        1 Why do session variables sometimes fail to work

        Session variables depend on browser cookies If a browser does not support cookies or a user has turned off cookies or the userrsquos cookie file is corrupted Session variables will not work

        2 How do you remove an application variable

        ltlt Need an answer gtgt

        3 How do you detect whether a File exists

        I can detect by using the FileExists method of the FileSystemObject

        4 How do you automatically display a list of the Files in a directory

        By using a list of files in a folder by using the FileSystemObject and the Folder object

        Image Questions

        1 How do you store an image in a database table

        Although you can store an image in a SQL Server BLOB column it is almost always better to store the URL of an image in a database table rather than the image itself

        2 How do you dynamically generate a graph or image in an ASP

        Several third-party ASP components enable you to dynamically create custom images

        Browser Questions

        1 How do you detect the type of browser a person is using to visit your web site

        The User-Agent header indicates the type of browser

        2 How do you detect a page from which a person originated

        The Referer header contains the URL of the last page the person visited This header can be retrieved from the ServerVariables collection

        ActiveX Data Objects Questions

        1 Why do you sometimes receive an error when using the Connection Object to execute a SQL string

        ltlt Need an answer gtgt

        2 How do you retrieve a Text filed in an ASP

        If you do not take special precautions when retrieving a Text field from a database table the value of the Text field might be truncated If you are using a forward-only cursor type you should use the Text field as the very last field in your select list Alternatively consider using a richer cursor type when opening a Recordset that contains a Text field

        3 Why does the RecordCount always return the Value-1

        The RecordCount property returns the number of rows in a Recordset after it has been opened you cannot use this property with a forward-only cursor when using SQL Server (it will always return ndash1)

        4 Why do you receive an error whenever you try to update the value of a filed in a recordset

        By default when you open a Recordset it is opened with a forward-only cursor and read-only lock type To update a Recordset you must open a Recordset that is not read-only

        5 How do you limit the number of rows returned by a Database Query

        If using SQL 70 or Access you can use the SQL Top keyword to limit the number of records returned Otherwise if you are using SQL 65 use the MaxRecords property of the Recordset object

        ltlt What about SQL 2000 gtgt

        6 How do you retrieve the value from a SQL Statement that uses Count() Max Min or Identity

        There are two methods that you can use to retrieve the value from a SQL function or a SQL global variable You can either use an alias for the value or refer to the value by its ordinal position in the Recordset

        7 How do you retrieve an output parameter from a SQL stored procedure within an ASPScript

        You must use the ADO Command nad parameter objects

        Form and Query String Questions

        1 How do you accept file uploads in an HTML form

        ltlt Need an answer gtgt

        2 What causes the value of a form field to become truncated

        HTML uses quotation marks to mark the beginning and end of a value So If a variable contains question marks in its values the value of the variablewill be truncated when displayed

        3 How do you include spaces or other special characters in a query string

        URL encode the query string

        C++ Questions

        1 What is an object in C++

        An object is a package that contains related data and instructions The data relates to what the object represents while the instructions define how this object relates to other objects and itself

        2 What is a message

        A message is a signal from one object to another requesting that a computation take place It is roughly equivalent to a function call in other languages

        3 What is a class

        A class defines the characteristics of a certain type of object It defines what its members will remember the messages to which they will respond and what form the response will take

        4 What is an instance

        It is an individual object that is a member of some class

        5 What is a super-class

        Given a class a super-class is the basis of the class under consideration The given class is defined as a subset (in some respects) of the super-class All objects of the given class potentially posses all the characteristics belonging to objects of the super-class

        6 What is inheritance

        Inheritance is property such that a parent (or super) class passes the characteristics of itself to children (or sub) classes that are derived from it The sub-class has the option of modifying these characteristics in order to make a different but fundamentally related class from the super-class

        7 To what does message protocol refer

        An objects message protocol is the exact form of the set of messages to which the object can respond

        8 What is polymorphism

        Polymorphism refers to the ability of an object to respond in a logically identical fashion to messages of the same protocol containing differing types of objects Consider 1 + 5 and 1 + 51 In the former the message + 5 is sent to an object of class integer (1) In the later the message + 51 is sent to the same integer object The form of the message (its protocol) is identical in both cases What differs is the type of object on the right-hand side of these messages The former is an integer object (5) while the later is a floating point object (51) The receiver (1) appears (to other objects) to respond in the same way to both messages Internally however it knows that it must treat the two types of objects differently in order to obtain the same overall response

        9 What are instance variables

        These represent an objects private memory They are defined in an objects class

        18 What is a virtual member function

        A virtual function allows derived classes to replace the implementation provided by the base class The compiler makes sure the replacement is always called whenever the object in question is actually of the derived class even if the object is accessed by a base pointer rather than a derived pointer This allows algorithms in the base class to be replaced in the derived class even if users dont know about the derived class

        The derived class can either fully replace (override) the base class member function or the derived class can partially replace (augment) the base class member function The latter is accomplished by having the derived class member function call the base class member function if desired

        19 How can C++ achieve dynamic binding yet also static typing

        When you have a pointer to an object the object may actually be of a class that is derived from the class of the pointer (eg a Vehicle that is actually pointing to a Car object) Thus there are two types the (static) type of the pointer (Vehicle in this case) and the (dynamic) type of the pointed-to object (Car in this case)

        Static typing means that the legality of a member function invocation is checked at the earliest possible moment by the compiler at compile time The compiler uses the static type of the pointer to determine whether the member function invocation is legal If the type of the pointer can handle the member function certainly the pointed-to object can handle it as well Eg if Vehicle has a certain member function certainly Car also has that member function since Car is a kind-of Vehicle

        Dynamic binding means that the address of the code in a member function invocation is determined at the last possible moment based on the dynamic type of the object at run time It is called dynamic binding because the binding to the code that actually gets called is accomplished dynamically (at run time) Dynamic binding is a result of virtual functions

        20 Whats the difference between how virtual and non-virtual member functions are called

        Non-virtual member functions are resolved statically That is the member function is selected statically (at compile-time) based on the type of the pointer (or reference) to the object

        In contrast virtual member functions are resolved dynamically (at run-time) That is the member function is selected dynamically (at run-time) based on the type of the object not the type of the pointerreference to that object This is called dynamic binding Most compilers use some variant of the following technique

        if the object has one or more virtual functions the compiler puts a hidden pointer in the object called a virtual-pointer or v-pointer This v-pointer points to a global table called the virtual-table or v-table

        The compiler creates a v-table for each class that has at least one virtual function For example if class Circle has virtual functions for draw() and move() and resize() there would be exactly one v-table associated with class Circle even if there were a gazillion Circle objects and the v-pointer of each of those Circle objects would point to the Circle v-table The v-table itself has pointers to each of the virtual functions in the class For example the Circle v-table would have three pointers a pointer to Circledraw() a pointer to Circlemove() and a pointer to Circleresize()

        During a dispatch of a virtual function the run-time system follows the objects v-pointer to the classs v-table then follows the appropriate slot in the v-table to the method code

        The space-cost overhead of the above technique is nominal an extra pointer per object (but only for objects that will need to do dynamic binding) plus an extra pointer per method (but only for virtual methods) The time-cost overhead is also fairly nominal compared to a normal function call a virtual function call requires two extra fetches (one to get the value of the v-pointer a second to get the address of the method) None of this runtime activity happens with non-virtual functions since the compiler resolves non-virtual functions exclusively at compile-time based on the type of the pointer

        21 When should my destructor be virtual

        When you may delete a derived object via a base pointer

        virtual functions bind to the code associated with the class of the object rather than with the class of the pointerreference When you say delete basePtr and the base class has a virtual destructor the destructor that gets invoked is the one associated with the type of the object basePtr rather than the one associated with the type of the pointer This is generally A Good Thing

        TECHNO-GEEK WARNING PUT YOUR PROPELLER HAT ON Technically speaking you need a base classs destructor to be virtual if and only if you intend to allow someone to invoke an objects destructor via a base class pointer (this is normally done implicitly via delete) and the object being destructed is of a derived class that has a non-trivial destructor A class has a non-trivial destructor if it either has an explicit destructor or if it has a member object or a base class that has a non-trivial destructor (note that this is a recursive definition (eg a class has a non-trivial destructor if it has a member object (which has a base class (which has a member object (which has a base class (which has an explicit destructor)))))) END TECHNO-GEEK WARNING REMOVE YOUR PROPELLER HAT

        If you had a hard grokking the previous rule try this (over)simplified one on for size A class should have a virtual destructor unless that class has no virtual functions Rationale if you have any virtual functions at all youre probably going to be doing stuff to derived objects via a base pointer and some of the stuff you may do may include invoking a destructor (normally done implicitly via delete) Plus once youve put the first virtual function into a class youve already paid all the per-object space cost that youll ever pay (one pointer per object note that this is theoretically compiler-specific in practice everyone does it pretty much the same way) so making the destructor virtual wont generally cost you anything extra

        22 What is a virtual constructor

        An idiom that allows you to do something that C++ doesnt directly support

        You can get the effect of a virtual constructor by a virtual clone() member function (for copy constructing) or a virtual create() member function (for the default constructor)

        class Shape public virtual ~Shape() A virtual destructor virtual void draw() = 0 A pure virtual function virtual void move() = 0 virtual Shape clone() const = 0 Uses the copy constructor virtual Shape create() const = 0 Uses the default constructor class Circle public Shape public Circle clone() const return new Circle(this) Circle create() const return new Circle()

        In the clone() member function the new Circle(this) code calls Circles copy constructor to copy the state of this into the newly created Circle object In the create() member function the new Circle() code calls Circles default constructor

        Users use these as if they were virtual constructors

        void userCode(Shapeamp s) Shape s2 = sclone() Shape s3 = screate() delete s2 You probably need a virtual destructor here

        delete s3

        23 How do you link a C++ program to C functions

        By using the extern C linkage specification around the C function declarations

        24 Explain the scope resolution operator

        The scope resolution operator permits a program to reference an identifier in the global scope that has been hidden by another identifier with the same name in the local scope

        25 What are the differences between a C++ struct and C++ class

        The default member and base class access specifiers are different

        26 How many ways are there to initialize an int with a constant

        Two

        27 How does throwing and catching exceptions differ from using setjmp and longjmp

        The throw operation calls the destructors for automatic objects instantiated since entry to the try block

        28 How does throwing and catching exceptions differ from using setjmp and longjmp

        The throw operation calls the destructors for automatic objects instantiated since entry to the try block

        29 What is a default constructor

        A constructor that has no arguments or one where all the arguments have default argument values

        If you dont code a default constructor the compiler provides one if there are no other constructors If you are going to instantiate an array of objects of the class the class must have a default constructor

        30 What is a conversion constructor

        It is a constructor that accepts one argument of a different type

        The compiler uses this idiom as one way to infer conversion rules for a class A constructor with more than one argument and with default argument values can be interpreted by the compiler as a conversion constructor when the compiler is looking for an object of the type and sees an object of the type of the constructors first argument

        31 What is the difference between a copy constructor and an overloaded assignment operator

        A copy constructor constructs a new object by using the content of the argument object An overloaded assignment operator assigns the contents of an existing object to another existing object of the same class

        First you must know that a copy constructor is one that has only one argument which is a reference to the same type as the constructor The compiler invokes a copy constructor wherever it needs to make a copy of the object for example to pass an argument by value If you do not provide a copy constructor the compiler creates a member-by-member copy constructor for you

        You can write overloaded assignment operators that take arguments of other classes but that behavior is usually implemented with implicit conversion constructors If you do not provide an overloaded assignment operator for the class the compiler creates a default member-by-member assignment operator

        This discussion is a good place to get into why classes need copy constructors and overloaded assignment operators By discussing the requirements with respect to data member pointers that point to dynamically allocated resources you demonstrate a good grasp of the problem

        32 When should you use multiple inheritance

        There are three acceptable answers Never Rarely and When the problem domain cannot be accurately modeled any other way

        33 What is a virtual destructor

        The simple answer is that a virtual destructor is one that is declared with the virtual attribute

        The behavior of a virtual destructor is what is important If you destroy an object through a pointer or reference to a base class and the base-class destructor is not virtual the derived-class destructors are not executed and the destruction might not be complete

        34 Explain the ISA and HASA class relationships How would you implement each in a class design

        A specialized class is a specialization of another class and therefore has the ISA relationship with the other class An Employee ISA Person This relationship is best implemented with inheritance Employee is derived from Person A class may have an instance of another class For example an Employee has a Salary therefore the Employee class has the HASA relationship with the Salary class This relationship is best implemented by embedding an object of the Salary class in the Employee class

        The answer to this question reveals whether you have an understanding of the fundamentals of object-oriented design which is important to reliable class design

        There are other relationships The USESA relationship is when one class uses the services of another The Employee class uses an object (cout) of the ostream class to display the employees name onscreen for example But if you get ISA and HASA right you usually dont need to go any further

        35 When is a template a better solution than a base class

        When you are designing a generic class to contain or otherwise manage objects of other types when the format and behavior of those other types are unimportant to their containment or management and particularly when those other types are unknown (thus the genericity) to the designer of the container or manager class

        Prior to templates you had to use inheritance your design might include a generic List container class and an application-specific Employee class To put employees in a list a ListedEmployee class is multiply derived (contrived) from the Employee and List classes These solutions were unwieldy and error-prone Templates solved that problem

        Questions for ANSI-Knowledgeable Applicants

        There are six questions for those who profess knowledge of the progress of the ANSI committee If you claim to have that much interest in the language you should know the answers to all these questions

        1 What is a mutable member

        A mutable member is one that can be modified by the class even when the object of the class or the member function doing the modification is const

        Understanding this requirement implies an understanding of C++ const which many programmers do not have I have seen large class designs that do not employ the const qualifier anywhere Some of those designs are my own early C++ efforts One author suggests that some programmers find const to be such a bother that it is easier to ignore const than to try to use it meaningfully No

        wonder many programmers dont understand the power and implications of const Someone who claims to have enough interest in the language and its evolution to keep pace with the ANSI deliberations should not be ignorant of const however

        2 What is an explicit constructor

        A conversion constructor declared with the explicit keyword The compiler does not use an explicit constructor to implement an implied conversion of types Its purpose is reserved explicitly for construction

        3 What is the Standard Template Library

        It is a library of container templates approved by the ANSI committee for inclusion in the standard C++ specification

        4 Describe run-time type identification

        It is the ability to determine at run time the type of an object by using the typeid operator or the dynamic_cast operator

        5 What problem does the namespace feature solve

        Multiple providers of libraries might use common global identifiers causing a name collision when an application tries to link with two or more such libraries The name-space feature surrounds a librarys external declarations with a unique namespace that eliminates the potential for those collisions

        This solution assumes that two library vendors dont use the same namespace of course

        6 Are there any new intrinsic (built-in) data types

        Yes The ANSI committee added the bool intrinsic type and its true and false value keywords and the wchar_t data type to support character sets wider than eight bits

        SQL Server

        1 What is a foreign key

        A foreign key is a column or combination of columns used to establish and enforce a link (referential integrity) between the data in two tables A link is created between two tables by adding the column or columns that hold one tablersquos primary key values to the other table This column becomes a foreign key in the second table

        2 What is the difference between a primary key and unique key

        There can be only one primary key constrain on a table but there can be many unique key constraints in a table

        Primary key doesnrsquot allow null values but Unique allows 1 Null value

        3 What is an index

        Indexes are database objects which provides faster data access The index provides pointers to the data values stored in specified columns of

        the table and then orders those pointers according to the sort order you specify

        Different types of indexes are unique index clustered index and non-clustered index

        4 How to return multiple result set from a stored proc and capture it in ADO

        Use multiple Select statements to return multiple result sets Use ADOrsquos GetNextRecordset() method to get the second recordset during the

        execution of the stored proc

        • COMDCOM
        • Visual Basic
        • General Scripting Questions
        • Session and Application Variable Questions
          • Image Questions
          • Browser Questions
          • ActiveX Data Objects Questions
          • Form and Query String Questions
            • 18 What is a virtual member function
            • 19 How can C++ achieve dynamic binding yet also static typing
            • 20 Whats the difference between how virtual and non-virtual member functions are called
            • 21 When should my destructor be virtual
            • 22 What is a virtual constructor
            • Questions for ANSI-Knowledgeable Applicants

          Manage server process pools and thread pools Ultimately rather than dedicating a thread to work on behalf of a single client servers need to manage thread pools for servicing multiple client requests

          Synchronize access to shared data and resources across concurrent requests from clients This requires sophisticated locking protocols that must account for deadlocks race conditions starvation and other performance issues

          Manage client context including database connections and per-user data structures (or objects)

          Cache state on the client for improved latency across slow networks Implement security to ensure that business functions and objects are only

          available to those authorized to use them Implement management and configuration tools to allow remote installation

          and administration of the servers

          5 What are AdvantagesDisadvantages of ActiveX controls over DLL

          Look for an answer similar to points mentioned in the table below

          ActiveX DLLEncapsulates the whole aspects of the object

          Encapsulates only functional aspect of the object

          Pretty complicated for implementation and usage

          Much easier to implement and use

          Binary compatibility specification (may be used in different platforms)

          Implemented only for Win32 platform

          6 What is IUnknown What methods provided by IUnknown

          It is generally good idea to have an answer for this question if you claim you know COM in your resume Otherwise you may consider your interview failed at this point

          IUnknown is the base interface of COM All other interfaces must derive directly or indirectly from IUnknown There are three methods in that interface AddRef Release and QueryInterface

          7 What are the purposes of AddRef Release and QueryInterface functions

          AddRef increments reference count of the object Release decrements reference counter of the object and QueryInterface obtains a pointer to the requested interface

          8 What is aggregation How can we get an interface of the aggregated object

          Aggregation is the reuse mechanism in which the outer object exposes interfaces from the inner object as if they were implemented on the outer object itself This is useful when the outer object would always delegate every call to one of its interfaces to the same interface in the inner object Aggregation is actually a specialized case of containmentdelegation and is available as a convenience to avoid extra implementation overhead in the outer object in these cases We can get a pointer to the inner interface calling QueryInterface of the outer object with IID of the inner interface

          9 C is aggregated by B which in turn aggregated by A Our client requested C What will happen

          QueryInterface to A will delegate request to B which in turn will delegate request for the interface to C This pointer will be returned to the client

          10 Whats the difference if any between OLE and COM

          OLE is build on top of COM The question is not strict because OLE was built over COM for years while COM as a technology was presented by Microsoft a few years ago You may mention also that COM is a specification while OLE is a particular implementation of this specification which in todays world is not exactly true as well because what people call COM today is likely implementation of COM spec by Microsoft

          11 Whats the difference between COM and DCOM

          Again the question does not require strict answer Any DCOM object is yet a COM object (DCOM extends COM) and any COM object may participate in DCOM transactions

          DCOM introduced several improvementsoptimizations for distributed environment such as MULTI_QI (multiple QueryInterface()) security contexts etc DCOM demonstrated importance of surrogate process (you cannot run in-proc server on a remote machine You need a surrogate process to do that) DCOM introduced a load balancing

          12 What is a dual interface

          Dual interface is one that supports both - IDispatch interface and vtbl-based interface Therefore it might be used in scripting environment like VBScript and yet to use power and speed of vtbl-based interface for non-scripting environment Discussion then may easily transform into analyzing of dual interface problems - be prepared to this twist

          13 What is a multi-threaded apartment (MTA) and what is a Single-threaded apartment (STA)

          This is pretty difficult question to describe shortly

          Anyway apartments were introduced by Microsoft in NT 351 and late Windows 95 to isolate the problem of running legacy non-thread safe code into multithreaded environment Each thread was encapsulated into so called single-threaded apartment The reason to create an object in apartment is thread-safety

          COM is the responsible synchronized way to access an object even if the object inside the apartment is not thread-safe Multithreaded apartments (MTA or free threading apartment) were introduced in NT 40 Idea behind MTA is that COM is

          not responsible to synchronize object calls between threads In MTA the developer is responsible for that

          ltlt See Professional DCOM Programming of Dr Grimes et al or Essential COM of Don Box for the further discussion on this topic gtgt

          14 Lets assume we have object B and aggregated object C (in-proc server) created by B Can you access any interface of B from C Whats the difference between aggregated and contained objects

          Yes you can This is fundamental postulate of COM If you can get there from here you can get there from anywhere ie QIing for IUnknown you may proceed and to get a pointer to any other interface supported by the object Aggregated object exposes its interface directly without visible intervention of the object container Contained object is created within the object container and its interfaces might be altered or filtered by the object container

          15 Is there a way to register in-proc server without regsvr32exe

          Yes Call DllRegisterServer() from the client Do not forget to call DLLUnregisterServer() from the same client You may also use Registrar object for the same purpose or use direct manipulation of the windows registry

          16 What is VARIANT Why and where would you use it

          VARIANT is a huge union containing automation type This allows easy conversion of one automation type to another The biggest disadvantage of VARIANT is size of the union

          17 What is __declspec(novtable) Why would you need this

          __declspec(novtable) is a Microsofts compiler optimization The main idea of this optimization is to strip the vtable initialization code from abstract class (for abstract class the vtable is empty while it is initialized in contructor) MSDN has an excellent article on this topic (search for ATL Virtual Functions and vtables)

          18 What is an IDL

          IDL stands for Interface Definition Language IDL is the language to describe COM interfaces

          19 What is In-proc

          In-proc is in-process COM object ie COM object that implemented as DLL and supposed to be hosted by a container When you have to instantiate the in-proc object remotely you may use DLLHostexe application that was design specially for this purpose

          20 What is OLE

          OLE is an object and embedding first implementation of COM spec available from MS before COM was officially named COM

          21 Give examples of OLE usage

          The most famous examples are probably drag and drop and structured storage implementations

          22 What are 2 storage types for composite document

          The two storage types are Storage and Stream

          23 Is doc document a compound document Is it a structured storage

          Compound document is a document that contains information about other documents hosted in this document All office documents may or may not be compound documents Word documents from version 60 and up are stored as structured storage

          Non-VB COMDCOM

          1 What should QueryInterface functions do if requested object was not found

          Return E_NOINTERFACE and nullify its out parameter

          2 How would you create an instance of the object in COM

          ltlt Well it all depends on your project Start your answer from CoCreateInstance or CoCreateInstanceEx explain the difference between them If interviewer is still not satisfied youll have to explain the whole kitchen behind the scenes including a difference between local server and inproc server meaning and mechanism of class factory etc You may also mention other methods of object creation like CoGetInstanceFromFile but discussion will likely turn to discussion of monikers then gtgt

          3 What happens when client calls CoCreateInstance

          ltlt Again all depends on the level of detail and expertise of interviewer Start with simple explanation of class object and class factory mechanism Further details would depend on a specific situation gtgt

          4 What are the limitations of CoCreateInstance

          Well a major problem with CoCreateInstance is that it is only able to create one object and only on local system To create a remote object or to get several objects based on single CLSID at the same time one should use CoCreateInstanceEx

          5 What is a moniker

          It is an object that implements the IMoniker interface A moniker acts as a name that uniquely identifies a COM object In the same way that a path identifies a file in the file system a moniker identifies a COM object in the directory namespace

          6 Can you have two dual interfaces in one class

          Yes You may have two dual interfaces in one class but only one of them may be default The bottom line is that you cannot work with two dual interfaces at the same time due to nature of dual interfaceTo support two dual interfaces in VB you would write something like

          dim d1 as IDualInterface1 dim d2 as IDualInterface2

          set d1 = new MyClassWithTwoDualsset d2 = d1

          In ATLs class you would have to use macro COM_INTERFACE_ENTRY2(IDispatch IDualInterface1) to distinguish between different dual interfaces

          7 What is a marshalling by value

          Some objects can essentially be considered static regardless of which methods are called the state of the object does not change Instead of accessing such an object remotely it is possible to copy the static state of the object and create a new object with the same state information on the caller side The caller wont be able to notice the difference but calls will be more efficient because they do not involve network round trips This is called marshaling by value

          8 What is ROT What is GIT Give pros and cons of both

          By definition running object table (ROT) is a globally accessible table on each computer that keeps track of all COM objects in the running state that can be identified by a moniker Moniker providers register an object in the table which increments the objects reference count Before the object can be destroyed its moniker must be released from the tableGlobal Interface Table (GIT) allows any apartment (either single- or multi-threaded) in a process to get access to an interface implemented on an object in any other apartment in the process

          9 If you have an object with two interfaces can you custom marshal one of them

          No The decision to use custom marshaling is an all-or-nothing decision an object has to custom marshal all its interfaces or none of them

          10 How can you guarantee that only a remote server is ever created by a client

          Create an object (call CoCreateObjectEx()) with CLSCTX_REMOTE_SERVER flag

          Visual Basic

          1 What are the properties and methods of ObjectControl interface

          Activate Deactivate CanBePooled

          2 How will you implement transaction in a visual basic ActiveX dll

          Set the MTSTransactionMode property of the class modules Use the ObjectContextSetcomplete SetAbort methods to commitrollback

          the transactions

          3 How to execute a stored proc from VB using ADO

          A stored proc can be executed using the command object

          4 What are the objects in ADO

          These are Connection Command Recordset Record Parameter and stream

          Visual Basic UI

          1 How to access a member variable in one form from another

          Set the access modifier of the member variable as Public Create a property procedure

          2 What is the listindex property of a list box control

          Listindex is the index of the currently selected item in the control

          3 Have you worked on grid controls

          ltlt Answer should be Yes or No gtgt

          ASP

          1 How will you describe a session

          Session object in ASP provides dynamic associative array that a script can use to store information

          ASP Sessions Are Cookie-based

          2 What are the different methods to pass an argument from one page to another

          Using Query string Using Hidden controls

          NET

          1 How NET My Services work

          From the developers perspective NET My Services is a set of XML Web services accessed by sending and receiving SOAP messages sent though the HTTP or DIME protocols and using the NET Passport system for authentication NET My Services consists of three things Authentication which will be provided by NET Passport when NET My Services goes live SOAP the communication protocol XML following the rules and schemas set out in the XMI Reference which provides the data formatting and organization

          2 What are Web Services

          Web Services are applications delivered as a service on the Web Web services allow for programmatic access of business logic over the Web Web services typically rely on XML-based protocols messages and interface descriptions for communication and access Web services are designed to be used by other programs or applications rather than directly by end user Programs invoking a Web service are called clients SOAP over HTTP is the most commonly used protocol for invoking Web services

          3 How do I use a proxy server when invoking a Web service

          If you are using the SOAP Toolkit you need to set some connector properties to use a proxy server Dim soap As SoapClient Set soap=New SoapClient soapConnectorProperty(ProxyServer) = ldquoproxyservernamerdquo soapConnectorProperty(ProxyPort) = ldquo8080rdquo soapConnectorProperty(UseProxy) = True While with NET you just need to create a SystemNetWebProxy object and use it to set the Proxy property Dim webs As localhostMyService() websProxy=New SystemNetWebProxy(ldquohttpproxyserver8080rdquo)

          4 What is Simple Object Access Protocol (SOAP)

          SOAP is an XML-based messaging framework specifically designed for exchanging formatted data across the Internet for example using request and reply messages or sending entire documents SOAP is simple easy to use and completely neutral with respect to operating system programming language or

          distributed computing platform

          5 What is Web Services Description Language (WSDL)

          After SOAP became available as a mechanism for exchanging XML messages among enterprises (or among disparate applications within the same enterprise) a better way was needed to describe the messages and how they are exchanged The Web Services Description Language (WSDL) is a particular form of an XML Schema developed by Microsoft and IBM for the purpose of defining the XML message operation and protocol mapping of a web service accessed using SOAP or other XML protocol WSDL defines web services in terms of endpoints that operate on XML messages The WSDL syntax allows both the messages and the operations on the messages to be defined abstractly so they can be mapped to multiple physical implementations The current WSDL spec describes how to map messages and operations to SOAP 11 HTTP GETPOST and MIME WSDL creates web service definitions by mapping a group of endpoints into a logical sequence of operations on XML messages The same XML message can be mapped to multiple operations (or services) and bound to one or more communications protocols (using ports)

          6 What is Universal Description Discovery and Integration (UDDI)

          The Universal Description Discovery and Integration (UDDI) framework defines a data model (in XML) and SOAP APIs for registration and searches on business information including the web services a business exposes to the Internet UDDI is an independent consortium of vendors founded by Microsoft IBM and Ariba for the purpose of developing an Internet standard for web service description registration and discovery Microsoft IBM and Ariba also are hosting the initial deployment of a UDDI service which is conceptually patterned after DNS (the Internet service that translates URLs into TCP addresses) UDDI uses a private agreement profile of SOAP (ie UDDI doesnt use the SOAP serialization format because its not well suited to passing complete XML documents (its aimed at RPC style interactions) The main idea is that businesses use the SOAP APIs to register themselves with UDDI and other businesses search UDDI when they want to discover a trading partner for example someone from whom they wish to procure sheet metal bolts or transistors The information in UDDI is categorized according to industry type and geographical location allowing UDDI consumers to search through lists of potentially matching businesses to find the specific one they want to contact Once a specific business is chosen another call to UDDI is made to obtain the specific contact information for that business The contact information includes a pointer to the target businesss WSDL or other XML schema file describing the web service that the target business publishes

          The interviewer should be well versed in NET to ask these questions The interview should know the answers

          Execution cycle of an assembly How does CLR comes into picture- Platform independence

          Managed unmanaged code Information about GAC How does GAC help in maintaining different versions of an assembly if

          changes are made to an assembly and the new version does not support some of functionality that previous version supported how will the runtime handle ito What is the sequence of steps followed by the runtime to look for the

          references like first to bin then GAC etco How to add assemblies in GAC

          How do we use MTS capabilities in NET assemblies Different type of data persistence in NET

          o Caching Data caching Output caching

          o Serialization Xml Bin

          Usercontrols vc Custom Controls ndash Composite controls Datareader vs Dataset Sorting in Datagrid adding custom controls in datagrid columns Use of view state in ASPX pages How to improve performance of the pages in web environment Is it possible to have both client side and server side functionality on aspx

          server controls In the page execution life cycle when is the page_init called What is AutoEventWireUp attribute used for What are delegates used for Webservices

          o How do you deploy web services Reflections Remoting

          o What is client activated objects and what are server activated objectso What are channels used for

          Interopo How does a NET component call a primitive one What are the steps taken

          General Scripting Questions

          1 How do you add a quotation mark to VB script string

          The first method uses two quotation marks in a row to create a single quotation mark The second method uses the ASCII value of the quotation mark character

          2 How do you break a single VBScript Statement into multiple lines

          A single VBScript Statement can be broken into multiple lines by using the _underscore character

          3 What is the proper method of comparing strings in VBScript

          The first method uses VBScript function with the vbTextCompare constant The second method forces both strings into uppercase

          4 How do you re-enable errors after using ON ERROR RESUME NEXT

          ltlt Need an answer gtgt

          5 How do you prevent My Script from timing out

          You can extend the amount of time a script is allowed to run by using the ScriptTimeout property of the Server object

          6 When do you need to explicitly convert a variable to a particular data type

          If you are comparing numbers or dates and there is a danger that VBScript might interpret the values as strings one of the VBScript conversion functions should be used

          7 When should one pass a variable by value and when by reference

          When you pass a variable by value to a subordinate or function a new instance of the variable is created Any changes made to the value of the variable do not affect the value of the original variable On the other hand whne you pass a variable by reference changes made to the variable do affect the value of the original variable

          8 How can you add a space between the output of two variables

          ltlt Need an answer gtgt

          9 Does ASP support dynamic includes

          It does not support

          10 How do you use the option Explicit statement in an ASP

          It must be used before nay other VBScript statement or HTML content in a script else it will generate and error

          Session and Application Variable Questions

          1 Why do session variables sometimes fail to work

          Session variables depend on browser cookies If a browser does not support cookies or a user has turned off cookies or the userrsquos cookie file is corrupted Session variables will not work

          2 How do you remove an application variable

          ltlt Need an answer gtgt

          3 How do you detect whether a File exists

          I can detect by using the FileExists method of the FileSystemObject

          4 How do you automatically display a list of the Files in a directory

          By using a list of files in a folder by using the FileSystemObject and the Folder object

          Image Questions

          1 How do you store an image in a database table

          Although you can store an image in a SQL Server BLOB column it is almost always better to store the URL of an image in a database table rather than the image itself

          2 How do you dynamically generate a graph or image in an ASP

          Several third-party ASP components enable you to dynamically create custom images

          Browser Questions

          1 How do you detect the type of browser a person is using to visit your web site

          The User-Agent header indicates the type of browser

          2 How do you detect a page from which a person originated

          The Referer header contains the URL of the last page the person visited This header can be retrieved from the ServerVariables collection

          ActiveX Data Objects Questions

          1 Why do you sometimes receive an error when using the Connection Object to execute a SQL string

          ltlt Need an answer gtgt

          2 How do you retrieve a Text filed in an ASP

          If you do not take special precautions when retrieving a Text field from a database table the value of the Text field might be truncated If you are using a forward-only cursor type you should use the Text field as the very last field in your select list Alternatively consider using a richer cursor type when opening a Recordset that contains a Text field

          3 Why does the RecordCount always return the Value-1

          The RecordCount property returns the number of rows in a Recordset after it has been opened you cannot use this property with a forward-only cursor when using SQL Server (it will always return ndash1)

          4 Why do you receive an error whenever you try to update the value of a filed in a recordset

          By default when you open a Recordset it is opened with a forward-only cursor and read-only lock type To update a Recordset you must open a Recordset that is not read-only

          5 How do you limit the number of rows returned by a Database Query

          If using SQL 70 or Access you can use the SQL Top keyword to limit the number of records returned Otherwise if you are using SQL 65 use the MaxRecords property of the Recordset object

          ltlt What about SQL 2000 gtgt

          6 How do you retrieve the value from a SQL Statement that uses Count() Max Min or Identity

          There are two methods that you can use to retrieve the value from a SQL function or a SQL global variable You can either use an alias for the value or refer to the value by its ordinal position in the Recordset

          7 How do you retrieve an output parameter from a SQL stored procedure within an ASPScript

          You must use the ADO Command nad parameter objects

          Form and Query String Questions

          1 How do you accept file uploads in an HTML form

          ltlt Need an answer gtgt

          2 What causes the value of a form field to become truncated

          HTML uses quotation marks to mark the beginning and end of a value So If a variable contains question marks in its values the value of the variablewill be truncated when displayed

          3 How do you include spaces or other special characters in a query string

          URL encode the query string

          C++ Questions

          1 What is an object in C++

          An object is a package that contains related data and instructions The data relates to what the object represents while the instructions define how this object relates to other objects and itself

          2 What is a message

          A message is a signal from one object to another requesting that a computation take place It is roughly equivalent to a function call in other languages

          3 What is a class

          A class defines the characteristics of a certain type of object It defines what its members will remember the messages to which they will respond and what form the response will take

          4 What is an instance

          It is an individual object that is a member of some class

          5 What is a super-class

          Given a class a super-class is the basis of the class under consideration The given class is defined as a subset (in some respects) of the super-class All objects of the given class potentially posses all the characteristics belonging to objects of the super-class

          6 What is inheritance

          Inheritance is property such that a parent (or super) class passes the characteristics of itself to children (or sub) classes that are derived from it The sub-class has the option of modifying these characteristics in order to make a different but fundamentally related class from the super-class

          7 To what does message protocol refer

          An objects message protocol is the exact form of the set of messages to which the object can respond

          8 What is polymorphism

          Polymorphism refers to the ability of an object to respond in a logically identical fashion to messages of the same protocol containing differing types of objects Consider 1 + 5 and 1 + 51 In the former the message + 5 is sent to an object of class integer (1) In the later the message + 51 is sent to the same integer object The form of the message (its protocol) is identical in both cases What differs is the type of object on the right-hand side of these messages The former is an integer object (5) while the later is a floating point object (51) The receiver (1) appears (to other objects) to respond in the same way to both messages Internally however it knows that it must treat the two types of objects differently in order to obtain the same overall response

          9 What are instance variables

          These represent an objects private memory They are defined in an objects class

          18 What is a virtual member function

          A virtual function allows derived classes to replace the implementation provided by the base class The compiler makes sure the replacement is always called whenever the object in question is actually of the derived class even if the object is accessed by a base pointer rather than a derived pointer This allows algorithms in the base class to be replaced in the derived class even if users dont know about the derived class

          The derived class can either fully replace (override) the base class member function or the derived class can partially replace (augment) the base class member function The latter is accomplished by having the derived class member function call the base class member function if desired

          19 How can C++ achieve dynamic binding yet also static typing

          When you have a pointer to an object the object may actually be of a class that is derived from the class of the pointer (eg a Vehicle that is actually pointing to a Car object) Thus there are two types the (static) type of the pointer (Vehicle in this case) and the (dynamic) type of the pointed-to object (Car in this case)

          Static typing means that the legality of a member function invocation is checked at the earliest possible moment by the compiler at compile time The compiler uses the static type of the pointer to determine whether the member function invocation is legal If the type of the pointer can handle the member function certainly the pointed-to object can handle it as well Eg if Vehicle has a certain member function certainly Car also has that member function since Car is a kind-of Vehicle

          Dynamic binding means that the address of the code in a member function invocation is determined at the last possible moment based on the dynamic type of the object at run time It is called dynamic binding because the binding to the code that actually gets called is accomplished dynamically (at run time) Dynamic binding is a result of virtual functions

          20 Whats the difference between how virtual and non-virtual member functions are called

          Non-virtual member functions are resolved statically That is the member function is selected statically (at compile-time) based on the type of the pointer (or reference) to the object

          In contrast virtual member functions are resolved dynamically (at run-time) That is the member function is selected dynamically (at run-time) based on the type of the object not the type of the pointerreference to that object This is called dynamic binding Most compilers use some variant of the following technique

          if the object has one or more virtual functions the compiler puts a hidden pointer in the object called a virtual-pointer or v-pointer This v-pointer points to a global table called the virtual-table or v-table

          The compiler creates a v-table for each class that has at least one virtual function For example if class Circle has virtual functions for draw() and move() and resize() there would be exactly one v-table associated with class Circle even if there were a gazillion Circle objects and the v-pointer of each of those Circle objects would point to the Circle v-table The v-table itself has pointers to each of the virtual functions in the class For example the Circle v-table would have three pointers a pointer to Circledraw() a pointer to Circlemove() and a pointer to Circleresize()

          During a dispatch of a virtual function the run-time system follows the objects v-pointer to the classs v-table then follows the appropriate slot in the v-table to the method code

          The space-cost overhead of the above technique is nominal an extra pointer per object (but only for objects that will need to do dynamic binding) plus an extra pointer per method (but only for virtual methods) The time-cost overhead is also fairly nominal compared to a normal function call a virtual function call requires two extra fetches (one to get the value of the v-pointer a second to get the address of the method) None of this runtime activity happens with non-virtual functions since the compiler resolves non-virtual functions exclusively at compile-time based on the type of the pointer

          21 When should my destructor be virtual

          When you may delete a derived object via a base pointer

          virtual functions bind to the code associated with the class of the object rather than with the class of the pointerreference When you say delete basePtr and the base class has a virtual destructor the destructor that gets invoked is the one associated with the type of the object basePtr rather than the one associated with the type of the pointer This is generally A Good Thing

          TECHNO-GEEK WARNING PUT YOUR PROPELLER HAT ON Technically speaking you need a base classs destructor to be virtual if and only if you intend to allow someone to invoke an objects destructor via a base class pointer (this is normally done implicitly via delete) and the object being destructed is of a derived class that has a non-trivial destructor A class has a non-trivial destructor if it either has an explicit destructor or if it has a member object or a base class that has a non-trivial destructor (note that this is a recursive definition (eg a class has a non-trivial destructor if it has a member object (which has a base class (which has a member object (which has a base class (which has an explicit destructor)))))) END TECHNO-GEEK WARNING REMOVE YOUR PROPELLER HAT

          If you had a hard grokking the previous rule try this (over)simplified one on for size A class should have a virtual destructor unless that class has no virtual functions Rationale if you have any virtual functions at all youre probably going to be doing stuff to derived objects via a base pointer and some of the stuff you may do may include invoking a destructor (normally done implicitly via delete) Plus once youve put the first virtual function into a class youve already paid all the per-object space cost that youll ever pay (one pointer per object note that this is theoretically compiler-specific in practice everyone does it pretty much the same way) so making the destructor virtual wont generally cost you anything extra

          22 What is a virtual constructor

          An idiom that allows you to do something that C++ doesnt directly support

          You can get the effect of a virtual constructor by a virtual clone() member function (for copy constructing) or a virtual create() member function (for the default constructor)

          class Shape public virtual ~Shape() A virtual destructor virtual void draw() = 0 A pure virtual function virtual void move() = 0 virtual Shape clone() const = 0 Uses the copy constructor virtual Shape create() const = 0 Uses the default constructor class Circle public Shape public Circle clone() const return new Circle(this) Circle create() const return new Circle()

          In the clone() member function the new Circle(this) code calls Circles copy constructor to copy the state of this into the newly created Circle object In the create() member function the new Circle() code calls Circles default constructor

          Users use these as if they were virtual constructors

          void userCode(Shapeamp s) Shape s2 = sclone() Shape s3 = screate() delete s2 You probably need a virtual destructor here

          delete s3

          23 How do you link a C++ program to C functions

          By using the extern C linkage specification around the C function declarations

          24 Explain the scope resolution operator

          The scope resolution operator permits a program to reference an identifier in the global scope that has been hidden by another identifier with the same name in the local scope

          25 What are the differences between a C++ struct and C++ class

          The default member and base class access specifiers are different

          26 How many ways are there to initialize an int with a constant

          Two

          27 How does throwing and catching exceptions differ from using setjmp and longjmp

          The throw operation calls the destructors for automatic objects instantiated since entry to the try block

          28 How does throwing and catching exceptions differ from using setjmp and longjmp

          The throw operation calls the destructors for automatic objects instantiated since entry to the try block

          29 What is a default constructor

          A constructor that has no arguments or one where all the arguments have default argument values

          If you dont code a default constructor the compiler provides one if there are no other constructors If you are going to instantiate an array of objects of the class the class must have a default constructor

          30 What is a conversion constructor

          It is a constructor that accepts one argument of a different type

          The compiler uses this idiom as one way to infer conversion rules for a class A constructor with more than one argument and with default argument values can be interpreted by the compiler as a conversion constructor when the compiler is looking for an object of the type and sees an object of the type of the constructors first argument

          31 What is the difference between a copy constructor and an overloaded assignment operator

          A copy constructor constructs a new object by using the content of the argument object An overloaded assignment operator assigns the contents of an existing object to another existing object of the same class

          First you must know that a copy constructor is one that has only one argument which is a reference to the same type as the constructor The compiler invokes a copy constructor wherever it needs to make a copy of the object for example to pass an argument by value If you do not provide a copy constructor the compiler creates a member-by-member copy constructor for you

          You can write overloaded assignment operators that take arguments of other classes but that behavior is usually implemented with implicit conversion constructors If you do not provide an overloaded assignment operator for the class the compiler creates a default member-by-member assignment operator

          This discussion is a good place to get into why classes need copy constructors and overloaded assignment operators By discussing the requirements with respect to data member pointers that point to dynamically allocated resources you demonstrate a good grasp of the problem

          32 When should you use multiple inheritance

          There are three acceptable answers Never Rarely and When the problem domain cannot be accurately modeled any other way

          33 What is a virtual destructor

          The simple answer is that a virtual destructor is one that is declared with the virtual attribute

          The behavior of a virtual destructor is what is important If you destroy an object through a pointer or reference to a base class and the base-class destructor is not virtual the derived-class destructors are not executed and the destruction might not be complete

          34 Explain the ISA and HASA class relationships How would you implement each in a class design

          A specialized class is a specialization of another class and therefore has the ISA relationship with the other class An Employee ISA Person This relationship is best implemented with inheritance Employee is derived from Person A class may have an instance of another class For example an Employee has a Salary therefore the Employee class has the HASA relationship with the Salary class This relationship is best implemented by embedding an object of the Salary class in the Employee class

          The answer to this question reveals whether you have an understanding of the fundamentals of object-oriented design which is important to reliable class design

          There are other relationships The USESA relationship is when one class uses the services of another The Employee class uses an object (cout) of the ostream class to display the employees name onscreen for example But if you get ISA and HASA right you usually dont need to go any further

          35 When is a template a better solution than a base class

          When you are designing a generic class to contain or otherwise manage objects of other types when the format and behavior of those other types are unimportant to their containment or management and particularly when those other types are unknown (thus the genericity) to the designer of the container or manager class

          Prior to templates you had to use inheritance your design might include a generic List container class and an application-specific Employee class To put employees in a list a ListedEmployee class is multiply derived (contrived) from the Employee and List classes These solutions were unwieldy and error-prone Templates solved that problem

          Questions for ANSI-Knowledgeable Applicants

          There are six questions for those who profess knowledge of the progress of the ANSI committee If you claim to have that much interest in the language you should know the answers to all these questions

          1 What is a mutable member

          A mutable member is one that can be modified by the class even when the object of the class or the member function doing the modification is const

          Understanding this requirement implies an understanding of C++ const which many programmers do not have I have seen large class designs that do not employ the const qualifier anywhere Some of those designs are my own early C++ efforts One author suggests that some programmers find const to be such a bother that it is easier to ignore const than to try to use it meaningfully No

          wonder many programmers dont understand the power and implications of const Someone who claims to have enough interest in the language and its evolution to keep pace with the ANSI deliberations should not be ignorant of const however

          2 What is an explicit constructor

          A conversion constructor declared with the explicit keyword The compiler does not use an explicit constructor to implement an implied conversion of types Its purpose is reserved explicitly for construction

          3 What is the Standard Template Library

          It is a library of container templates approved by the ANSI committee for inclusion in the standard C++ specification

          4 Describe run-time type identification

          It is the ability to determine at run time the type of an object by using the typeid operator or the dynamic_cast operator

          5 What problem does the namespace feature solve

          Multiple providers of libraries might use common global identifiers causing a name collision when an application tries to link with two or more such libraries The name-space feature surrounds a librarys external declarations with a unique namespace that eliminates the potential for those collisions

          This solution assumes that two library vendors dont use the same namespace of course

          6 Are there any new intrinsic (built-in) data types

          Yes The ANSI committee added the bool intrinsic type and its true and false value keywords and the wchar_t data type to support character sets wider than eight bits

          SQL Server

          1 What is a foreign key

          A foreign key is a column or combination of columns used to establish and enforce a link (referential integrity) between the data in two tables A link is created between two tables by adding the column or columns that hold one tablersquos primary key values to the other table This column becomes a foreign key in the second table

          2 What is the difference between a primary key and unique key

          There can be only one primary key constrain on a table but there can be many unique key constraints in a table

          Primary key doesnrsquot allow null values but Unique allows 1 Null value

          3 What is an index

          Indexes are database objects which provides faster data access The index provides pointers to the data values stored in specified columns of

          the table and then orders those pointers according to the sort order you specify

          Different types of indexes are unique index clustered index and non-clustered index

          4 How to return multiple result set from a stored proc and capture it in ADO

          Use multiple Select statements to return multiple result sets Use ADOrsquos GetNextRecordset() method to get the second recordset during the

          execution of the stored proc

          • COMDCOM
          • Visual Basic
          • General Scripting Questions
          • Session and Application Variable Questions
            • Image Questions
            • Browser Questions
            • ActiveX Data Objects Questions
            • Form and Query String Questions
              • 18 What is a virtual member function
              • 19 How can C++ achieve dynamic binding yet also static typing
              • 20 Whats the difference between how virtual and non-virtual member functions are called
              • 21 When should my destructor be virtual
              • 22 What is a virtual constructor
              • Questions for ANSI-Knowledgeable Applicants

            5 What are AdvantagesDisadvantages of ActiveX controls over DLL

            Look for an answer similar to points mentioned in the table below

            ActiveX DLLEncapsulates the whole aspects of the object

            Encapsulates only functional aspect of the object

            Pretty complicated for implementation and usage

            Much easier to implement and use

            Binary compatibility specification (may be used in different platforms)

            Implemented only for Win32 platform

            6 What is IUnknown What methods provided by IUnknown

            It is generally good idea to have an answer for this question if you claim you know COM in your resume Otherwise you may consider your interview failed at this point

            IUnknown is the base interface of COM All other interfaces must derive directly or indirectly from IUnknown There are three methods in that interface AddRef Release and QueryInterface

            7 What are the purposes of AddRef Release and QueryInterface functions

            AddRef increments reference count of the object Release decrements reference counter of the object and QueryInterface obtains a pointer to the requested interface

            8 What is aggregation How can we get an interface of the aggregated object

            Aggregation is the reuse mechanism in which the outer object exposes interfaces from the inner object as if they were implemented on the outer object itself This is useful when the outer object would always delegate every call to one of its interfaces to the same interface in the inner object Aggregation is actually a specialized case of containmentdelegation and is available as a convenience to avoid extra implementation overhead in the outer object in these cases We can get a pointer to the inner interface calling QueryInterface of the outer object with IID of the inner interface

            9 C is aggregated by B which in turn aggregated by A Our client requested C What will happen

            QueryInterface to A will delegate request to B which in turn will delegate request for the interface to C This pointer will be returned to the client

            10 Whats the difference if any between OLE and COM

            OLE is build on top of COM The question is not strict because OLE was built over COM for years while COM as a technology was presented by Microsoft a few years ago You may mention also that COM is a specification while OLE is a particular implementation of this specification which in todays world is not exactly true as well because what people call COM today is likely implementation of COM spec by Microsoft

            11 Whats the difference between COM and DCOM

            Again the question does not require strict answer Any DCOM object is yet a COM object (DCOM extends COM) and any COM object may participate in DCOM transactions

            DCOM introduced several improvementsoptimizations for distributed environment such as MULTI_QI (multiple QueryInterface()) security contexts etc DCOM demonstrated importance of surrogate process (you cannot run in-proc server on a remote machine You need a surrogate process to do that) DCOM introduced a load balancing

            12 What is a dual interface

            Dual interface is one that supports both - IDispatch interface and vtbl-based interface Therefore it might be used in scripting environment like VBScript and yet to use power and speed of vtbl-based interface for non-scripting environment Discussion then may easily transform into analyzing of dual interface problems - be prepared to this twist

            13 What is a multi-threaded apartment (MTA) and what is a Single-threaded apartment (STA)

            This is pretty difficult question to describe shortly

            Anyway apartments were introduced by Microsoft in NT 351 and late Windows 95 to isolate the problem of running legacy non-thread safe code into multithreaded environment Each thread was encapsulated into so called single-threaded apartment The reason to create an object in apartment is thread-safety

            COM is the responsible synchronized way to access an object even if the object inside the apartment is not thread-safe Multithreaded apartments (MTA or free threading apartment) were introduced in NT 40 Idea behind MTA is that COM is

            not responsible to synchronize object calls between threads In MTA the developer is responsible for that

            ltlt See Professional DCOM Programming of Dr Grimes et al or Essential COM of Don Box for the further discussion on this topic gtgt

            14 Lets assume we have object B and aggregated object C (in-proc server) created by B Can you access any interface of B from C Whats the difference between aggregated and contained objects

            Yes you can This is fundamental postulate of COM If you can get there from here you can get there from anywhere ie QIing for IUnknown you may proceed and to get a pointer to any other interface supported by the object Aggregated object exposes its interface directly without visible intervention of the object container Contained object is created within the object container and its interfaces might be altered or filtered by the object container

            15 Is there a way to register in-proc server without regsvr32exe

            Yes Call DllRegisterServer() from the client Do not forget to call DLLUnregisterServer() from the same client You may also use Registrar object for the same purpose or use direct manipulation of the windows registry

            16 What is VARIANT Why and where would you use it

            VARIANT is a huge union containing automation type This allows easy conversion of one automation type to another The biggest disadvantage of VARIANT is size of the union

            17 What is __declspec(novtable) Why would you need this

            __declspec(novtable) is a Microsofts compiler optimization The main idea of this optimization is to strip the vtable initialization code from abstract class (for abstract class the vtable is empty while it is initialized in contructor) MSDN has an excellent article on this topic (search for ATL Virtual Functions and vtables)

            18 What is an IDL

            IDL stands for Interface Definition Language IDL is the language to describe COM interfaces

            19 What is In-proc

            In-proc is in-process COM object ie COM object that implemented as DLL and supposed to be hosted by a container When you have to instantiate the in-proc object remotely you may use DLLHostexe application that was design specially for this purpose

            20 What is OLE

            OLE is an object and embedding first implementation of COM spec available from MS before COM was officially named COM

            21 Give examples of OLE usage

            The most famous examples are probably drag and drop and structured storage implementations

            22 What are 2 storage types for composite document

            The two storage types are Storage and Stream

            23 Is doc document a compound document Is it a structured storage

            Compound document is a document that contains information about other documents hosted in this document All office documents may or may not be compound documents Word documents from version 60 and up are stored as structured storage

            Non-VB COMDCOM

            1 What should QueryInterface functions do if requested object was not found

            Return E_NOINTERFACE and nullify its out parameter

            2 How would you create an instance of the object in COM

            ltlt Well it all depends on your project Start your answer from CoCreateInstance or CoCreateInstanceEx explain the difference between them If interviewer is still not satisfied youll have to explain the whole kitchen behind the scenes including a difference between local server and inproc server meaning and mechanism of class factory etc You may also mention other methods of object creation like CoGetInstanceFromFile but discussion will likely turn to discussion of monikers then gtgt

            3 What happens when client calls CoCreateInstance

            ltlt Again all depends on the level of detail and expertise of interviewer Start with simple explanation of class object and class factory mechanism Further details would depend on a specific situation gtgt

            4 What are the limitations of CoCreateInstance

            Well a major problem with CoCreateInstance is that it is only able to create one object and only on local system To create a remote object or to get several objects based on single CLSID at the same time one should use CoCreateInstanceEx

            5 What is a moniker

            It is an object that implements the IMoniker interface A moniker acts as a name that uniquely identifies a COM object In the same way that a path identifies a file in the file system a moniker identifies a COM object in the directory namespace

            6 Can you have two dual interfaces in one class

            Yes You may have two dual interfaces in one class but only one of them may be default The bottom line is that you cannot work with two dual interfaces at the same time due to nature of dual interfaceTo support two dual interfaces in VB you would write something like

            dim d1 as IDualInterface1 dim d2 as IDualInterface2

            set d1 = new MyClassWithTwoDualsset d2 = d1

            In ATLs class you would have to use macro COM_INTERFACE_ENTRY2(IDispatch IDualInterface1) to distinguish between different dual interfaces

            7 What is a marshalling by value

            Some objects can essentially be considered static regardless of which methods are called the state of the object does not change Instead of accessing such an object remotely it is possible to copy the static state of the object and create a new object with the same state information on the caller side The caller wont be able to notice the difference but calls will be more efficient because they do not involve network round trips This is called marshaling by value

            8 What is ROT What is GIT Give pros and cons of both

            By definition running object table (ROT) is a globally accessible table on each computer that keeps track of all COM objects in the running state that can be identified by a moniker Moniker providers register an object in the table which increments the objects reference count Before the object can be destroyed its moniker must be released from the tableGlobal Interface Table (GIT) allows any apartment (either single- or multi-threaded) in a process to get access to an interface implemented on an object in any other apartment in the process

            9 If you have an object with two interfaces can you custom marshal one of them

            No The decision to use custom marshaling is an all-or-nothing decision an object has to custom marshal all its interfaces or none of them

            10 How can you guarantee that only a remote server is ever created by a client

            Create an object (call CoCreateObjectEx()) with CLSCTX_REMOTE_SERVER flag

            Visual Basic

            1 What are the properties and methods of ObjectControl interface

            Activate Deactivate CanBePooled

            2 How will you implement transaction in a visual basic ActiveX dll

            Set the MTSTransactionMode property of the class modules Use the ObjectContextSetcomplete SetAbort methods to commitrollback

            the transactions

            3 How to execute a stored proc from VB using ADO

            A stored proc can be executed using the command object

            4 What are the objects in ADO

            These are Connection Command Recordset Record Parameter and stream

            Visual Basic UI

            1 How to access a member variable in one form from another

            Set the access modifier of the member variable as Public Create a property procedure

            2 What is the listindex property of a list box control

            Listindex is the index of the currently selected item in the control

            3 Have you worked on grid controls

            ltlt Answer should be Yes or No gtgt

            ASP

            1 How will you describe a session

            Session object in ASP provides dynamic associative array that a script can use to store information

            ASP Sessions Are Cookie-based

            2 What are the different methods to pass an argument from one page to another

            Using Query string Using Hidden controls

            NET

            1 How NET My Services work

            From the developers perspective NET My Services is a set of XML Web services accessed by sending and receiving SOAP messages sent though the HTTP or DIME protocols and using the NET Passport system for authentication NET My Services consists of three things Authentication which will be provided by NET Passport when NET My Services goes live SOAP the communication protocol XML following the rules and schemas set out in the XMI Reference which provides the data formatting and organization

            2 What are Web Services

            Web Services are applications delivered as a service on the Web Web services allow for programmatic access of business logic over the Web Web services typically rely on XML-based protocols messages and interface descriptions for communication and access Web services are designed to be used by other programs or applications rather than directly by end user Programs invoking a Web service are called clients SOAP over HTTP is the most commonly used protocol for invoking Web services

            3 How do I use a proxy server when invoking a Web service

            If you are using the SOAP Toolkit you need to set some connector properties to use a proxy server Dim soap As SoapClient Set soap=New SoapClient soapConnectorProperty(ProxyServer) = ldquoproxyservernamerdquo soapConnectorProperty(ProxyPort) = ldquo8080rdquo soapConnectorProperty(UseProxy) = True While with NET you just need to create a SystemNetWebProxy object and use it to set the Proxy property Dim webs As localhostMyService() websProxy=New SystemNetWebProxy(ldquohttpproxyserver8080rdquo)

            4 What is Simple Object Access Protocol (SOAP)

            SOAP is an XML-based messaging framework specifically designed for exchanging formatted data across the Internet for example using request and reply messages or sending entire documents SOAP is simple easy to use and completely neutral with respect to operating system programming language or

            distributed computing platform

            5 What is Web Services Description Language (WSDL)

            After SOAP became available as a mechanism for exchanging XML messages among enterprises (or among disparate applications within the same enterprise) a better way was needed to describe the messages and how they are exchanged The Web Services Description Language (WSDL) is a particular form of an XML Schema developed by Microsoft and IBM for the purpose of defining the XML message operation and protocol mapping of a web service accessed using SOAP or other XML protocol WSDL defines web services in terms of endpoints that operate on XML messages The WSDL syntax allows both the messages and the operations on the messages to be defined abstractly so they can be mapped to multiple physical implementations The current WSDL spec describes how to map messages and operations to SOAP 11 HTTP GETPOST and MIME WSDL creates web service definitions by mapping a group of endpoints into a logical sequence of operations on XML messages The same XML message can be mapped to multiple operations (or services) and bound to one or more communications protocols (using ports)

            6 What is Universal Description Discovery and Integration (UDDI)

            The Universal Description Discovery and Integration (UDDI) framework defines a data model (in XML) and SOAP APIs for registration and searches on business information including the web services a business exposes to the Internet UDDI is an independent consortium of vendors founded by Microsoft IBM and Ariba for the purpose of developing an Internet standard for web service description registration and discovery Microsoft IBM and Ariba also are hosting the initial deployment of a UDDI service which is conceptually patterned after DNS (the Internet service that translates URLs into TCP addresses) UDDI uses a private agreement profile of SOAP (ie UDDI doesnt use the SOAP serialization format because its not well suited to passing complete XML documents (its aimed at RPC style interactions) The main idea is that businesses use the SOAP APIs to register themselves with UDDI and other businesses search UDDI when they want to discover a trading partner for example someone from whom they wish to procure sheet metal bolts or transistors The information in UDDI is categorized according to industry type and geographical location allowing UDDI consumers to search through lists of potentially matching businesses to find the specific one they want to contact Once a specific business is chosen another call to UDDI is made to obtain the specific contact information for that business The contact information includes a pointer to the target businesss WSDL or other XML schema file describing the web service that the target business publishes

            The interviewer should be well versed in NET to ask these questions The interview should know the answers

            Execution cycle of an assembly How does CLR comes into picture- Platform independence

            Managed unmanaged code Information about GAC How does GAC help in maintaining different versions of an assembly if

            changes are made to an assembly and the new version does not support some of functionality that previous version supported how will the runtime handle ito What is the sequence of steps followed by the runtime to look for the

            references like first to bin then GAC etco How to add assemblies in GAC

            How do we use MTS capabilities in NET assemblies Different type of data persistence in NET

            o Caching Data caching Output caching

            o Serialization Xml Bin

            Usercontrols vc Custom Controls ndash Composite controls Datareader vs Dataset Sorting in Datagrid adding custom controls in datagrid columns Use of view state in ASPX pages How to improve performance of the pages in web environment Is it possible to have both client side and server side functionality on aspx

            server controls In the page execution life cycle when is the page_init called What is AutoEventWireUp attribute used for What are delegates used for Webservices

            o How do you deploy web services Reflections Remoting

            o What is client activated objects and what are server activated objectso What are channels used for

            Interopo How does a NET component call a primitive one What are the steps taken

            General Scripting Questions

            1 How do you add a quotation mark to VB script string

            The first method uses two quotation marks in a row to create a single quotation mark The second method uses the ASCII value of the quotation mark character

            2 How do you break a single VBScript Statement into multiple lines

            A single VBScript Statement can be broken into multiple lines by using the _underscore character

            3 What is the proper method of comparing strings in VBScript

            The first method uses VBScript function with the vbTextCompare constant The second method forces both strings into uppercase

            4 How do you re-enable errors after using ON ERROR RESUME NEXT

            ltlt Need an answer gtgt

            5 How do you prevent My Script from timing out

            You can extend the amount of time a script is allowed to run by using the ScriptTimeout property of the Server object

            6 When do you need to explicitly convert a variable to a particular data type

            If you are comparing numbers or dates and there is a danger that VBScript might interpret the values as strings one of the VBScript conversion functions should be used

            7 When should one pass a variable by value and when by reference

            When you pass a variable by value to a subordinate or function a new instance of the variable is created Any changes made to the value of the variable do not affect the value of the original variable On the other hand whne you pass a variable by reference changes made to the variable do affect the value of the original variable

            8 How can you add a space between the output of two variables

            ltlt Need an answer gtgt

            9 Does ASP support dynamic includes

            It does not support

            10 How do you use the option Explicit statement in an ASP

            It must be used before nay other VBScript statement or HTML content in a script else it will generate and error

            Session and Application Variable Questions

            1 Why do session variables sometimes fail to work

            Session variables depend on browser cookies If a browser does not support cookies or a user has turned off cookies or the userrsquos cookie file is corrupted Session variables will not work

            2 How do you remove an application variable

            ltlt Need an answer gtgt

            3 How do you detect whether a File exists

            I can detect by using the FileExists method of the FileSystemObject

            4 How do you automatically display a list of the Files in a directory

            By using a list of files in a folder by using the FileSystemObject and the Folder object

            Image Questions

            1 How do you store an image in a database table

            Although you can store an image in a SQL Server BLOB column it is almost always better to store the URL of an image in a database table rather than the image itself

            2 How do you dynamically generate a graph or image in an ASP

            Several third-party ASP components enable you to dynamically create custom images

            Browser Questions

            1 How do you detect the type of browser a person is using to visit your web site

            The User-Agent header indicates the type of browser

            2 How do you detect a page from which a person originated

            The Referer header contains the URL of the last page the person visited This header can be retrieved from the ServerVariables collection

            ActiveX Data Objects Questions

            1 Why do you sometimes receive an error when using the Connection Object to execute a SQL string

            ltlt Need an answer gtgt

            2 How do you retrieve a Text filed in an ASP

            If you do not take special precautions when retrieving a Text field from a database table the value of the Text field might be truncated If you are using a forward-only cursor type you should use the Text field as the very last field in your select list Alternatively consider using a richer cursor type when opening a Recordset that contains a Text field

            3 Why does the RecordCount always return the Value-1

            The RecordCount property returns the number of rows in a Recordset after it has been opened you cannot use this property with a forward-only cursor when using SQL Server (it will always return ndash1)

            4 Why do you receive an error whenever you try to update the value of a filed in a recordset

            By default when you open a Recordset it is opened with a forward-only cursor and read-only lock type To update a Recordset you must open a Recordset that is not read-only

            5 How do you limit the number of rows returned by a Database Query

            If using SQL 70 or Access you can use the SQL Top keyword to limit the number of records returned Otherwise if you are using SQL 65 use the MaxRecords property of the Recordset object

            ltlt What about SQL 2000 gtgt

            6 How do you retrieve the value from a SQL Statement that uses Count() Max Min or Identity

            There are two methods that you can use to retrieve the value from a SQL function or a SQL global variable You can either use an alias for the value or refer to the value by its ordinal position in the Recordset

            7 How do you retrieve an output parameter from a SQL stored procedure within an ASPScript

            You must use the ADO Command nad parameter objects

            Form and Query String Questions

            1 How do you accept file uploads in an HTML form

            ltlt Need an answer gtgt

            2 What causes the value of a form field to become truncated

            HTML uses quotation marks to mark the beginning and end of a value So If a variable contains question marks in its values the value of the variablewill be truncated when displayed

            3 How do you include spaces or other special characters in a query string

            URL encode the query string

            C++ Questions

            1 What is an object in C++

            An object is a package that contains related data and instructions The data relates to what the object represents while the instructions define how this object relates to other objects and itself

            2 What is a message

            A message is a signal from one object to another requesting that a computation take place It is roughly equivalent to a function call in other languages

            3 What is a class

            A class defines the characteristics of a certain type of object It defines what its members will remember the messages to which they will respond and what form the response will take

            4 What is an instance

            It is an individual object that is a member of some class

            5 What is a super-class

            Given a class a super-class is the basis of the class under consideration The given class is defined as a subset (in some respects) of the super-class All objects of the given class potentially posses all the characteristics belonging to objects of the super-class

            6 What is inheritance

            Inheritance is property such that a parent (or super) class passes the characteristics of itself to children (or sub) classes that are derived from it The sub-class has the option of modifying these characteristics in order to make a different but fundamentally related class from the super-class

            7 To what does message protocol refer

            An objects message protocol is the exact form of the set of messages to which the object can respond

            8 What is polymorphism

            Polymorphism refers to the ability of an object to respond in a logically identical fashion to messages of the same protocol containing differing types of objects Consider 1 + 5 and 1 + 51 In the former the message + 5 is sent to an object of class integer (1) In the later the message + 51 is sent to the same integer object The form of the message (its protocol) is identical in both cases What differs is the type of object on the right-hand side of these messages The former is an integer object (5) while the later is a floating point object (51) The receiver (1) appears (to other objects) to respond in the same way to both messages Internally however it knows that it must treat the two types of objects differently in order to obtain the same overall response

            9 What are instance variables

            These represent an objects private memory They are defined in an objects class

            18 What is a virtual member function

            A virtual function allows derived classes to replace the implementation provided by the base class The compiler makes sure the replacement is always called whenever the object in question is actually of the derived class even if the object is accessed by a base pointer rather than a derived pointer This allows algorithms in the base class to be replaced in the derived class even if users dont know about the derived class

            The derived class can either fully replace (override) the base class member function or the derived class can partially replace (augment) the base class member function The latter is accomplished by having the derived class member function call the base class member function if desired

            19 How can C++ achieve dynamic binding yet also static typing

            When you have a pointer to an object the object may actually be of a class that is derived from the class of the pointer (eg a Vehicle that is actually pointing to a Car object) Thus there are two types the (static) type of the pointer (Vehicle in this case) and the (dynamic) type of the pointed-to object (Car in this case)

            Static typing means that the legality of a member function invocation is checked at the earliest possible moment by the compiler at compile time The compiler uses the static type of the pointer to determine whether the member function invocation is legal If the type of the pointer can handle the member function certainly the pointed-to object can handle it as well Eg if Vehicle has a certain member function certainly Car also has that member function since Car is a kind-of Vehicle

            Dynamic binding means that the address of the code in a member function invocation is determined at the last possible moment based on the dynamic type of the object at run time It is called dynamic binding because the binding to the code that actually gets called is accomplished dynamically (at run time) Dynamic binding is a result of virtual functions

            20 Whats the difference between how virtual and non-virtual member functions are called

            Non-virtual member functions are resolved statically That is the member function is selected statically (at compile-time) based on the type of the pointer (or reference) to the object

            In contrast virtual member functions are resolved dynamically (at run-time) That is the member function is selected dynamically (at run-time) based on the type of the object not the type of the pointerreference to that object This is called dynamic binding Most compilers use some variant of the following technique

            if the object has one or more virtual functions the compiler puts a hidden pointer in the object called a virtual-pointer or v-pointer This v-pointer points to a global table called the virtual-table or v-table

            The compiler creates a v-table for each class that has at least one virtual function For example if class Circle has virtual functions for draw() and move() and resize() there would be exactly one v-table associated with class Circle even if there were a gazillion Circle objects and the v-pointer of each of those Circle objects would point to the Circle v-table The v-table itself has pointers to each of the virtual functions in the class For example the Circle v-table would have three pointers a pointer to Circledraw() a pointer to Circlemove() and a pointer to Circleresize()

            During a dispatch of a virtual function the run-time system follows the objects v-pointer to the classs v-table then follows the appropriate slot in the v-table to the method code

            The space-cost overhead of the above technique is nominal an extra pointer per object (but only for objects that will need to do dynamic binding) plus an extra pointer per method (but only for virtual methods) The time-cost overhead is also fairly nominal compared to a normal function call a virtual function call requires two extra fetches (one to get the value of the v-pointer a second to get the address of the method) None of this runtime activity happens with non-virtual functions since the compiler resolves non-virtual functions exclusively at compile-time based on the type of the pointer

            21 When should my destructor be virtual

            When you may delete a derived object via a base pointer

            virtual functions bind to the code associated with the class of the object rather than with the class of the pointerreference When you say delete basePtr and the base class has a virtual destructor the destructor that gets invoked is the one associated with the type of the object basePtr rather than the one associated with the type of the pointer This is generally A Good Thing

            TECHNO-GEEK WARNING PUT YOUR PROPELLER HAT ON Technically speaking you need a base classs destructor to be virtual if and only if you intend to allow someone to invoke an objects destructor via a base class pointer (this is normally done implicitly via delete) and the object being destructed is of a derived class that has a non-trivial destructor A class has a non-trivial destructor if it either has an explicit destructor or if it has a member object or a base class that has a non-trivial destructor (note that this is a recursive definition (eg a class has a non-trivial destructor if it has a member object (which has a base class (which has a member object (which has a base class (which has an explicit destructor)))))) END TECHNO-GEEK WARNING REMOVE YOUR PROPELLER HAT

            If you had a hard grokking the previous rule try this (over)simplified one on for size A class should have a virtual destructor unless that class has no virtual functions Rationale if you have any virtual functions at all youre probably going to be doing stuff to derived objects via a base pointer and some of the stuff you may do may include invoking a destructor (normally done implicitly via delete) Plus once youve put the first virtual function into a class youve already paid all the per-object space cost that youll ever pay (one pointer per object note that this is theoretically compiler-specific in practice everyone does it pretty much the same way) so making the destructor virtual wont generally cost you anything extra

            22 What is a virtual constructor

            An idiom that allows you to do something that C++ doesnt directly support

            You can get the effect of a virtual constructor by a virtual clone() member function (for copy constructing) or a virtual create() member function (for the default constructor)

            class Shape public virtual ~Shape() A virtual destructor virtual void draw() = 0 A pure virtual function virtual void move() = 0 virtual Shape clone() const = 0 Uses the copy constructor virtual Shape create() const = 0 Uses the default constructor class Circle public Shape public Circle clone() const return new Circle(this) Circle create() const return new Circle()

            In the clone() member function the new Circle(this) code calls Circles copy constructor to copy the state of this into the newly created Circle object In the create() member function the new Circle() code calls Circles default constructor

            Users use these as if they were virtual constructors

            void userCode(Shapeamp s) Shape s2 = sclone() Shape s3 = screate() delete s2 You probably need a virtual destructor here

            delete s3

            23 How do you link a C++ program to C functions

            By using the extern C linkage specification around the C function declarations

            24 Explain the scope resolution operator

            The scope resolution operator permits a program to reference an identifier in the global scope that has been hidden by another identifier with the same name in the local scope

            25 What are the differences between a C++ struct and C++ class

            The default member and base class access specifiers are different

            26 How many ways are there to initialize an int with a constant

            Two

            27 How does throwing and catching exceptions differ from using setjmp and longjmp

            The throw operation calls the destructors for automatic objects instantiated since entry to the try block

            28 How does throwing and catching exceptions differ from using setjmp and longjmp

            The throw operation calls the destructors for automatic objects instantiated since entry to the try block

            29 What is a default constructor

            A constructor that has no arguments or one where all the arguments have default argument values

            If you dont code a default constructor the compiler provides one if there are no other constructors If you are going to instantiate an array of objects of the class the class must have a default constructor

            30 What is a conversion constructor

            It is a constructor that accepts one argument of a different type

            The compiler uses this idiom as one way to infer conversion rules for a class A constructor with more than one argument and with default argument values can be interpreted by the compiler as a conversion constructor when the compiler is looking for an object of the type and sees an object of the type of the constructors first argument

            31 What is the difference between a copy constructor and an overloaded assignment operator

            A copy constructor constructs a new object by using the content of the argument object An overloaded assignment operator assigns the contents of an existing object to another existing object of the same class

            First you must know that a copy constructor is one that has only one argument which is a reference to the same type as the constructor The compiler invokes a copy constructor wherever it needs to make a copy of the object for example to pass an argument by value If you do not provide a copy constructor the compiler creates a member-by-member copy constructor for you

            You can write overloaded assignment operators that take arguments of other classes but that behavior is usually implemented with implicit conversion constructors If you do not provide an overloaded assignment operator for the class the compiler creates a default member-by-member assignment operator

            This discussion is a good place to get into why classes need copy constructors and overloaded assignment operators By discussing the requirements with respect to data member pointers that point to dynamically allocated resources you demonstrate a good grasp of the problem

            32 When should you use multiple inheritance

            There are three acceptable answers Never Rarely and When the problem domain cannot be accurately modeled any other way

            33 What is a virtual destructor

            The simple answer is that a virtual destructor is one that is declared with the virtual attribute

            The behavior of a virtual destructor is what is important If you destroy an object through a pointer or reference to a base class and the base-class destructor is not virtual the derived-class destructors are not executed and the destruction might not be complete

            34 Explain the ISA and HASA class relationships How would you implement each in a class design

            A specialized class is a specialization of another class and therefore has the ISA relationship with the other class An Employee ISA Person This relationship is best implemented with inheritance Employee is derived from Person A class may have an instance of another class For example an Employee has a Salary therefore the Employee class has the HASA relationship with the Salary class This relationship is best implemented by embedding an object of the Salary class in the Employee class

            The answer to this question reveals whether you have an understanding of the fundamentals of object-oriented design which is important to reliable class design

            There are other relationships The USESA relationship is when one class uses the services of another The Employee class uses an object (cout) of the ostream class to display the employees name onscreen for example But if you get ISA and HASA right you usually dont need to go any further

            35 When is a template a better solution than a base class

            When you are designing a generic class to contain or otherwise manage objects of other types when the format and behavior of those other types are unimportant to their containment or management and particularly when those other types are unknown (thus the genericity) to the designer of the container or manager class

            Prior to templates you had to use inheritance your design might include a generic List container class and an application-specific Employee class To put employees in a list a ListedEmployee class is multiply derived (contrived) from the Employee and List classes These solutions were unwieldy and error-prone Templates solved that problem

            Questions for ANSI-Knowledgeable Applicants

            There are six questions for those who profess knowledge of the progress of the ANSI committee If you claim to have that much interest in the language you should know the answers to all these questions

            1 What is a mutable member

            A mutable member is one that can be modified by the class even when the object of the class or the member function doing the modification is const

            Understanding this requirement implies an understanding of C++ const which many programmers do not have I have seen large class designs that do not employ the const qualifier anywhere Some of those designs are my own early C++ efforts One author suggests that some programmers find const to be such a bother that it is easier to ignore const than to try to use it meaningfully No

            wonder many programmers dont understand the power and implications of const Someone who claims to have enough interest in the language and its evolution to keep pace with the ANSI deliberations should not be ignorant of const however

            2 What is an explicit constructor

            A conversion constructor declared with the explicit keyword The compiler does not use an explicit constructor to implement an implied conversion of types Its purpose is reserved explicitly for construction

            3 What is the Standard Template Library

            It is a library of container templates approved by the ANSI committee for inclusion in the standard C++ specification

            4 Describe run-time type identification

            It is the ability to determine at run time the type of an object by using the typeid operator or the dynamic_cast operator

            5 What problem does the namespace feature solve

            Multiple providers of libraries might use common global identifiers causing a name collision when an application tries to link with two or more such libraries The name-space feature surrounds a librarys external declarations with a unique namespace that eliminates the potential for those collisions

            This solution assumes that two library vendors dont use the same namespace of course

            6 Are there any new intrinsic (built-in) data types

            Yes The ANSI committee added the bool intrinsic type and its true and false value keywords and the wchar_t data type to support character sets wider than eight bits

            SQL Server

            1 What is a foreign key

            A foreign key is a column or combination of columns used to establish and enforce a link (referential integrity) between the data in two tables A link is created between two tables by adding the column or columns that hold one tablersquos primary key values to the other table This column becomes a foreign key in the second table

            2 What is the difference between a primary key and unique key

            There can be only one primary key constrain on a table but there can be many unique key constraints in a table

            Primary key doesnrsquot allow null values but Unique allows 1 Null value

            3 What is an index

            Indexes are database objects which provides faster data access The index provides pointers to the data values stored in specified columns of

            the table and then orders those pointers according to the sort order you specify

            Different types of indexes are unique index clustered index and non-clustered index

            4 How to return multiple result set from a stored proc and capture it in ADO

            Use multiple Select statements to return multiple result sets Use ADOrsquos GetNextRecordset() method to get the second recordset during the

            execution of the stored proc

            • COMDCOM
            • Visual Basic
            • General Scripting Questions
            • Session and Application Variable Questions
              • Image Questions
              • Browser Questions
              • ActiveX Data Objects Questions
              • Form and Query String Questions
                • 18 What is a virtual member function
                • 19 How can C++ achieve dynamic binding yet also static typing
                • 20 Whats the difference between how virtual and non-virtual member functions are called
                • 21 When should my destructor be virtual
                • 22 What is a virtual constructor
                • Questions for ANSI-Knowledgeable Applicants

              QueryInterface to A will delegate request to B which in turn will delegate request for the interface to C This pointer will be returned to the client

              10 Whats the difference if any between OLE and COM

              OLE is build on top of COM The question is not strict because OLE was built over COM for years while COM as a technology was presented by Microsoft a few years ago You may mention also that COM is a specification while OLE is a particular implementation of this specification which in todays world is not exactly true as well because what people call COM today is likely implementation of COM spec by Microsoft

              11 Whats the difference between COM and DCOM

              Again the question does not require strict answer Any DCOM object is yet a COM object (DCOM extends COM) and any COM object may participate in DCOM transactions

              DCOM introduced several improvementsoptimizations for distributed environment such as MULTI_QI (multiple QueryInterface()) security contexts etc DCOM demonstrated importance of surrogate process (you cannot run in-proc server on a remote machine You need a surrogate process to do that) DCOM introduced a load balancing

              12 What is a dual interface

              Dual interface is one that supports both - IDispatch interface and vtbl-based interface Therefore it might be used in scripting environment like VBScript and yet to use power and speed of vtbl-based interface for non-scripting environment Discussion then may easily transform into analyzing of dual interface problems - be prepared to this twist

              13 What is a multi-threaded apartment (MTA) and what is a Single-threaded apartment (STA)

              This is pretty difficult question to describe shortly

              Anyway apartments were introduced by Microsoft in NT 351 and late Windows 95 to isolate the problem of running legacy non-thread safe code into multithreaded environment Each thread was encapsulated into so called single-threaded apartment The reason to create an object in apartment is thread-safety

              COM is the responsible synchronized way to access an object even if the object inside the apartment is not thread-safe Multithreaded apartments (MTA or free threading apartment) were introduced in NT 40 Idea behind MTA is that COM is

              not responsible to synchronize object calls between threads In MTA the developer is responsible for that

              ltlt See Professional DCOM Programming of Dr Grimes et al or Essential COM of Don Box for the further discussion on this topic gtgt

              14 Lets assume we have object B and aggregated object C (in-proc server) created by B Can you access any interface of B from C Whats the difference between aggregated and contained objects

              Yes you can This is fundamental postulate of COM If you can get there from here you can get there from anywhere ie QIing for IUnknown you may proceed and to get a pointer to any other interface supported by the object Aggregated object exposes its interface directly without visible intervention of the object container Contained object is created within the object container and its interfaces might be altered or filtered by the object container

              15 Is there a way to register in-proc server without regsvr32exe

              Yes Call DllRegisterServer() from the client Do not forget to call DLLUnregisterServer() from the same client You may also use Registrar object for the same purpose or use direct manipulation of the windows registry

              16 What is VARIANT Why and where would you use it

              VARIANT is a huge union containing automation type This allows easy conversion of one automation type to another The biggest disadvantage of VARIANT is size of the union

              17 What is __declspec(novtable) Why would you need this

              __declspec(novtable) is a Microsofts compiler optimization The main idea of this optimization is to strip the vtable initialization code from abstract class (for abstract class the vtable is empty while it is initialized in contructor) MSDN has an excellent article on this topic (search for ATL Virtual Functions and vtables)

              18 What is an IDL

              IDL stands for Interface Definition Language IDL is the language to describe COM interfaces

              19 What is In-proc

              In-proc is in-process COM object ie COM object that implemented as DLL and supposed to be hosted by a container When you have to instantiate the in-proc object remotely you may use DLLHostexe application that was design specially for this purpose

              20 What is OLE

              OLE is an object and embedding first implementation of COM spec available from MS before COM was officially named COM

              21 Give examples of OLE usage

              The most famous examples are probably drag and drop and structured storage implementations

              22 What are 2 storage types for composite document

              The two storage types are Storage and Stream

              23 Is doc document a compound document Is it a structured storage

              Compound document is a document that contains information about other documents hosted in this document All office documents may or may not be compound documents Word documents from version 60 and up are stored as structured storage

              Non-VB COMDCOM

              1 What should QueryInterface functions do if requested object was not found

              Return E_NOINTERFACE and nullify its out parameter

              2 How would you create an instance of the object in COM

              ltlt Well it all depends on your project Start your answer from CoCreateInstance or CoCreateInstanceEx explain the difference between them If interviewer is still not satisfied youll have to explain the whole kitchen behind the scenes including a difference between local server and inproc server meaning and mechanism of class factory etc You may also mention other methods of object creation like CoGetInstanceFromFile but discussion will likely turn to discussion of monikers then gtgt

              3 What happens when client calls CoCreateInstance

              ltlt Again all depends on the level of detail and expertise of interviewer Start with simple explanation of class object and class factory mechanism Further details would depend on a specific situation gtgt

              4 What are the limitations of CoCreateInstance

              Well a major problem with CoCreateInstance is that it is only able to create one object and only on local system To create a remote object or to get several objects based on single CLSID at the same time one should use CoCreateInstanceEx

              5 What is a moniker

              It is an object that implements the IMoniker interface A moniker acts as a name that uniquely identifies a COM object In the same way that a path identifies a file in the file system a moniker identifies a COM object in the directory namespace

              6 Can you have two dual interfaces in one class

              Yes You may have two dual interfaces in one class but only one of them may be default The bottom line is that you cannot work with two dual interfaces at the same time due to nature of dual interfaceTo support two dual interfaces in VB you would write something like

              dim d1 as IDualInterface1 dim d2 as IDualInterface2

              set d1 = new MyClassWithTwoDualsset d2 = d1

              In ATLs class you would have to use macro COM_INTERFACE_ENTRY2(IDispatch IDualInterface1) to distinguish between different dual interfaces

              7 What is a marshalling by value

              Some objects can essentially be considered static regardless of which methods are called the state of the object does not change Instead of accessing such an object remotely it is possible to copy the static state of the object and create a new object with the same state information on the caller side The caller wont be able to notice the difference but calls will be more efficient because they do not involve network round trips This is called marshaling by value

              8 What is ROT What is GIT Give pros and cons of both

              By definition running object table (ROT) is a globally accessible table on each computer that keeps track of all COM objects in the running state that can be identified by a moniker Moniker providers register an object in the table which increments the objects reference count Before the object can be destroyed its moniker must be released from the tableGlobal Interface Table (GIT) allows any apartment (either single- or multi-threaded) in a process to get access to an interface implemented on an object in any other apartment in the process

              9 If you have an object with two interfaces can you custom marshal one of them

              No The decision to use custom marshaling is an all-or-nothing decision an object has to custom marshal all its interfaces or none of them

              10 How can you guarantee that only a remote server is ever created by a client

              Create an object (call CoCreateObjectEx()) with CLSCTX_REMOTE_SERVER flag

              Visual Basic

              1 What are the properties and methods of ObjectControl interface

              Activate Deactivate CanBePooled

              2 How will you implement transaction in a visual basic ActiveX dll

              Set the MTSTransactionMode property of the class modules Use the ObjectContextSetcomplete SetAbort methods to commitrollback

              the transactions

              3 How to execute a stored proc from VB using ADO

              A stored proc can be executed using the command object

              4 What are the objects in ADO

              These are Connection Command Recordset Record Parameter and stream

              Visual Basic UI

              1 How to access a member variable in one form from another

              Set the access modifier of the member variable as Public Create a property procedure

              2 What is the listindex property of a list box control

              Listindex is the index of the currently selected item in the control

              3 Have you worked on grid controls

              ltlt Answer should be Yes or No gtgt

              ASP

              1 How will you describe a session

              Session object in ASP provides dynamic associative array that a script can use to store information

              ASP Sessions Are Cookie-based

              2 What are the different methods to pass an argument from one page to another

              Using Query string Using Hidden controls

              NET

              1 How NET My Services work

              From the developers perspective NET My Services is a set of XML Web services accessed by sending and receiving SOAP messages sent though the HTTP or DIME protocols and using the NET Passport system for authentication NET My Services consists of three things Authentication which will be provided by NET Passport when NET My Services goes live SOAP the communication protocol XML following the rules and schemas set out in the XMI Reference which provides the data formatting and organization

              2 What are Web Services

              Web Services are applications delivered as a service on the Web Web services allow for programmatic access of business logic over the Web Web services typically rely on XML-based protocols messages and interface descriptions for communication and access Web services are designed to be used by other programs or applications rather than directly by end user Programs invoking a Web service are called clients SOAP over HTTP is the most commonly used protocol for invoking Web services

              3 How do I use a proxy server when invoking a Web service

              If you are using the SOAP Toolkit you need to set some connector properties to use a proxy server Dim soap As SoapClient Set soap=New SoapClient soapConnectorProperty(ProxyServer) = ldquoproxyservernamerdquo soapConnectorProperty(ProxyPort) = ldquo8080rdquo soapConnectorProperty(UseProxy) = True While with NET you just need to create a SystemNetWebProxy object and use it to set the Proxy property Dim webs As localhostMyService() websProxy=New SystemNetWebProxy(ldquohttpproxyserver8080rdquo)

              4 What is Simple Object Access Protocol (SOAP)

              SOAP is an XML-based messaging framework specifically designed for exchanging formatted data across the Internet for example using request and reply messages or sending entire documents SOAP is simple easy to use and completely neutral with respect to operating system programming language or

              distributed computing platform

              5 What is Web Services Description Language (WSDL)

              After SOAP became available as a mechanism for exchanging XML messages among enterprises (or among disparate applications within the same enterprise) a better way was needed to describe the messages and how they are exchanged The Web Services Description Language (WSDL) is a particular form of an XML Schema developed by Microsoft and IBM for the purpose of defining the XML message operation and protocol mapping of a web service accessed using SOAP or other XML protocol WSDL defines web services in terms of endpoints that operate on XML messages The WSDL syntax allows both the messages and the operations on the messages to be defined abstractly so they can be mapped to multiple physical implementations The current WSDL spec describes how to map messages and operations to SOAP 11 HTTP GETPOST and MIME WSDL creates web service definitions by mapping a group of endpoints into a logical sequence of operations on XML messages The same XML message can be mapped to multiple operations (or services) and bound to one or more communications protocols (using ports)

              6 What is Universal Description Discovery and Integration (UDDI)

              The Universal Description Discovery and Integration (UDDI) framework defines a data model (in XML) and SOAP APIs for registration and searches on business information including the web services a business exposes to the Internet UDDI is an independent consortium of vendors founded by Microsoft IBM and Ariba for the purpose of developing an Internet standard for web service description registration and discovery Microsoft IBM and Ariba also are hosting the initial deployment of a UDDI service which is conceptually patterned after DNS (the Internet service that translates URLs into TCP addresses) UDDI uses a private agreement profile of SOAP (ie UDDI doesnt use the SOAP serialization format because its not well suited to passing complete XML documents (its aimed at RPC style interactions) The main idea is that businesses use the SOAP APIs to register themselves with UDDI and other businesses search UDDI when they want to discover a trading partner for example someone from whom they wish to procure sheet metal bolts or transistors The information in UDDI is categorized according to industry type and geographical location allowing UDDI consumers to search through lists of potentially matching businesses to find the specific one they want to contact Once a specific business is chosen another call to UDDI is made to obtain the specific contact information for that business The contact information includes a pointer to the target businesss WSDL or other XML schema file describing the web service that the target business publishes

              The interviewer should be well versed in NET to ask these questions The interview should know the answers

              Execution cycle of an assembly How does CLR comes into picture- Platform independence

              Managed unmanaged code Information about GAC How does GAC help in maintaining different versions of an assembly if

              changes are made to an assembly and the new version does not support some of functionality that previous version supported how will the runtime handle ito What is the sequence of steps followed by the runtime to look for the

              references like first to bin then GAC etco How to add assemblies in GAC

              How do we use MTS capabilities in NET assemblies Different type of data persistence in NET

              o Caching Data caching Output caching

              o Serialization Xml Bin

              Usercontrols vc Custom Controls ndash Composite controls Datareader vs Dataset Sorting in Datagrid adding custom controls in datagrid columns Use of view state in ASPX pages How to improve performance of the pages in web environment Is it possible to have both client side and server side functionality on aspx

              server controls In the page execution life cycle when is the page_init called What is AutoEventWireUp attribute used for What are delegates used for Webservices

              o How do you deploy web services Reflections Remoting

              o What is client activated objects and what are server activated objectso What are channels used for

              Interopo How does a NET component call a primitive one What are the steps taken

              General Scripting Questions

              1 How do you add a quotation mark to VB script string

              The first method uses two quotation marks in a row to create a single quotation mark The second method uses the ASCII value of the quotation mark character

              2 How do you break a single VBScript Statement into multiple lines

              A single VBScript Statement can be broken into multiple lines by using the _underscore character

              3 What is the proper method of comparing strings in VBScript

              The first method uses VBScript function with the vbTextCompare constant The second method forces both strings into uppercase

              4 How do you re-enable errors after using ON ERROR RESUME NEXT

              ltlt Need an answer gtgt

              5 How do you prevent My Script from timing out

              You can extend the amount of time a script is allowed to run by using the ScriptTimeout property of the Server object

              6 When do you need to explicitly convert a variable to a particular data type

              If you are comparing numbers or dates and there is a danger that VBScript might interpret the values as strings one of the VBScript conversion functions should be used

              7 When should one pass a variable by value and when by reference

              When you pass a variable by value to a subordinate or function a new instance of the variable is created Any changes made to the value of the variable do not affect the value of the original variable On the other hand whne you pass a variable by reference changes made to the variable do affect the value of the original variable

              8 How can you add a space between the output of two variables

              ltlt Need an answer gtgt

              9 Does ASP support dynamic includes

              It does not support

              10 How do you use the option Explicit statement in an ASP

              It must be used before nay other VBScript statement or HTML content in a script else it will generate and error

              Session and Application Variable Questions

              1 Why do session variables sometimes fail to work

              Session variables depend on browser cookies If a browser does not support cookies or a user has turned off cookies or the userrsquos cookie file is corrupted Session variables will not work

              2 How do you remove an application variable

              ltlt Need an answer gtgt

              3 How do you detect whether a File exists

              I can detect by using the FileExists method of the FileSystemObject

              4 How do you automatically display a list of the Files in a directory

              By using a list of files in a folder by using the FileSystemObject and the Folder object

              Image Questions

              1 How do you store an image in a database table

              Although you can store an image in a SQL Server BLOB column it is almost always better to store the URL of an image in a database table rather than the image itself

              2 How do you dynamically generate a graph or image in an ASP

              Several third-party ASP components enable you to dynamically create custom images

              Browser Questions

              1 How do you detect the type of browser a person is using to visit your web site

              The User-Agent header indicates the type of browser

              2 How do you detect a page from which a person originated

              The Referer header contains the URL of the last page the person visited This header can be retrieved from the ServerVariables collection

              ActiveX Data Objects Questions

              1 Why do you sometimes receive an error when using the Connection Object to execute a SQL string

              ltlt Need an answer gtgt

              2 How do you retrieve a Text filed in an ASP

              If you do not take special precautions when retrieving a Text field from a database table the value of the Text field might be truncated If you are using a forward-only cursor type you should use the Text field as the very last field in your select list Alternatively consider using a richer cursor type when opening a Recordset that contains a Text field

              3 Why does the RecordCount always return the Value-1

              The RecordCount property returns the number of rows in a Recordset after it has been opened you cannot use this property with a forward-only cursor when using SQL Server (it will always return ndash1)

              4 Why do you receive an error whenever you try to update the value of a filed in a recordset

              By default when you open a Recordset it is opened with a forward-only cursor and read-only lock type To update a Recordset you must open a Recordset that is not read-only

              5 How do you limit the number of rows returned by a Database Query

              If using SQL 70 or Access you can use the SQL Top keyword to limit the number of records returned Otherwise if you are using SQL 65 use the MaxRecords property of the Recordset object

              ltlt What about SQL 2000 gtgt

              6 How do you retrieve the value from a SQL Statement that uses Count() Max Min or Identity

              There are two methods that you can use to retrieve the value from a SQL function or a SQL global variable You can either use an alias for the value or refer to the value by its ordinal position in the Recordset

              7 How do you retrieve an output parameter from a SQL stored procedure within an ASPScript

              You must use the ADO Command nad parameter objects

              Form and Query String Questions

              1 How do you accept file uploads in an HTML form

              ltlt Need an answer gtgt

              2 What causes the value of a form field to become truncated

              HTML uses quotation marks to mark the beginning and end of a value So If a variable contains question marks in its values the value of the variablewill be truncated when displayed

              3 How do you include spaces or other special characters in a query string

              URL encode the query string

              C++ Questions

              1 What is an object in C++

              An object is a package that contains related data and instructions The data relates to what the object represents while the instructions define how this object relates to other objects and itself

              2 What is a message

              A message is a signal from one object to another requesting that a computation take place It is roughly equivalent to a function call in other languages

              3 What is a class

              A class defines the characteristics of a certain type of object It defines what its members will remember the messages to which they will respond and what form the response will take

              4 What is an instance

              It is an individual object that is a member of some class

              5 What is a super-class

              Given a class a super-class is the basis of the class under consideration The given class is defined as a subset (in some respects) of the super-class All objects of the given class potentially posses all the characteristics belonging to objects of the super-class

              6 What is inheritance

              Inheritance is property such that a parent (or super) class passes the characteristics of itself to children (or sub) classes that are derived from it The sub-class has the option of modifying these characteristics in order to make a different but fundamentally related class from the super-class

              7 To what does message protocol refer

              An objects message protocol is the exact form of the set of messages to which the object can respond

              8 What is polymorphism

              Polymorphism refers to the ability of an object to respond in a logically identical fashion to messages of the same protocol containing differing types of objects Consider 1 + 5 and 1 + 51 In the former the message + 5 is sent to an object of class integer (1) In the later the message + 51 is sent to the same integer object The form of the message (its protocol) is identical in both cases What differs is the type of object on the right-hand side of these messages The former is an integer object (5) while the later is a floating point object (51) The receiver (1) appears (to other objects) to respond in the same way to both messages Internally however it knows that it must treat the two types of objects differently in order to obtain the same overall response

              9 What are instance variables

              These represent an objects private memory They are defined in an objects class

              18 What is a virtual member function

              A virtual function allows derived classes to replace the implementation provided by the base class The compiler makes sure the replacement is always called whenever the object in question is actually of the derived class even if the object is accessed by a base pointer rather than a derived pointer This allows algorithms in the base class to be replaced in the derived class even if users dont know about the derived class

              The derived class can either fully replace (override) the base class member function or the derived class can partially replace (augment) the base class member function The latter is accomplished by having the derived class member function call the base class member function if desired

              19 How can C++ achieve dynamic binding yet also static typing

              When you have a pointer to an object the object may actually be of a class that is derived from the class of the pointer (eg a Vehicle that is actually pointing to a Car object) Thus there are two types the (static) type of the pointer (Vehicle in this case) and the (dynamic) type of the pointed-to object (Car in this case)

              Static typing means that the legality of a member function invocation is checked at the earliest possible moment by the compiler at compile time The compiler uses the static type of the pointer to determine whether the member function invocation is legal If the type of the pointer can handle the member function certainly the pointed-to object can handle it as well Eg if Vehicle has a certain member function certainly Car also has that member function since Car is a kind-of Vehicle

              Dynamic binding means that the address of the code in a member function invocation is determined at the last possible moment based on the dynamic type of the object at run time It is called dynamic binding because the binding to the code that actually gets called is accomplished dynamically (at run time) Dynamic binding is a result of virtual functions

              20 Whats the difference between how virtual and non-virtual member functions are called

              Non-virtual member functions are resolved statically That is the member function is selected statically (at compile-time) based on the type of the pointer (or reference) to the object

              In contrast virtual member functions are resolved dynamically (at run-time) That is the member function is selected dynamically (at run-time) based on the type of the object not the type of the pointerreference to that object This is called dynamic binding Most compilers use some variant of the following technique

              if the object has one or more virtual functions the compiler puts a hidden pointer in the object called a virtual-pointer or v-pointer This v-pointer points to a global table called the virtual-table or v-table

              The compiler creates a v-table for each class that has at least one virtual function For example if class Circle has virtual functions for draw() and move() and resize() there would be exactly one v-table associated with class Circle even if there were a gazillion Circle objects and the v-pointer of each of those Circle objects would point to the Circle v-table The v-table itself has pointers to each of the virtual functions in the class For example the Circle v-table would have three pointers a pointer to Circledraw() a pointer to Circlemove() and a pointer to Circleresize()

              During a dispatch of a virtual function the run-time system follows the objects v-pointer to the classs v-table then follows the appropriate slot in the v-table to the method code

              The space-cost overhead of the above technique is nominal an extra pointer per object (but only for objects that will need to do dynamic binding) plus an extra pointer per method (but only for virtual methods) The time-cost overhead is also fairly nominal compared to a normal function call a virtual function call requires two extra fetches (one to get the value of the v-pointer a second to get the address of the method) None of this runtime activity happens with non-virtual functions since the compiler resolves non-virtual functions exclusively at compile-time based on the type of the pointer

              21 When should my destructor be virtual

              When you may delete a derived object via a base pointer

              virtual functions bind to the code associated with the class of the object rather than with the class of the pointerreference When you say delete basePtr and the base class has a virtual destructor the destructor that gets invoked is the one associated with the type of the object basePtr rather than the one associated with the type of the pointer This is generally A Good Thing

              TECHNO-GEEK WARNING PUT YOUR PROPELLER HAT ON Technically speaking you need a base classs destructor to be virtual if and only if you intend to allow someone to invoke an objects destructor via a base class pointer (this is normally done implicitly via delete) and the object being destructed is of a derived class that has a non-trivial destructor A class has a non-trivial destructor if it either has an explicit destructor or if it has a member object or a base class that has a non-trivial destructor (note that this is a recursive definition (eg a class has a non-trivial destructor if it has a member object (which has a base class (which has a member object (which has a base class (which has an explicit destructor)))))) END TECHNO-GEEK WARNING REMOVE YOUR PROPELLER HAT

              If you had a hard grokking the previous rule try this (over)simplified one on for size A class should have a virtual destructor unless that class has no virtual functions Rationale if you have any virtual functions at all youre probably going to be doing stuff to derived objects via a base pointer and some of the stuff you may do may include invoking a destructor (normally done implicitly via delete) Plus once youve put the first virtual function into a class youve already paid all the per-object space cost that youll ever pay (one pointer per object note that this is theoretically compiler-specific in practice everyone does it pretty much the same way) so making the destructor virtual wont generally cost you anything extra

              22 What is a virtual constructor

              An idiom that allows you to do something that C++ doesnt directly support

              You can get the effect of a virtual constructor by a virtual clone() member function (for copy constructing) or a virtual create() member function (for the default constructor)

              class Shape public virtual ~Shape() A virtual destructor virtual void draw() = 0 A pure virtual function virtual void move() = 0 virtual Shape clone() const = 0 Uses the copy constructor virtual Shape create() const = 0 Uses the default constructor class Circle public Shape public Circle clone() const return new Circle(this) Circle create() const return new Circle()

              In the clone() member function the new Circle(this) code calls Circles copy constructor to copy the state of this into the newly created Circle object In the create() member function the new Circle() code calls Circles default constructor

              Users use these as if they were virtual constructors

              void userCode(Shapeamp s) Shape s2 = sclone() Shape s3 = screate() delete s2 You probably need a virtual destructor here

              delete s3

              23 How do you link a C++ program to C functions

              By using the extern C linkage specification around the C function declarations

              24 Explain the scope resolution operator

              The scope resolution operator permits a program to reference an identifier in the global scope that has been hidden by another identifier with the same name in the local scope

              25 What are the differences between a C++ struct and C++ class

              The default member and base class access specifiers are different

              26 How many ways are there to initialize an int with a constant

              Two

              27 How does throwing and catching exceptions differ from using setjmp and longjmp

              The throw operation calls the destructors for automatic objects instantiated since entry to the try block

              28 How does throwing and catching exceptions differ from using setjmp and longjmp

              The throw operation calls the destructors for automatic objects instantiated since entry to the try block

              29 What is a default constructor

              A constructor that has no arguments or one where all the arguments have default argument values

              If you dont code a default constructor the compiler provides one if there are no other constructors If you are going to instantiate an array of objects of the class the class must have a default constructor

              30 What is a conversion constructor

              It is a constructor that accepts one argument of a different type

              The compiler uses this idiom as one way to infer conversion rules for a class A constructor with more than one argument and with default argument values can be interpreted by the compiler as a conversion constructor when the compiler is looking for an object of the type and sees an object of the type of the constructors first argument

              31 What is the difference between a copy constructor and an overloaded assignment operator

              A copy constructor constructs a new object by using the content of the argument object An overloaded assignment operator assigns the contents of an existing object to another existing object of the same class

              First you must know that a copy constructor is one that has only one argument which is a reference to the same type as the constructor The compiler invokes a copy constructor wherever it needs to make a copy of the object for example to pass an argument by value If you do not provide a copy constructor the compiler creates a member-by-member copy constructor for you

              You can write overloaded assignment operators that take arguments of other classes but that behavior is usually implemented with implicit conversion constructors If you do not provide an overloaded assignment operator for the class the compiler creates a default member-by-member assignment operator

              This discussion is a good place to get into why classes need copy constructors and overloaded assignment operators By discussing the requirements with respect to data member pointers that point to dynamically allocated resources you demonstrate a good grasp of the problem

              32 When should you use multiple inheritance

              There are three acceptable answers Never Rarely and When the problem domain cannot be accurately modeled any other way

              33 What is a virtual destructor

              The simple answer is that a virtual destructor is one that is declared with the virtual attribute

              The behavior of a virtual destructor is what is important If you destroy an object through a pointer or reference to a base class and the base-class destructor is not virtual the derived-class destructors are not executed and the destruction might not be complete

              34 Explain the ISA and HASA class relationships How would you implement each in a class design

              A specialized class is a specialization of another class and therefore has the ISA relationship with the other class An Employee ISA Person This relationship is best implemented with inheritance Employee is derived from Person A class may have an instance of another class For example an Employee has a Salary therefore the Employee class has the HASA relationship with the Salary class This relationship is best implemented by embedding an object of the Salary class in the Employee class

              The answer to this question reveals whether you have an understanding of the fundamentals of object-oriented design which is important to reliable class design

              There are other relationships The USESA relationship is when one class uses the services of another The Employee class uses an object (cout) of the ostream class to display the employees name onscreen for example But if you get ISA and HASA right you usually dont need to go any further

              35 When is a template a better solution than a base class

              When you are designing a generic class to contain or otherwise manage objects of other types when the format and behavior of those other types are unimportant to their containment or management and particularly when those other types are unknown (thus the genericity) to the designer of the container or manager class

              Prior to templates you had to use inheritance your design might include a generic List container class and an application-specific Employee class To put employees in a list a ListedEmployee class is multiply derived (contrived) from the Employee and List classes These solutions were unwieldy and error-prone Templates solved that problem

              Questions for ANSI-Knowledgeable Applicants

              There are six questions for those who profess knowledge of the progress of the ANSI committee If you claim to have that much interest in the language you should know the answers to all these questions

              1 What is a mutable member

              A mutable member is one that can be modified by the class even when the object of the class or the member function doing the modification is const

              Understanding this requirement implies an understanding of C++ const which many programmers do not have I have seen large class designs that do not employ the const qualifier anywhere Some of those designs are my own early C++ efforts One author suggests that some programmers find const to be such a bother that it is easier to ignore const than to try to use it meaningfully No

              wonder many programmers dont understand the power and implications of const Someone who claims to have enough interest in the language and its evolution to keep pace with the ANSI deliberations should not be ignorant of const however

              2 What is an explicit constructor

              A conversion constructor declared with the explicit keyword The compiler does not use an explicit constructor to implement an implied conversion of types Its purpose is reserved explicitly for construction

              3 What is the Standard Template Library

              It is a library of container templates approved by the ANSI committee for inclusion in the standard C++ specification

              4 Describe run-time type identification

              It is the ability to determine at run time the type of an object by using the typeid operator or the dynamic_cast operator

              5 What problem does the namespace feature solve

              Multiple providers of libraries might use common global identifiers causing a name collision when an application tries to link with two or more such libraries The name-space feature surrounds a librarys external declarations with a unique namespace that eliminates the potential for those collisions

              This solution assumes that two library vendors dont use the same namespace of course

              6 Are there any new intrinsic (built-in) data types

              Yes The ANSI committee added the bool intrinsic type and its true and false value keywords and the wchar_t data type to support character sets wider than eight bits

              SQL Server

              1 What is a foreign key

              A foreign key is a column or combination of columns used to establish and enforce a link (referential integrity) between the data in two tables A link is created between two tables by adding the column or columns that hold one tablersquos primary key values to the other table This column becomes a foreign key in the second table

              2 What is the difference between a primary key and unique key

              There can be only one primary key constrain on a table but there can be many unique key constraints in a table

              Primary key doesnrsquot allow null values but Unique allows 1 Null value

              3 What is an index

              Indexes are database objects which provides faster data access The index provides pointers to the data values stored in specified columns of

              the table and then orders those pointers according to the sort order you specify

              Different types of indexes are unique index clustered index and non-clustered index

              4 How to return multiple result set from a stored proc and capture it in ADO

              Use multiple Select statements to return multiple result sets Use ADOrsquos GetNextRecordset() method to get the second recordset during the

              execution of the stored proc

              • COMDCOM
              • Visual Basic
              • General Scripting Questions
              • Session and Application Variable Questions
                • Image Questions
                • Browser Questions
                • ActiveX Data Objects Questions
                • Form and Query String Questions
                  • 18 What is a virtual member function
                  • 19 How can C++ achieve dynamic binding yet also static typing
                  • 20 Whats the difference between how virtual and non-virtual member functions are called
                  • 21 When should my destructor be virtual
                  • 22 What is a virtual constructor
                  • Questions for ANSI-Knowledgeable Applicants

                not responsible to synchronize object calls between threads In MTA the developer is responsible for that

                ltlt See Professional DCOM Programming of Dr Grimes et al or Essential COM of Don Box for the further discussion on this topic gtgt

                14 Lets assume we have object B and aggregated object C (in-proc server) created by B Can you access any interface of B from C Whats the difference between aggregated and contained objects

                Yes you can This is fundamental postulate of COM If you can get there from here you can get there from anywhere ie QIing for IUnknown you may proceed and to get a pointer to any other interface supported by the object Aggregated object exposes its interface directly without visible intervention of the object container Contained object is created within the object container and its interfaces might be altered or filtered by the object container

                15 Is there a way to register in-proc server without regsvr32exe

                Yes Call DllRegisterServer() from the client Do not forget to call DLLUnregisterServer() from the same client You may also use Registrar object for the same purpose or use direct manipulation of the windows registry

                16 What is VARIANT Why and where would you use it

                VARIANT is a huge union containing automation type This allows easy conversion of one automation type to another The biggest disadvantage of VARIANT is size of the union

                17 What is __declspec(novtable) Why would you need this

                __declspec(novtable) is a Microsofts compiler optimization The main idea of this optimization is to strip the vtable initialization code from abstract class (for abstract class the vtable is empty while it is initialized in contructor) MSDN has an excellent article on this topic (search for ATL Virtual Functions and vtables)

                18 What is an IDL

                IDL stands for Interface Definition Language IDL is the language to describe COM interfaces

                19 What is In-proc

                In-proc is in-process COM object ie COM object that implemented as DLL and supposed to be hosted by a container When you have to instantiate the in-proc object remotely you may use DLLHostexe application that was design specially for this purpose

                20 What is OLE

                OLE is an object and embedding first implementation of COM spec available from MS before COM was officially named COM

                21 Give examples of OLE usage

                The most famous examples are probably drag and drop and structured storage implementations

                22 What are 2 storage types for composite document

                The two storage types are Storage and Stream

                23 Is doc document a compound document Is it a structured storage

                Compound document is a document that contains information about other documents hosted in this document All office documents may or may not be compound documents Word documents from version 60 and up are stored as structured storage

                Non-VB COMDCOM

                1 What should QueryInterface functions do if requested object was not found

                Return E_NOINTERFACE and nullify its out parameter

                2 How would you create an instance of the object in COM

                ltlt Well it all depends on your project Start your answer from CoCreateInstance or CoCreateInstanceEx explain the difference between them If interviewer is still not satisfied youll have to explain the whole kitchen behind the scenes including a difference between local server and inproc server meaning and mechanism of class factory etc You may also mention other methods of object creation like CoGetInstanceFromFile but discussion will likely turn to discussion of monikers then gtgt

                3 What happens when client calls CoCreateInstance

                ltlt Again all depends on the level of detail and expertise of interviewer Start with simple explanation of class object and class factory mechanism Further details would depend on a specific situation gtgt

                4 What are the limitations of CoCreateInstance

                Well a major problem with CoCreateInstance is that it is only able to create one object and only on local system To create a remote object or to get several objects based on single CLSID at the same time one should use CoCreateInstanceEx

                5 What is a moniker

                It is an object that implements the IMoniker interface A moniker acts as a name that uniquely identifies a COM object In the same way that a path identifies a file in the file system a moniker identifies a COM object in the directory namespace

                6 Can you have two dual interfaces in one class

                Yes You may have two dual interfaces in one class but only one of them may be default The bottom line is that you cannot work with two dual interfaces at the same time due to nature of dual interfaceTo support two dual interfaces in VB you would write something like

                dim d1 as IDualInterface1 dim d2 as IDualInterface2

                set d1 = new MyClassWithTwoDualsset d2 = d1

                In ATLs class you would have to use macro COM_INTERFACE_ENTRY2(IDispatch IDualInterface1) to distinguish between different dual interfaces

                7 What is a marshalling by value

                Some objects can essentially be considered static regardless of which methods are called the state of the object does not change Instead of accessing such an object remotely it is possible to copy the static state of the object and create a new object with the same state information on the caller side The caller wont be able to notice the difference but calls will be more efficient because they do not involve network round trips This is called marshaling by value

                8 What is ROT What is GIT Give pros and cons of both

                By definition running object table (ROT) is a globally accessible table on each computer that keeps track of all COM objects in the running state that can be identified by a moniker Moniker providers register an object in the table which increments the objects reference count Before the object can be destroyed its moniker must be released from the tableGlobal Interface Table (GIT) allows any apartment (either single- or multi-threaded) in a process to get access to an interface implemented on an object in any other apartment in the process

                9 If you have an object with two interfaces can you custom marshal one of them

                No The decision to use custom marshaling is an all-or-nothing decision an object has to custom marshal all its interfaces or none of them

                10 How can you guarantee that only a remote server is ever created by a client

                Create an object (call CoCreateObjectEx()) with CLSCTX_REMOTE_SERVER flag

                Visual Basic

                1 What are the properties and methods of ObjectControl interface

                Activate Deactivate CanBePooled

                2 How will you implement transaction in a visual basic ActiveX dll

                Set the MTSTransactionMode property of the class modules Use the ObjectContextSetcomplete SetAbort methods to commitrollback

                the transactions

                3 How to execute a stored proc from VB using ADO

                A stored proc can be executed using the command object

                4 What are the objects in ADO

                These are Connection Command Recordset Record Parameter and stream

                Visual Basic UI

                1 How to access a member variable in one form from another

                Set the access modifier of the member variable as Public Create a property procedure

                2 What is the listindex property of a list box control

                Listindex is the index of the currently selected item in the control

                3 Have you worked on grid controls

                ltlt Answer should be Yes or No gtgt

                ASP

                1 How will you describe a session

                Session object in ASP provides dynamic associative array that a script can use to store information

                ASP Sessions Are Cookie-based

                2 What are the different methods to pass an argument from one page to another

                Using Query string Using Hidden controls

                NET

                1 How NET My Services work

                From the developers perspective NET My Services is a set of XML Web services accessed by sending and receiving SOAP messages sent though the HTTP or DIME protocols and using the NET Passport system for authentication NET My Services consists of three things Authentication which will be provided by NET Passport when NET My Services goes live SOAP the communication protocol XML following the rules and schemas set out in the XMI Reference which provides the data formatting and organization

                2 What are Web Services

                Web Services are applications delivered as a service on the Web Web services allow for programmatic access of business logic over the Web Web services typically rely on XML-based protocols messages and interface descriptions for communication and access Web services are designed to be used by other programs or applications rather than directly by end user Programs invoking a Web service are called clients SOAP over HTTP is the most commonly used protocol for invoking Web services

                3 How do I use a proxy server when invoking a Web service

                If you are using the SOAP Toolkit you need to set some connector properties to use a proxy server Dim soap As SoapClient Set soap=New SoapClient soapConnectorProperty(ProxyServer) = ldquoproxyservernamerdquo soapConnectorProperty(ProxyPort) = ldquo8080rdquo soapConnectorProperty(UseProxy) = True While with NET you just need to create a SystemNetWebProxy object and use it to set the Proxy property Dim webs As localhostMyService() websProxy=New SystemNetWebProxy(ldquohttpproxyserver8080rdquo)

                4 What is Simple Object Access Protocol (SOAP)

                SOAP is an XML-based messaging framework specifically designed for exchanging formatted data across the Internet for example using request and reply messages or sending entire documents SOAP is simple easy to use and completely neutral with respect to operating system programming language or

                distributed computing platform

                5 What is Web Services Description Language (WSDL)

                After SOAP became available as a mechanism for exchanging XML messages among enterprises (or among disparate applications within the same enterprise) a better way was needed to describe the messages and how they are exchanged The Web Services Description Language (WSDL) is a particular form of an XML Schema developed by Microsoft and IBM for the purpose of defining the XML message operation and protocol mapping of a web service accessed using SOAP or other XML protocol WSDL defines web services in terms of endpoints that operate on XML messages The WSDL syntax allows both the messages and the operations on the messages to be defined abstractly so they can be mapped to multiple physical implementations The current WSDL spec describes how to map messages and operations to SOAP 11 HTTP GETPOST and MIME WSDL creates web service definitions by mapping a group of endpoints into a logical sequence of operations on XML messages The same XML message can be mapped to multiple operations (or services) and bound to one or more communications protocols (using ports)

                6 What is Universal Description Discovery and Integration (UDDI)

                The Universal Description Discovery and Integration (UDDI) framework defines a data model (in XML) and SOAP APIs for registration and searches on business information including the web services a business exposes to the Internet UDDI is an independent consortium of vendors founded by Microsoft IBM and Ariba for the purpose of developing an Internet standard for web service description registration and discovery Microsoft IBM and Ariba also are hosting the initial deployment of a UDDI service which is conceptually patterned after DNS (the Internet service that translates URLs into TCP addresses) UDDI uses a private agreement profile of SOAP (ie UDDI doesnt use the SOAP serialization format because its not well suited to passing complete XML documents (its aimed at RPC style interactions) The main idea is that businesses use the SOAP APIs to register themselves with UDDI and other businesses search UDDI when they want to discover a trading partner for example someone from whom they wish to procure sheet metal bolts or transistors The information in UDDI is categorized according to industry type and geographical location allowing UDDI consumers to search through lists of potentially matching businesses to find the specific one they want to contact Once a specific business is chosen another call to UDDI is made to obtain the specific contact information for that business The contact information includes a pointer to the target businesss WSDL or other XML schema file describing the web service that the target business publishes

                The interviewer should be well versed in NET to ask these questions The interview should know the answers

                Execution cycle of an assembly How does CLR comes into picture- Platform independence

                Managed unmanaged code Information about GAC How does GAC help in maintaining different versions of an assembly if

                changes are made to an assembly and the new version does not support some of functionality that previous version supported how will the runtime handle ito What is the sequence of steps followed by the runtime to look for the

                references like first to bin then GAC etco How to add assemblies in GAC

                How do we use MTS capabilities in NET assemblies Different type of data persistence in NET

                o Caching Data caching Output caching

                o Serialization Xml Bin

                Usercontrols vc Custom Controls ndash Composite controls Datareader vs Dataset Sorting in Datagrid adding custom controls in datagrid columns Use of view state in ASPX pages How to improve performance of the pages in web environment Is it possible to have both client side and server side functionality on aspx

                server controls In the page execution life cycle when is the page_init called What is AutoEventWireUp attribute used for What are delegates used for Webservices

                o How do you deploy web services Reflections Remoting

                o What is client activated objects and what are server activated objectso What are channels used for

                Interopo How does a NET component call a primitive one What are the steps taken

                General Scripting Questions

                1 How do you add a quotation mark to VB script string

                The first method uses two quotation marks in a row to create a single quotation mark The second method uses the ASCII value of the quotation mark character

                2 How do you break a single VBScript Statement into multiple lines

                A single VBScript Statement can be broken into multiple lines by using the _underscore character

                3 What is the proper method of comparing strings in VBScript

                The first method uses VBScript function with the vbTextCompare constant The second method forces both strings into uppercase

                4 How do you re-enable errors after using ON ERROR RESUME NEXT

                ltlt Need an answer gtgt

                5 How do you prevent My Script from timing out

                You can extend the amount of time a script is allowed to run by using the ScriptTimeout property of the Server object

                6 When do you need to explicitly convert a variable to a particular data type

                If you are comparing numbers or dates and there is a danger that VBScript might interpret the values as strings one of the VBScript conversion functions should be used

                7 When should one pass a variable by value and when by reference

                When you pass a variable by value to a subordinate or function a new instance of the variable is created Any changes made to the value of the variable do not affect the value of the original variable On the other hand whne you pass a variable by reference changes made to the variable do affect the value of the original variable

                8 How can you add a space between the output of two variables

                ltlt Need an answer gtgt

                9 Does ASP support dynamic includes

                It does not support

                10 How do you use the option Explicit statement in an ASP

                It must be used before nay other VBScript statement or HTML content in a script else it will generate and error

                Session and Application Variable Questions

                1 Why do session variables sometimes fail to work

                Session variables depend on browser cookies If a browser does not support cookies or a user has turned off cookies or the userrsquos cookie file is corrupted Session variables will not work

                2 How do you remove an application variable

                ltlt Need an answer gtgt

                3 How do you detect whether a File exists

                I can detect by using the FileExists method of the FileSystemObject

                4 How do you automatically display a list of the Files in a directory

                By using a list of files in a folder by using the FileSystemObject and the Folder object

                Image Questions

                1 How do you store an image in a database table

                Although you can store an image in a SQL Server BLOB column it is almost always better to store the URL of an image in a database table rather than the image itself

                2 How do you dynamically generate a graph or image in an ASP

                Several third-party ASP components enable you to dynamically create custom images

                Browser Questions

                1 How do you detect the type of browser a person is using to visit your web site

                The User-Agent header indicates the type of browser

                2 How do you detect a page from which a person originated

                The Referer header contains the URL of the last page the person visited This header can be retrieved from the ServerVariables collection

                ActiveX Data Objects Questions

                1 Why do you sometimes receive an error when using the Connection Object to execute a SQL string

                ltlt Need an answer gtgt

                2 How do you retrieve a Text filed in an ASP

                If you do not take special precautions when retrieving a Text field from a database table the value of the Text field might be truncated If you are using a forward-only cursor type you should use the Text field as the very last field in your select list Alternatively consider using a richer cursor type when opening a Recordset that contains a Text field

                3 Why does the RecordCount always return the Value-1

                The RecordCount property returns the number of rows in a Recordset after it has been opened you cannot use this property with a forward-only cursor when using SQL Server (it will always return ndash1)

                4 Why do you receive an error whenever you try to update the value of a filed in a recordset

                By default when you open a Recordset it is opened with a forward-only cursor and read-only lock type To update a Recordset you must open a Recordset that is not read-only

                5 How do you limit the number of rows returned by a Database Query

                If using SQL 70 or Access you can use the SQL Top keyword to limit the number of records returned Otherwise if you are using SQL 65 use the MaxRecords property of the Recordset object

                ltlt What about SQL 2000 gtgt

                6 How do you retrieve the value from a SQL Statement that uses Count() Max Min or Identity

                There are two methods that you can use to retrieve the value from a SQL function or a SQL global variable You can either use an alias for the value or refer to the value by its ordinal position in the Recordset

                7 How do you retrieve an output parameter from a SQL stored procedure within an ASPScript

                You must use the ADO Command nad parameter objects

                Form and Query String Questions

                1 How do you accept file uploads in an HTML form

                ltlt Need an answer gtgt

                2 What causes the value of a form field to become truncated

                HTML uses quotation marks to mark the beginning and end of a value So If a variable contains question marks in its values the value of the variablewill be truncated when displayed

                3 How do you include spaces or other special characters in a query string

                URL encode the query string

                C++ Questions

                1 What is an object in C++

                An object is a package that contains related data and instructions The data relates to what the object represents while the instructions define how this object relates to other objects and itself

                2 What is a message

                A message is a signal from one object to another requesting that a computation take place It is roughly equivalent to a function call in other languages

                3 What is a class

                A class defines the characteristics of a certain type of object It defines what its members will remember the messages to which they will respond and what form the response will take

                4 What is an instance

                It is an individual object that is a member of some class

                5 What is a super-class

                Given a class a super-class is the basis of the class under consideration The given class is defined as a subset (in some respects) of the super-class All objects of the given class potentially posses all the characteristics belonging to objects of the super-class

                6 What is inheritance

                Inheritance is property such that a parent (or super) class passes the characteristics of itself to children (or sub) classes that are derived from it The sub-class has the option of modifying these characteristics in order to make a different but fundamentally related class from the super-class

                7 To what does message protocol refer

                An objects message protocol is the exact form of the set of messages to which the object can respond

                8 What is polymorphism

                Polymorphism refers to the ability of an object to respond in a logically identical fashion to messages of the same protocol containing differing types of objects Consider 1 + 5 and 1 + 51 In the former the message + 5 is sent to an object of class integer (1) In the later the message + 51 is sent to the same integer object The form of the message (its protocol) is identical in both cases What differs is the type of object on the right-hand side of these messages The former is an integer object (5) while the later is a floating point object (51) The receiver (1) appears (to other objects) to respond in the same way to both messages Internally however it knows that it must treat the two types of objects differently in order to obtain the same overall response

                9 What are instance variables

                These represent an objects private memory They are defined in an objects class

                18 What is a virtual member function

                A virtual function allows derived classes to replace the implementation provided by the base class The compiler makes sure the replacement is always called whenever the object in question is actually of the derived class even if the object is accessed by a base pointer rather than a derived pointer This allows algorithms in the base class to be replaced in the derived class even if users dont know about the derived class

                The derived class can either fully replace (override) the base class member function or the derived class can partially replace (augment) the base class member function The latter is accomplished by having the derived class member function call the base class member function if desired

                19 How can C++ achieve dynamic binding yet also static typing

                When you have a pointer to an object the object may actually be of a class that is derived from the class of the pointer (eg a Vehicle that is actually pointing to a Car object) Thus there are two types the (static) type of the pointer (Vehicle in this case) and the (dynamic) type of the pointed-to object (Car in this case)

                Static typing means that the legality of a member function invocation is checked at the earliest possible moment by the compiler at compile time The compiler uses the static type of the pointer to determine whether the member function invocation is legal If the type of the pointer can handle the member function certainly the pointed-to object can handle it as well Eg if Vehicle has a certain member function certainly Car also has that member function since Car is a kind-of Vehicle

                Dynamic binding means that the address of the code in a member function invocation is determined at the last possible moment based on the dynamic type of the object at run time It is called dynamic binding because the binding to the code that actually gets called is accomplished dynamically (at run time) Dynamic binding is a result of virtual functions

                20 Whats the difference between how virtual and non-virtual member functions are called

                Non-virtual member functions are resolved statically That is the member function is selected statically (at compile-time) based on the type of the pointer (or reference) to the object

                In contrast virtual member functions are resolved dynamically (at run-time) That is the member function is selected dynamically (at run-time) based on the type of the object not the type of the pointerreference to that object This is called dynamic binding Most compilers use some variant of the following technique

                if the object has one or more virtual functions the compiler puts a hidden pointer in the object called a virtual-pointer or v-pointer This v-pointer points to a global table called the virtual-table or v-table

                The compiler creates a v-table for each class that has at least one virtual function For example if class Circle has virtual functions for draw() and move() and resize() there would be exactly one v-table associated with class Circle even if there were a gazillion Circle objects and the v-pointer of each of those Circle objects would point to the Circle v-table The v-table itself has pointers to each of the virtual functions in the class For example the Circle v-table would have three pointers a pointer to Circledraw() a pointer to Circlemove() and a pointer to Circleresize()

                During a dispatch of a virtual function the run-time system follows the objects v-pointer to the classs v-table then follows the appropriate slot in the v-table to the method code

                The space-cost overhead of the above technique is nominal an extra pointer per object (but only for objects that will need to do dynamic binding) plus an extra pointer per method (but only for virtual methods) The time-cost overhead is also fairly nominal compared to a normal function call a virtual function call requires two extra fetches (one to get the value of the v-pointer a second to get the address of the method) None of this runtime activity happens with non-virtual functions since the compiler resolves non-virtual functions exclusively at compile-time based on the type of the pointer

                21 When should my destructor be virtual

                When you may delete a derived object via a base pointer

                virtual functions bind to the code associated with the class of the object rather than with the class of the pointerreference When you say delete basePtr and the base class has a virtual destructor the destructor that gets invoked is the one associated with the type of the object basePtr rather than the one associated with the type of the pointer This is generally A Good Thing

                TECHNO-GEEK WARNING PUT YOUR PROPELLER HAT ON Technically speaking you need a base classs destructor to be virtual if and only if you intend to allow someone to invoke an objects destructor via a base class pointer (this is normally done implicitly via delete) and the object being destructed is of a derived class that has a non-trivial destructor A class has a non-trivial destructor if it either has an explicit destructor or if it has a member object or a base class that has a non-trivial destructor (note that this is a recursive definition (eg a class has a non-trivial destructor if it has a member object (which has a base class (which has a member object (which has a base class (which has an explicit destructor)))))) END TECHNO-GEEK WARNING REMOVE YOUR PROPELLER HAT

                If you had a hard grokking the previous rule try this (over)simplified one on for size A class should have a virtual destructor unless that class has no virtual functions Rationale if you have any virtual functions at all youre probably going to be doing stuff to derived objects via a base pointer and some of the stuff you may do may include invoking a destructor (normally done implicitly via delete) Plus once youve put the first virtual function into a class youve already paid all the per-object space cost that youll ever pay (one pointer per object note that this is theoretically compiler-specific in practice everyone does it pretty much the same way) so making the destructor virtual wont generally cost you anything extra

                22 What is a virtual constructor

                An idiom that allows you to do something that C++ doesnt directly support

                You can get the effect of a virtual constructor by a virtual clone() member function (for copy constructing) or a virtual create() member function (for the default constructor)

                class Shape public virtual ~Shape() A virtual destructor virtual void draw() = 0 A pure virtual function virtual void move() = 0 virtual Shape clone() const = 0 Uses the copy constructor virtual Shape create() const = 0 Uses the default constructor class Circle public Shape public Circle clone() const return new Circle(this) Circle create() const return new Circle()

                In the clone() member function the new Circle(this) code calls Circles copy constructor to copy the state of this into the newly created Circle object In the create() member function the new Circle() code calls Circles default constructor

                Users use these as if they were virtual constructors

                void userCode(Shapeamp s) Shape s2 = sclone() Shape s3 = screate() delete s2 You probably need a virtual destructor here

                delete s3

                23 How do you link a C++ program to C functions

                By using the extern C linkage specification around the C function declarations

                24 Explain the scope resolution operator

                The scope resolution operator permits a program to reference an identifier in the global scope that has been hidden by another identifier with the same name in the local scope

                25 What are the differences between a C++ struct and C++ class

                The default member and base class access specifiers are different

                26 How many ways are there to initialize an int with a constant

                Two

                27 How does throwing and catching exceptions differ from using setjmp and longjmp

                The throw operation calls the destructors for automatic objects instantiated since entry to the try block

                28 How does throwing and catching exceptions differ from using setjmp and longjmp

                The throw operation calls the destructors for automatic objects instantiated since entry to the try block

                29 What is a default constructor

                A constructor that has no arguments or one where all the arguments have default argument values

                If you dont code a default constructor the compiler provides one if there are no other constructors If you are going to instantiate an array of objects of the class the class must have a default constructor

                30 What is a conversion constructor

                It is a constructor that accepts one argument of a different type

                The compiler uses this idiom as one way to infer conversion rules for a class A constructor with more than one argument and with default argument values can be interpreted by the compiler as a conversion constructor when the compiler is looking for an object of the type and sees an object of the type of the constructors first argument

                31 What is the difference between a copy constructor and an overloaded assignment operator

                A copy constructor constructs a new object by using the content of the argument object An overloaded assignment operator assigns the contents of an existing object to another existing object of the same class

                First you must know that a copy constructor is one that has only one argument which is a reference to the same type as the constructor The compiler invokes a copy constructor wherever it needs to make a copy of the object for example to pass an argument by value If you do not provide a copy constructor the compiler creates a member-by-member copy constructor for you

                You can write overloaded assignment operators that take arguments of other classes but that behavior is usually implemented with implicit conversion constructors If you do not provide an overloaded assignment operator for the class the compiler creates a default member-by-member assignment operator

                This discussion is a good place to get into why classes need copy constructors and overloaded assignment operators By discussing the requirements with respect to data member pointers that point to dynamically allocated resources you demonstrate a good grasp of the problem

                32 When should you use multiple inheritance

                There are three acceptable answers Never Rarely and When the problem domain cannot be accurately modeled any other way

                33 What is a virtual destructor

                The simple answer is that a virtual destructor is one that is declared with the virtual attribute

                The behavior of a virtual destructor is what is important If you destroy an object through a pointer or reference to a base class and the base-class destructor is not virtual the derived-class destructors are not executed and the destruction might not be complete

                34 Explain the ISA and HASA class relationships How would you implement each in a class design

                A specialized class is a specialization of another class and therefore has the ISA relationship with the other class An Employee ISA Person This relationship is best implemented with inheritance Employee is derived from Person A class may have an instance of another class For example an Employee has a Salary therefore the Employee class has the HASA relationship with the Salary class This relationship is best implemented by embedding an object of the Salary class in the Employee class

                The answer to this question reveals whether you have an understanding of the fundamentals of object-oriented design which is important to reliable class design

                There are other relationships The USESA relationship is when one class uses the services of another The Employee class uses an object (cout) of the ostream class to display the employees name onscreen for example But if you get ISA and HASA right you usually dont need to go any further

                35 When is a template a better solution than a base class

                When you are designing a generic class to contain or otherwise manage objects of other types when the format and behavior of those other types are unimportant to their containment or management and particularly when those other types are unknown (thus the genericity) to the designer of the container or manager class

                Prior to templates you had to use inheritance your design might include a generic List container class and an application-specific Employee class To put employees in a list a ListedEmployee class is multiply derived (contrived) from the Employee and List classes These solutions were unwieldy and error-prone Templates solved that problem

                Questions for ANSI-Knowledgeable Applicants

                There are six questions for those who profess knowledge of the progress of the ANSI committee If you claim to have that much interest in the language you should know the answers to all these questions

                1 What is a mutable member

                A mutable member is one that can be modified by the class even when the object of the class or the member function doing the modification is const

                Understanding this requirement implies an understanding of C++ const which many programmers do not have I have seen large class designs that do not employ the const qualifier anywhere Some of those designs are my own early C++ efforts One author suggests that some programmers find const to be such a bother that it is easier to ignore const than to try to use it meaningfully No

                wonder many programmers dont understand the power and implications of const Someone who claims to have enough interest in the language and its evolution to keep pace with the ANSI deliberations should not be ignorant of const however

                2 What is an explicit constructor

                A conversion constructor declared with the explicit keyword The compiler does not use an explicit constructor to implement an implied conversion of types Its purpose is reserved explicitly for construction

                3 What is the Standard Template Library

                It is a library of container templates approved by the ANSI committee for inclusion in the standard C++ specification

                4 Describe run-time type identification

                It is the ability to determine at run time the type of an object by using the typeid operator or the dynamic_cast operator

                5 What problem does the namespace feature solve

                Multiple providers of libraries might use common global identifiers causing a name collision when an application tries to link with two or more such libraries The name-space feature surrounds a librarys external declarations with a unique namespace that eliminates the potential for those collisions

                This solution assumes that two library vendors dont use the same namespace of course

                6 Are there any new intrinsic (built-in) data types

                Yes The ANSI committee added the bool intrinsic type and its true and false value keywords and the wchar_t data type to support character sets wider than eight bits

                SQL Server

                1 What is a foreign key

                A foreign key is a column or combination of columns used to establish and enforce a link (referential integrity) between the data in two tables A link is created between two tables by adding the column or columns that hold one tablersquos primary key values to the other table This column becomes a foreign key in the second table

                2 What is the difference between a primary key and unique key

                There can be only one primary key constrain on a table but there can be many unique key constraints in a table

                Primary key doesnrsquot allow null values but Unique allows 1 Null value

                3 What is an index

                Indexes are database objects which provides faster data access The index provides pointers to the data values stored in specified columns of

                the table and then orders those pointers according to the sort order you specify

                Different types of indexes are unique index clustered index and non-clustered index

                4 How to return multiple result set from a stored proc and capture it in ADO

                Use multiple Select statements to return multiple result sets Use ADOrsquos GetNextRecordset() method to get the second recordset during the

                execution of the stored proc

                • COMDCOM
                • Visual Basic
                • General Scripting Questions
                • Session and Application Variable Questions
                  • Image Questions
                  • Browser Questions
                  • ActiveX Data Objects Questions
                  • Form and Query String Questions
                    • 18 What is a virtual member function
                    • 19 How can C++ achieve dynamic binding yet also static typing
                    • 20 Whats the difference between how virtual and non-virtual member functions are called
                    • 21 When should my destructor be virtual
                    • 22 What is a virtual constructor
                    • Questions for ANSI-Knowledgeable Applicants

                  19 What is In-proc

                  In-proc is in-process COM object ie COM object that implemented as DLL and supposed to be hosted by a container When you have to instantiate the in-proc object remotely you may use DLLHostexe application that was design specially for this purpose

                  20 What is OLE

                  OLE is an object and embedding first implementation of COM spec available from MS before COM was officially named COM

                  21 Give examples of OLE usage

                  The most famous examples are probably drag and drop and structured storage implementations

                  22 What are 2 storage types for composite document

                  The two storage types are Storage and Stream

                  23 Is doc document a compound document Is it a structured storage

                  Compound document is a document that contains information about other documents hosted in this document All office documents may or may not be compound documents Word documents from version 60 and up are stored as structured storage

                  Non-VB COMDCOM

                  1 What should QueryInterface functions do if requested object was not found

                  Return E_NOINTERFACE and nullify its out parameter

                  2 How would you create an instance of the object in COM

                  ltlt Well it all depends on your project Start your answer from CoCreateInstance or CoCreateInstanceEx explain the difference between them If interviewer is still not satisfied youll have to explain the whole kitchen behind the scenes including a difference between local server and inproc server meaning and mechanism of class factory etc You may also mention other methods of object creation like CoGetInstanceFromFile but discussion will likely turn to discussion of monikers then gtgt

                  3 What happens when client calls CoCreateInstance

                  ltlt Again all depends on the level of detail and expertise of interviewer Start with simple explanation of class object and class factory mechanism Further details would depend on a specific situation gtgt

                  4 What are the limitations of CoCreateInstance

                  Well a major problem with CoCreateInstance is that it is only able to create one object and only on local system To create a remote object or to get several objects based on single CLSID at the same time one should use CoCreateInstanceEx

                  5 What is a moniker

                  It is an object that implements the IMoniker interface A moniker acts as a name that uniquely identifies a COM object In the same way that a path identifies a file in the file system a moniker identifies a COM object in the directory namespace

                  6 Can you have two dual interfaces in one class

                  Yes You may have two dual interfaces in one class but only one of them may be default The bottom line is that you cannot work with two dual interfaces at the same time due to nature of dual interfaceTo support two dual interfaces in VB you would write something like

                  dim d1 as IDualInterface1 dim d2 as IDualInterface2

                  set d1 = new MyClassWithTwoDualsset d2 = d1

                  In ATLs class you would have to use macro COM_INTERFACE_ENTRY2(IDispatch IDualInterface1) to distinguish between different dual interfaces

                  7 What is a marshalling by value

                  Some objects can essentially be considered static regardless of which methods are called the state of the object does not change Instead of accessing such an object remotely it is possible to copy the static state of the object and create a new object with the same state information on the caller side The caller wont be able to notice the difference but calls will be more efficient because they do not involve network round trips This is called marshaling by value

                  8 What is ROT What is GIT Give pros and cons of both

                  By definition running object table (ROT) is a globally accessible table on each computer that keeps track of all COM objects in the running state that can be identified by a moniker Moniker providers register an object in the table which increments the objects reference count Before the object can be destroyed its moniker must be released from the tableGlobal Interface Table (GIT) allows any apartment (either single- or multi-threaded) in a process to get access to an interface implemented on an object in any other apartment in the process

                  9 If you have an object with two interfaces can you custom marshal one of them

                  No The decision to use custom marshaling is an all-or-nothing decision an object has to custom marshal all its interfaces or none of them

                  10 How can you guarantee that only a remote server is ever created by a client

                  Create an object (call CoCreateObjectEx()) with CLSCTX_REMOTE_SERVER flag

                  Visual Basic

                  1 What are the properties and methods of ObjectControl interface

                  Activate Deactivate CanBePooled

                  2 How will you implement transaction in a visual basic ActiveX dll

                  Set the MTSTransactionMode property of the class modules Use the ObjectContextSetcomplete SetAbort methods to commitrollback

                  the transactions

                  3 How to execute a stored proc from VB using ADO

                  A stored proc can be executed using the command object

                  4 What are the objects in ADO

                  These are Connection Command Recordset Record Parameter and stream

                  Visual Basic UI

                  1 How to access a member variable in one form from another

                  Set the access modifier of the member variable as Public Create a property procedure

                  2 What is the listindex property of a list box control

                  Listindex is the index of the currently selected item in the control

                  3 Have you worked on grid controls

                  ltlt Answer should be Yes or No gtgt

                  ASP

                  1 How will you describe a session

                  Session object in ASP provides dynamic associative array that a script can use to store information

                  ASP Sessions Are Cookie-based

                  2 What are the different methods to pass an argument from one page to another

                  Using Query string Using Hidden controls

                  NET

                  1 How NET My Services work

                  From the developers perspective NET My Services is a set of XML Web services accessed by sending and receiving SOAP messages sent though the HTTP or DIME protocols and using the NET Passport system for authentication NET My Services consists of three things Authentication which will be provided by NET Passport when NET My Services goes live SOAP the communication protocol XML following the rules and schemas set out in the XMI Reference which provides the data formatting and organization

                  2 What are Web Services

                  Web Services are applications delivered as a service on the Web Web services allow for programmatic access of business logic over the Web Web services typically rely on XML-based protocols messages and interface descriptions for communication and access Web services are designed to be used by other programs or applications rather than directly by end user Programs invoking a Web service are called clients SOAP over HTTP is the most commonly used protocol for invoking Web services

                  3 How do I use a proxy server when invoking a Web service

                  If you are using the SOAP Toolkit you need to set some connector properties to use a proxy server Dim soap As SoapClient Set soap=New SoapClient soapConnectorProperty(ProxyServer) = ldquoproxyservernamerdquo soapConnectorProperty(ProxyPort) = ldquo8080rdquo soapConnectorProperty(UseProxy) = True While with NET you just need to create a SystemNetWebProxy object and use it to set the Proxy property Dim webs As localhostMyService() websProxy=New SystemNetWebProxy(ldquohttpproxyserver8080rdquo)

                  4 What is Simple Object Access Protocol (SOAP)

                  SOAP is an XML-based messaging framework specifically designed for exchanging formatted data across the Internet for example using request and reply messages or sending entire documents SOAP is simple easy to use and completely neutral with respect to operating system programming language or

                  distributed computing platform

                  5 What is Web Services Description Language (WSDL)

                  After SOAP became available as a mechanism for exchanging XML messages among enterprises (or among disparate applications within the same enterprise) a better way was needed to describe the messages and how they are exchanged The Web Services Description Language (WSDL) is a particular form of an XML Schema developed by Microsoft and IBM for the purpose of defining the XML message operation and protocol mapping of a web service accessed using SOAP or other XML protocol WSDL defines web services in terms of endpoints that operate on XML messages The WSDL syntax allows both the messages and the operations on the messages to be defined abstractly so they can be mapped to multiple physical implementations The current WSDL spec describes how to map messages and operations to SOAP 11 HTTP GETPOST and MIME WSDL creates web service definitions by mapping a group of endpoints into a logical sequence of operations on XML messages The same XML message can be mapped to multiple operations (or services) and bound to one or more communications protocols (using ports)

                  6 What is Universal Description Discovery and Integration (UDDI)

                  The Universal Description Discovery and Integration (UDDI) framework defines a data model (in XML) and SOAP APIs for registration and searches on business information including the web services a business exposes to the Internet UDDI is an independent consortium of vendors founded by Microsoft IBM and Ariba for the purpose of developing an Internet standard for web service description registration and discovery Microsoft IBM and Ariba also are hosting the initial deployment of a UDDI service which is conceptually patterned after DNS (the Internet service that translates URLs into TCP addresses) UDDI uses a private agreement profile of SOAP (ie UDDI doesnt use the SOAP serialization format because its not well suited to passing complete XML documents (its aimed at RPC style interactions) The main idea is that businesses use the SOAP APIs to register themselves with UDDI and other businesses search UDDI when they want to discover a trading partner for example someone from whom they wish to procure sheet metal bolts or transistors The information in UDDI is categorized according to industry type and geographical location allowing UDDI consumers to search through lists of potentially matching businesses to find the specific one they want to contact Once a specific business is chosen another call to UDDI is made to obtain the specific contact information for that business The contact information includes a pointer to the target businesss WSDL or other XML schema file describing the web service that the target business publishes

                  The interviewer should be well versed in NET to ask these questions The interview should know the answers

                  Execution cycle of an assembly How does CLR comes into picture- Platform independence

                  Managed unmanaged code Information about GAC How does GAC help in maintaining different versions of an assembly if

                  changes are made to an assembly and the new version does not support some of functionality that previous version supported how will the runtime handle ito What is the sequence of steps followed by the runtime to look for the

                  references like first to bin then GAC etco How to add assemblies in GAC

                  How do we use MTS capabilities in NET assemblies Different type of data persistence in NET

                  o Caching Data caching Output caching

                  o Serialization Xml Bin

                  Usercontrols vc Custom Controls ndash Composite controls Datareader vs Dataset Sorting in Datagrid adding custom controls in datagrid columns Use of view state in ASPX pages How to improve performance of the pages in web environment Is it possible to have both client side and server side functionality on aspx

                  server controls In the page execution life cycle when is the page_init called What is AutoEventWireUp attribute used for What are delegates used for Webservices

                  o How do you deploy web services Reflections Remoting

                  o What is client activated objects and what are server activated objectso What are channels used for

                  Interopo How does a NET component call a primitive one What are the steps taken

                  General Scripting Questions

                  1 How do you add a quotation mark to VB script string

                  The first method uses two quotation marks in a row to create a single quotation mark The second method uses the ASCII value of the quotation mark character

                  2 How do you break a single VBScript Statement into multiple lines

                  A single VBScript Statement can be broken into multiple lines by using the _underscore character

                  3 What is the proper method of comparing strings in VBScript

                  The first method uses VBScript function with the vbTextCompare constant The second method forces both strings into uppercase

                  4 How do you re-enable errors after using ON ERROR RESUME NEXT

                  ltlt Need an answer gtgt

                  5 How do you prevent My Script from timing out

                  You can extend the amount of time a script is allowed to run by using the ScriptTimeout property of the Server object

                  6 When do you need to explicitly convert a variable to a particular data type

                  If you are comparing numbers or dates and there is a danger that VBScript might interpret the values as strings one of the VBScript conversion functions should be used

                  7 When should one pass a variable by value and when by reference

                  When you pass a variable by value to a subordinate or function a new instance of the variable is created Any changes made to the value of the variable do not affect the value of the original variable On the other hand whne you pass a variable by reference changes made to the variable do affect the value of the original variable

                  8 How can you add a space between the output of two variables

                  ltlt Need an answer gtgt

                  9 Does ASP support dynamic includes

                  It does not support

                  10 How do you use the option Explicit statement in an ASP

                  It must be used before nay other VBScript statement or HTML content in a script else it will generate and error

                  Session and Application Variable Questions

                  1 Why do session variables sometimes fail to work

                  Session variables depend on browser cookies If a browser does not support cookies or a user has turned off cookies or the userrsquos cookie file is corrupted Session variables will not work

                  2 How do you remove an application variable

                  ltlt Need an answer gtgt

                  3 How do you detect whether a File exists

                  I can detect by using the FileExists method of the FileSystemObject

                  4 How do you automatically display a list of the Files in a directory

                  By using a list of files in a folder by using the FileSystemObject and the Folder object

                  Image Questions

                  1 How do you store an image in a database table

                  Although you can store an image in a SQL Server BLOB column it is almost always better to store the URL of an image in a database table rather than the image itself

                  2 How do you dynamically generate a graph or image in an ASP

                  Several third-party ASP components enable you to dynamically create custom images

                  Browser Questions

                  1 How do you detect the type of browser a person is using to visit your web site

                  The User-Agent header indicates the type of browser

                  2 How do you detect a page from which a person originated

                  The Referer header contains the URL of the last page the person visited This header can be retrieved from the ServerVariables collection

                  ActiveX Data Objects Questions

                  1 Why do you sometimes receive an error when using the Connection Object to execute a SQL string

                  ltlt Need an answer gtgt

                  2 How do you retrieve a Text filed in an ASP

                  If you do not take special precautions when retrieving a Text field from a database table the value of the Text field might be truncated If you are using a forward-only cursor type you should use the Text field as the very last field in your select list Alternatively consider using a richer cursor type when opening a Recordset that contains a Text field

                  3 Why does the RecordCount always return the Value-1

                  The RecordCount property returns the number of rows in a Recordset after it has been opened you cannot use this property with a forward-only cursor when using SQL Server (it will always return ndash1)

                  4 Why do you receive an error whenever you try to update the value of a filed in a recordset

                  By default when you open a Recordset it is opened with a forward-only cursor and read-only lock type To update a Recordset you must open a Recordset that is not read-only

                  5 How do you limit the number of rows returned by a Database Query

                  If using SQL 70 or Access you can use the SQL Top keyword to limit the number of records returned Otherwise if you are using SQL 65 use the MaxRecords property of the Recordset object

                  ltlt What about SQL 2000 gtgt

                  6 How do you retrieve the value from a SQL Statement that uses Count() Max Min or Identity

                  There are two methods that you can use to retrieve the value from a SQL function or a SQL global variable You can either use an alias for the value or refer to the value by its ordinal position in the Recordset

                  7 How do you retrieve an output parameter from a SQL stored procedure within an ASPScript

                  You must use the ADO Command nad parameter objects

                  Form and Query String Questions

                  1 How do you accept file uploads in an HTML form

                  ltlt Need an answer gtgt

                  2 What causes the value of a form field to become truncated

                  HTML uses quotation marks to mark the beginning and end of a value So If a variable contains question marks in its values the value of the variablewill be truncated when displayed

                  3 How do you include spaces or other special characters in a query string

                  URL encode the query string

                  C++ Questions

                  1 What is an object in C++

                  An object is a package that contains related data and instructions The data relates to what the object represents while the instructions define how this object relates to other objects and itself

                  2 What is a message

                  A message is a signal from one object to another requesting that a computation take place It is roughly equivalent to a function call in other languages

                  3 What is a class

                  A class defines the characteristics of a certain type of object It defines what its members will remember the messages to which they will respond and what form the response will take

                  4 What is an instance

                  It is an individual object that is a member of some class

                  5 What is a super-class

                  Given a class a super-class is the basis of the class under consideration The given class is defined as a subset (in some respects) of the super-class All objects of the given class potentially posses all the characteristics belonging to objects of the super-class

                  6 What is inheritance

                  Inheritance is property such that a parent (or super) class passes the characteristics of itself to children (or sub) classes that are derived from it The sub-class has the option of modifying these characteristics in order to make a different but fundamentally related class from the super-class

                  7 To what does message protocol refer

                  An objects message protocol is the exact form of the set of messages to which the object can respond

                  8 What is polymorphism

                  Polymorphism refers to the ability of an object to respond in a logically identical fashion to messages of the same protocol containing differing types of objects Consider 1 + 5 and 1 + 51 In the former the message + 5 is sent to an object of class integer (1) In the later the message + 51 is sent to the same integer object The form of the message (its protocol) is identical in both cases What differs is the type of object on the right-hand side of these messages The former is an integer object (5) while the later is a floating point object (51) The receiver (1) appears (to other objects) to respond in the same way to both messages Internally however it knows that it must treat the two types of objects differently in order to obtain the same overall response

                  9 What are instance variables

                  These represent an objects private memory They are defined in an objects class

                  18 What is a virtual member function

                  A virtual function allows derived classes to replace the implementation provided by the base class The compiler makes sure the replacement is always called whenever the object in question is actually of the derived class even if the object is accessed by a base pointer rather than a derived pointer This allows algorithms in the base class to be replaced in the derived class even if users dont know about the derived class

                  The derived class can either fully replace (override) the base class member function or the derived class can partially replace (augment) the base class member function The latter is accomplished by having the derived class member function call the base class member function if desired

                  19 How can C++ achieve dynamic binding yet also static typing

                  When you have a pointer to an object the object may actually be of a class that is derived from the class of the pointer (eg a Vehicle that is actually pointing to a Car object) Thus there are two types the (static) type of the pointer (Vehicle in this case) and the (dynamic) type of the pointed-to object (Car in this case)

                  Static typing means that the legality of a member function invocation is checked at the earliest possible moment by the compiler at compile time The compiler uses the static type of the pointer to determine whether the member function invocation is legal If the type of the pointer can handle the member function certainly the pointed-to object can handle it as well Eg if Vehicle has a certain member function certainly Car also has that member function since Car is a kind-of Vehicle

                  Dynamic binding means that the address of the code in a member function invocation is determined at the last possible moment based on the dynamic type of the object at run time It is called dynamic binding because the binding to the code that actually gets called is accomplished dynamically (at run time) Dynamic binding is a result of virtual functions

                  20 Whats the difference between how virtual and non-virtual member functions are called

                  Non-virtual member functions are resolved statically That is the member function is selected statically (at compile-time) based on the type of the pointer (or reference) to the object

                  In contrast virtual member functions are resolved dynamically (at run-time) That is the member function is selected dynamically (at run-time) based on the type of the object not the type of the pointerreference to that object This is called dynamic binding Most compilers use some variant of the following technique

                  if the object has one or more virtual functions the compiler puts a hidden pointer in the object called a virtual-pointer or v-pointer This v-pointer points to a global table called the virtual-table or v-table

                  The compiler creates a v-table for each class that has at least one virtual function For example if class Circle has virtual functions for draw() and move() and resize() there would be exactly one v-table associated with class Circle even if there were a gazillion Circle objects and the v-pointer of each of those Circle objects would point to the Circle v-table The v-table itself has pointers to each of the virtual functions in the class For example the Circle v-table would have three pointers a pointer to Circledraw() a pointer to Circlemove() and a pointer to Circleresize()

                  During a dispatch of a virtual function the run-time system follows the objects v-pointer to the classs v-table then follows the appropriate slot in the v-table to the method code

                  The space-cost overhead of the above technique is nominal an extra pointer per object (but only for objects that will need to do dynamic binding) plus an extra pointer per method (but only for virtual methods) The time-cost overhead is also fairly nominal compared to a normal function call a virtual function call requires two extra fetches (one to get the value of the v-pointer a second to get the address of the method) None of this runtime activity happens with non-virtual functions since the compiler resolves non-virtual functions exclusively at compile-time based on the type of the pointer

                  21 When should my destructor be virtual

                  When you may delete a derived object via a base pointer

                  virtual functions bind to the code associated with the class of the object rather than with the class of the pointerreference When you say delete basePtr and the base class has a virtual destructor the destructor that gets invoked is the one associated with the type of the object basePtr rather than the one associated with the type of the pointer This is generally A Good Thing

                  TECHNO-GEEK WARNING PUT YOUR PROPELLER HAT ON Technically speaking you need a base classs destructor to be virtual if and only if you intend to allow someone to invoke an objects destructor via a base class pointer (this is normally done implicitly via delete) and the object being destructed is of a derived class that has a non-trivial destructor A class has a non-trivial destructor if it either has an explicit destructor or if it has a member object or a base class that has a non-trivial destructor (note that this is a recursive definition (eg a class has a non-trivial destructor if it has a member object (which has a base class (which has a member object (which has a base class (which has an explicit destructor)))))) END TECHNO-GEEK WARNING REMOVE YOUR PROPELLER HAT

                  If you had a hard grokking the previous rule try this (over)simplified one on for size A class should have a virtual destructor unless that class has no virtual functions Rationale if you have any virtual functions at all youre probably going to be doing stuff to derived objects via a base pointer and some of the stuff you may do may include invoking a destructor (normally done implicitly via delete) Plus once youve put the first virtual function into a class youve already paid all the per-object space cost that youll ever pay (one pointer per object note that this is theoretically compiler-specific in practice everyone does it pretty much the same way) so making the destructor virtual wont generally cost you anything extra

                  22 What is a virtual constructor

                  An idiom that allows you to do something that C++ doesnt directly support

                  You can get the effect of a virtual constructor by a virtual clone() member function (for copy constructing) or a virtual create() member function (for the default constructor)

                  class Shape public virtual ~Shape() A virtual destructor virtual void draw() = 0 A pure virtual function virtual void move() = 0 virtual Shape clone() const = 0 Uses the copy constructor virtual Shape create() const = 0 Uses the default constructor class Circle public Shape public Circle clone() const return new Circle(this) Circle create() const return new Circle()

                  In the clone() member function the new Circle(this) code calls Circles copy constructor to copy the state of this into the newly created Circle object In the create() member function the new Circle() code calls Circles default constructor

                  Users use these as if they were virtual constructors

                  void userCode(Shapeamp s) Shape s2 = sclone() Shape s3 = screate() delete s2 You probably need a virtual destructor here

                  delete s3

                  23 How do you link a C++ program to C functions

                  By using the extern C linkage specification around the C function declarations

                  24 Explain the scope resolution operator

                  The scope resolution operator permits a program to reference an identifier in the global scope that has been hidden by another identifier with the same name in the local scope

                  25 What are the differences between a C++ struct and C++ class

                  The default member and base class access specifiers are different

                  26 How many ways are there to initialize an int with a constant

                  Two

                  27 How does throwing and catching exceptions differ from using setjmp and longjmp

                  The throw operation calls the destructors for automatic objects instantiated since entry to the try block

                  28 How does throwing and catching exceptions differ from using setjmp and longjmp

                  The throw operation calls the destructors for automatic objects instantiated since entry to the try block

                  29 What is a default constructor

                  A constructor that has no arguments or one where all the arguments have default argument values

                  If you dont code a default constructor the compiler provides one if there are no other constructors If you are going to instantiate an array of objects of the class the class must have a default constructor

                  30 What is a conversion constructor

                  It is a constructor that accepts one argument of a different type

                  The compiler uses this idiom as one way to infer conversion rules for a class A constructor with more than one argument and with default argument values can be interpreted by the compiler as a conversion constructor when the compiler is looking for an object of the type and sees an object of the type of the constructors first argument

                  31 What is the difference between a copy constructor and an overloaded assignment operator

                  A copy constructor constructs a new object by using the content of the argument object An overloaded assignment operator assigns the contents of an existing object to another existing object of the same class

                  First you must know that a copy constructor is one that has only one argument which is a reference to the same type as the constructor The compiler invokes a copy constructor wherever it needs to make a copy of the object for example to pass an argument by value If you do not provide a copy constructor the compiler creates a member-by-member copy constructor for you

                  You can write overloaded assignment operators that take arguments of other classes but that behavior is usually implemented with implicit conversion constructors If you do not provide an overloaded assignment operator for the class the compiler creates a default member-by-member assignment operator

                  This discussion is a good place to get into why classes need copy constructors and overloaded assignment operators By discussing the requirements with respect to data member pointers that point to dynamically allocated resources you demonstrate a good grasp of the problem

                  32 When should you use multiple inheritance

                  There are three acceptable answers Never Rarely and When the problem domain cannot be accurately modeled any other way

                  33 What is a virtual destructor

                  The simple answer is that a virtual destructor is one that is declared with the virtual attribute

                  The behavior of a virtual destructor is what is important If you destroy an object through a pointer or reference to a base class and the base-class destructor is not virtual the derived-class destructors are not executed and the destruction might not be complete

                  34 Explain the ISA and HASA class relationships How would you implement each in a class design

                  A specialized class is a specialization of another class and therefore has the ISA relationship with the other class An Employee ISA Person This relationship is best implemented with inheritance Employee is derived from Person A class may have an instance of another class For example an Employee has a Salary therefore the Employee class has the HASA relationship with the Salary class This relationship is best implemented by embedding an object of the Salary class in the Employee class

                  The answer to this question reveals whether you have an understanding of the fundamentals of object-oriented design which is important to reliable class design

                  There are other relationships The USESA relationship is when one class uses the services of another The Employee class uses an object (cout) of the ostream class to display the employees name onscreen for example But if you get ISA and HASA right you usually dont need to go any further

                  35 When is a template a better solution than a base class

                  When you are designing a generic class to contain or otherwise manage objects of other types when the format and behavior of those other types are unimportant to their containment or management and particularly when those other types are unknown (thus the genericity) to the designer of the container or manager class

                  Prior to templates you had to use inheritance your design might include a generic List container class and an application-specific Employee class To put employees in a list a ListedEmployee class is multiply derived (contrived) from the Employee and List classes These solutions were unwieldy and error-prone Templates solved that problem

                  Questions for ANSI-Knowledgeable Applicants

                  There are six questions for those who profess knowledge of the progress of the ANSI committee If you claim to have that much interest in the language you should know the answers to all these questions

                  1 What is a mutable member

                  A mutable member is one that can be modified by the class even when the object of the class or the member function doing the modification is const

                  Understanding this requirement implies an understanding of C++ const which many programmers do not have I have seen large class designs that do not employ the const qualifier anywhere Some of those designs are my own early C++ efforts One author suggests that some programmers find const to be such a bother that it is easier to ignore const than to try to use it meaningfully No

                  wonder many programmers dont understand the power and implications of const Someone who claims to have enough interest in the language and its evolution to keep pace with the ANSI deliberations should not be ignorant of const however

                  2 What is an explicit constructor

                  A conversion constructor declared with the explicit keyword The compiler does not use an explicit constructor to implement an implied conversion of types Its purpose is reserved explicitly for construction

                  3 What is the Standard Template Library

                  It is a library of container templates approved by the ANSI committee for inclusion in the standard C++ specification

                  4 Describe run-time type identification

                  It is the ability to determine at run time the type of an object by using the typeid operator or the dynamic_cast operator

                  5 What problem does the namespace feature solve

                  Multiple providers of libraries might use common global identifiers causing a name collision when an application tries to link with two or more such libraries The name-space feature surrounds a librarys external declarations with a unique namespace that eliminates the potential for those collisions

                  This solution assumes that two library vendors dont use the same namespace of course

                  6 Are there any new intrinsic (built-in) data types

                  Yes The ANSI committee added the bool intrinsic type and its true and false value keywords and the wchar_t data type to support character sets wider than eight bits

                  SQL Server

                  1 What is a foreign key

                  A foreign key is a column or combination of columns used to establish and enforce a link (referential integrity) between the data in two tables A link is created between two tables by adding the column or columns that hold one tablersquos primary key values to the other table This column becomes a foreign key in the second table

                  2 What is the difference between a primary key and unique key

                  There can be only one primary key constrain on a table but there can be many unique key constraints in a table

                  Primary key doesnrsquot allow null values but Unique allows 1 Null value

                  3 What is an index

                  Indexes are database objects which provides faster data access The index provides pointers to the data values stored in specified columns of

                  the table and then orders those pointers according to the sort order you specify

                  Different types of indexes are unique index clustered index and non-clustered index

                  4 How to return multiple result set from a stored proc and capture it in ADO

                  Use multiple Select statements to return multiple result sets Use ADOrsquos GetNextRecordset() method to get the second recordset during the

                  execution of the stored proc

                  • COMDCOM
                  • Visual Basic
                  • General Scripting Questions
                  • Session and Application Variable Questions
                    • Image Questions
                    • Browser Questions
                    • ActiveX Data Objects Questions
                    • Form and Query String Questions
                      • 18 What is a virtual member function
                      • 19 How can C++ achieve dynamic binding yet also static typing
                      • 20 Whats the difference between how virtual and non-virtual member functions are called
                      • 21 When should my destructor be virtual
                      • 22 What is a virtual constructor
                      • Questions for ANSI-Knowledgeable Applicants

                    Non-VB COMDCOM

                    1 What should QueryInterface functions do if requested object was not found

                    Return E_NOINTERFACE and nullify its out parameter

                    2 How would you create an instance of the object in COM

                    ltlt Well it all depends on your project Start your answer from CoCreateInstance or CoCreateInstanceEx explain the difference between them If interviewer is still not satisfied youll have to explain the whole kitchen behind the scenes including a difference between local server and inproc server meaning and mechanism of class factory etc You may also mention other methods of object creation like CoGetInstanceFromFile but discussion will likely turn to discussion of monikers then gtgt

                    3 What happens when client calls CoCreateInstance

                    ltlt Again all depends on the level of detail and expertise of interviewer Start with simple explanation of class object and class factory mechanism Further details would depend on a specific situation gtgt

                    4 What are the limitations of CoCreateInstance

                    Well a major problem with CoCreateInstance is that it is only able to create one object and only on local system To create a remote object or to get several objects based on single CLSID at the same time one should use CoCreateInstanceEx

                    5 What is a moniker

                    It is an object that implements the IMoniker interface A moniker acts as a name that uniquely identifies a COM object In the same way that a path identifies a file in the file system a moniker identifies a COM object in the directory namespace

                    6 Can you have two dual interfaces in one class

                    Yes You may have two dual interfaces in one class but only one of them may be default The bottom line is that you cannot work with two dual interfaces at the same time due to nature of dual interfaceTo support two dual interfaces in VB you would write something like

                    dim d1 as IDualInterface1 dim d2 as IDualInterface2

                    set d1 = new MyClassWithTwoDualsset d2 = d1

                    In ATLs class you would have to use macro COM_INTERFACE_ENTRY2(IDispatch IDualInterface1) to distinguish between different dual interfaces

                    7 What is a marshalling by value

                    Some objects can essentially be considered static regardless of which methods are called the state of the object does not change Instead of accessing such an object remotely it is possible to copy the static state of the object and create a new object with the same state information on the caller side The caller wont be able to notice the difference but calls will be more efficient because they do not involve network round trips This is called marshaling by value

                    8 What is ROT What is GIT Give pros and cons of both

                    By definition running object table (ROT) is a globally accessible table on each computer that keeps track of all COM objects in the running state that can be identified by a moniker Moniker providers register an object in the table which increments the objects reference count Before the object can be destroyed its moniker must be released from the tableGlobal Interface Table (GIT) allows any apartment (either single- or multi-threaded) in a process to get access to an interface implemented on an object in any other apartment in the process

                    9 If you have an object with two interfaces can you custom marshal one of them

                    No The decision to use custom marshaling is an all-or-nothing decision an object has to custom marshal all its interfaces or none of them

                    10 How can you guarantee that only a remote server is ever created by a client

                    Create an object (call CoCreateObjectEx()) with CLSCTX_REMOTE_SERVER flag

                    Visual Basic

                    1 What are the properties and methods of ObjectControl interface

                    Activate Deactivate CanBePooled

                    2 How will you implement transaction in a visual basic ActiveX dll

                    Set the MTSTransactionMode property of the class modules Use the ObjectContextSetcomplete SetAbort methods to commitrollback

                    the transactions

                    3 How to execute a stored proc from VB using ADO

                    A stored proc can be executed using the command object

                    4 What are the objects in ADO

                    These are Connection Command Recordset Record Parameter and stream

                    Visual Basic UI

                    1 How to access a member variable in one form from another

                    Set the access modifier of the member variable as Public Create a property procedure

                    2 What is the listindex property of a list box control

                    Listindex is the index of the currently selected item in the control

                    3 Have you worked on grid controls

                    ltlt Answer should be Yes or No gtgt

                    ASP

                    1 How will you describe a session

                    Session object in ASP provides dynamic associative array that a script can use to store information

                    ASP Sessions Are Cookie-based

                    2 What are the different methods to pass an argument from one page to another

                    Using Query string Using Hidden controls

                    NET

                    1 How NET My Services work

                    From the developers perspective NET My Services is a set of XML Web services accessed by sending and receiving SOAP messages sent though the HTTP or DIME protocols and using the NET Passport system for authentication NET My Services consists of three things Authentication which will be provided by NET Passport when NET My Services goes live SOAP the communication protocol XML following the rules and schemas set out in the XMI Reference which provides the data formatting and organization

                    2 What are Web Services

                    Web Services are applications delivered as a service on the Web Web services allow for programmatic access of business logic over the Web Web services typically rely on XML-based protocols messages and interface descriptions for communication and access Web services are designed to be used by other programs or applications rather than directly by end user Programs invoking a Web service are called clients SOAP over HTTP is the most commonly used protocol for invoking Web services

                    3 How do I use a proxy server when invoking a Web service

                    If you are using the SOAP Toolkit you need to set some connector properties to use a proxy server Dim soap As SoapClient Set soap=New SoapClient soapConnectorProperty(ProxyServer) = ldquoproxyservernamerdquo soapConnectorProperty(ProxyPort) = ldquo8080rdquo soapConnectorProperty(UseProxy) = True While with NET you just need to create a SystemNetWebProxy object and use it to set the Proxy property Dim webs As localhostMyService() websProxy=New SystemNetWebProxy(ldquohttpproxyserver8080rdquo)

                    4 What is Simple Object Access Protocol (SOAP)

                    SOAP is an XML-based messaging framework specifically designed for exchanging formatted data across the Internet for example using request and reply messages or sending entire documents SOAP is simple easy to use and completely neutral with respect to operating system programming language or

                    distributed computing platform

                    5 What is Web Services Description Language (WSDL)

                    After SOAP became available as a mechanism for exchanging XML messages among enterprises (or among disparate applications within the same enterprise) a better way was needed to describe the messages and how they are exchanged The Web Services Description Language (WSDL) is a particular form of an XML Schema developed by Microsoft and IBM for the purpose of defining the XML message operation and protocol mapping of a web service accessed using SOAP or other XML protocol WSDL defines web services in terms of endpoints that operate on XML messages The WSDL syntax allows both the messages and the operations on the messages to be defined abstractly so they can be mapped to multiple physical implementations The current WSDL spec describes how to map messages and operations to SOAP 11 HTTP GETPOST and MIME WSDL creates web service definitions by mapping a group of endpoints into a logical sequence of operations on XML messages The same XML message can be mapped to multiple operations (or services) and bound to one or more communications protocols (using ports)

                    6 What is Universal Description Discovery and Integration (UDDI)

                    The Universal Description Discovery and Integration (UDDI) framework defines a data model (in XML) and SOAP APIs for registration and searches on business information including the web services a business exposes to the Internet UDDI is an independent consortium of vendors founded by Microsoft IBM and Ariba for the purpose of developing an Internet standard for web service description registration and discovery Microsoft IBM and Ariba also are hosting the initial deployment of a UDDI service which is conceptually patterned after DNS (the Internet service that translates URLs into TCP addresses) UDDI uses a private agreement profile of SOAP (ie UDDI doesnt use the SOAP serialization format because its not well suited to passing complete XML documents (its aimed at RPC style interactions) The main idea is that businesses use the SOAP APIs to register themselves with UDDI and other businesses search UDDI when they want to discover a trading partner for example someone from whom they wish to procure sheet metal bolts or transistors The information in UDDI is categorized according to industry type and geographical location allowing UDDI consumers to search through lists of potentially matching businesses to find the specific one they want to contact Once a specific business is chosen another call to UDDI is made to obtain the specific contact information for that business The contact information includes a pointer to the target businesss WSDL or other XML schema file describing the web service that the target business publishes

                    The interviewer should be well versed in NET to ask these questions The interview should know the answers

                    Execution cycle of an assembly How does CLR comes into picture- Platform independence

                    Managed unmanaged code Information about GAC How does GAC help in maintaining different versions of an assembly if

                    changes are made to an assembly and the new version does not support some of functionality that previous version supported how will the runtime handle ito What is the sequence of steps followed by the runtime to look for the

                    references like first to bin then GAC etco How to add assemblies in GAC

                    How do we use MTS capabilities in NET assemblies Different type of data persistence in NET

                    o Caching Data caching Output caching

                    o Serialization Xml Bin

                    Usercontrols vc Custom Controls ndash Composite controls Datareader vs Dataset Sorting in Datagrid adding custom controls in datagrid columns Use of view state in ASPX pages How to improve performance of the pages in web environment Is it possible to have both client side and server side functionality on aspx

                    server controls In the page execution life cycle when is the page_init called What is AutoEventWireUp attribute used for What are delegates used for Webservices

                    o How do you deploy web services Reflections Remoting

                    o What is client activated objects and what are server activated objectso What are channels used for

                    Interopo How does a NET component call a primitive one What are the steps taken

                    General Scripting Questions

                    1 How do you add a quotation mark to VB script string

                    The first method uses two quotation marks in a row to create a single quotation mark The second method uses the ASCII value of the quotation mark character

                    2 How do you break a single VBScript Statement into multiple lines

                    A single VBScript Statement can be broken into multiple lines by using the _underscore character

                    3 What is the proper method of comparing strings in VBScript

                    The first method uses VBScript function with the vbTextCompare constant The second method forces both strings into uppercase

                    4 How do you re-enable errors after using ON ERROR RESUME NEXT

                    ltlt Need an answer gtgt

                    5 How do you prevent My Script from timing out

                    You can extend the amount of time a script is allowed to run by using the ScriptTimeout property of the Server object

                    6 When do you need to explicitly convert a variable to a particular data type

                    If you are comparing numbers or dates and there is a danger that VBScript might interpret the values as strings one of the VBScript conversion functions should be used

                    7 When should one pass a variable by value and when by reference

                    When you pass a variable by value to a subordinate or function a new instance of the variable is created Any changes made to the value of the variable do not affect the value of the original variable On the other hand whne you pass a variable by reference changes made to the variable do affect the value of the original variable

                    8 How can you add a space between the output of two variables

                    ltlt Need an answer gtgt

                    9 Does ASP support dynamic includes

                    It does not support

                    10 How do you use the option Explicit statement in an ASP

                    It must be used before nay other VBScript statement or HTML content in a script else it will generate and error

                    Session and Application Variable Questions

                    1 Why do session variables sometimes fail to work

                    Session variables depend on browser cookies If a browser does not support cookies or a user has turned off cookies or the userrsquos cookie file is corrupted Session variables will not work

                    2 How do you remove an application variable

                    ltlt Need an answer gtgt

                    3 How do you detect whether a File exists

                    I can detect by using the FileExists method of the FileSystemObject

                    4 How do you automatically display a list of the Files in a directory

                    By using a list of files in a folder by using the FileSystemObject and the Folder object

                    Image Questions

                    1 How do you store an image in a database table

                    Although you can store an image in a SQL Server BLOB column it is almost always better to store the URL of an image in a database table rather than the image itself

                    2 How do you dynamically generate a graph or image in an ASP

                    Several third-party ASP components enable you to dynamically create custom images

                    Browser Questions

                    1 How do you detect the type of browser a person is using to visit your web site

                    The User-Agent header indicates the type of browser

                    2 How do you detect a page from which a person originated

                    The Referer header contains the URL of the last page the person visited This header can be retrieved from the ServerVariables collection

                    ActiveX Data Objects Questions

                    1 Why do you sometimes receive an error when using the Connection Object to execute a SQL string

                    ltlt Need an answer gtgt

                    2 How do you retrieve a Text filed in an ASP

                    If you do not take special precautions when retrieving a Text field from a database table the value of the Text field might be truncated If you are using a forward-only cursor type you should use the Text field as the very last field in your select list Alternatively consider using a richer cursor type when opening a Recordset that contains a Text field

                    3 Why does the RecordCount always return the Value-1

                    The RecordCount property returns the number of rows in a Recordset after it has been opened you cannot use this property with a forward-only cursor when using SQL Server (it will always return ndash1)

                    4 Why do you receive an error whenever you try to update the value of a filed in a recordset

                    By default when you open a Recordset it is opened with a forward-only cursor and read-only lock type To update a Recordset you must open a Recordset that is not read-only

                    5 How do you limit the number of rows returned by a Database Query

                    If using SQL 70 or Access you can use the SQL Top keyword to limit the number of records returned Otherwise if you are using SQL 65 use the MaxRecords property of the Recordset object

                    ltlt What about SQL 2000 gtgt

                    6 How do you retrieve the value from a SQL Statement that uses Count() Max Min or Identity

                    There are two methods that you can use to retrieve the value from a SQL function or a SQL global variable You can either use an alias for the value or refer to the value by its ordinal position in the Recordset

                    7 How do you retrieve an output parameter from a SQL stored procedure within an ASPScript

                    You must use the ADO Command nad parameter objects

                    Form and Query String Questions

                    1 How do you accept file uploads in an HTML form

                    ltlt Need an answer gtgt

                    2 What causes the value of a form field to become truncated

                    HTML uses quotation marks to mark the beginning and end of a value So If a variable contains question marks in its values the value of the variablewill be truncated when displayed

                    3 How do you include spaces or other special characters in a query string

                    URL encode the query string

                    C++ Questions

                    1 What is an object in C++

                    An object is a package that contains related data and instructions The data relates to what the object represents while the instructions define how this object relates to other objects and itself

                    2 What is a message

                    A message is a signal from one object to another requesting that a computation take place It is roughly equivalent to a function call in other languages

                    3 What is a class

                    A class defines the characteristics of a certain type of object It defines what its members will remember the messages to which they will respond and what form the response will take

                    4 What is an instance

                    It is an individual object that is a member of some class

                    5 What is a super-class

                    Given a class a super-class is the basis of the class under consideration The given class is defined as a subset (in some respects) of the super-class All objects of the given class potentially posses all the characteristics belonging to objects of the super-class

                    6 What is inheritance

                    Inheritance is property such that a parent (or super) class passes the characteristics of itself to children (or sub) classes that are derived from it The sub-class has the option of modifying these characteristics in order to make a different but fundamentally related class from the super-class

                    7 To what does message protocol refer

                    An objects message protocol is the exact form of the set of messages to which the object can respond

                    8 What is polymorphism

                    Polymorphism refers to the ability of an object to respond in a logically identical fashion to messages of the same protocol containing differing types of objects Consider 1 + 5 and 1 + 51 In the former the message + 5 is sent to an object of class integer (1) In the later the message + 51 is sent to the same integer object The form of the message (its protocol) is identical in both cases What differs is the type of object on the right-hand side of these messages The former is an integer object (5) while the later is a floating point object (51) The receiver (1) appears (to other objects) to respond in the same way to both messages Internally however it knows that it must treat the two types of objects differently in order to obtain the same overall response

                    9 What are instance variables

                    These represent an objects private memory They are defined in an objects class

                    18 What is a virtual member function

                    A virtual function allows derived classes to replace the implementation provided by the base class The compiler makes sure the replacement is always called whenever the object in question is actually of the derived class even if the object is accessed by a base pointer rather than a derived pointer This allows algorithms in the base class to be replaced in the derived class even if users dont know about the derived class

                    The derived class can either fully replace (override) the base class member function or the derived class can partially replace (augment) the base class member function The latter is accomplished by having the derived class member function call the base class member function if desired

                    19 How can C++ achieve dynamic binding yet also static typing

                    When you have a pointer to an object the object may actually be of a class that is derived from the class of the pointer (eg a Vehicle that is actually pointing to a Car object) Thus there are two types the (static) type of the pointer (Vehicle in this case) and the (dynamic) type of the pointed-to object (Car in this case)

                    Static typing means that the legality of a member function invocation is checked at the earliest possible moment by the compiler at compile time The compiler uses the static type of the pointer to determine whether the member function invocation is legal If the type of the pointer can handle the member function certainly the pointed-to object can handle it as well Eg if Vehicle has a certain member function certainly Car also has that member function since Car is a kind-of Vehicle

                    Dynamic binding means that the address of the code in a member function invocation is determined at the last possible moment based on the dynamic type of the object at run time It is called dynamic binding because the binding to the code that actually gets called is accomplished dynamically (at run time) Dynamic binding is a result of virtual functions

                    20 Whats the difference between how virtual and non-virtual member functions are called

                    Non-virtual member functions are resolved statically That is the member function is selected statically (at compile-time) based on the type of the pointer (or reference) to the object

                    In contrast virtual member functions are resolved dynamically (at run-time) That is the member function is selected dynamically (at run-time) based on the type of the object not the type of the pointerreference to that object This is called dynamic binding Most compilers use some variant of the following technique

                    if the object has one or more virtual functions the compiler puts a hidden pointer in the object called a virtual-pointer or v-pointer This v-pointer points to a global table called the virtual-table or v-table

                    The compiler creates a v-table for each class that has at least one virtual function For example if class Circle has virtual functions for draw() and move() and resize() there would be exactly one v-table associated with class Circle even if there were a gazillion Circle objects and the v-pointer of each of those Circle objects would point to the Circle v-table The v-table itself has pointers to each of the virtual functions in the class For example the Circle v-table would have three pointers a pointer to Circledraw() a pointer to Circlemove() and a pointer to Circleresize()

                    During a dispatch of a virtual function the run-time system follows the objects v-pointer to the classs v-table then follows the appropriate slot in the v-table to the method code

                    The space-cost overhead of the above technique is nominal an extra pointer per object (but only for objects that will need to do dynamic binding) plus an extra pointer per method (but only for virtual methods) The time-cost overhead is also fairly nominal compared to a normal function call a virtual function call requires two extra fetches (one to get the value of the v-pointer a second to get the address of the method) None of this runtime activity happens with non-virtual functions since the compiler resolves non-virtual functions exclusively at compile-time based on the type of the pointer

                    21 When should my destructor be virtual

                    When you may delete a derived object via a base pointer

                    virtual functions bind to the code associated with the class of the object rather than with the class of the pointerreference When you say delete basePtr and the base class has a virtual destructor the destructor that gets invoked is the one associated with the type of the object basePtr rather than the one associated with the type of the pointer This is generally A Good Thing

                    TECHNO-GEEK WARNING PUT YOUR PROPELLER HAT ON Technically speaking you need a base classs destructor to be virtual if and only if you intend to allow someone to invoke an objects destructor via a base class pointer (this is normally done implicitly via delete) and the object being destructed is of a derived class that has a non-trivial destructor A class has a non-trivial destructor if it either has an explicit destructor or if it has a member object or a base class that has a non-trivial destructor (note that this is a recursive definition (eg a class has a non-trivial destructor if it has a member object (which has a base class (which has a member object (which has a base class (which has an explicit destructor)))))) END TECHNO-GEEK WARNING REMOVE YOUR PROPELLER HAT

                    If you had a hard grokking the previous rule try this (over)simplified one on for size A class should have a virtual destructor unless that class has no virtual functions Rationale if you have any virtual functions at all youre probably going to be doing stuff to derived objects via a base pointer and some of the stuff you may do may include invoking a destructor (normally done implicitly via delete) Plus once youve put the first virtual function into a class youve already paid all the per-object space cost that youll ever pay (one pointer per object note that this is theoretically compiler-specific in practice everyone does it pretty much the same way) so making the destructor virtual wont generally cost you anything extra

                    22 What is a virtual constructor

                    An idiom that allows you to do something that C++ doesnt directly support

                    You can get the effect of a virtual constructor by a virtual clone() member function (for copy constructing) or a virtual create() member function (for the default constructor)

                    class Shape public virtual ~Shape() A virtual destructor virtual void draw() = 0 A pure virtual function virtual void move() = 0 virtual Shape clone() const = 0 Uses the copy constructor virtual Shape create() const = 0 Uses the default constructor class Circle public Shape public Circle clone() const return new Circle(this) Circle create() const return new Circle()

                    In the clone() member function the new Circle(this) code calls Circles copy constructor to copy the state of this into the newly created Circle object In the create() member function the new Circle() code calls Circles default constructor

                    Users use these as if they were virtual constructors

                    void userCode(Shapeamp s) Shape s2 = sclone() Shape s3 = screate() delete s2 You probably need a virtual destructor here

                    delete s3

                    23 How do you link a C++ program to C functions

                    By using the extern C linkage specification around the C function declarations

                    24 Explain the scope resolution operator

                    The scope resolution operator permits a program to reference an identifier in the global scope that has been hidden by another identifier with the same name in the local scope

                    25 What are the differences between a C++ struct and C++ class

                    The default member and base class access specifiers are different

                    26 How many ways are there to initialize an int with a constant

                    Two

                    27 How does throwing and catching exceptions differ from using setjmp and longjmp

                    The throw operation calls the destructors for automatic objects instantiated since entry to the try block

                    28 How does throwing and catching exceptions differ from using setjmp and longjmp

                    The throw operation calls the destructors for automatic objects instantiated since entry to the try block

                    29 What is a default constructor

                    A constructor that has no arguments or one where all the arguments have default argument values

                    If you dont code a default constructor the compiler provides one if there are no other constructors If you are going to instantiate an array of objects of the class the class must have a default constructor

                    30 What is a conversion constructor

                    It is a constructor that accepts one argument of a different type

                    The compiler uses this idiom as one way to infer conversion rules for a class A constructor with more than one argument and with default argument values can be interpreted by the compiler as a conversion constructor when the compiler is looking for an object of the type and sees an object of the type of the constructors first argument

                    31 What is the difference between a copy constructor and an overloaded assignment operator

                    A copy constructor constructs a new object by using the content of the argument object An overloaded assignment operator assigns the contents of an existing object to another existing object of the same class

                    First you must know that a copy constructor is one that has only one argument which is a reference to the same type as the constructor The compiler invokes a copy constructor wherever it needs to make a copy of the object for example to pass an argument by value If you do not provide a copy constructor the compiler creates a member-by-member copy constructor for you

                    You can write overloaded assignment operators that take arguments of other classes but that behavior is usually implemented with implicit conversion constructors If you do not provide an overloaded assignment operator for the class the compiler creates a default member-by-member assignment operator

                    This discussion is a good place to get into why classes need copy constructors and overloaded assignment operators By discussing the requirements with respect to data member pointers that point to dynamically allocated resources you demonstrate a good grasp of the problem

                    32 When should you use multiple inheritance

                    There are three acceptable answers Never Rarely and When the problem domain cannot be accurately modeled any other way

                    33 What is a virtual destructor

                    The simple answer is that a virtual destructor is one that is declared with the virtual attribute

                    The behavior of a virtual destructor is what is important If you destroy an object through a pointer or reference to a base class and the base-class destructor is not virtual the derived-class destructors are not executed and the destruction might not be complete

                    34 Explain the ISA and HASA class relationships How would you implement each in a class design

                    A specialized class is a specialization of another class and therefore has the ISA relationship with the other class An Employee ISA Person This relationship is best implemented with inheritance Employee is derived from Person A class may have an instance of another class For example an Employee has a Salary therefore the Employee class has the HASA relationship with the Salary class This relationship is best implemented by embedding an object of the Salary class in the Employee class

                    The answer to this question reveals whether you have an understanding of the fundamentals of object-oriented design which is important to reliable class design

                    There are other relationships The USESA relationship is when one class uses the services of another The Employee class uses an object (cout) of the ostream class to display the employees name onscreen for example But if you get ISA and HASA right you usually dont need to go any further

                    35 When is a template a better solution than a base class

                    When you are designing a generic class to contain or otherwise manage objects of other types when the format and behavior of those other types are unimportant to their containment or management and particularly when those other types are unknown (thus the genericity) to the designer of the container or manager class

                    Prior to templates you had to use inheritance your design might include a generic List container class and an application-specific Employee class To put employees in a list a ListedEmployee class is multiply derived (contrived) from the Employee and List classes These solutions were unwieldy and error-prone Templates solved that problem

                    Questions for ANSI-Knowledgeable Applicants

                    There are six questions for those who profess knowledge of the progress of the ANSI committee If you claim to have that much interest in the language you should know the answers to all these questions

                    1 What is a mutable member

                    A mutable member is one that can be modified by the class even when the object of the class or the member function doing the modification is const

                    Understanding this requirement implies an understanding of C++ const which many programmers do not have I have seen large class designs that do not employ the const qualifier anywhere Some of those designs are my own early C++ efforts One author suggests that some programmers find const to be such a bother that it is easier to ignore const than to try to use it meaningfully No

                    wonder many programmers dont understand the power and implications of const Someone who claims to have enough interest in the language and its evolution to keep pace with the ANSI deliberations should not be ignorant of const however

                    2 What is an explicit constructor

                    A conversion constructor declared with the explicit keyword The compiler does not use an explicit constructor to implement an implied conversion of types Its purpose is reserved explicitly for construction

                    3 What is the Standard Template Library

                    It is a library of container templates approved by the ANSI committee for inclusion in the standard C++ specification

                    4 Describe run-time type identification

                    It is the ability to determine at run time the type of an object by using the typeid operator or the dynamic_cast operator

                    5 What problem does the namespace feature solve

                    Multiple providers of libraries might use common global identifiers causing a name collision when an application tries to link with two or more such libraries The name-space feature surrounds a librarys external declarations with a unique namespace that eliminates the potential for those collisions

                    This solution assumes that two library vendors dont use the same namespace of course

                    6 Are there any new intrinsic (built-in) data types

                    Yes The ANSI committee added the bool intrinsic type and its true and false value keywords and the wchar_t data type to support character sets wider than eight bits

                    SQL Server

                    1 What is a foreign key

                    A foreign key is a column or combination of columns used to establish and enforce a link (referential integrity) between the data in two tables A link is created between two tables by adding the column or columns that hold one tablersquos primary key values to the other table This column becomes a foreign key in the second table

                    2 What is the difference between a primary key and unique key

                    There can be only one primary key constrain on a table but there can be many unique key constraints in a table

                    Primary key doesnrsquot allow null values but Unique allows 1 Null value

                    3 What is an index

                    Indexes are database objects which provides faster data access The index provides pointers to the data values stored in specified columns of

                    the table and then orders those pointers according to the sort order you specify

                    Different types of indexes are unique index clustered index and non-clustered index

                    4 How to return multiple result set from a stored proc and capture it in ADO

                    Use multiple Select statements to return multiple result sets Use ADOrsquos GetNextRecordset() method to get the second recordset during the

                    execution of the stored proc

                    • COMDCOM
                    • Visual Basic
                    • General Scripting Questions
                    • Session and Application Variable Questions
                      • Image Questions
                      • Browser Questions
                      • ActiveX Data Objects Questions
                      • Form and Query String Questions
                        • 18 What is a virtual member function
                        • 19 How can C++ achieve dynamic binding yet also static typing
                        • 20 Whats the difference between how virtual and non-virtual member functions are called
                        • 21 When should my destructor be virtual
                        • 22 What is a virtual constructor
                        • Questions for ANSI-Knowledgeable Applicants

                      In ATLs class you would have to use macro COM_INTERFACE_ENTRY2(IDispatch IDualInterface1) to distinguish between different dual interfaces

                      7 What is a marshalling by value

                      Some objects can essentially be considered static regardless of which methods are called the state of the object does not change Instead of accessing such an object remotely it is possible to copy the static state of the object and create a new object with the same state information on the caller side The caller wont be able to notice the difference but calls will be more efficient because they do not involve network round trips This is called marshaling by value

                      8 What is ROT What is GIT Give pros and cons of both

                      By definition running object table (ROT) is a globally accessible table on each computer that keeps track of all COM objects in the running state that can be identified by a moniker Moniker providers register an object in the table which increments the objects reference count Before the object can be destroyed its moniker must be released from the tableGlobal Interface Table (GIT) allows any apartment (either single- or multi-threaded) in a process to get access to an interface implemented on an object in any other apartment in the process

                      9 If you have an object with two interfaces can you custom marshal one of them

                      No The decision to use custom marshaling is an all-or-nothing decision an object has to custom marshal all its interfaces or none of them

                      10 How can you guarantee that only a remote server is ever created by a client

                      Create an object (call CoCreateObjectEx()) with CLSCTX_REMOTE_SERVER flag

                      Visual Basic

                      1 What are the properties and methods of ObjectControl interface

                      Activate Deactivate CanBePooled

                      2 How will you implement transaction in a visual basic ActiveX dll

                      Set the MTSTransactionMode property of the class modules Use the ObjectContextSetcomplete SetAbort methods to commitrollback

                      the transactions

                      3 How to execute a stored proc from VB using ADO

                      A stored proc can be executed using the command object

                      4 What are the objects in ADO

                      These are Connection Command Recordset Record Parameter and stream

                      Visual Basic UI

                      1 How to access a member variable in one form from another

                      Set the access modifier of the member variable as Public Create a property procedure

                      2 What is the listindex property of a list box control

                      Listindex is the index of the currently selected item in the control

                      3 Have you worked on grid controls

                      ltlt Answer should be Yes or No gtgt

                      ASP

                      1 How will you describe a session

                      Session object in ASP provides dynamic associative array that a script can use to store information

                      ASP Sessions Are Cookie-based

                      2 What are the different methods to pass an argument from one page to another

                      Using Query string Using Hidden controls

                      NET

                      1 How NET My Services work

                      From the developers perspective NET My Services is a set of XML Web services accessed by sending and receiving SOAP messages sent though the HTTP or DIME protocols and using the NET Passport system for authentication NET My Services consists of three things Authentication which will be provided by NET Passport when NET My Services goes live SOAP the communication protocol XML following the rules and schemas set out in the XMI Reference which provides the data formatting and organization

                      2 What are Web Services

                      Web Services are applications delivered as a service on the Web Web services allow for programmatic access of business logic over the Web Web services typically rely on XML-based protocols messages and interface descriptions for communication and access Web services are designed to be used by other programs or applications rather than directly by end user Programs invoking a Web service are called clients SOAP over HTTP is the most commonly used protocol for invoking Web services

                      3 How do I use a proxy server when invoking a Web service

                      If you are using the SOAP Toolkit you need to set some connector properties to use a proxy server Dim soap As SoapClient Set soap=New SoapClient soapConnectorProperty(ProxyServer) = ldquoproxyservernamerdquo soapConnectorProperty(ProxyPort) = ldquo8080rdquo soapConnectorProperty(UseProxy) = True While with NET you just need to create a SystemNetWebProxy object and use it to set the Proxy property Dim webs As localhostMyService() websProxy=New SystemNetWebProxy(ldquohttpproxyserver8080rdquo)

                      4 What is Simple Object Access Protocol (SOAP)

                      SOAP is an XML-based messaging framework specifically designed for exchanging formatted data across the Internet for example using request and reply messages or sending entire documents SOAP is simple easy to use and completely neutral with respect to operating system programming language or

                      distributed computing platform

                      5 What is Web Services Description Language (WSDL)

                      After SOAP became available as a mechanism for exchanging XML messages among enterprises (or among disparate applications within the same enterprise) a better way was needed to describe the messages and how they are exchanged The Web Services Description Language (WSDL) is a particular form of an XML Schema developed by Microsoft and IBM for the purpose of defining the XML message operation and protocol mapping of a web service accessed using SOAP or other XML protocol WSDL defines web services in terms of endpoints that operate on XML messages The WSDL syntax allows both the messages and the operations on the messages to be defined abstractly so they can be mapped to multiple physical implementations The current WSDL spec describes how to map messages and operations to SOAP 11 HTTP GETPOST and MIME WSDL creates web service definitions by mapping a group of endpoints into a logical sequence of operations on XML messages The same XML message can be mapped to multiple operations (or services) and bound to one or more communications protocols (using ports)

                      6 What is Universal Description Discovery and Integration (UDDI)

                      The Universal Description Discovery and Integration (UDDI) framework defines a data model (in XML) and SOAP APIs for registration and searches on business information including the web services a business exposes to the Internet UDDI is an independent consortium of vendors founded by Microsoft IBM and Ariba for the purpose of developing an Internet standard for web service description registration and discovery Microsoft IBM and Ariba also are hosting the initial deployment of a UDDI service which is conceptually patterned after DNS (the Internet service that translates URLs into TCP addresses) UDDI uses a private agreement profile of SOAP (ie UDDI doesnt use the SOAP serialization format because its not well suited to passing complete XML documents (its aimed at RPC style interactions) The main idea is that businesses use the SOAP APIs to register themselves with UDDI and other businesses search UDDI when they want to discover a trading partner for example someone from whom they wish to procure sheet metal bolts or transistors The information in UDDI is categorized according to industry type and geographical location allowing UDDI consumers to search through lists of potentially matching businesses to find the specific one they want to contact Once a specific business is chosen another call to UDDI is made to obtain the specific contact information for that business The contact information includes a pointer to the target businesss WSDL or other XML schema file describing the web service that the target business publishes

                      The interviewer should be well versed in NET to ask these questions The interview should know the answers

                      Execution cycle of an assembly How does CLR comes into picture- Platform independence

                      Managed unmanaged code Information about GAC How does GAC help in maintaining different versions of an assembly if

                      changes are made to an assembly and the new version does not support some of functionality that previous version supported how will the runtime handle ito What is the sequence of steps followed by the runtime to look for the

                      references like first to bin then GAC etco How to add assemblies in GAC

                      How do we use MTS capabilities in NET assemblies Different type of data persistence in NET

                      o Caching Data caching Output caching

                      o Serialization Xml Bin

                      Usercontrols vc Custom Controls ndash Composite controls Datareader vs Dataset Sorting in Datagrid adding custom controls in datagrid columns Use of view state in ASPX pages How to improve performance of the pages in web environment Is it possible to have both client side and server side functionality on aspx

                      server controls In the page execution life cycle when is the page_init called What is AutoEventWireUp attribute used for What are delegates used for Webservices

                      o How do you deploy web services Reflections Remoting

                      o What is client activated objects and what are server activated objectso What are channels used for

                      Interopo How does a NET component call a primitive one What are the steps taken

                      General Scripting Questions

                      1 How do you add a quotation mark to VB script string

                      The first method uses two quotation marks in a row to create a single quotation mark The second method uses the ASCII value of the quotation mark character

                      2 How do you break a single VBScript Statement into multiple lines

                      A single VBScript Statement can be broken into multiple lines by using the _underscore character

                      3 What is the proper method of comparing strings in VBScript

                      The first method uses VBScript function with the vbTextCompare constant The second method forces both strings into uppercase

                      4 How do you re-enable errors after using ON ERROR RESUME NEXT

                      ltlt Need an answer gtgt

                      5 How do you prevent My Script from timing out

                      You can extend the amount of time a script is allowed to run by using the ScriptTimeout property of the Server object

                      6 When do you need to explicitly convert a variable to a particular data type

                      If you are comparing numbers or dates and there is a danger that VBScript might interpret the values as strings one of the VBScript conversion functions should be used

                      7 When should one pass a variable by value and when by reference

                      When you pass a variable by value to a subordinate or function a new instance of the variable is created Any changes made to the value of the variable do not affect the value of the original variable On the other hand whne you pass a variable by reference changes made to the variable do affect the value of the original variable

                      8 How can you add a space between the output of two variables

                      ltlt Need an answer gtgt

                      9 Does ASP support dynamic includes

                      It does not support

                      10 How do you use the option Explicit statement in an ASP

                      It must be used before nay other VBScript statement or HTML content in a script else it will generate and error

                      Session and Application Variable Questions

                      1 Why do session variables sometimes fail to work

                      Session variables depend on browser cookies If a browser does not support cookies or a user has turned off cookies or the userrsquos cookie file is corrupted Session variables will not work

                      2 How do you remove an application variable

                      ltlt Need an answer gtgt

                      3 How do you detect whether a File exists

                      I can detect by using the FileExists method of the FileSystemObject

                      4 How do you automatically display a list of the Files in a directory

                      By using a list of files in a folder by using the FileSystemObject and the Folder object

                      Image Questions

                      1 How do you store an image in a database table

                      Although you can store an image in a SQL Server BLOB column it is almost always better to store the URL of an image in a database table rather than the image itself

                      2 How do you dynamically generate a graph or image in an ASP

                      Several third-party ASP components enable you to dynamically create custom images

                      Browser Questions

                      1 How do you detect the type of browser a person is using to visit your web site

                      The User-Agent header indicates the type of browser

                      2 How do you detect a page from which a person originated

                      The Referer header contains the URL of the last page the person visited This header can be retrieved from the ServerVariables collection

                      ActiveX Data Objects Questions

                      1 Why do you sometimes receive an error when using the Connection Object to execute a SQL string

                      ltlt Need an answer gtgt

                      2 How do you retrieve a Text filed in an ASP

                      If you do not take special precautions when retrieving a Text field from a database table the value of the Text field might be truncated If you are using a forward-only cursor type you should use the Text field as the very last field in your select list Alternatively consider using a richer cursor type when opening a Recordset that contains a Text field

                      3 Why does the RecordCount always return the Value-1

                      The RecordCount property returns the number of rows in a Recordset after it has been opened you cannot use this property with a forward-only cursor when using SQL Server (it will always return ndash1)

                      4 Why do you receive an error whenever you try to update the value of a filed in a recordset

                      By default when you open a Recordset it is opened with a forward-only cursor and read-only lock type To update a Recordset you must open a Recordset that is not read-only

                      5 How do you limit the number of rows returned by a Database Query

                      If using SQL 70 or Access you can use the SQL Top keyword to limit the number of records returned Otherwise if you are using SQL 65 use the MaxRecords property of the Recordset object

                      ltlt What about SQL 2000 gtgt

                      6 How do you retrieve the value from a SQL Statement that uses Count() Max Min or Identity

                      There are two methods that you can use to retrieve the value from a SQL function or a SQL global variable You can either use an alias for the value or refer to the value by its ordinal position in the Recordset

                      7 How do you retrieve an output parameter from a SQL stored procedure within an ASPScript

                      You must use the ADO Command nad parameter objects

                      Form and Query String Questions

                      1 How do you accept file uploads in an HTML form

                      ltlt Need an answer gtgt

                      2 What causes the value of a form field to become truncated

                      HTML uses quotation marks to mark the beginning and end of a value So If a variable contains question marks in its values the value of the variablewill be truncated when displayed

                      3 How do you include spaces or other special characters in a query string

                      URL encode the query string

                      C++ Questions

                      1 What is an object in C++

                      An object is a package that contains related data and instructions The data relates to what the object represents while the instructions define how this object relates to other objects and itself

                      2 What is a message

                      A message is a signal from one object to another requesting that a computation take place It is roughly equivalent to a function call in other languages

                      3 What is a class

                      A class defines the characteristics of a certain type of object It defines what its members will remember the messages to which they will respond and what form the response will take

                      4 What is an instance

                      It is an individual object that is a member of some class

                      5 What is a super-class

                      Given a class a super-class is the basis of the class under consideration The given class is defined as a subset (in some respects) of the super-class All objects of the given class potentially posses all the characteristics belonging to objects of the super-class

                      6 What is inheritance

                      Inheritance is property such that a parent (or super) class passes the characteristics of itself to children (or sub) classes that are derived from it The sub-class has the option of modifying these characteristics in order to make a different but fundamentally related class from the super-class

                      7 To what does message protocol refer

                      An objects message protocol is the exact form of the set of messages to which the object can respond

                      8 What is polymorphism

                      Polymorphism refers to the ability of an object to respond in a logically identical fashion to messages of the same protocol containing differing types of objects Consider 1 + 5 and 1 + 51 In the former the message + 5 is sent to an object of class integer (1) In the later the message + 51 is sent to the same integer object The form of the message (its protocol) is identical in both cases What differs is the type of object on the right-hand side of these messages The former is an integer object (5) while the later is a floating point object (51) The receiver (1) appears (to other objects) to respond in the same way to both messages Internally however it knows that it must treat the two types of objects differently in order to obtain the same overall response

                      9 What are instance variables

                      These represent an objects private memory They are defined in an objects class

                      18 What is a virtual member function

                      A virtual function allows derived classes to replace the implementation provided by the base class The compiler makes sure the replacement is always called whenever the object in question is actually of the derived class even if the object is accessed by a base pointer rather than a derived pointer This allows algorithms in the base class to be replaced in the derived class even if users dont know about the derived class

                      The derived class can either fully replace (override) the base class member function or the derived class can partially replace (augment) the base class member function The latter is accomplished by having the derived class member function call the base class member function if desired

                      19 How can C++ achieve dynamic binding yet also static typing

                      When you have a pointer to an object the object may actually be of a class that is derived from the class of the pointer (eg a Vehicle that is actually pointing to a Car object) Thus there are two types the (static) type of the pointer (Vehicle in this case) and the (dynamic) type of the pointed-to object (Car in this case)

                      Static typing means that the legality of a member function invocation is checked at the earliest possible moment by the compiler at compile time The compiler uses the static type of the pointer to determine whether the member function invocation is legal If the type of the pointer can handle the member function certainly the pointed-to object can handle it as well Eg if Vehicle has a certain member function certainly Car also has that member function since Car is a kind-of Vehicle

                      Dynamic binding means that the address of the code in a member function invocation is determined at the last possible moment based on the dynamic type of the object at run time It is called dynamic binding because the binding to the code that actually gets called is accomplished dynamically (at run time) Dynamic binding is a result of virtual functions

                      20 Whats the difference between how virtual and non-virtual member functions are called

                      Non-virtual member functions are resolved statically That is the member function is selected statically (at compile-time) based on the type of the pointer (or reference) to the object

                      In contrast virtual member functions are resolved dynamically (at run-time) That is the member function is selected dynamically (at run-time) based on the type of the object not the type of the pointerreference to that object This is called dynamic binding Most compilers use some variant of the following technique

                      if the object has one or more virtual functions the compiler puts a hidden pointer in the object called a virtual-pointer or v-pointer This v-pointer points to a global table called the virtual-table or v-table

                      The compiler creates a v-table for each class that has at least one virtual function For example if class Circle has virtual functions for draw() and move() and resize() there would be exactly one v-table associated with class Circle even if there were a gazillion Circle objects and the v-pointer of each of those Circle objects would point to the Circle v-table The v-table itself has pointers to each of the virtual functions in the class For example the Circle v-table would have three pointers a pointer to Circledraw() a pointer to Circlemove() and a pointer to Circleresize()

                      During a dispatch of a virtual function the run-time system follows the objects v-pointer to the classs v-table then follows the appropriate slot in the v-table to the method code

                      The space-cost overhead of the above technique is nominal an extra pointer per object (but only for objects that will need to do dynamic binding) plus an extra pointer per method (but only for virtual methods) The time-cost overhead is also fairly nominal compared to a normal function call a virtual function call requires two extra fetches (one to get the value of the v-pointer a second to get the address of the method) None of this runtime activity happens with non-virtual functions since the compiler resolves non-virtual functions exclusively at compile-time based on the type of the pointer

                      21 When should my destructor be virtual

                      When you may delete a derived object via a base pointer

                      virtual functions bind to the code associated with the class of the object rather than with the class of the pointerreference When you say delete basePtr and the base class has a virtual destructor the destructor that gets invoked is the one associated with the type of the object basePtr rather than the one associated with the type of the pointer This is generally A Good Thing

                      TECHNO-GEEK WARNING PUT YOUR PROPELLER HAT ON Technically speaking you need a base classs destructor to be virtual if and only if you intend to allow someone to invoke an objects destructor via a base class pointer (this is normally done implicitly via delete) and the object being destructed is of a derived class that has a non-trivial destructor A class has a non-trivial destructor if it either has an explicit destructor or if it has a member object or a base class that has a non-trivial destructor (note that this is a recursive definition (eg a class has a non-trivial destructor if it has a member object (which has a base class (which has a member object (which has a base class (which has an explicit destructor)))))) END TECHNO-GEEK WARNING REMOVE YOUR PROPELLER HAT

                      If you had a hard grokking the previous rule try this (over)simplified one on for size A class should have a virtual destructor unless that class has no virtual functions Rationale if you have any virtual functions at all youre probably going to be doing stuff to derived objects via a base pointer and some of the stuff you may do may include invoking a destructor (normally done implicitly via delete) Plus once youve put the first virtual function into a class youve already paid all the per-object space cost that youll ever pay (one pointer per object note that this is theoretically compiler-specific in practice everyone does it pretty much the same way) so making the destructor virtual wont generally cost you anything extra

                      22 What is a virtual constructor

                      An idiom that allows you to do something that C++ doesnt directly support

                      You can get the effect of a virtual constructor by a virtual clone() member function (for copy constructing) or a virtual create() member function (for the default constructor)

                      class Shape public virtual ~Shape() A virtual destructor virtual void draw() = 0 A pure virtual function virtual void move() = 0 virtual Shape clone() const = 0 Uses the copy constructor virtual Shape create() const = 0 Uses the default constructor class Circle public Shape public Circle clone() const return new Circle(this) Circle create() const return new Circle()

                      In the clone() member function the new Circle(this) code calls Circles copy constructor to copy the state of this into the newly created Circle object In the create() member function the new Circle() code calls Circles default constructor

                      Users use these as if they were virtual constructors

                      void userCode(Shapeamp s) Shape s2 = sclone() Shape s3 = screate() delete s2 You probably need a virtual destructor here

                      delete s3

                      23 How do you link a C++ program to C functions

                      By using the extern C linkage specification around the C function declarations

                      24 Explain the scope resolution operator

                      The scope resolution operator permits a program to reference an identifier in the global scope that has been hidden by another identifier with the same name in the local scope

                      25 What are the differences between a C++ struct and C++ class

                      The default member and base class access specifiers are different

                      26 How many ways are there to initialize an int with a constant

                      Two

                      27 How does throwing and catching exceptions differ from using setjmp and longjmp

                      The throw operation calls the destructors for automatic objects instantiated since entry to the try block

                      28 How does throwing and catching exceptions differ from using setjmp and longjmp

                      The throw operation calls the destructors for automatic objects instantiated since entry to the try block

                      29 What is a default constructor

                      A constructor that has no arguments or one where all the arguments have default argument values

                      If you dont code a default constructor the compiler provides one if there are no other constructors If you are going to instantiate an array of objects of the class the class must have a default constructor

                      30 What is a conversion constructor

                      It is a constructor that accepts one argument of a different type

                      The compiler uses this idiom as one way to infer conversion rules for a class A constructor with more than one argument and with default argument values can be interpreted by the compiler as a conversion constructor when the compiler is looking for an object of the type and sees an object of the type of the constructors first argument

                      31 What is the difference between a copy constructor and an overloaded assignment operator

                      A copy constructor constructs a new object by using the content of the argument object An overloaded assignment operator assigns the contents of an existing object to another existing object of the same class

                      First you must know that a copy constructor is one that has only one argument which is a reference to the same type as the constructor The compiler invokes a copy constructor wherever it needs to make a copy of the object for example to pass an argument by value If you do not provide a copy constructor the compiler creates a member-by-member copy constructor for you

                      You can write overloaded assignment operators that take arguments of other classes but that behavior is usually implemented with implicit conversion constructors If you do not provide an overloaded assignment operator for the class the compiler creates a default member-by-member assignment operator

                      This discussion is a good place to get into why classes need copy constructors and overloaded assignment operators By discussing the requirements with respect to data member pointers that point to dynamically allocated resources you demonstrate a good grasp of the problem

                      32 When should you use multiple inheritance

                      There are three acceptable answers Never Rarely and When the problem domain cannot be accurately modeled any other way

                      33 What is a virtual destructor

                      The simple answer is that a virtual destructor is one that is declared with the virtual attribute

                      The behavior of a virtual destructor is what is important If you destroy an object through a pointer or reference to a base class and the base-class destructor is not virtual the derived-class destructors are not executed and the destruction might not be complete

                      34 Explain the ISA and HASA class relationships How would you implement each in a class design

                      A specialized class is a specialization of another class and therefore has the ISA relationship with the other class An Employee ISA Person This relationship is best implemented with inheritance Employee is derived from Person A class may have an instance of another class For example an Employee has a Salary therefore the Employee class has the HASA relationship with the Salary class This relationship is best implemented by embedding an object of the Salary class in the Employee class

                      The answer to this question reveals whether you have an understanding of the fundamentals of object-oriented design which is important to reliable class design

                      There are other relationships The USESA relationship is when one class uses the services of another The Employee class uses an object (cout) of the ostream class to display the employees name onscreen for example But if you get ISA and HASA right you usually dont need to go any further

                      35 When is a template a better solution than a base class

                      When you are designing a generic class to contain or otherwise manage objects of other types when the format and behavior of those other types are unimportant to their containment or management and particularly when those other types are unknown (thus the genericity) to the designer of the container or manager class

                      Prior to templates you had to use inheritance your design might include a generic List container class and an application-specific Employee class To put employees in a list a ListedEmployee class is multiply derived (contrived) from the Employee and List classes These solutions were unwieldy and error-prone Templates solved that problem

                      Questions for ANSI-Knowledgeable Applicants

                      There are six questions for those who profess knowledge of the progress of the ANSI committee If you claim to have that much interest in the language you should know the answers to all these questions

                      1 What is a mutable member

                      A mutable member is one that can be modified by the class even when the object of the class or the member function doing the modification is const

                      Understanding this requirement implies an understanding of C++ const which many programmers do not have I have seen large class designs that do not employ the const qualifier anywhere Some of those designs are my own early C++ efforts One author suggests that some programmers find const to be such a bother that it is easier to ignore const than to try to use it meaningfully No

                      wonder many programmers dont understand the power and implications of const Someone who claims to have enough interest in the language and its evolution to keep pace with the ANSI deliberations should not be ignorant of const however

                      2 What is an explicit constructor

                      A conversion constructor declared with the explicit keyword The compiler does not use an explicit constructor to implement an implied conversion of types Its purpose is reserved explicitly for construction

                      3 What is the Standard Template Library

                      It is a library of container templates approved by the ANSI committee for inclusion in the standard C++ specification

                      4 Describe run-time type identification

                      It is the ability to determine at run time the type of an object by using the typeid operator or the dynamic_cast operator

                      5 What problem does the namespace feature solve

                      Multiple providers of libraries might use common global identifiers causing a name collision when an application tries to link with two or more such libraries The name-space feature surrounds a librarys external declarations with a unique namespace that eliminates the potential for those collisions

                      This solution assumes that two library vendors dont use the same namespace of course

                      6 Are there any new intrinsic (built-in) data types

                      Yes The ANSI committee added the bool intrinsic type and its true and false value keywords and the wchar_t data type to support character sets wider than eight bits

                      SQL Server

                      1 What is a foreign key

                      A foreign key is a column or combination of columns used to establish and enforce a link (referential integrity) between the data in two tables A link is created between two tables by adding the column or columns that hold one tablersquos primary key values to the other table This column becomes a foreign key in the second table

                      2 What is the difference between a primary key and unique key

                      There can be only one primary key constrain on a table but there can be many unique key constraints in a table

                      Primary key doesnrsquot allow null values but Unique allows 1 Null value

                      3 What is an index

                      Indexes are database objects which provides faster data access The index provides pointers to the data values stored in specified columns of

                      the table and then orders those pointers according to the sort order you specify

                      Different types of indexes are unique index clustered index and non-clustered index

                      4 How to return multiple result set from a stored proc and capture it in ADO

                      Use multiple Select statements to return multiple result sets Use ADOrsquos GetNextRecordset() method to get the second recordset during the

                      execution of the stored proc

                      • COMDCOM
                      • Visual Basic
                      • General Scripting Questions
                      • Session and Application Variable Questions
                        • Image Questions
                        • Browser Questions
                        • ActiveX Data Objects Questions
                        • Form and Query String Questions
                          • 18 What is a virtual member function
                          • 19 How can C++ achieve dynamic binding yet also static typing
                          • 20 Whats the difference between how virtual and non-virtual member functions are called
                          • 21 When should my destructor be virtual
                          • 22 What is a virtual constructor
                          • Questions for ANSI-Knowledgeable Applicants

                        Visual Basic

                        1 What are the properties and methods of ObjectControl interface

                        Activate Deactivate CanBePooled

                        2 How will you implement transaction in a visual basic ActiveX dll

                        Set the MTSTransactionMode property of the class modules Use the ObjectContextSetcomplete SetAbort methods to commitrollback

                        the transactions

                        3 How to execute a stored proc from VB using ADO

                        A stored proc can be executed using the command object

                        4 What are the objects in ADO

                        These are Connection Command Recordset Record Parameter and stream

                        Visual Basic UI

                        1 How to access a member variable in one form from another

                        Set the access modifier of the member variable as Public Create a property procedure

                        2 What is the listindex property of a list box control

                        Listindex is the index of the currently selected item in the control

                        3 Have you worked on grid controls

                        ltlt Answer should be Yes or No gtgt

                        ASP

                        1 How will you describe a session

                        Session object in ASP provides dynamic associative array that a script can use to store information

                        ASP Sessions Are Cookie-based

                        2 What are the different methods to pass an argument from one page to another

                        Using Query string Using Hidden controls

                        NET

                        1 How NET My Services work

                        From the developers perspective NET My Services is a set of XML Web services accessed by sending and receiving SOAP messages sent though the HTTP or DIME protocols and using the NET Passport system for authentication NET My Services consists of three things Authentication which will be provided by NET Passport when NET My Services goes live SOAP the communication protocol XML following the rules and schemas set out in the XMI Reference which provides the data formatting and organization

                        2 What are Web Services

                        Web Services are applications delivered as a service on the Web Web services allow for programmatic access of business logic over the Web Web services typically rely on XML-based protocols messages and interface descriptions for communication and access Web services are designed to be used by other programs or applications rather than directly by end user Programs invoking a Web service are called clients SOAP over HTTP is the most commonly used protocol for invoking Web services

                        3 How do I use a proxy server when invoking a Web service

                        If you are using the SOAP Toolkit you need to set some connector properties to use a proxy server Dim soap As SoapClient Set soap=New SoapClient soapConnectorProperty(ProxyServer) = ldquoproxyservernamerdquo soapConnectorProperty(ProxyPort) = ldquo8080rdquo soapConnectorProperty(UseProxy) = True While with NET you just need to create a SystemNetWebProxy object and use it to set the Proxy property Dim webs As localhostMyService() websProxy=New SystemNetWebProxy(ldquohttpproxyserver8080rdquo)

                        4 What is Simple Object Access Protocol (SOAP)

                        SOAP is an XML-based messaging framework specifically designed for exchanging formatted data across the Internet for example using request and reply messages or sending entire documents SOAP is simple easy to use and completely neutral with respect to operating system programming language or

                        distributed computing platform

                        5 What is Web Services Description Language (WSDL)

                        After SOAP became available as a mechanism for exchanging XML messages among enterprises (or among disparate applications within the same enterprise) a better way was needed to describe the messages and how they are exchanged The Web Services Description Language (WSDL) is a particular form of an XML Schema developed by Microsoft and IBM for the purpose of defining the XML message operation and protocol mapping of a web service accessed using SOAP or other XML protocol WSDL defines web services in terms of endpoints that operate on XML messages The WSDL syntax allows both the messages and the operations on the messages to be defined abstractly so they can be mapped to multiple physical implementations The current WSDL spec describes how to map messages and operations to SOAP 11 HTTP GETPOST and MIME WSDL creates web service definitions by mapping a group of endpoints into a logical sequence of operations on XML messages The same XML message can be mapped to multiple operations (or services) and bound to one or more communications protocols (using ports)

                        6 What is Universal Description Discovery and Integration (UDDI)

                        The Universal Description Discovery and Integration (UDDI) framework defines a data model (in XML) and SOAP APIs for registration and searches on business information including the web services a business exposes to the Internet UDDI is an independent consortium of vendors founded by Microsoft IBM and Ariba for the purpose of developing an Internet standard for web service description registration and discovery Microsoft IBM and Ariba also are hosting the initial deployment of a UDDI service which is conceptually patterned after DNS (the Internet service that translates URLs into TCP addresses) UDDI uses a private agreement profile of SOAP (ie UDDI doesnt use the SOAP serialization format because its not well suited to passing complete XML documents (its aimed at RPC style interactions) The main idea is that businesses use the SOAP APIs to register themselves with UDDI and other businesses search UDDI when they want to discover a trading partner for example someone from whom they wish to procure sheet metal bolts or transistors The information in UDDI is categorized according to industry type and geographical location allowing UDDI consumers to search through lists of potentially matching businesses to find the specific one they want to contact Once a specific business is chosen another call to UDDI is made to obtain the specific contact information for that business The contact information includes a pointer to the target businesss WSDL or other XML schema file describing the web service that the target business publishes

                        The interviewer should be well versed in NET to ask these questions The interview should know the answers

                        Execution cycle of an assembly How does CLR comes into picture- Platform independence

                        Managed unmanaged code Information about GAC How does GAC help in maintaining different versions of an assembly if

                        changes are made to an assembly and the new version does not support some of functionality that previous version supported how will the runtime handle ito What is the sequence of steps followed by the runtime to look for the

                        references like first to bin then GAC etco How to add assemblies in GAC

                        How do we use MTS capabilities in NET assemblies Different type of data persistence in NET

                        o Caching Data caching Output caching

                        o Serialization Xml Bin

                        Usercontrols vc Custom Controls ndash Composite controls Datareader vs Dataset Sorting in Datagrid adding custom controls in datagrid columns Use of view state in ASPX pages How to improve performance of the pages in web environment Is it possible to have both client side and server side functionality on aspx

                        server controls In the page execution life cycle when is the page_init called What is AutoEventWireUp attribute used for What are delegates used for Webservices

                        o How do you deploy web services Reflections Remoting

                        o What is client activated objects and what are server activated objectso What are channels used for

                        Interopo How does a NET component call a primitive one What are the steps taken

                        General Scripting Questions

                        1 How do you add a quotation mark to VB script string

                        The first method uses two quotation marks in a row to create a single quotation mark The second method uses the ASCII value of the quotation mark character

                        2 How do you break a single VBScript Statement into multiple lines

                        A single VBScript Statement can be broken into multiple lines by using the _underscore character

                        3 What is the proper method of comparing strings in VBScript

                        The first method uses VBScript function with the vbTextCompare constant The second method forces both strings into uppercase

                        4 How do you re-enable errors after using ON ERROR RESUME NEXT

                        ltlt Need an answer gtgt

                        5 How do you prevent My Script from timing out

                        You can extend the amount of time a script is allowed to run by using the ScriptTimeout property of the Server object

                        6 When do you need to explicitly convert a variable to a particular data type

                        If you are comparing numbers or dates and there is a danger that VBScript might interpret the values as strings one of the VBScript conversion functions should be used

                        7 When should one pass a variable by value and when by reference

                        When you pass a variable by value to a subordinate or function a new instance of the variable is created Any changes made to the value of the variable do not affect the value of the original variable On the other hand whne you pass a variable by reference changes made to the variable do affect the value of the original variable

                        8 How can you add a space between the output of two variables

                        ltlt Need an answer gtgt

                        9 Does ASP support dynamic includes

                        It does not support

                        10 How do you use the option Explicit statement in an ASP

                        It must be used before nay other VBScript statement or HTML content in a script else it will generate and error

                        Session and Application Variable Questions

                        1 Why do session variables sometimes fail to work

                        Session variables depend on browser cookies If a browser does not support cookies or a user has turned off cookies or the userrsquos cookie file is corrupted Session variables will not work

                        2 How do you remove an application variable

                        ltlt Need an answer gtgt

                        3 How do you detect whether a File exists

                        I can detect by using the FileExists method of the FileSystemObject

                        4 How do you automatically display a list of the Files in a directory

                        By using a list of files in a folder by using the FileSystemObject and the Folder object

                        Image Questions

                        1 How do you store an image in a database table

                        Although you can store an image in a SQL Server BLOB column it is almost always better to store the URL of an image in a database table rather than the image itself

                        2 How do you dynamically generate a graph or image in an ASP

                        Several third-party ASP components enable you to dynamically create custom images

                        Browser Questions

                        1 How do you detect the type of browser a person is using to visit your web site

                        The User-Agent header indicates the type of browser

                        2 How do you detect a page from which a person originated

                        The Referer header contains the URL of the last page the person visited This header can be retrieved from the ServerVariables collection

                        ActiveX Data Objects Questions

                        1 Why do you sometimes receive an error when using the Connection Object to execute a SQL string

                        ltlt Need an answer gtgt

                        2 How do you retrieve a Text filed in an ASP

                        If you do not take special precautions when retrieving a Text field from a database table the value of the Text field might be truncated If you are using a forward-only cursor type you should use the Text field as the very last field in your select list Alternatively consider using a richer cursor type when opening a Recordset that contains a Text field

                        3 Why does the RecordCount always return the Value-1

                        The RecordCount property returns the number of rows in a Recordset after it has been opened you cannot use this property with a forward-only cursor when using SQL Server (it will always return ndash1)

                        4 Why do you receive an error whenever you try to update the value of a filed in a recordset

                        By default when you open a Recordset it is opened with a forward-only cursor and read-only lock type To update a Recordset you must open a Recordset that is not read-only

                        5 How do you limit the number of rows returned by a Database Query

                        If using SQL 70 or Access you can use the SQL Top keyword to limit the number of records returned Otherwise if you are using SQL 65 use the MaxRecords property of the Recordset object

                        ltlt What about SQL 2000 gtgt

                        6 How do you retrieve the value from a SQL Statement that uses Count() Max Min or Identity

                        There are two methods that you can use to retrieve the value from a SQL function or a SQL global variable You can either use an alias for the value or refer to the value by its ordinal position in the Recordset

                        7 How do you retrieve an output parameter from a SQL stored procedure within an ASPScript

                        You must use the ADO Command nad parameter objects

                        Form and Query String Questions

                        1 How do you accept file uploads in an HTML form

                        ltlt Need an answer gtgt

                        2 What causes the value of a form field to become truncated

                        HTML uses quotation marks to mark the beginning and end of a value So If a variable contains question marks in its values the value of the variablewill be truncated when displayed

                        3 How do you include spaces or other special characters in a query string

                        URL encode the query string

                        C++ Questions

                        1 What is an object in C++

                        An object is a package that contains related data and instructions The data relates to what the object represents while the instructions define how this object relates to other objects and itself

                        2 What is a message

                        A message is a signal from one object to another requesting that a computation take place It is roughly equivalent to a function call in other languages

                        3 What is a class

                        A class defines the characteristics of a certain type of object It defines what its members will remember the messages to which they will respond and what form the response will take

                        4 What is an instance

                        It is an individual object that is a member of some class

                        5 What is a super-class

                        Given a class a super-class is the basis of the class under consideration The given class is defined as a subset (in some respects) of the super-class All objects of the given class potentially posses all the characteristics belonging to objects of the super-class

                        6 What is inheritance

                        Inheritance is property such that a parent (or super) class passes the characteristics of itself to children (or sub) classes that are derived from it The sub-class has the option of modifying these characteristics in order to make a different but fundamentally related class from the super-class

                        7 To what does message protocol refer

                        An objects message protocol is the exact form of the set of messages to which the object can respond

                        8 What is polymorphism

                        Polymorphism refers to the ability of an object to respond in a logically identical fashion to messages of the same protocol containing differing types of objects Consider 1 + 5 and 1 + 51 In the former the message + 5 is sent to an object of class integer (1) In the later the message + 51 is sent to the same integer object The form of the message (its protocol) is identical in both cases What differs is the type of object on the right-hand side of these messages The former is an integer object (5) while the later is a floating point object (51) The receiver (1) appears (to other objects) to respond in the same way to both messages Internally however it knows that it must treat the two types of objects differently in order to obtain the same overall response

                        9 What are instance variables

                        These represent an objects private memory They are defined in an objects class

                        18 What is a virtual member function

                        A virtual function allows derived classes to replace the implementation provided by the base class The compiler makes sure the replacement is always called whenever the object in question is actually of the derived class even if the object is accessed by a base pointer rather than a derived pointer This allows algorithms in the base class to be replaced in the derived class even if users dont know about the derived class

                        The derived class can either fully replace (override) the base class member function or the derived class can partially replace (augment) the base class member function The latter is accomplished by having the derived class member function call the base class member function if desired

                        19 How can C++ achieve dynamic binding yet also static typing

                        When you have a pointer to an object the object may actually be of a class that is derived from the class of the pointer (eg a Vehicle that is actually pointing to a Car object) Thus there are two types the (static) type of the pointer (Vehicle in this case) and the (dynamic) type of the pointed-to object (Car in this case)

                        Static typing means that the legality of a member function invocation is checked at the earliest possible moment by the compiler at compile time The compiler uses the static type of the pointer to determine whether the member function invocation is legal If the type of the pointer can handle the member function certainly the pointed-to object can handle it as well Eg if Vehicle has a certain member function certainly Car also has that member function since Car is a kind-of Vehicle

                        Dynamic binding means that the address of the code in a member function invocation is determined at the last possible moment based on the dynamic type of the object at run time It is called dynamic binding because the binding to the code that actually gets called is accomplished dynamically (at run time) Dynamic binding is a result of virtual functions

                        20 Whats the difference between how virtual and non-virtual member functions are called

                        Non-virtual member functions are resolved statically That is the member function is selected statically (at compile-time) based on the type of the pointer (or reference) to the object

                        In contrast virtual member functions are resolved dynamically (at run-time) That is the member function is selected dynamically (at run-time) based on the type of the object not the type of the pointerreference to that object This is called dynamic binding Most compilers use some variant of the following technique

                        if the object has one or more virtual functions the compiler puts a hidden pointer in the object called a virtual-pointer or v-pointer This v-pointer points to a global table called the virtual-table or v-table

                        The compiler creates a v-table for each class that has at least one virtual function For example if class Circle has virtual functions for draw() and move() and resize() there would be exactly one v-table associated with class Circle even if there were a gazillion Circle objects and the v-pointer of each of those Circle objects would point to the Circle v-table The v-table itself has pointers to each of the virtual functions in the class For example the Circle v-table would have three pointers a pointer to Circledraw() a pointer to Circlemove() and a pointer to Circleresize()

                        During a dispatch of a virtual function the run-time system follows the objects v-pointer to the classs v-table then follows the appropriate slot in the v-table to the method code

                        The space-cost overhead of the above technique is nominal an extra pointer per object (but only for objects that will need to do dynamic binding) plus an extra pointer per method (but only for virtual methods) The time-cost overhead is also fairly nominal compared to a normal function call a virtual function call requires two extra fetches (one to get the value of the v-pointer a second to get the address of the method) None of this runtime activity happens with non-virtual functions since the compiler resolves non-virtual functions exclusively at compile-time based on the type of the pointer

                        21 When should my destructor be virtual

                        When you may delete a derived object via a base pointer

                        virtual functions bind to the code associated with the class of the object rather than with the class of the pointerreference When you say delete basePtr and the base class has a virtual destructor the destructor that gets invoked is the one associated with the type of the object basePtr rather than the one associated with the type of the pointer This is generally A Good Thing

                        TECHNO-GEEK WARNING PUT YOUR PROPELLER HAT ON Technically speaking you need a base classs destructor to be virtual if and only if you intend to allow someone to invoke an objects destructor via a base class pointer (this is normally done implicitly via delete) and the object being destructed is of a derived class that has a non-trivial destructor A class has a non-trivial destructor if it either has an explicit destructor or if it has a member object or a base class that has a non-trivial destructor (note that this is a recursive definition (eg a class has a non-trivial destructor if it has a member object (which has a base class (which has a member object (which has a base class (which has an explicit destructor)))))) END TECHNO-GEEK WARNING REMOVE YOUR PROPELLER HAT

                        If you had a hard grokking the previous rule try this (over)simplified one on for size A class should have a virtual destructor unless that class has no virtual functions Rationale if you have any virtual functions at all youre probably going to be doing stuff to derived objects via a base pointer and some of the stuff you may do may include invoking a destructor (normally done implicitly via delete) Plus once youve put the first virtual function into a class youve already paid all the per-object space cost that youll ever pay (one pointer per object note that this is theoretically compiler-specific in practice everyone does it pretty much the same way) so making the destructor virtual wont generally cost you anything extra

                        22 What is a virtual constructor

                        An idiom that allows you to do something that C++ doesnt directly support

                        You can get the effect of a virtual constructor by a virtual clone() member function (for copy constructing) or a virtual create() member function (for the default constructor)

                        class Shape public virtual ~Shape() A virtual destructor virtual void draw() = 0 A pure virtual function virtual void move() = 0 virtual Shape clone() const = 0 Uses the copy constructor virtual Shape create() const = 0 Uses the default constructor class Circle public Shape public Circle clone() const return new Circle(this) Circle create() const return new Circle()

                        In the clone() member function the new Circle(this) code calls Circles copy constructor to copy the state of this into the newly created Circle object In the create() member function the new Circle() code calls Circles default constructor

                        Users use these as if they were virtual constructors

                        void userCode(Shapeamp s) Shape s2 = sclone() Shape s3 = screate() delete s2 You probably need a virtual destructor here

                        delete s3

                        23 How do you link a C++ program to C functions

                        By using the extern C linkage specification around the C function declarations

                        24 Explain the scope resolution operator

                        The scope resolution operator permits a program to reference an identifier in the global scope that has been hidden by another identifier with the same name in the local scope

                        25 What are the differences between a C++ struct and C++ class

                        The default member and base class access specifiers are different

                        26 How many ways are there to initialize an int with a constant

                        Two

                        27 How does throwing and catching exceptions differ from using setjmp and longjmp

                        The throw operation calls the destructors for automatic objects instantiated since entry to the try block

                        28 How does throwing and catching exceptions differ from using setjmp and longjmp

                        The throw operation calls the destructors for automatic objects instantiated since entry to the try block

                        29 What is a default constructor

                        A constructor that has no arguments or one where all the arguments have default argument values

                        If you dont code a default constructor the compiler provides one if there are no other constructors If you are going to instantiate an array of objects of the class the class must have a default constructor

                        30 What is a conversion constructor

                        It is a constructor that accepts one argument of a different type

                        The compiler uses this idiom as one way to infer conversion rules for a class A constructor with more than one argument and with default argument values can be interpreted by the compiler as a conversion constructor when the compiler is looking for an object of the type and sees an object of the type of the constructors first argument

                        31 What is the difference between a copy constructor and an overloaded assignment operator

                        A copy constructor constructs a new object by using the content of the argument object An overloaded assignment operator assigns the contents of an existing object to another existing object of the same class

                        First you must know that a copy constructor is one that has only one argument which is a reference to the same type as the constructor The compiler invokes a copy constructor wherever it needs to make a copy of the object for example to pass an argument by value If you do not provide a copy constructor the compiler creates a member-by-member copy constructor for you

                        You can write overloaded assignment operators that take arguments of other classes but that behavior is usually implemented with implicit conversion constructors If you do not provide an overloaded assignment operator for the class the compiler creates a default member-by-member assignment operator

                        This discussion is a good place to get into why classes need copy constructors and overloaded assignment operators By discussing the requirements with respect to data member pointers that point to dynamically allocated resources you demonstrate a good grasp of the problem

                        32 When should you use multiple inheritance

                        There are three acceptable answers Never Rarely and When the problem domain cannot be accurately modeled any other way

                        33 What is a virtual destructor

                        The simple answer is that a virtual destructor is one that is declared with the virtual attribute

                        The behavior of a virtual destructor is what is important If you destroy an object through a pointer or reference to a base class and the base-class destructor is not virtual the derived-class destructors are not executed and the destruction might not be complete

                        34 Explain the ISA and HASA class relationships How would you implement each in a class design

                        A specialized class is a specialization of another class and therefore has the ISA relationship with the other class An Employee ISA Person This relationship is best implemented with inheritance Employee is derived from Person A class may have an instance of another class For example an Employee has a Salary therefore the Employee class has the HASA relationship with the Salary class This relationship is best implemented by embedding an object of the Salary class in the Employee class

                        The answer to this question reveals whether you have an understanding of the fundamentals of object-oriented design which is important to reliable class design

                        There are other relationships The USESA relationship is when one class uses the services of another The Employee class uses an object (cout) of the ostream class to display the employees name onscreen for example But if you get ISA and HASA right you usually dont need to go any further

                        35 When is a template a better solution than a base class

                        When you are designing a generic class to contain or otherwise manage objects of other types when the format and behavior of those other types are unimportant to their containment or management and particularly when those other types are unknown (thus the genericity) to the designer of the container or manager class

                        Prior to templates you had to use inheritance your design might include a generic List container class and an application-specific Employee class To put employees in a list a ListedEmployee class is multiply derived (contrived) from the Employee and List classes These solutions were unwieldy and error-prone Templates solved that problem

                        Questions for ANSI-Knowledgeable Applicants

                        There are six questions for those who profess knowledge of the progress of the ANSI committee If you claim to have that much interest in the language you should know the answers to all these questions

                        1 What is a mutable member

                        A mutable member is one that can be modified by the class even when the object of the class or the member function doing the modification is const

                        Understanding this requirement implies an understanding of C++ const which many programmers do not have I have seen large class designs that do not employ the const qualifier anywhere Some of those designs are my own early C++ efforts One author suggests that some programmers find const to be such a bother that it is easier to ignore const than to try to use it meaningfully No

                        wonder many programmers dont understand the power and implications of const Someone who claims to have enough interest in the language and its evolution to keep pace with the ANSI deliberations should not be ignorant of const however

                        2 What is an explicit constructor

                        A conversion constructor declared with the explicit keyword The compiler does not use an explicit constructor to implement an implied conversion of types Its purpose is reserved explicitly for construction

                        3 What is the Standard Template Library

                        It is a library of container templates approved by the ANSI committee for inclusion in the standard C++ specification

                        4 Describe run-time type identification

                        It is the ability to determine at run time the type of an object by using the typeid operator or the dynamic_cast operator

                        5 What problem does the namespace feature solve

                        Multiple providers of libraries might use common global identifiers causing a name collision when an application tries to link with two or more such libraries The name-space feature surrounds a librarys external declarations with a unique namespace that eliminates the potential for those collisions

                        This solution assumes that two library vendors dont use the same namespace of course

                        6 Are there any new intrinsic (built-in) data types

                        Yes The ANSI committee added the bool intrinsic type and its true and false value keywords and the wchar_t data type to support character sets wider than eight bits

                        SQL Server

                        1 What is a foreign key

                        A foreign key is a column or combination of columns used to establish and enforce a link (referential integrity) between the data in two tables A link is created between two tables by adding the column or columns that hold one tablersquos primary key values to the other table This column becomes a foreign key in the second table

                        2 What is the difference between a primary key and unique key

                        There can be only one primary key constrain on a table but there can be many unique key constraints in a table

                        Primary key doesnrsquot allow null values but Unique allows 1 Null value

                        3 What is an index

                        Indexes are database objects which provides faster data access The index provides pointers to the data values stored in specified columns of

                        the table and then orders those pointers according to the sort order you specify

                        Different types of indexes are unique index clustered index and non-clustered index

                        4 How to return multiple result set from a stored proc and capture it in ADO

                        Use multiple Select statements to return multiple result sets Use ADOrsquos GetNextRecordset() method to get the second recordset during the

                        execution of the stored proc

                        • COMDCOM
                        • Visual Basic
                        • General Scripting Questions
                        • Session and Application Variable Questions
                          • Image Questions
                          • Browser Questions
                          • ActiveX Data Objects Questions
                          • Form and Query String Questions
                            • 18 What is a virtual member function
                            • 19 How can C++ achieve dynamic binding yet also static typing
                            • 20 Whats the difference between how virtual and non-virtual member functions are called
                            • 21 When should my destructor be virtual
                            • 22 What is a virtual constructor
                            • Questions for ANSI-Knowledgeable Applicants

                          2 What are the different methods to pass an argument from one page to another

                          Using Query string Using Hidden controls

                          NET

                          1 How NET My Services work

                          From the developers perspective NET My Services is a set of XML Web services accessed by sending and receiving SOAP messages sent though the HTTP or DIME protocols and using the NET Passport system for authentication NET My Services consists of three things Authentication which will be provided by NET Passport when NET My Services goes live SOAP the communication protocol XML following the rules and schemas set out in the XMI Reference which provides the data formatting and organization

                          2 What are Web Services

                          Web Services are applications delivered as a service on the Web Web services allow for programmatic access of business logic over the Web Web services typically rely on XML-based protocols messages and interface descriptions for communication and access Web services are designed to be used by other programs or applications rather than directly by end user Programs invoking a Web service are called clients SOAP over HTTP is the most commonly used protocol for invoking Web services

                          3 How do I use a proxy server when invoking a Web service

                          If you are using the SOAP Toolkit you need to set some connector properties to use a proxy server Dim soap As SoapClient Set soap=New SoapClient soapConnectorProperty(ProxyServer) = ldquoproxyservernamerdquo soapConnectorProperty(ProxyPort) = ldquo8080rdquo soapConnectorProperty(UseProxy) = True While with NET you just need to create a SystemNetWebProxy object and use it to set the Proxy property Dim webs As localhostMyService() websProxy=New SystemNetWebProxy(ldquohttpproxyserver8080rdquo)

                          4 What is Simple Object Access Protocol (SOAP)

                          SOAP is an XML-based messaging framework specifically designed for exchanging formatted data across the Internet for example using request and reply messages or sending entire documents SOAP is simple easy to use and completely neutral with respect to operating system programming language or

                          distributed computing platform

                          5 What is Web Services Description Language (WSDL)

                          After SOAP became available as a mechanism for exchanging XML messages among enterprises (or among disparate applications within the same enterprise) a better way was needed to describe the messages and how they are exchanged The Web Services Description Language (WSDL) is a particular form of an XML Schema developed by Microsoft and IBM for the purpose of defining the XML message operation and protocol mapping of a web service accessed using SOAP or other XML protocol WSDL defines web services in terms of endpoints that operate on XML messages The WSDL syntax allows both the messages and the operations on the messages to be defined abstractly so they can be mapped to multiple physical implementations The current WSDL spec describes how to map messages and operations to SOAP 11 HTTP GETPOST and MIME WSDL creates web service definitions by mapping a group of endpoints into a logical sequence of operations on XML messages The same XML message can be mapped to multiple operations (or services) and bound to one or more communications protocols (using ports)

                          6 What is Universal Description Discovery and Integration (UDDI)

                          The Universal Description Discovery and Integration (UDDI) framework defines a data model (in XML) and SOAP APIs for registration and searches on business information including the web services a business exposes to the Internet UDDI is an independent consortium of vendors founded by Microsoft IBM and Ariba for the purpose of developing an Internet standard for web service description registration and discovery Microsoft IBM and Ariba also are hosting the initial deployment of a UDDI service which is conceptually patterned after DNS (the Internet service that translates URLs into TCP addresses) UDDI uses a private agreement profile of SOAP (ie UDDI doesnt use the SOAP serialization format because its not well suited to passing complete XML documents (its aimed at RPC style interactions) The main idea is that businesses use the SOAP APIs to register themselves with UDDI and other businesses search UDDI when they want to discover a trading partner for example someone from whom they wish to procure sheet metal bolts or transistors The information in UDDI is categorized according to industry type and geographical location allowing UDDI consumers to search through lists of potentially matching businesses to find the specific one they want to contact Once a specific business is chosen another call to UDDI is made to obtain the specific contact information for that business The contact information includes a pointer to the target businesss WSDL or other XML schema file describing the web service that the target business publishes

                          The interviewer should be well versed in NET to ask these questions The interview should know the answers

                          Execution cycle of an assembly How does CLR comes into picture- Platform independence

                          Managed unmanaged code Information about GAC How does GAC help in maintaining different versions of an assembly if

                          changes are made to an assembly and the new version does not support some of functionality that previous version supported how will the runtime handle ito What is the sequence of steps followed by the runtime to look for the

                          references like first to bin then GAC etco How to add assemblies in GAC

                          How do we use MTS capabilities in NET assemblies Different type of data persistence in NET

                          o Caching Data caching Output caching

                          o Serialization Xml Bin

                          Usercontrols vc Custom Controls ndash Composite controls Datareader vs Dataset Sorting in Datagrid adding custom controls in datagrid columns Use of view state in ASPX pages How to improve performance of the pages in web environment Is it possible to have both client side and server side functionality on aspx

                          server controls In the page execution life cycle when is the page_init called What is AutoEventWireUp attribute used for What are delegates used for Webservices

                          o How do you deploy web services Reflections Remoting

                          o What is client activated objects and what are server activated objectso What are channels used for

                          Interopo How does a NET component call a primitive one What are the steps taken

                          General Scripting Questions

                          1 How do you add a quotation mark to VB script string

                          The first method uses two quotation marks in a row to create a single quotation mark The second method uses the ASCII value of the quotation mark character

                          2 How do you break a single VBScript Statement into multiple lines

                          A single VBScript Statement can be broken into multiple lines by using the _underscore character

                          3 What is the proper method of comparing strings in VBScript

                          The first method uses VBScript function with the vbTextCompare constant The second method forces both strings into uppercase

                          4 How do you re-enable errors after using ON ERROR RESUME NEXT

                          ltlt Need an answer gtgt

                          5 How do you prevent My Script from timing out

                          You can extend the amount of time a script is allowed to run by using the ScriptTimeout property of the Server object

                          6 When do you need to explicitly convert a variable to a particular data type

                          If you are comparing numbers or dates and there is a danger that VBScript might interpret the values as strings one of the VBScript conversion functions should be used

                          7 When should one pass a variable by value and when by reference

                          When you pass a variable by value to a subordinate or function a new instance of the variable is created Any changes made to the value of the variable do not affect the value of the original variable On the other hand whne you pass a variable by reference changes made to the variable do affect the value of the original variable

                          8 How can you add a space between the output of two variables

                          ltlt Need an answer gtgt

                          9 Does ASP support dynamic includes

                          It does not support

                          10 How do you use the option Explicit statement in an ASP

                          It must be used before nay other VBScript statement or HTML content in a script else it will generate and error

                          Session and Application Variable Questions

                          1 Why do session variables sometimes fail to work

                          Session variables depend on browser cookies If a browser does not support cookies or a user has turned off cookies or the userrsquos cookie file is corrupted Session variables will not work

                          2 How do you remove an application variable

                          ltlt Need an answer gtgt

                          3 How do you detect whether a File exists

                          I can detect by using the FileExists method of the FileSystemObject

                          4 How do you automatically display a list of the Files in a directory

                          By using a list of files in a folder by using the FileSystemObject and the Folder object

                          Image Questions

                          1 How do you store an image in a database table

                          Although you can store an image in a SQL Server BLOB column it is almost always better to store the URL of an image in a database table rather than the image itself

                          2 How do you dynamically generate a graph or image in an ASP

                          Several third-party ASP components enable you to dynamically create custom images

                          Browser Questions

                          1 How do you detect the type of browser a person is using to visit your web site

                          The User-Agent header indicates the type of browser

                          2 How do you detect a page from which a person originated

                          The Referer header contains the URL of the last page the person visited This header can be retrieved from the ServerVariables collection

                          ActiveX Data Objects Questions

                          1 Why do you sometimes receive an error when using the Connection Object to execute a SQL string

                          ltlt Need an answer gtgt

                          2 How do you retrieve a Text filed in an ASP

                          If you do not take special precautions when retrieving a Text field from a database table the value of the Text field might be truncated If you are using a forward-only cursor type you should use the Text field as the very last field in your select list Alternatively consider using a richer cursor type when opening a Recordset that contains a Text field

                          3 Why does the RecordCount always return the Value-1

                          The RecordCount property returns the number of rows in a Recordset after it has been opened you cannot use this property with a forward-only cursor when using SQL Server (it will always return ndash1)

                          4 Why do you receive an error whenever you try to update the value of a filed in a recordset

                          By default when you open a Recordset it is opened with a forward-only cursor and read-only lock type To update a Recordset you must open a Recordset that is not read-only

                          5 How do you limit the number of rows returned by a Database Query

                          If using SQL 70 or Access you can use the SQL Top keyword to limit the number of records returned Otherwise if you are using SQL 65 use the MaxRecords property of the Recordset object

                          ltlt What about SQL 2000 gtgt

                          6 How do you retrieve the value from a SQL Statement that uses Count() Max Min or Identity

                          There are two methods that you can use to retrieve the value from a SQL function or a SQL global variable You can either use an alias for the value or refer to the value by its ordinal position in the Recordset

                          7 How do you retrieve an output parameter from a SQL stored procedure within an ASPScript

                          You must use the ADO Command nad parameter objects

                          Form and Query String Questions

                          1 How do you accept file uploads in an HTML form

                          ltlt Need an answer gtgt

                          2 What causes the value of a form field to become truncated

                          HTML uses quotation marks to mark the beginning and end of a value So If a variable contains question marks in its values the value of the variablewill be truncated when displayed

                          3 How do you include spaces or other special characters in a query string

                          URL encode the query string

                          C++ Questions

                          1 What is an object in C++

                          An object is a package that contains related data and instructions The data relates to what the object represents while the instructions define how this object relates to other objects and itself

                          2 What is a message

                          A message is a signal from one object to another requesting that a computation take place It is roughly equivalent to a function call in other languages

                          3 What is a class

                          A class defines the characteristics of a certain type of object It defines what its members will remember the messages to which they will respond and what form the response will take

                          4 What is an instance

                          It is an individual object that is a member of some class

                          5 What is a super-class

                          Given a class a super-class is the basis of the class under consideration The given class is defined as a subset (in some respects) of the super-class All objects of the given class potentially posses all the characteristics belonging to objects of the super-class

                          6 What is inheritance

                          Inheritance is property such that a parent (or super) class passes the characteristics of itself to children (or sub) classes that are derived from it The sub-class has the option of modifying these characteristics in order to make a different but fundamentally related class from the super-class

                          7 To what does message protocol refer

                          An objects message protocol is the exact form of the set of messages to which the object can respond

                          8 What is polymorphism

                          Polymorphism refers to the ability of an object to respond in a logically identical fashion to messages of the same protocol containing differing types of objects Consider 1 + 5 and 1 + 51 In the former the message + 5 is sent to an object of class integer (1) In the later the message + 51 is sent to the same integer object The form of the message (its protocol) is identical in both cases What differs is the type of object on the right-hand side of these messages The former is an integer object (5) while the later is a floating point object (51) The receiver (1) appears (to other objects) to respond in the same way to both messages Internally however it knows that it must treat the two types of objects differently in order to obtain the same overall response

                          9 What are instance variables

                          These represent an objects private memory They are defined in an objects class

                          18 What is a virtual member function

                          A virtual function allows derived classes to replace the implementation provided by the base class The compiler makes sure the replacement is always called whenever the object in question is actually of the derived class even if the object is accessed by a base pointer rather than a derived pointer This allows algorithms in the base class to be replaced in the derived class even if users dont know about the derived class

                          The derived class can either fully replace (override) the base class member function or the derived class can partially replace (augment) the base class member function The latter is accomplished by having the derived class member function call the base class member function if desired

                          19 How can C++ achieve dynamic binding yet also static typing

                          When you have a pointer to an object the object may actually be of a class that is derived from the class of the pointer (eg a Vehicle that is actually pointing to a Car object) Thus there are two types the (static) type of the pointer (Vehicle in this case) and the (dynamic) type of the pointed-to object (Car in this case)

                          Static typing means that the legality of a member function invocation is checked at the earliest possible moment by the compiler at compile time The compiler uses the static type of the pointer to determine whether the member function invocation is legal If the type of the pointer can handle the member function certainly the pointed-to object can handle it as well Eg if Vehicle has a certain member function certainly Car also has that member function since Car is a kind-of Vehicle

                          Dynamic binding means that the address of the code in a member function invocation is determined at the last possible moment based on the dynamic type of the object at run time It is called dynamic binding because the binding to the code that actually gets called is accomplished dynamically (at run time) Dynamic binding is a result of virtual functions

                          20 Whats the difference between how virtual and non-virtual member functions are called

                          Non-virtual member functions are resolved statically That is the member function is selected statically (at compile-time) based on the type of the pointer (or reference) to the object

                          In contrast virtual member functions are resolved dynamically (at run-time) That is the member function is selected dynamically (at run-time) based on the type of the object not the type of the pointerreference to that object This is called dynamic binding Most compilers use some variant of the following technique

                          if the object has one or more virtual functions the compiler puts a hidden pointer in the object called a virtual-pointer or v-pointer This v-pointer points to a global table called the virtual-table or v-table

                          The compiler creates a v-table for each class that has at least one virtual function For example if class Circle has virtual functions for draw() and move() and resize() there would be exactly one v-table associated with class Circle even if there were a gazillion Circle objects and the v-pointer of each of those Circle objects would point to the Circle v-table The v-table itself has pointers to each of the virtual functions in the class For example the Circle v-table would have three pointers a pointer to Circledraw() a pointer to Circlemove() and a pointer to Circleresize()

                          During a dispatch of a virtual function the run-time system follows the objects v-pointer to the classs v-table then follows the appropriate slot in the v-table to the method code

                          The space-cost overhead of the above technique is nominal an extra pointer per object (but only for objects that will need to do dynamic binding) plus an extra pointer per method (but only for virtual methods) The time-cost overhead is also fairly nominal compared to a normal function call a virtual function call requires two extra fetches (one to get the value of the v-pointer a second to get the address of the method) None of this runtime activity happens with non-virtual functions since the compiler resolves non-virtual functions exclusively at compile-time based on the type of the pointer

                          21 When should my destructor be virtual

                          When you may delete a derived object via a base pointer

                          virtual functions bind to the code associated with the class of the object rather than with the class of the pointerreference When you say delete basePtr and the base class has a virtual destructor the destructor that gets invoked is the one associated with the type of the object basePtr rather than the one associated with the type of the pointer This is generally A Good Thing

                          TECHNO-GEEK WARNING PUT YOUR PROPELLER HAT ON Technically speaking you need a base classs destructor to be virtual if and only if you intend to allow someone to invoke an objects destructor via a base class pointer (this is normally done implicitly via delete) and the object being destructed is of a derived class that has a non-trivial destructor A class has a non-trivial destructor if it either has an explicit destructor or if it has a member object or a base class that has a non-trivial destructor (note that this is a recursive definition (eg a class has a non-trivial destructor if it has a member object (which has a base class (which has a member object (which has a base class (which has an explicit destructor)))))) END TECHNO-GEEK WARNING REMOVE YOUR PROPELLER HAT

                          If you had a hard grokking the previous rule try this (over)simplified one on for size A class should have a virtual destructor unless that class has no virtual functions Rationale if you have any virtual functions at all youre probably going to be doing stuff to derived objects via a base pointer and some of the stuff you may do may include invoking a destructor (normally done implicitly via delete) Plus once youve put the first virtual function into a class youve already paid all the per-object space cost that youll ever pay (one pointer per object note that this is theoretically compiler-specific in practice everyone does it pretty much the same way) so making the destructor virtual wont generally cost you anything extra

                          22 What is a virtual constructor

                          An idiom that allows you to do something that C++ doesnt directly support

                          You can get the effect of a virtual constructor by a virtual clone() member function (for copy constructing) or a virtual create() member function (for the default constructor)

                          class Shape public virtual ~Shape() A virtual destructor virtual void draw() = 0 A pure virtual function virtual void move() = 0 virtual Shape clone() const = 0 Uses the copy constructor virtual Shape create() const = 0 Uses the default constructor class Circle public Shape public Circle clone() const return new Circle(this) Circle create() const return new Circle()

                          In the clone() member function the new Circle(this) code calls Circles copy constructor to copy the state of this into the newly created Circle object In the create() member function the new Circle() code calls Circles default constructor

                          Users use these as if they were virtual constructors

                          void userCode(Shapeamp s) Shape s2 = sclone() Shape s3 = screate() delete s2 You probably need a virtual destructor here

                          delete s3

                          23 How do you link a C++ program to C functions

                          By using the extern C linkage specification around the C function declarations

                          24 Explain the scope resolution operator

                          The scope resolution operator permits a program to reference an identifier in the global scope that has been hidden by another identifier with the same name in the local scope

                          25 What are the differences between a C++ struct and C++ class

                          The default member and base class access specifiers are different

                          26 How many ways are there to initialize an int with a constant

                          Two

                          27 How does throwing and catching exceptions differ from using setjmp and longjmp

                          The throw operation calls the destructors for automatic objects instantiated since entry to the try block

                          28 How does throwing and catching exceptions differ from using setjmp and longjmp

                          The throw operation calls the destructors for automatic objects instantiated since entry to the try block

                          29 What is a default constructor

                          A constructor that has no arguments or one where all the arguments have default argument values

                          If you dont code a default constructor the compiler provides one if there are no other constructors If you are going to instantiate an array of objects of the class the class must have a default constructor

                          30 What is a conversion constructor

                          It is a constructor that accepts one argument of a different type

                          The compiler uses this idiom as one way to infer conversion rules for a class A constructor with more than one argument and with default argument values can be interpreted by the compiler as a conversion constructor when the compiler is looking for an object of the type and sees an object of the type of the constructors first argument

                          31 What is the difference between a copy constructor and an overloaded assignment operator

                          A copy constructor constructs a new object by using the content of the argument object An overloaded assignment operator assigns the contents of an existing object to another existing object of the same class

                          First you must know that a copy constructor is one that has only one argument which is a reference to the same type as the constructor The compiler invokes a copy constructor wherever it needs to make a copy of the object for example to pass an argument by value If you do not provide a copy constructor the compiler creates a member-by-member copy constructor for you

                          You can write overloaded assignment operators that take arguments of other classes but that behavior is usually implemented with implicit conversion constructors If you do not provide an overloaded assignment operator for the class the compiler creates a default member-by-member assignment operator

                          This discussion is a good place to get into why classes need copy constructors and overloaded assignment operators By discussing the requirements with respect to data member pointers that point to dynamically allocated resources you demonstrate a good grasp of the problem

                          32 When should you use multiple inheritance

                          There are three acceptable answers Never Rarely and When the problem domain cannot be accurately modeled any other way

                          33 What is a virtual destructor

                          The simple answer is that a virtual destructor is one that is declared with the virtual attribute

                          The behavior of a virtual destructor is what is important If you destroy an object through a pointer or reference to a base class and the base-class destructor is not virtual the derived-class destructors are not executed and the destruction might not be complete

                          34 Explain the ISA and HASA class relationships How would you implement each in a class design

                          A specialized class is a specialization of another class and therefore has the ISA relationship with the other class An Employee ISA Person This relationship is best implemented with inheritance Employee is derived from Person A class may have an instance of another class For example an Employee has a Salary therefore the Employee class has the HASA relationship with the Salary class This relationship is best implemented by embedding an object of the Salary class in the Employee class

                          The answer to this question reveals whether you have an understanding of the fundamentals of object-oriented design which is important to reliable class design

                          There are other relationships The USESA relationship is when one class uses the services of another The Employee class uses an object (cout) of the ostream class to display the employees name onscreen for example But if you get ISA and HASA right you usually dont need to go any further

                          35 When is a template a better solution than a base class

                          When you are designing a generic class to contain or otherwise manage objects of other types when the format and behavior of those other types are unimportant to their containment or management and particularly when those other types are unknown (thus the genericity) to the designer of the container or manager class

                          Prior to templates you had to use inheritance your design might include a generic List container class and an application-specific Employee class To put employees in a list a ListedEmployee class is multiply derived (contrived) from the Employee and List classes These solutions were unwieldy and error-prone Templates solved that problem

                          Questions for ANSI-Knowledgeable Applicants

                          There are six questions for those who profess knowledge of the progress of the ANSI committee If you claim to have that much interest in the language you should know the answers to all these questions

                          1 What is a mutable member

                          A mutable member is one that can be modified by the class even when the object of the class or the member function doing the modification is const

                          Understanding this requirement implies an understanding of C++ const which many programmers do not have I have seen large class designs that do not employ the const qualifier anywhere Some of those designs are my own early C++ efforts One author suggests that some programmers find const to be such a bother that it is easier to ignore const than to try to use it meaningfully No

                          wonder many programmers dont understand the power and implications of const Someone who claims to have enough interest in the language and its evolution to keep pace with the ANSI deliberations should not be ignorant of const however

                          2 What is an explicit constructor

                          A conversion constructor declared with the explicit keyword The compiler does not use an explicit constructor to implement an implied conversion of types Its purpose is reserved explicitly for construction

                          3 What is the Standard Template Library

                          It is a library of container templates approved by the ANSI committee for inclusion in the standard C++ specification

                          4 Describe run-time type identification

                          It is the ability to determine at run time the type of an object by using the typeid operator or the dynamic_cast operator

                          5 What problem does the namespace feature solve

                          Multiple providers of libraries might use common global identifiers causing a name collision when an application tries to link with two or more such libraries The name-space feature surrounds a librarys external declarations with a unique namespace that eliminates the potential for those collisions

                          This solution assumes that two library vendors dont use the same namespace of course

                          6 Are there any new intrinsic (built-in) data types

                          Yes The ANSI committee added the bool intrinsic type and its true and false value keywords and the wchar_t data type to support character sets wider than eight bits

                          SQL Server

                          1 What is a foreign key

                          A foreign key is a column or combination of columns used to establish and enforce a link (referential integrity) between the data in two tables A link is created between two tables by adding the column or columns that hold one tablersquos primary key values to the other table This column becomes a foreign key in the second table

                          2 What is the difference between a primary key and unique key

                          There can be only one primary key constrain on a table but there can be many unique key constraints in a table

                          Primary key doesnrsquot allow null values but Unique allows 1 Null value

                          3 What is an index

                          Indexes are database objects which provides faster data access The index provides pointers to the data values stored in specified columns of

                          the table and then orders those pointers according to the sort order you specify

                          Different types of indexes are unique index clustered index and non-clustered index

                          4 How to return multiple result set from a stored proc and capture it in ADO

                          Use multiple Select statements to return multiple result sets Use ADOrsquos GetNextRecordset() method to get the second recordset during the

                          execution of the stored proc

                          • COMDCOM
                          • Visual Basic
                          • General Scripting Questions
                          • Session and Application Variable Questions
                            • Image Questions
                            • Browser Questions
                            • ActiveX Data Objects Questions
                            • Form and Query String Questions
                              • 18 What is a virtual member function
                              • 19 How can C++ achieve dynamic binding yet also static typing
                              • 20 Whats the difference between how virtual and non-virtual member functions are called
                              • 21 When should my destructor be virtual
                              • 22 What is a virtual constructor
                              • Questions for ANSI-Knowledgeable Applicants

                            distributed computing platform

                            5 What is Web Services Description Language (WSDL)

                            After SOAP became available as a mechanism for exchanging XML messages among enterprises (or among disparate applications within the same enterprise) a better way was needed to describe the messages and how they are exchanged The Web Services Description Language (WSDL) is a particular form of an XML Schema developed by Microsoft and IBM for the purpose of defining the XML message operation and protocol mapping of a web service accessed using SOAP or other XML protocol WSDL defines web services in terms of endpoints that operate on XML messages The WSDL syntax allows both the messages and the operations on the messages to be defined abstractly so they can be mapped to multiple physical implementations The current WSDL spec describes how to map messages and operations to SOAP 11 HTTP GETPOST and MIME WSDL creates web service definitions by mapping a group of endpoints into a logical sequence of operations on XML messages The same XML message can be mapped to multiple operations (or services) and bound to one or more communications protocols (using ports)

                            6 What is Universal Description Discovery and Integration (UDDI)

                            The Universal Description Discovery and Integration (UDDI) framework defines a data model (in XML) and SOAP APIs for registration and searches on business information including the web services a business exposes to the Internet UDDI is an independent consortium of vendors founded by Microsoft IBM and Ariba for the purpose of developing an Internet standard for web service description registration and discovery Microsoft IBM and Ariba also are hosting the initial deployment of a UDDI service which is conceptually patterned after DNS (the Internet service that translates URLs into TCP addresses) UDDI uses a private agreement profile of SOAP (ie UDDI doesnt use the SOAP serialization format because its not well suited to passing complete XML documents (its aimed at RPC style interactions) The main idea is that businesses use the SOAP APIs to register themselves with UDDI and other businesses search UDDI when they want to discover a trading partner for example someone from whom they wish to procure sheet metal bolts or transistors The information in UDDI is categorized according to industry type and geographical location allowing UDDI consumers to search through lists of potentially matching businesses to find the specific one they want to contact Once a specific business is chosen another call to UDDI is made to obtain the specific contact information for that business The contact information includes a pointer to the target businesss WSDL or other XML schema file describing the web service that the target business publishes

                            The interviewer should be well versed in NET to ask these questions The interview should know the answers

                            Execution cycle of an assembly How does CLR comes into picture- Platform independence

                            Managed unmanaged code Information about GAC How does GAC help in maintaining different versions of an assembly if

                            changes are made to an assembly and the new version does not support some of functionality that previous version supported how will the runtime handle ito What is the sequence of steps followed by the runtime to look for the

                            references like first to bin then GAC etco How to add assemblies in GAC

                            How do we use MTS capabilities in NET assemblies Different type of data persistence in NET

                            o Caching Data caching Output caching

                            o Serialization Xml Bin

                            Usercontrols vc Custom Controls ndash Composite controls Datareader vs Dataset Sorting in Datagrid adding custom controls in datagrid columns Use of view state in ASPX pages How to improve performance of the pages in web environment Is it possible to have both client side and server side functionality on aspx

                            server controls In the page execution life cycle when is the page_init called What is AutoEventWireUp attribute used for What are delegates used for Webservices

                            o How do you deploy web services Reflections Remoting

                            o What is client activated objects and what are server activated objectso What are channels used for

                            Interopo How does a NET component call a primitive one What are the steps taken

                            General Scripting Questions

                            1 How do you add a quotation mark to VB script string

                            The first method uses two quotation marks in a row to create a single quotation mark The second method uses the ASCII value of the quotation mark character

                            2 How do you break a single VBScript Statement into multiple lines

                            A single VBScript Statement can be broken into multiple lines by using the _underscore character

                            3 What is the proper method of comparing strings in VBScript

                            The first method uses VBScript function with the vbTextCompare constant The second method forces both strings into uppercase

                            4 How do you re-enable errors after using ON ERROR RESUME NEXT

                            ltlt Need an answer gtgt

                            5 How do you prevent My Script from timing out

                            You can extend the amount of time a script is allowed to run by using the ScriptTimeout property of the Server object

                            6 When do you need to explicitly convert a variable to a particular data type

                            If you are comparing numbers or dates and there is a danger that VBScript might interpret the values as strings one of the VBScript conversion functions should be used

                            7 When should one pass a variable by value and when by reference

                            When you pass a variable by value to a subordinate or function a new instance of the variable is created Any changes made to the value of the variable do not affect the value of the original variable On the other hand whne you pass a variable by reference changes made to the variable do affect the value of the original variable

                            8 How can you add a space between the output of two variables

                            ltlt Need an answer gtgt

                            9 Does ASP support dynamic includes

                            It does not support

                            10 How do you use the option Explicit statement in an ASP

                            It must be used before nay other VBScript statement or HTML content in a script else it will generate and error

                            Session and Application Variable Questions

                            1 Why do session variables sometimes fail to work

                            Session variables depend on browser cookies If a browser does not support cookies or a user has turned off cookies or the userrsquos cookie file is corrupted Session variables will not work

                            2 How do you remove an application variable

                            ltlt Need an answer gtgt

                            3 How do you detect whether a File exists

                            I can detect by using the FileExists method of the FileSystemObject

                            4 How do you automatically display a list of the Files in a directory

                            By using a list of files in a folder by using the FileSystemObject and the Folder object

                            Image Questions

                            1 How do you store an image in a database table

                            Although you can store an image in a SQL Server BLOB column it is almost always better to store the URL of an image in a database table rather than the image itself

                            2 How do you dynamically generate a graph or image in an ASP

                            Several third-party ASP components enable you to dynamically create custom images

                            Browser Questions

                            1 How do you detect the type of browser a person is using to visit your web site

                            The User-Agent header indicates the type of browser

                            2 How do you detect a page from which a person originated

                            The Referer header contains the URL of the last page the person visited This header can be retrieved from the ServerVariables collection

                            ActiveX Data Objects Questions

                            1 Why do you sometimes receive an error when using the Connection Object to execute a SQL string

                            ltlt Need an answer gtgt

                            2 How do you retrieve a Text filed in an ASP

                            If you do not take special precautions when retrieving a Text field from a database table the value of the Text field might be truncated If you are using a forward-only cursor type you should use the Text field as the very last field in your select list Alternatively consider using a richer cursor type when opening a Recordset that contains a Text field

                            3 Why does the RecordCount always return the Value-1

                            The RecordCount property returns the number of rows in a Recordset after it has been opened you cannot use this property with a forward-only cursor when using SQL Server (it will always return ndash1)

                            4 Why do you receive an error whenever you try to update the value of a filed in a recordset

                            By default when you open a Recordset it is opened with a forward-only cursor and read-only lock type To update a Recordset you must open a Recordset that is not read-only

                            5 How do you limit the number of rows returned by a Database Query

                            If using SQL 70 or Access you can use the SQL Top keyword to limit the number of records returned Otherwise if you are using SQL 65 use the MaxRecords property of the Recordset object

                            ltlt What about SQL 2000 gtgt

                            6 How do you retrieve the value from a SQL Statement that uses Count() Max Min or Identity

                            There are two methods that you can use to retrieve the value from a SQL function or a SQL global variable You can either use an alias for the value or refer to the value by its ordinal position in the Recordset

                            7 How do you retrieve an output parameter from a SQL stored procedure within an ASPScript

                            You must use the ADO Command nad parameter objects

                            Form and Query String Questions

                            1 How do you accept file uploads in an HTML form

                            ltlt Need an answer gtgt

                            2 What causes the value of a form field to become truncated

                            HTML uses quotation marks to mark the beginning and end of a value So If a variable contains question marks in its values the value of the variablewill be truncated when displayed

                            3 How do you include spaces or other special characters in a query string

                            URL encode the query string

                            C++ Questions

                            1 What is an object in C++

                            An object is a package that contains related data and instructions The data relates to what the object represents while the instructions define how this object relates to other objects and itself

                            2 What is a message

                            A message is a signal from one object to another requesting that a computation take place It is roughly equivalent to a function call in other languages

                            3 What is a class

                            A class defines the characteristics of a certain type of object It defines what its members will remember the messages to which they will respond and what form the response will take

                            4 What is an instance

                            It is an individual object that is a member of some class

                            5 What is a super-class

                            Given a class a super-class is the basis of the class under consideration The given class is defined as a subset (in some respects) of the super-class All objects of the given class potentially posses all the characteristics belonging to objects of the super-class

                            6 What is inheritance

                            Inheritance is property such that a parent (or super) class passes the characteristics of itself to children (or sub) classes that are derived from it The sub-class has the option of modifying these characteristics in order to make a different but fundamentally related class from the super-class

                            7 To what does message protocol refer

                            An objects message protocol is the exact form of the set of messages to which the object can respond

                            8 What is polymorphism

                            Polymorphism refers to the ability of an object to respond in a logically identical fashion to messages of the same protocol containing differing types of objects Consider 1 + 5 and 1 + 51 In the former the message + 5 is sent to an object of class integer (1) In the later the message + 51 is sent to the same integer object The form of the message (its protocol) is identical in both cases What differs is the type of object on the right-hand side of these messages The former is an integer object (5) while the later is a floating point object (51) The receiver (1) appears (to other objects) to respond in the same way to both messages Internally however it knows that it must treat the two types of objects differently in order to obtain the same overall response

                            9 What are instance variables

                            These represent an objects private memory They are defined in an objects class

                            18 What is a virtual member function

                            A virtual function allows derived classes to replace the implementation provided by the base class The compiler makes sure the replacement is always called whenever the object in question is actually of the derived class even if the object is accessed by a base pointer rather than a derived pointer This allows algorithms in the base class to be replaced in the derived class even if users dont know about the derived class

                            The derived class can either fully replace (override) the base class member function or the derived class can partially replace (augment) the base class member function The latter is accomplished by having the derived class member function call the base class member function if desired

                            19 How can C++ achieve dynamic binding yet also static typing

                            When you have a pointer to an object the object may actually be of a class that is derived from the class of the pointer (eg a Vehicle that is actually pointing to a Car object) Thus there are two types the (static) type of the pointer (Vehicle in this case) and the (dynamic) type of the pointed-to object (Car in this case)

                            Static typing means that the legality of a member function invocation is checked at the earliest possible moment by the compiler at compile time The compiler uses the static type of the pointer to determine whether the member function invocation is legal If the type of the pointer can handle the member function certainly the pointed-to object can handle it as well Eg if Vehicle has a certain member function certainly Car also has that member function since Car is a kind-of Vehicle

                            Dynamic binding means that the address of the code in a member function invocation is determined at the last possible moment based on the dynamic type of the object at run time It is called dynamic binding because the binding to the code that actually gets called is accomplished dynamically (at run time) Dynamic binding is a result of virtual functions

                            20 Whats the difference between how virtual and non-virtual member functions are called

                            Non-virtual member functions are resolved statically That is the member function is selected statically (at compile-time) based on the type of the pointer (or reference) to the object

                            In contrast virtual member functions are resolved dynamically (at run-time) That is the member function is selected dynamically (at run-time) based on the type of the object not the type of the pointerreference to that object This is called dynamic binding Most compilers use some variant of the following technique

                            if the object has one or more virtual functions the compiler puts a hidden pointer in the object called a virtual-pointer or v-pointer This v-pointer points to a global table called the virtual-table or v-table

                            The compiler creates a v-table for each class that has at least one virtual function For example if class Circle has virtual functions for draw() and move() and resize() there would be exactly one v-table associated with class Circle even if there were a gazillion Circle objects and the v-pointer of each of those Circle objects would point to the Circle v-table The v-table itself has pointers to each of the virtual functions in the class For example the Circle v-table would have three pointers a pointer to Circledraw() a pointer to Circlemove() and a pointer to Circleresize()

                            During a dispatch of a virtual function the run-time system follows the objects v-pointer to the classs v-table then follows the appropriate slot in the v-table to the method code

                            The space-cost overhead of the above technique is nominal an extra pointer per object (but only for objects that will need to do dynamic binding) plus an extra pointer per method (but only for virtual methods) The time-cost overhead is also fairly nominal compared to a normal function call a virtual function call requires two extra fetches (one to get the value of the v-pointer a second to get the address of the method) None of this runtime activity happens with non-virtual functions since the compiler resolves non-virtual functions exclusively at compile-time based on the type of the pointer

                            21 When should my destructor be virtual

                            When you may delete a derived object via a base pointer

                            virtual functions bind to the code associated with the class of the object rather than with the class of the pointerreference When you say delete basePtr and the base class has a virtual destructor the destructor that gets invoked is the one associated with the type of the object basePtr rather than the one associated with the type of the pointer This is generally A Good Thing

                            TECHNO-GEEK WARNING PUT YOUR PROPELLER HAT ON Technically speaking you need a base classs destructor to be virtual if and only if you intend to allow someone to invoke an objects destructor via a base class pointer (this is normally done implicitly via delete) and the object being destructed is of a derived class that has a non-trivial destructor A class has a non-trivial destructor if it either has an explicit destructor or if it has a member object or a base class that has a non-trivial destructor (note that this is a recursive definition (eg a class has a non-trivial destructor if it has a member object (which has a base class (which has a member object (which has a base class (which has an explicit destructor)))))) END TECHNO-GEEK WARNING REMOVE YOUR PROPELLER HAT

                            If you had a hard grokking the previous rule try this (over)simplified one on for size A class should have a virtual destructor unless that class has no virtual functions Rationale if you have any virtual functions at all youre probably going to be doing stuff to derived objects via a base pointer and some of the stuff you may do may include invoking a destructor (normally done implicitly via delete) Plus once youve put the first virtual function into a class youve already paid all the per-object space cost that youll ever pay (one pointer per object note that this is theoretically compiler-specific in practice everyone does it pretty much the same way) so making the destructor virtual wont generally cost you anything extra

                            22 What is a virtual constructor

                            An idiom that allows you to do something that C++ doesnt directly support

                            You can get the effect of a virtual constructor by a virtual clone() member function (for copy constructing) or a virtual create() member function (for the default constructor)

                            class Shape public virtual ~Shape() A virtual destructor virtual void draw() = 0 A pure virtual function virtual void move() = 0 virtual Shape clone() const = 0 Uses the copy constructor virtual Shape create() const = 0 Uses the default constructor class Circle public Shape public Circle clone() const return new Circle(this) Circle create() const return new Circle()

                            In the clone() member function the new Circle(this) code calls Circles copy constructor to copy the state of this into the newly created Circle object In the create() member function the new Circle() code calls Circles default constructor

                            Users use these as if they were virtual constructors

                            void userCode(Shapeamp s) Shape s2 = sclone() Shape s3 = screate() delete s2 You probably need a virtual destructor here

                            delete s3

                            23 How do you link a C++ program to C functions

                            By using the extern C linkage specification around the C function declarations

                            24 Explain the scope resolution operator

                            The scope resolution operator permits a program to reference an identifier in the global scope that has been hidden by another identifier with the same name in the local scope

                            25 What are the differences between a C++ struct and C++ class

                            The default member and base class access specifiers are different

                            26 How many ways are there to initialize an int with a constant

                            Two

                            27 How does throwing and catching exceptions differ from using setjmp and longjmp

                            The throw operation calls the destructors for automatic objects instantiated since entry to the try block

                            28 How does throwing and catching exceptions differ from using setjmp and longjmp

                            The throw operation calls the destructors for automatic objects instantiated since entry to the try block

                            29 What is a default constructor

                            A constructor that has no arguments or one where all the arguments have default argument values

                            If you dont code a default constructor the compiler provides one if there are no other constructors If you are going to instantiate an array of objects of the class the class must have a default constructor

                            30 What is a conversion constructor

                            It is a constructor that accepts one argument of a different type

                            The compiler uses this idiom as one way to infer conversion rules for a class A constructor with more than one argument and with default argument values can be interpreted by the compiler as a conversion constructor when the compiler is looking for an object of the type and sees an object of the type of the constructors first argument

                            31 What is the difference between a copy constructor and an overloaded assignment operator

                            A copy constructor constructs a new object by using the content of the argument object An overloaded assignment operator assigns the contents of an existing object to another existing object of the same class

                            First you must know that a copy constructor is one that has only one argument which is a reference to the same type as the constructor The compiler invokes a copy constructor wherever it needs to make a copy of the object for example to pass an argument by value If you do not provide a copy constructor the compiler creates a member-by-member copy constructor for you

                            You can write overloaded assignment operators that take arguments of other classes but that behavior is usually implemented with implicit conversion constructors If you do not provide an overloaded assignment operator for the class the compiler creates a default member-by-member assignment operator

                            This discussion is a good place to get into why classes need copy constructors and overloaded assignment operators By discussing the requirements with respect to data member pointers that point to dynamically allocated resources you demonstrate a good grasp of the problem

                            32 When should you use multiple inheritance

                            There are three acceptable answers Never Rarely and When the problem domain cannot be accurately modeled any other way

                            33 What is a virtual destructor

                            The simple answer is that a virtual destructor is one that is declared with the virtual attribute

                            The behavior of a virtual destructor is what is important If you destroy an object through a pointer or reference to a base class and the base-class destructor is not virtual the derived-class destructors are not executed and the destruction might not be complete

                            34 Explain the ISA and HASA class relationships How would you implement each in a class design

                            A specialized class is a specialization of another class and therefore has the ISA relationship with the other class An Employee ISA Person This relationship is best implemented with inheritance Employee is derived from Person A class may have an instance of another class For example an Employee has a Salary therefore the Employee class has the HASA relationship with the Salary class This relationship is best implemented by embedding an object of the Salary class in the Employee class

                            The answer to this question reveals whether you have an understanding of the fundamentals of object-oriented design which is important to reliable class design

                            There are other relationships The USESA relationship is when one class uses the services of another The Employee class uses an object (cout) of the ostream class to display the employees name onscreen for example But if you get ISA and HASA right you usually dont need to go any further

                            35 When is a template a better solution than a base class

                            When you are designing a generic class to contain or otherwise manage objects of other types when the format and behavior of those other types are unimportant to their containment or management and particularly when those other types are unknown (thus the genericity) to the designer of the container or manager class

                            Prior to templates you had to use inheritance your design might include a generic List container class and an application-specific Employee class To put employees in a list a ListedEmployee class is multiply derived (contrived) from the Employee and List classes These solutions were unwieldy and error-prone Templates solved that problem

                            Questions for ANSI-Knowledgeable Applicants

                            There are six questions for those who profess knowledge of the progress of the ANSI committee If you claim to have that much interest in the language you should know the answers to all these questions

                            1 What is a mutable member

                            A mutable member is one that can be modified by the class even when the object of the class or the member function doing the modification is const

                            Understanding this requirement implies an understanding of C++ const which many programmers do not have I have seen large class designs that do not employ the const qualifier anywhere Some of those designs are my own early C++ efforts One author suggests that some programmers find const to be such a bother that it is easier to ignore const than to try to use it meaningfully No

                            wonder many programmers dont understand the power and implications of const Someone who claims to have enough interest in the language and its evolution to keep pace with the ANSI deliberations should not be ignorant of const however

                            2 What is an explicit constructor

                            A conversion constructor declared with the explicit keyword The compiler does not use an explicit constructor to implement an implied conversion of types Its purpose is reserved explicitly for construction

                            3 What is the Standard Template Library

                            It is a library of container templates approved by the ANSI committee for inclusion in the standard C++ specification

                            4 Describe run-time type identification

                            It is the ability to determine at run time the type of an object by using the typeid operator or the dynamic_cast operator

                            5 What problem does the namespace feature solve

                            Multiple providers of libraries might use common global identifiers causing a name collision when an application tries to link with two or more such libraries The name-space feature surrounds a librarys external declarations with a unique namespace that eliminates the potential for those collisions

                            This solution assumes that two library vendors dont use the same namespace of course

                            6 Are there any new intrinsic (built-in) data types

                            Yes The ANSI committee added the bool intrinsic type and its true and false value keywords and the wchar_t data type to support character sets wider than eight bits

                            SQL Server

                            1 What is a foreign key

                            A foreign key is a column or combination of columns used to establish and enforce a link (referential integrity) between the data in two tables A link is created between two tables by adding the column or columns that hold one tablersquos primary key values to the other table This column becomes a foreign key in the second table

                            2 What is the difference between a primary key and unique key

                            There can be only one primary key constrain on a table but there can be many unique key constraints in a table

                            Primary key doesnrsquot allow null values but Unique allows 1 Null value

                            3 What is an index

                            Indexes are database objects which provides faster data access The index provides pointers to the data values stored in specified columns of

                            the table and then orders those pointers according to the sort order you specify

                            Different types of indexes are unique index clustered index and non-clustered index

                            4 How to return multiple result set from a stored proc and capture it in ADO

                            Use multiple Select statements to return multiple result sets Use ADOrsquos GetNextRecordset() method to get the second recordset during the

                            execution of the stored proc

                            • COMDCOM
                            • Visual Basic
                            • General Scripting Questions
                            • Session and Application Variable Questions
                              • Image Questions
                              • Browser Questions
                              • ActiveX Data Objects Questions
                              • Form and Query String Questions
                                • 18 What is a virtual member function
                                • 19 How can C++ achieve dynamic binding yet also static typing
                                • 20 Whats the difference between how virtual and non-virtual member functions are called
                                • 21 When should my destructor be virtual
                                • 22 What is a virtual constructor
                                • Questions for ANSI-Knowledgeable Applicants

                              The interviewer should be well versed in NET to ask these questions The interview should know the answers

                              Execution cycle of an assembly How does CLR comes into picture- Platform independence

                              Managed unmanaged code Information about GAC How does GAC help in maintaining different versions of an assembly if

                              changes are made to an assembly and the new version does not support some of functionality that previous version supported how will the runtime handle ito What is the sequence of steps followed by the runtime to look for the

                              references like first to bin then GAC etco How to add assemblies in GAC

                              How do we use MTS capabilities in NET assemblies Different type of data persistence in NET

                              o Caching Data caching Output caching

                              o Serialization Xml Bin

                              Usercontrols vc Custom Controls ndash Composite controls Datareader vs Dataset Sorting in Datagrid adding custom controls in datagrid columns Use of view state in ASPX pages How to improve performance of the pages in web environment Is it possible to have both client side and server side functionality on aspx

                              server controls In the page execution life cycle when is the page_init called What is AutoEventWireUp attribute used for What are delegates used for Webservices

                              o How do you deploy web services Reflections Remoting

                              o What is client activated objects and what are server activated objectso What are channels used for

                              Interopo How does a NET component call a primitive one What are the steps taken

                              General Scripting Questions

                              1 How do you add a quotation mark to VB script string

                              The first method uses two quotation marks in a row to create a single quotation mark The second method uses the ASCII value of the quotation mark character

                              2 How do you break a single VBScript Statement into multiple lines

                              A single VBScript Statement can be broken into multiple lines by using the _underscore character

                              3 What is the proper method of comparing strings in VBScript

                              The first method uses VBScript function with the vbTextCompare constant The second method forces both strings into uppercase

                              4 How do you re-enable errors after using ON ERROR RESUME NEXT

                              ltlt Need an answer gtgt

                              5 How do you prevent My Script from timing out

                              You can extend the amount of time a script is allowed to run by using the ScriptTimeout property of the Server object

                              6 When do you need to explicitly convert a variable to a particular data type

                              If you are comparing numbers or dates and there is a danger that VBScript might interpret the values as strings one of the VBScript conversion functions should be used

                              7 When should one pass a variable by value and when by reference

                              When you pass a variable by value to a subordinate or function a new instance of the variable is created Any changes made to the value of the variable do not affect the value of the original variable On the other hand whne you pass a variable by reference changes made to the variable do affect the value of the original variable

                              8 How can you add a space between the output of two variables

                              ltlt Need an answer gtgt

                              9 Does ASP support dynamic includes

                              It does not support

                              10 How do you use the option Explicit statement in an ASP

                              It must be used before nay other VBScript statement or HTML content in a script else it will generate and error

                              Session and Application Variable Questions

                              1 Why do session variables sometimes fail to work

                              Session variables depend on browser cookies If a browser does not support cookies or a user has turned off cookies or the userrsquos cookie file is corrupted Session variables will not work

                              2 How do you remove an application variable

                              ltlt Need an answer gtgt

                              3 How do you detect whether a File exists

                              I can detect by using the FileExists method of the FileSystemObject

                              4 How do you automatically display a list of the Files in a directory

                              By using a list of files in a folder by using the FileSystemObject and the Folder object

                              Image Questions

                              1 How do you store an image in a database table

                              Although you can store an image in a SQL Server BLOB column it is almost always better to store the URL of an image in a database table rather than the image itself

                              2 How do you dynamically generate a graph or image in an ASP

                              Several third-party ASP components enable you to dynamically create custom images

                              Browser Questions

                              1 How do you detect the type of browser a person is using to visit your web site

                              The User-Agent header indicates the type of browser

                              2 How do you detect a page from which a person originated

                              The Referer header contains the URL of the last page the person visited This header can be retrieved from the ServerVariables collection

                              ActiveX Data Objects Questions

                              1 Why do you sometimes receive an error when using the Connection Object to execute a SQL string

                              ltlt Need an answer gtgt

                              2 How do you retrieve a Text filed in an ASP

                              If you do not take special precautions when retrieving a Text field from a database table the value of the Text field might be truncated If you are using a forward-only cursor type you should use the Text field as the very last field in your select list Alternatively consider using a richer cursor type when opening a Recordset that contains a Text field

                              3 Why does the RecordCount always return the Value-1

                              The RecordCount property returns the number of rows in a Recordset after it has been opened you cannot use this property with a forward-only cursor when using SQL Server (it will always return ndash1)

                              4 Why do you receive an error whenever you try to update the value of a filed in a recordset

                              By default when you open a Recordset it is opened with a forward-only cursor and read-only lock type To update a Recordset you must open a Recordset that is not read-only

                              5 How do you limit the number of rows returned by a Database Query

                              If using SQL 70 or Access you can use the SQL Top keyword to limit the number of records returned Otherwise if you are using SQL 65 use the MaxRecords property of the Recordset object

                              ltlt What about SQL 2000 gtgt

                              6 How do you retrieve the value from a SQL Statement that uses Count() Max Min or Identity

                              There are two methods that you can use to retrieve the value from a SQL function or a SQL global variable You can either use an alias for the value or refer to the value by its ordinal position in the Recordset

                              7 How do you retrieve an output parameter from a SQL stored procedure within an ASPScript

                              You must use the ADO Command nad parameter objects

                              Form and Query String Questions

                              1 How do you accept file uploads in an HTML form

                              ltlt Need an answer gtgt

                              2 What causes the value of a form field to become truncated

                              HTML uses quotation marks to mark the beginning and end of a value So If a variable contains question marks in its values the value of the variablewill be truncated when displayed

                              3 How do you include spaces or other special characters in a query string

                              URL encode the query string

                              C++ Questions

                              1 What is an object in C++

                              An object is a package that contains related data and instructions The data relates to what the object represents while the instructions define how this object relates to other objects and itself

                              2 What is a message

                              A message is a signal from one object to another requesting that a computation take place It is roughly equivalent to a function call in other languages

                              3 What is a class

                              A class defines the characteristics of a certain type of object It defines what its members will remember the messages to which they will respond and what form the response will take

                              4 What is an instance

                              It is an individual object that is a member of some class

                              5 What is a super-class

                              Given a class a super-class is the basis of the class under consideration The given class is defined as a subset (in some respects) of the super-class All objects of the given class potentially posses all the characteristics belonging to objects of the super-class

                              6 What is inheritance

                              Inheritance is property such that a parent (or super) class passes the characteristics of itself to children (or sub) classes that are derived from it The sub-class has the option of modifying these characteristics in order to make a different but fundamentally related class from the super-class

                              7 To what does message protocol refer

                              An objects message protocol is the exact form of the set of messages to which the object can respond

                              8 What is polymorphism

                              Polymorphism refers to the ability of an object to respond in a logically identical fashion to messages of the same protocol containing differing types of objects Consider 1 + 5 and 1 + 51 In the former the message + 5 is sent to an object of class integer (1) In the later the message + 51 is sent to the same integer object The form of the message (its protocol) is identical in both cases What differs is the type of object on the right-hand side of these messages The former is an integer object (5) while the later is a floating point object (51) The receiver (1) appears (to other objects) to respond in the same way to both messages Internally however it knows that it must treat the two types of objects differently in order to obtain the same overall response

                              9 What are instance variables

                              These represent an objects private memory They are defined in an objects class

                              18 What is a virtual member function

                              A virtual function allows derived classes to replace the implementation provided by the base class The compiler makes sure the replacement is always called whenever the object in question is actually of the derived class even if the object is accessed by a base pointer rather than a derived pointer This allows algorithms in the base class to be replaced in the derived class even if users dont know about the derived class

                              The derived class can either fully replace (override) the base class member function or the derived class can partially replace (augment) the base class member function The latter is accomplished by having the derived class member function call the base class member function if desired

                              19 How can C++ achieve dynamic binding yet also static typing

                              When you have a pointer to an object the object may actually be of a class that is derived from the class of the pointer (eg a Vehicle that is actually pointing to a Car object) Thus there are two types the (static) type of the pointer (Vehicle in this case) and the (dynamic) type of the pointed-to object (Car in this case)

                              Static typing means that the legality of a member function invocation is checked at the earliest possible moment by the compiler at compile time The compiler uses the static type of the pointer to determine whether the member function invocation is legal If the type of the pointer can handle the member function certainly the pointed-to object can handle it as well Eg if Vehicle has a certain member function certainly Car also has that member function since Car is a kind-of Vehicle

                              Dynamic binding means that the address of the code in a member function invocation is determined at the last possible moment based on the dynamic type of the object at run time It is called dynamic binding because the binding to the code that actually gets called is accomplished dynamically (at run time) Dynamic binding is a result of virtual functions

                              20 Whats the difference between how virtual and non-virtual member functions are called

                              Non-virtual member functions are resolved statically That is the member function is selected statically (at compile-time) based on the type of the pointer (or reference) to the object

                              In contrast virtual member functions are resolved dynamically (at run-time) That is the member function is selected dynamically (at run-time) based on the type of the object not the type of the pointerreference to that object This is called dynamic binding Most compilers use some variant of the following technique

                              if the object has one or more virtual functions the compiler puts a hidden pointer in the object called a virtual-pointer or v-pointer This v-pointer points to a global table called the virtual-table or v-table

                              The compiler creates a v-table for each class that has at least one virtual function For example if class Circle has virtual functions for draw() and move() and resize() there would be exactly one v-table associated with class Circle even if there were a gazillion Circle objects and the v-pointer of each of those Circle objects would point to the Circle v-table The v-table itself has pointers to each of the virtual functions in the class For example the Circle v-table would have three pointers a pointer to Circledraw() a pointer to Circlemove() and a pointer to Circleresize()

                              During a dispatch of a virtual function the run-time system follows the objects v-pointer to the classs v-table then follows the appropriate slot in the v-table to the method code

                              The space-cost overhead of the above technique is nominal an extra pointer per object (but only for objects that will need to do dynamic binding) plus an extra pointer per method (but only for virtual methods) The time-cost overhead is also fairly nominal compared to a normal function call a virtual function call requires two extra fetches (one to get the value of the v-pointer a second to get the address of the method) None of this runtime activity happens with non-virtual functions since the compiler resolves non-virtual functions exclusively at compile-time based on the type of the pointer

                              21 When should my destructor be virtual

                              When you may delete a derived object via a base pointer

                              virtual functions bind to the code associated with the class of the object rather than with the class of the pointerreference When you say delete basePtr and the base class has a virtual destructor the destructor that gets invoked is the one associated with the type of the object basePtr rather than the one associated with the type of the pointer This is generally A Good Thing

                              TECHNO-GEEK WARNING PUT YOUR PROPELLER HAT ON Technically speaking you need a base classs destructor to be virtual if and only if you intend to allow someone to invoke an objects destructor via a base class pointer (this is normally done implicitly via delete) and the object being destructed is of a derived class that has a non-trivial destructor A class has a non-trivial destructor if it either has an explicit destructor or if it has a member object or a base class that has a non-trivial destructor (note that this is a recursive definition (eg a class has a non-trivial destructor if it has a member object (which has a base class (which has a member object (which has a base class (which has an explicit destructor)))))) END TECHNO-GEEK WARNING REMOVE YOUR PROPELLER HAT

                              If you had a hard grokking the previous rule try this (over)simplified one on for size A class should have a virtual destructor unless that class has no virtual functions Rationale if you have any virtual functions at all youre probably going to be doing stuff to derived objects via a base pointer and some of the stuff you may do may include invoking a destructor (normally done implicitly via delete) Plus once youve put the first virtual function into a class youve already paid all the per-object space cost that youll ever pay (one pointer per object note that this is theoretically compiler-specific in practice everyone does it pretty much the same way) so making the destructor virtual wont generally cost you anything extra

                              22 What is a virtual constructor

                              An idiom that allows you to do something that C++ doesnt directly support

                              You can get the effect of a virtual constructor by a virtual clone() member function (for copy constructing) or a virtual create() member function (for the default constructor)

                              class Shape public virtual ~Shape() A virtual destructor virtual void draw() = 0 A pure virtual function virtual void move() = 0 virtual Shape clone() const = 0 Uses the copy constructor virtual Shape create() const = 0 Uses the default constructor class Circle public Shape public Circle clone() const return new Circle(this) Circle create() const return new Circle()

                              In the clone() member function the new Circle(this) code calls Circles copy constructor to copy the state of this into the newly created Circle object In the create() member function the new Circle() code calls Circles default constructor

                              Users use these as if they were virtual constructors

                              void userCode(Shapeamp s) Shape s2 = sclone() Shape s3 = screate() delete s2 You probably need a virtual destructor here

                              delete s3

                              23 How do you link a C++ program to C functions

                              By using the extern C linkage specification around the C function declarations

                              24 Explain the scope resolution operator

                              The scope resolution operator permits a program to reference an identifier in the global scope that has been hidden by another identifier with the same name in the local scope

                              25 What are the differences between a C++ struct and C++ class

                              The default member and base class access specifiers are different

                              26 How many ways are there to initialize an int with a constant

                              Two

                              27 How does throwing and catching exceptions differ from using setjmp and longjmp

                              The throw operation calls the destructors for automatic objects instantiated since entry to the try block

                              28 How does throwing and catching exceptions differ from using setjmp and longjmp

                              The throw operation calls the destructors for automatic objects instantiated since entry to the try block

                              29 What is a default constructor

                              A constructor that has no arguments or one where all the arguments have default argument values

                              If you dont code a default constructor the compiler provides one if there are no other constructors If you are going to instantiate an array of objects of the class the class must have a default constructor

                              30 What is a conversion constructor

                              It is a constructor that accepts one argument of a different type

                              The compiler uses this idiom as one way to infer conversion rules for a class A constructor with more than one argument and with default argument values can be interpreted by the compiler as a conversion constructor when the compiler is looking for an object of the type and sees an object of the type of the constructors first argument

                              31 What is the difference between a copy constructor and an overloaded assignment operator

                              A copy constructor constructs a new object by using the content of the argument object An overloaded assignment operator assigns the contents of an existing object to another existing object of the same class

                              First you must know that a copy constructor is one that has only one argument which is a reference to the same type as the constructor The compiler invokes a copy constructor wherever it needs to make a copy of the object for example to pass an argument by value If you do not provide a copy constructor the compiler creates a member-by-member copy constructor for you

                              You can write overloaded assignment operators that take arguments of other classes but that behavior is usually implemented with implicit conversion constructors If you do not provide an overloaded assignment operator for the class the compiler creates a default member-by-member assignment operator

                              This discussion is a good place to get into why classes need copy constructors and overloaded assignment operators By discussing the requirements with respect to data member pointers that point to dynamically allocated resources you demonstrate a good grasp of the problem

                              32 When should you use multiple inheritance

                              There are three acceptable answers Never Rarely and When the problem domain cannot be accurately modeled any other way

                              33 What is a virtual destructor

                              The simple answer is that a virtual destructor is one that is declared with the virtual attribute

                              The behavior of a virtual destructor is what is important If you destroy an object through a pointer or reference to a base class and the base-class destructor is not virtual the derived-class destructors are not executed and the destruction might not be complete

                              34 Explain the ISA and HASA class relationships How would you implement each in a class design

                              A specialized class is a specialization of another class and therefore has the ISA relationship with the other class An Employee ISA Person This relationship is best implemented with inheritance Employee is derived from Person A class may have an instance of another class For example an Employee has a Salary therefore the Employee class has the HASA relationship with the Salary class This relationship is best implemented by embedding an object of the Salary class in the Employee class

                              The answer to this question reveals whether you have an understanding of the fundamentals of object-oriented design which is important to reliable class design

                              There are other relationships The USESA relationship is when one class uses the services of another The Employee class uses an object (cout) of the ostream class to display the employees name onscreen for example But if you get ISA and HASA right you usually dont need to go any further

                              35 When is a template a better solution than a base class

                              When you are designing a generic class to contain or otherwise manage objects of other types when the format and behavior of those other types are unimportant to their containment or management and particularly when those other types are unknown (thus the genericity) to the designer of the container or manager class

                              Prior to templates you had to use inheritance your design might include a generic List container class and an application-specific Employee class To put employees in a list a ListedEmployee class is multiply derived (contrived) from the Employee and List classes These solutions were unwieldy and error-prone Templates solved that problem

                              Questions for ANSI-Knowledgeable Applicants

                              There are six questions for those who profess knowledge of the progress of the ANSI committee If you claim to have that much interest in the language you should know the answers to all these questions

                              1 What is a mutable member

                              A mutable member is one that can be modified by the class even when the object of the class or the member function doing the modification is const

                              Understanding this requirement implies an understanding of C++ const which many programmers do not have I have seen large class designs that do not employ the const qualifier anywhere Some of those designs are my own early C++ efforts One author suggests that some programmers find const to be such a bother that it is easier to ignore const than to try to use it meaningfully No

                              wonder many programmers dont understand the power and implications of const Someone who claims to have enough interest in the language and its evolution to keep pace with the ANSI deliberations should not be ignorant of const however

                              2 What is an explicit constructor

                              A conversion constructor declared with the explicit keyword The compiler does not use an explicit constructor to implement an implied conversion of types Its purpose is reserved explicitly for construction

                              3 What is the Standard Template Library

                              It is a library of container templates approved by the ANSI committee for inclusion in the standard C++ specification

                              4 Describe run-time type identification

                              It is the ability to determine at run time the type of an object by using the typeid operator or the dynamic_cast operator

                              5 What problem does the namespace feature solve

                              Multiple providers of libraries might use common global identifiers causing a name collision when an application tries to link with two or more such libraries The name-space feature surrounds a librarys external declarations with a unique namespace that eliminates the potential for those collisions

                              This solution assumes that two library vendors dont use the same namespace of course

                              6 Are there any new intrinsic (built-in) data types

                              Yes The ANSI committee added the bool intrinsic type and its true and false value keywords and the wchar_t data type to support character sets wider than eight bits

                              SQL Server

                              1 What is a foreign key

                              A foreign key is a column or combination of columns used to establish and enforce a link (referential integrity) between the data in two tables A link is created between two tables by adding the column or columns that hold one tablersquos primary key values to the other table This column becomes a foreign key in the second table

                              2 What is the difference between a primary key and unique key

                              There can be only one primary key constrain on a table but there can be many unique key constraints in a table

                              Primary key doesnrsquot allow null values but Unique allows 1 Null value

                              3 What is an index

                              Indexes are database objects which provides faster data access The index provides pointers to the data values stored in specified columns of

                              the table and then orders those pointers according to the sort order you specify

                              Different types of indexes are unique index clustered index and non-clustered index

                              4 How to return multiple result set from a stored proc and capture it in ADO

                              Use multiple Select statements to return multiple result sets Use ADOrsquos GetNextRecordset() method to get the second recordset during the

                              execution of the stored proc

                              • COMDCOM
                              • Visual Basic
                              • General Scripting Questions
                              • Session and Application Variable Questions
                                • Image Questions
                                • Browser Questions
                                • ActiveX Data Objects Questions
                                • Form and Query String Questions
                                  • 18 What is a virtual member function
                                  • 19 How can C++ achieve dynamic binding yet also static typing
                                  • 20 Whats the difference between how virtual and non-virtual member functions are called
                                  • 21 When should my destructor be virtual
                                  • 22 What is a virtual constructor
                                  • Questions for ANSI-Knowledgeable Applicants

                                General Scripting Questions

                                1 How do you add a quotation mark to VB script string

                                The first method uses two quotation marks in a row to create a single quotation mark The second method uses the ASCII value of the quotation mark character

                                2 How do you break a single VBScript Statement into multiple lines

                                A single VBScript Statement can be broken into multiple lines by using the _underscore character

                                3 What is the proper method of comparing strings in VBScript

                                The first method uses VBScript function with the vbTextCompare constant The second method forces both strings into uppercase

                                4 How do you re-enable errors after using ON ERROR RESUME NEXT

                                ltlt Need an answer gtgt

                                5 How do you prevent My Script from timing out

                                You can extend the amount of time a script is allowed to run by using the ScriptTimeout property of the Server object

                                6 When do you need to explicitly convert a variable to a particular data type

                                If you are comparing numbers or dates and there is a danger that VBScript might interpret the values as strings one of the VBScript conversion functions should be used

                                7 When should one pass a variable by value and when by reference

                                When you pass a variable by value to a subordinate or function a new instance of the variable is created Any changes made to the value of the variable do not affect the value of the original variable On the other hand whne you pass a variable by reference changes made to the variable do affect the value of the original variable

                                8 How can you add a space between the output of two variables

                                ltlt Need an answer gtgt

                                9 Does ASP support dynamic includes

                                It does not support

                                10 How do you use the option Explicit statement in an ASP

                                It must be used before nay other VBScript statement or HTML content in a script else it will generate and error

                                Session and Application Variable Questions

                                1 Why do session variables sometimes fail to work

                                Session variables depend on browser cookies If a browser does not support cookies or a user has turned off cookies or the userrsquos cookie file is corrupted Session variables will not work

                                2 How do you remove an application variable

                                ltlt Need an answer gtgt

                                3 How do you detect whether a File exists

                                I can detect by using the FileExists method of the FileSystemObject

                                4 How do you automatically display a list of the Files in a directory

                                By using a list of files in a folder by using the FileSystemObject and the Folder object

                                Image Questions

                                1 How do you store an image in a database table

                                Although you can store an image in a SQL Server BLOB column it is almost always better to store the URL of an image in a database table rather than the image itself

                                2 How do you dynamically generate a graph or image in an ASP

                                Several third-party ASP components enable you to dynamically create custom images

                                Browser Questions

                                1 How do you detect the type of browser a person is using to visit your web site

                                The User-Agent header indicates the type of browser

                                2 How do you detect a page from which a person originated

                                The Referer header contains the URL of the last page the person visited This header can be retrieved from the ServerVariables collection

                                ActiveX Data Objects Questions

                                1 Why do you sometimes receive an error when using the Connection Object to execute a SQL string

                                ltlt Need an answer gtgt

                                2 How do you retrieve a Text filed in an ASP

                                If you do not take special precautions when retrieving a Text field from a database table the value of the Text field might be truncated If you are using a forward-only cursor type you should use the Text field as the very last field in your select list Alternatively consider using a richer cursor type when opening a Recordset that contains a Text field

                                3 Why does the RecordCount always return the Value-1

                                The RecordCount property returns the number of rows in a Recordset after it has been opened you cannot use this property with a forward-only cursor when using SQL Server (it will always return ndash1)

                                4 Why do you receive an error whenever you try to update the value of a filed in a recordset

                                By default when you open a Recordset it is opened with a forward-only cursor and read-only lock type To update a Recordset you must open a Recordset that is not read-only

                                5 How do you limit the number of rows returned by a Database Query

                                If using SQL 70 or Access you can use the SQL Top keyword to limit the number of records returned Otherwise if you are using SQL 65 use the MaxRecords property of the Recordset object

                                ltlt What about SQL 2000 gtgt

                                6 How do you retrieve the value from a SQL Statement that uses Count() Max Min or Identity

                                There are two methods that you can use to retrieve the value from a SQL function or a SQL global variable You can either use an alias for the value or refer to the value by its ordinal position in the Recordset

                                7 How do you retrieve an output parameter from a SQL stored procedure within an ASPScript

                                You must use the ADO Command nad parameter objects

                                Form and Query String Questions

                                1 How do you accept file uploads in an HTML form

                                ltlt Need an answer gtgt

                                2 What causes the value of a form field to become truncated

                                HTML uses quotation marks to mark the beginning and end of a value So If a variable contains question marks in its values the value of the variablewill be truncated when displayed

                                3 How do you include spaces or other special characters in a query string

                                URL encode the query string

                                C++ Questions

                                1 What is an object in C++

                                An object is a package that contains related data and instructions The data relates to what the object represents while the instructions define how this object relates to other objects and itself

                                2 What is a message

                                A message is a signal from one object to another requesting that a computation take place It is roughly equivalent to a function call in other languages

                                3 What is a class

                                A class defines the characteristics of a certain type of object It defines what its members will remember the messages to which they will respond and what form the response will take

                                4 What is an instance

                                It is an individual object that is a member of some class

                                5 What is a super-class

                                Given a class a super-class is the basis of the class under consideration The given class is defined as a subset (in some respects) of the super-class All objects of the given class potentially posses all the characteristics belonging to objects of the super-class

                                6 What is inheritance

                                Inheritance is property such that a parent (or super) class passes the characteristics of itself to children (or sub) classes that are derived from it The sub-class has the option of modifying these characteristics in order to make a different but fundamentally related class from the super-class

                                7 To what does message protocol refer

                                An objects message protocol is the exact form of the set of messages to which the object can respond

                                8 What is polymorphism

                                Polymorphism refers to the ability of an object to respond in a logically identical fashion to messages of the same protocol containing differing types of objects Consider 1 + 5 and 1 + 51 In the former the message + 5 is sent to an object of class integer (1) In the later the message + 51 is sent to the same integer object The form of the message (its protocol) is identical in both cases What differs is the type of object on the right-hand side of these messages The former is an integer object (5) while the later is a floating point object (51) The receiver (1) appears (to other objects) to respond in the same way to both messages Internally however it knows that it must treat the two types of objects differently in order to obtain the same overall response

                                9 What are instance variables

                                These represent an objects private memory They are defined in an objects class

                                18 What is a virtual member function

                                A virtual function allows derived classes to replace the implementation provided by the base class The compiler makes sure the replacement is always called whenever the object in question is actually of the derived class even if the object is accessed by a base pointer rather than a derived pointer This allows algorithms in the base class to be replaced in the derived class even if users dont know about the derived class

                                The derived class can either fully replace (override) the base class member function or the derived class can partially replace (augment) the base class member function The latter is accomplished by having the derived class member function call the base class member function if desired

                                19 How can C++ achieve dynamic binding yet also static typing

                                When you have a pointer to an object the object may actually be of a class that is derived from the class of the pointer (eg a Vehicle that is actually pointing to a Car object) Thus there are two types the (static) type of the pointer (Vehicle in this case) and the (dynamic) type of the pointed-to object (Car in this case)

                                Static typing means that the legality of a member function invocation is checked at the earliest possible moment by the compiler at compile time The compiler uses the static type of the pointer to determine whether the member function invocation is legal If the type of the pointer can handle the member function certainly the pointed-to object can handle it as well Eg if Vehicle has a certain member function certainly Car also has that member function since Car is a kind-of Vehicle

                                Dynamic binding means that the address of the code in a member function invocation is determined at the last possible moment based on the dynamic type of the object at run time It is called dynamic binding because the binding to the code that actually gets called is accomplished dynamically (at run time) Dynamic binding is a result of virtual functions

                                20 Whats the difference between how virtual and non-virtual member functions are called

                                Non-virtual member functions are resolved statically That is the member function is selected statically (at compile-time) based on the type of the pointer (or reference) to the object

                                In contrast virtual member functions are resolved dynamically (at run-time) That is the member function is selected dynamically (at run-time) based on the type of the object not the type of the pointerreference to that object This is called dynamic binding Most compilers use some variant of the following technique

                                if the object has one or more virtual functions the compiler puts a hidden pointer in the object called a virtual-pointer or v-pointer This v-pointer points to a global table called the virtual-table or v-table

                                The compiler creates a v-table for each class that has at least one virtual function For example if class Circle has virtual functions for draw() and move() and resize() there would be exactly one v-table associated with class Circle even if there were a gazillion Circle objects and the v-pointer of each of those Circle objects would point to the Circle v-table The v-table itself has pointers to each of the virtual functions in the class For example the Circle v-table would have three pointers a pointer to Circledraw() a pointer to Circlemove() and a pointer to Circleresize()

                                During a dispatch of a virtual function the run-time system follows the objects v-pointer to the classs v-table then follows the appropriate slot in the v-table to the method code

                                The space-cost overhead of the above technique is nominal an extra pointer per object (but only for objects that will need to do dynamic binding) plus an extra pointer per method (but only for virtual methods) The time-cost overhead is also fairly nominal compared to a normal function call a virtual function call requires two extra fetches (one to get the value of the v-pointer a second to get the address of the method) None of this runtime activity happens with non-virtual functions since the compiler resolves non-virtual functions exclusively at compile-time based on the type of the pointer

                                21 When should my destructor be virtual

                                When you may delete a derived object via a base pointer

                                virtual functions bind to the code associated with the class of the object rather than with the class of the pointerreference When you say delete basePtr and the base class has a virtual destructor the destructor that gets invoked is the one associated with the type of the object basePtr rather than the one associated with the type of the pointer This is generally A Good Thing

                                TECHNO-GEEK WARNING PUT YOUR PROPELLER HAT ON Technically speaking you need a base classs destructor to be virtual if and only if you intend to allow someone to invoke an objects destructor via a base class pointer (this is normally done implicitly via delete) and the object being destructed is of a derived class that has a non-trivial destructor A class has a non-trivial destructor if it either has an explicit destructor or if it has a member object or a base class that has a non-trivial destructor (note that this is a recursive definition (eg a class has a non-trivial destructor if it has a member object (which has a base class (which has a member object (which has a base class (which has an explicit destructor)))))) END TECHNO-GEEK WARNING REMOVE YOUR PROPELLER HAT

                                If you had a hard grokking the previous rule try this (over)simplified one on for size A class should have a virtual destructor unless that class has no virtual functions Rationale if you have any virtual functions at all youre probably going to be doing stuff to derived objects via a base pointer and some of the stuff you may do may include invoking a destructor (normally done implicitly via delete) Plus once youve put the first virtual function into a class youve already paid all the per-object space cost that youll ever pay (one pointer per object note that this is theoretically compiler-specific in practice everyone does it pretty much the same way) so making the destructor virtual wont generally cost you anything extra

                                22 What is a virtual constructor

                                An idiom that allows you to do something that C++ doesnt directly support

                                You can get the effect of a virtual constructor by a virtual clone() member function (for copy constructing) or a virtual create() member function (for the default constructor)

                                class Shape public virtual ~Shape() A virtual destructor virtual void draw() = 0 A pure virtual function virtual void move() = 0 virtual Shape clone() const = 0 Uses the copy constructor virtual Shape create() const = 0 Uses the default constructor class Circle public Shape public Circle clone() const return new Circle(this) Circle create() const return new Circle()

                                In the clone() member function the new Circle(this) code calls Circles copy constructor to copy the state of this into the newly created Circle object In the create() member function the new Circle() code calls Circles default constructor

                                Users use these as if they were virtual constructors

                                void userCode(Shapeamp s) Shape s2 = sclone() Shape s3 = screate() delete s2 You probably need a virtual destructor here

                                delete s3

                                23 How do you link a C++ program to C functions

                                By using the extern C linkage specification around the C function declarations

                                24 Explain the scope resolution operator

                                The scope resolution operator permits a program to reference an identifier in the global scope that has been hidden by another identifier with the same name in the local scope

                                25 What are the differences between a C++ struct and C++ class

                                The default member and base class access specifiers are different

                                26 How many ways are there to initialize an int with a constant

                                Two

                                27 How does throwing and catching exceptions differ from using setjmp and longjmp

                                The throw operation calls the destructors for automatic objects instantiated since entry to the try block

                                28 How does throwing and catching exceptions differ from using setjmp and longjmp

                                The throw operation calls the destructors for automatic objects instantiated since entry to the try block

                                29 What is a default constructor

                                A constructor that has no arguments or one where all the arguments have default argument values

                                If you dont code a default constructor the compiler provides one if there are no other constructors If you are going to instantiate an array of objects of the class the class must have a default constructor

                                30 What is a conversion constructor

                                It is a constructor that accepts one argument of a different type

                                The compiler uses this idiom as one way to infer conversion rules for a class A constructor with more than one argument and with default argument values can be interpreted by the compiler as a conversion constructor when the compiler is looking for an object of the type and sees an object of the type of the constructors first argument

                                31 What is the difference between a copy constructor and an overloaded assignment operator

                                A copy constructor constructs a new object by using the content of the argument object An overloaded assignment operator assigns the contents of an existing object to another existing object of the same class

                                First you must know that a copy constructor is one that has only one argument which is a reference to the same type as the constructor The compiler invokes a copy constructor wherever it needs to make a copy of the object for example to pass an argument by value If you do not provide a copy constructor the compiler creates a member-by-member copy constructor for you

                                You can write overloaded assignment operators that take arguments of other classes but that behavior is usually implemented with implicit conversion constructors If you do not provide an overloaded assignment operator for the class the compiler creates a default member-by-member assignment operator

                                This discussion is a good place to get into why classes need copy constructors and overloaded assignment operators By discussing the requirements with respect to data member pointers that point to dynamically allocated resources you demonstrate a good grasp of the problem

                                32 When should you use multiple inheritance

                                There are three acceptable answers Never Rarely and When the problem domain cannot be accurately modeled any other way

                                33 What is a virtual destructor

                                The simple answer is that a virtual destructor is one that is declared with the virtual attribute

                                The behavior of a virtual destructor is what is important If you destroy an object through a pointer or reference to a base class and the base-class destructor is not virtual the derived-class destructors are not executed and the destruction might not be complete

                                34 Explain the ISA and HASA class relationships How would you implement each in a class design

                                A specialized class is a specialization of another class and therefore has the ISA relationship with the other class An Employee ISA Person This relationship is best implemented with inheritance Employee is derived from Person A class may have an instance of another class For example an Employee has a Salary therefore the Employee class has the HASA relationship with the Salary class This relationship is best implemented by embedding an object of the Salary class in the Employee class

                                The answer to this question reveals whether you have an understanding of the fundamentals of object-oriented design which is important to reliable class design

                                There are other relationships The USESA relationship is when one class uses the services of another The Employee class uses an object (cout) of the ostream class to display the employees name onscreen for example But if you get ISA and HASA right you usually dont need to go any further

                                35 When is a template a better solution than a base class

                                When you are designing a generic class to contain or otherwise manage objects of other types when the format and behavior of those other types are unimportant to their containment or management and particularly when those other types are unknown (thus the genericity) to the designer of the container or manager class

                                Prior to templates you had to use inheritance your design might include a generic List container class and an application-specific Employee class To put employees in a list a ListedEmployee class is multiply derived (contrived) from the Employee and List classes These solutions were unwieldy and error-prone Templates solved that problem

                                Questions for ANSI-Knowledgeable Applicants

                                There are six questions for those who profess knowledge of the progress of the ANSI committee If you claim to have that much interest in the language you should know the answers to all these questions

                                1 What is a mutable member

                                A mutable member is one that can be modified by the class even when the object of the class or the member function doing the modification is const

                                Understanding this requirement implies an understanding of C++ const which many programmers do not have I have seen large class designs that do not employ the const qualifier anywhere Some of those designs are my own early C++ efforts One author suggests that some programmers find const to be such a bother that it is easier to ignore const than to try to use it meaningfully No

                                wonder many programmers dont understand the power and implications of const Someone who claims to have enough interest in the language and its evolution to keep pace with the ANSI deliberations should not be ignorant of const however

                                2 What is an explicit constructor

                                A conversion constructor declared with the explicit keyword The compiler does not use an explicit constructor to implement an implied conversion of types Its purpose is reserved explicitly for construction

                                3 What is the Standard Template Library

                                It is a library of container templates approved by the ANSI committee for inclusion in the standard C++ specification

                                4 Describe run-time type identification

                                It is the ability to determine at run time the type of an object by using the typeid operator or the dynamic_cast operator

                                5 What problem does the namespace feature solve

                                Multiple providers of libraries might use common global identifiers causing a name collision when an application tries to link with two or more such libraries The name-space feature surrounds a librarys external declarations with a unique namespace that eliminates the potential for those collisions

                                This solution assumes that two library vendors dont use the same namespace of course

                                6 Are there any new intrinsic (built-in) data types

                                Yes The ANSI committee added the bool intrinsic type and its true and false value keywords and the wchar_t data type to support character sets wider than eight bits

                                SQL Server

                                1 What is a foreign key

                                A foreign key is a column or combination of columns used to establish and enforce a link (referential integrity) between the data in two tables A link is created between two tables by adding the column or columns that hold one tablersquos primary key values to the other table This column becomes a foreign key in the second table

                                2 What is the difference between a primary key and unique key

                                There can be only one primary key constrain on a table but there can be many unique key constraints in a table

                                Primary key doesnrsquot allow null values but Unique allows 1 Null value

                                3 What is an index

                                Indexes are database objects which provides faster data access The index provides pointers to the data values stored in specified columns of

                                the table and then orders those pointers according to the sort order you specify

                                Different types of indexes are unique index clustered index and non-clustered index

                                4 How to return multiple result set from a stored proc and capture it in ADO

                                Use multiple Select statements to return multiple result sets Use ADOrsquos GetNextRecordset() method to get the second recordset during the

                                execution of the stored proc

                                • COMDCOM
                                • Visual Basic
                                • General Scripting Questions
                                • Session and Application Variable Questions
                                  • Image Questions
                                  • Browser Questions
                                  • ActiveX Data Objects Questions
                                  • Form and Query String Questions
                                    • 18 What is a virtual member function
                                    • 19 How can C++ achieve dynamic binding yet also static typing
                                    • 20 Whats the difference between how virtual and non-virtual member functions are called
                                    • 21 When should my destructor be virtual
                                    • 22 What is a virtual constructor
                                    • Questions for ANSI-Knowledgeable Applicants

                                  It does not support

                                  10 How do you use the option Explicit statement in an ASP

                                  It must be used before nay other VBScript statement or HTML content in a script else it will generate and error

                                  Session and Application Variable Questions

                                  1 Why do session variables sometimes fail to work

                                  Session variables depend on browser cookies If a browser does not support cookies or a user has turned off cookies or the userrsquos cookie file is corrupted Session variables will not work

                                  2 How do you remove an application variable

                                  ltlt Need an answer gtgt

                                  3 How do you detect whether a File exists

                                  I can detect by using the FileExists method of the FileSystemObject

                                  4 How do you automatically display a list of the Files in a directory

                                  By using a list of files in a folder by using the FileSystemObject and the Folder object

                                  Image Questions

                                  1 How do you store an image in a database table

                                  Although you can store an image in a SQL Server BLOB column it is almost always better to store the URL of an image in a database table rather than the image itself

                                  2 How do you dynamically generate a graph or image in an ASP

                                  Several third-party ASP components enable you to dynamically create custom images

                                  Browser Questions

                                  1 How do you detect the type of browser a person is using to visit your web site

                                  The User-Agent header indicates the type of browser

                                  2 How do you detect a page from which a person originated

                                  The Referer header contains the URL of the last page the person visited This header can be retrieved from the ServerVariables collection

                                  ActiveX Data Objects Questions

                                  1 Why do you sometimes receive an error when using the Connection Object to execute a SQL string

                                  ltlt Need an answer gtgt

                                  2 How do you retrieve a Text filed in an ASP

                                  If you do not take special precautions when retrieving a Text field from a database table the value of the Text field might be truncated If you are using a forward-only cursor type you should use the Text field as the very last field in your select list Alternatively consider using a richer cursor type when opening a Recordset that contains a Text field

                                  3 Why does the RecordCount always return the Value-1

                                  The RecordCount property returns the number of rows in a Recordset after it has been opened you cannot use this property with a forward-only cursor when using SQL Server (it will always return ndash1)

                                  4 Why do you receive an error whenever you try to update the value of a filed in a recordset

                                  By default when you open a Recordset it is opened with a forward-only cursor and read-only lock type To update a Recordset you must open a Recordset that is not read-only

                                  5 How do you limit the number of rows returned by a Database Query

                                  If using SQL 70 or Access you can use the SQL Top keyword to limit the number of records returned Otherwise if you are using SQL 65 use the MaxRecords property of the Recordset object

                                  ltlt What about SQL 2000 gtgt

                                  6 How do you retrieve the value from a SQL Statement that uses Count() Max Min or Identity

                                  There are two methods that you can use to retrieve the value from a SQL function or a SQL global variable You can either use an alias for the value or refer to the value by its ordinal position in the Recordset

                                  7 How do you retrieve an output parameter from a SQL stored procedure within an ASPScript

                                  You must use the ADO Command nad parameter objects

                                  Form and Query String Questions

                                  1 How do you accept file uploads in an HTML form

                                  ltlt Need an answer gtgt

                                  2 What causes the value of a form field to become truncated

                                  HTML uses quotation marks to mark the beginning and end of a value So If a variable contains question marks in its values the value of the variablewill be truncated when displayed

                                  3 How do you include spaces or other special characters in a query string

                                  URL encode the query string

                                  C++ Questions

                                  1 What is an object in C++

                                  An object is a package that contains related data and instructions The data relates to what the object represents while the instructions define how this object relates to other objects and itself

                                  2 What is a message

                                  A message is a signal from one object to another requesting that a computation take place It is roughly equivalent to a function call in other languages

                                  3 What is a class

                                  A class defines the characteristics of a certain type of object It defines what its members will remember the messages to which they will respond and what form the response will take

                                  4 What is an instance

                                  It is an individual object that is a member of some class

                                  5 What is a super-class

                                  Given a class a super-class is the basis of the class under consideration The given class is defined as a subset (in some respects) of the super-class All objects of the given class potentially posses all the characteristics belonging to objects of the super-class

                                  6 What is inheritance

                                  Inheritance is property such that a parent (or super) class passes the characteristics of itself to children (or sub) classes that are derived from it The sub-class has the option of modifying these characteristics in order to make a different but fundamentally related class from the super-class

                                  7 To what does message protocol refer

                                  An objects message protocol is the exact form of the set of messages to which the object can respond

                                  8 What is polymorphism

                                  Polymorphism refers to the ability of an object to respond in a logically identical fashion to messages of the same protocol containing differing types of objects Consider 1 + 5 and 1 + 51 In the former the message + 5 is sent to an object of class integer (1) In the later the message + 51 is sent to the same integer object The form of the message (its protocol) is identical in both cases What differs is the type of object on the right-hand side of these messages The former is an integer object (5) while the later is a floating point object (51) The receiver (1) appears (to other objects) to respond in the same way to both messages Internally however it knows that it must treat the two types of objects differently in order to obtain the same overall response

                                  9 What are instance variables

                                  These represent an objects private memory They are defined in an objects class

                                  18 What is a virtual member function

                                  A virtual function allows derived classes to replace the implementation provided by the base class The compiler makes sure the replacement is always called whenever the object in question is actually of the derived class even if the object is accessed by a base pointer rather than a derived pointer This allows algorithms in the base class to be replaced in the derived class even if users dont know about the derived class

                                  The derived class can either fully replace (override) the base class member function or the derived class can partially replace (augment) the base class member function The latter is accomplished by having the derived class member function call the base class member function if desired

                                  19 How can C++ achieve dynamic binding yet also static typing

                                  When you have a pointer to an object the object may actually be of a class that is derived from the class of the pointer (eg a Vehicle that is actually pointing to a Car object) Thus there are two types the (static) type of the pointer (Vehicle in this case) and the (dynamic) type of the pointed-to object (Car in this case)

                                  Static typing means that the legality of a member function invocation is checked at the earliest possible moment by the compiler at compile time The compiler uses the static type of the pointer to determine whether the member function invocation is legal If the type of the pointer can handle the member function certainly the pointed-to object can handle it as well Eg if Vehicle has a certain member function certainly Car also has that member function since Car is a kind-of Vehicle

                                  Dynamic binding means that the address of the code in a member function invocation is determined at the last possible moment based on the dynamic type of the object at run time It is called dynamic binding because the binding to the code that actually gets called is accomplished dynamically (at run time) Dynamic binding is a result of virtual functions

                                  20 Whats the difference between how virtual and non-virtual member functions are called

                                  Non-virtual member functions are resolved statically That is the member function is selected statically (at compile-time) based on the type of the pointer (or reference) to the object

                                  In contrast virtual member functions are resolved dynamically (at run-time) That is the member function is selected dynamically (at run-time) based on the type of the object not the type of the pointerreference to that object This is called dynamic binding Most compilers use some variant of the following technique

                                  if the object has one or more virtual functions the compiler puts a hidden pointer in the object called a virtual-pointer or v-pointer This v-pointer points to a global table called the virtual-table or v-table

                                  The compiler creates a v-table for each class that has at least one virtual function For example if class Circle has virtual functions for draw() and move() and resize() there would be exactly one v-table associated with class Circle even if there were a gazillion Circle objects and the v-pointer of each of those Circle objects would point to the Circle v-table The v-table itself has pointers to each of the virtual functions in the class For example the Circle v-table would have three pointers a pointer to Circledraw() a pointer to Circlemove() and a pointer to Circleresize()

                                  During a dispatch of a virtual function the run-time system follows the objects v-pointer to the classs v-table then follows the appropriate slot in the v-table to the method code

                                  The space-cost overhead of the above technique is nominal an extra pointer per object (but only for objects that will need to do dynamic binding) plus an extra pointer per method (but only for virtual methods) The time-cost overhead is also fairly nominal compared to a normal function call a virtual function call requires two extra fetches (one to get the value of the v-pointer a second to get the address of the method) None of this runtime activity happens with non-virtual functions since the compiler resolves non-virtual functions exclusively at compile-time based on the type of the pointer

                                  21 When should my destructor be virtual

                                  When you may delete a derived object via a base pointer

                                  virtual functions bind to the code associated with the class of the object rather than with the class of the pointerreference When you say delete basePtr and the base class has a virtual destructor the destructor that gets invoked is the one associated with the type of the object basePtr rather than the one associated with the type of the pointer This is generally A Good Thing

                                  TECHNO-GEEK WARNING PUT YOUR PROPELLER HAT ON Technically speaking you need a base classs destructor to be virtual if and only if you intend to allow someone to invoke an objects destructor via a base class pointer (this is normally done implicitly via delete) and the object being destructed is of a derived class that has a non-trivial destructor A class has a non-trivial destructor if it either has an explicit destructor or if it has a member object or a base class that has a non-trivial destructor (note that this is a recursive definition (eg a class has a non-trivial destructor if it has a member object (which has a base class (which has a member object (which has a base class (which has an explicit destructor)))))) END TECHNO-GEEK WARNING REMOVE YOUR PROPELLER HAT

                                  If you had a hard grokking the previous rule try this (over)simplified one on for size A class should have a virtual destructor unless that class has no virtual functions Rationale if you have any virtual functions at all youre probably going to be doing stuff to derived objects via a base pointer and some of the stuff you may do may include invoking a destructor (normally done implicitly via delete) Plus once youve put the first virtual function into a class youve already paid all the per-object space cost that youll ever pay (one pointer per object note that this is theoretically compiler-specific in practice everyone does it pretty much the same way) so making the destructor virtual wont generally cost you anything extra

                                  22 What is a virtual constructor

                                  An idiom that allows you to do something that C++ doesnt directly support

                                  You can get the effect of a virtual constructor by a virtual clone() member function (for copy constructing) or a virtual create() member function (for the default constructor)

                                  class Shape public virtual ~Shape() A virtual destructor virtual void draw() = 0 A pure virtual function virtual void move() = 0 virtual Shape clone() const = 0 Uses the copy constructor virtual Shape create() const = 0 Uses the default constructor class Circle public Shape public Circle clone() const return new Circle(this) Circle create() const return new Circle()

                                  In the clone() member function the new Circle(this) code calls Circles copy constructor to copy the state of this into the newly created Circle object In the create() member function the new Circle() code calls Circles default constructor

                                  Users use these as if they were virtual constructors

                                  void userCode(Shapeamp s) Shape s2 = sclone() Shape s3 = screate() delete s2 You probably need a virtual destructor here

                                  delete s3

                                  23 How do you link a C++ program to C functions

                                  By using the extern C linkage specification around the C function declarations

                                  24 Explain the scope resolution operator

                                  The scope resolution operator permits a program to reference an identifier in the global scope that has been hidden by another identifier with the same name in the local scope

                                  25 What are the differences between a C++ struct and C++ class

                                  The default member and base class access specifiers are different

                                  26 How many ways are there to initialize an int with a constant

                                  Two

                                  27 How does throwing and catching exceptions differ from using setjmp and longjmp

                                  The throw operation calls the destructors for automatic objects instantiated since entry to the try block

                                  28 How does throwing and catching exceptions differ from using setjmp and longjmp

                                  The throw operation calls the destructors for automatic objects instantiated since entry to the try block

                                  29 What is a default constructor

                                  A constructor that has no arguments or one where all the arguments have default argument values

                                  If you dont code a default constructor the compiler provides one if there are no other constructors If you are going to instantiate an array of objects of the class the class must have a default constructor

                                  30 What is a conversion constructor

                                  It is a constructor that accepts one argument of a different type

                                  The compiler uses this idiom as one way to infer conversion rules for a class A constructor with more than one argument and with default argument values can be interpreted by the compiler as a conversion constructor when the compiler is looking for an object of the type and sees an object of the type of the constructors first argument

                                  31 What is the difference between a copy constructor and an overloaded assignment operator

                                  A copy constructor constructs a new object by using the content of the argument object An overloaded assignment operator assigns the contents of an existing object to another existing object of the same class

                                  First you must know that a copy constructor is one that has only one argument which is a reference to the same type as the constructor The compiler invokes a copy constructor wherever it needs to make a copy of the object for example to pass an argument by value If you do not provide a copy constructor the compiler creates a member-by-member copy constructor for you

                                  You can write overloaded assignment operators that take arguments of other classes but that behavior is usually implemented with implicit conversion constructors If you do not provide an overloaded assignment operator for the class the compiler creates a default member-by-member assignment operator

                                  This discussion is a good place to get into why classes need copy constructors and overloaded assignment operators By discussing the requirements with respect to data member pointers that point to dynamically allocated resources you demonstrate a good grasp of the problem

                                  32 When should you use multiple inheritance

                                  There are three acceptable answers Never Rarely and When the problem domain cannot be accurately modeled any other way

                                  33 What is a virtual destructor

                                  The simple answer is that a virtual destructor is one that is declared with the virtual attribute

                                  The behavior of a virtual destructor is what is important If you destroy an object through a pointer or reference to a base class and the base-class destructor is not virtual the derived-class destructors are not executed and the destruction might not be complete

                                  34 Explain the ISA and HASA class relationships How would you implement each in a class design

                                  A specialized class is a specialization of another class and therefore has the ISA relationship with the other class An Employee ISA Person This relationship is best implemented with inheritance Employee is derived from Person A class may have an instance of another class For example an Employee has a Salary therefore the Employee class has the HASA relationship with the Salary class This relationship is best implemented by embedding an object of the Salary class in the Employee class

                                  The answer to this question reveals whether you have an understanding of the fundamentals of object-oriented design which is important to reliable class design

                                  There are other relationships The USESA relationship is when one class uses the services of another The Employee class uses an object (cout) of the ostream class to display the employees name onscreen for example But if you get ISA and HASA right you usually dont need to go any further

                                  35 When is a template a better solution than a base class

                                  When you are designing a generic class to contain or otherwise manage objects of other types when the format and behavior of those other types are unimportant to their containment or management and particularly when those other types are unknown (thus the genericity) to the designer of the container or manager class

                                  Prior to templates you had to use inheritance your design might include a generic List container class and an application-specific Employee class To put employees in a list a ListedEmployee class is multiply derived (contrived) from the Employee and List classes These solutions were unwieldy and error-prone Templates solved that problem

                                  Questions for ANSI-Knowledgeable Applicants

                                  There are six questions for those who profess knowledge of the progress of the ANSI committee If you claim to have that much interest in the language you should know the answers to all these questions

                                  1 What is a mutable member

                                  A mutable member is one that can be modified by the class even when the object of the class or the member function doing the modification is const

                                  Understanding this requirement implies an understanding of C++ const which many programmers do not have I have seen large class designs that do not employ the const qualifier anywhere Some of those designs are my own early C++ efforts One author suggests that some programmers find const to be such a bother that it is easier to ignore const than to try to use it meaningfully No

                                  wonder many programmers dont understand the power and implications of const Someone who claims to have enough interest in the language and its evolution to keep pace with the ANSI deliberations should not be ignorant of const however

                                  2 What is an explicit constructor

                                  A conversion constructor declared with the explicit keyword The compiler does not use an explicit constructor to implement an implied conversion of types Its purpose is reserved explicitly for construction

                                  3 What is the Standard Template Library

                                  It is a library of container templates approved by the ANSI committee for inclusion in the standard C++ specification

                                  4 Describe run-time type identification

                                  It is the ability to determine at run time the type of an object by using the typeid operator or the dynamic_cast operator

                                  5 What problem does the namespace feature solve

                                  Multiple providers of libraries might use common global identifiers causing a name collision when an application tries to link with two or more such libraries The name-space feature surrounds a librarys external declarations with a unique namespace that eliminates the potential for those collisions

                                  This solution assumes that two library vendors dont use the same namespace of course

                                  6 Are there any new intrinsic (built-in) data types

                                  Yes The ANSI committee added the bool intrinsic type and its true and false value keywords and the wchar_t data type to support character sets wider than eight bits

                                  SQL Server

                                  1 What is a foreign key

                                  A foreign key is a column or combination of columns used to establish and enforce a link (referential integrity) between the data in two tables A link is created between two tables by adding the column or columns that hold one tablersquos primary key values to the other table This column becomes a foreign key in the second table

                                  2 What is the difference between a primary key and unique key

                                  There can be only one primary key constrain on a table but there can be many unique key constraints in a table

                                  Primary key doesnrsquot allow null values but Unique allows 1 Null value

                                  3 What is an index

                                  Indexes are database objects which provides faster data access The index provides pointers to the data values stored in specified columns of

                                  the table and then orders those pointers according to the sort order you specify

                                  Different types of indexes are unique index clustered index and non-clustered index

                                  4 How to return multiple result set from a stored proc and capture it in ADO

                                  Use multiple Select statements to return multiple result sets Use ADOrsquos GetNextRecordset() method to get the second recordset during the

                                  execution of the stored proc

                                  • COMDCOM
                                  • Visual Basic
                                  • General Scripting Questions
                                  • Session and Application Variable Questions
                                    • Image Questions
                                    • Browser Questions
                                    • ActiveX Data Objects Questions
                                    • Form and Query String Questions
                                      • 18 What is a virtual member function
                                      • 19 How can C++ achieve dynamic binding yet also static typing
                                      • 20 Whats the difference between how virtual and non-virtual member functions are called
                                      • 21 When should my destructor be virtual
                                      • 22 What is a virtual constructor
                                      • Questions for ANSI-Knowledgeable Applicants

                                    The User-Agent header indicates the type of browser

                                    2 How do you detect a page from which a person originated

                                    The Referer header contains the URL of the last page the person visited This header can be retrieved from the ServerVariables collection

                                    ActiveX Data Objects Questions

                                    1 Why do you sometimes receive an error when using the Connection Object to execute a SQL string

                                    ltlt Need an answer gtgt

                                    2 How do you retrieve a Text filed in an ASP

                                    If you do not take special precautions when retrieving a Text field from a database table the value of the Text field might be truncated If you are using a forward-only cursor type you should use the Text field as the very last field in your select list Alternatively consider using a richer cursor type when opening a Recordset that contains a Text field

                                    3 Why does the RecordCount always return the Value-1

                                    The RecordCount property returns the number of rows in a Recordset after it has been opened you cannot use this property with a forward-only cursor when using SQL Server (it will always return ndash1)

                                    4 Why do you receive an error whenever you try to update the value of a filed in a recordset

                                    By default when you open a Recordset it is opened with a forward-only cursor and read-only lock type To update a Recordset you must open a Recordset that is not read-only

                                    5 How do you limit the number of rows returned by a Database Query

                                    If using SQL 70 or Access you can use the SQL Top keyword to limit the number of records returned Otherwise if you are using SQL 65 use the MaxRecords property of the Recordset object

                                    ltlt What about SQL 2000 gtgt

                                    6 How do you retrieve the value from a SQL Statement that uses Count() Max Min or Identity

                                    There are two methods that you can use to retrieve the value from a SQL function or a SQL global variable You can either use an alias for the value or refer to the value by its ordinal position in the Recordset

                                    7 How do you retrieve an output parameter from a SQL stored procedure within an ASPScript

                                    You must use the ADO Command nad parameter objects

                                    Form and Query String Questions

                                    1 How do you accept file uploads in an HTML form

                                    ltlt Need an answer gtgt

                                    2 What causes the value of a form field to become truncated

                                    HTML uses quotation marks to mark the beginning and end of a value So If a variable contains question marks in its values the value of the variablewill be truncated when displayed

                                    3 How do you include spaces or other special characters in a query string

                                    URL encode the query string

                                    C++ Questions

                                    1 What is an object in C++

                                    An object is a package that contains related data and instructions The data relates to what the object represents while the instructions define how this object relates to other objects and itself

                                    2 What is a message

                                    A message is a signal from one object to another requesting that a computation take place It is roughly equivalent to a function call in other languages

                                    3 What is a class

                                    A class defines the characteristics of a certain type of object It defines what its members will remember the messages to which they will respond and what form the response will take

                                    4 What is an instance

                                    It is an individual object that is a member of some class

                                    5 What is a super-class

                                    Given a class a super-class is the basis of the class under consideration The given class is defined as a subset (in some respects) of the super-class All objects of the given class potentially posses all the characteristics belonging to objects of the super-class

                                    6 What is inheritance

                                    Inheritance is property such that a parent (or super) class passes the characteristics of itself to children (or sub) classes that are derived from it The sub-class has the option of modifying these characteristics in order to make a different but fundamentally related class from the super-class

                                    7 To what does message protocol refer

                                    An objects message protocol is the exact form of the set of messages to which the object can respond

                                    8 What is polymorphism

                                    Polymorphism refers to the ability of an object to respond in a logically identical fashion to messages of the same protocol containing differing types of objects Consider 1 + 5 and 1 + 51 In the former the message + 5 is sent to an object of class integer (1) In the later the message + 51 is sent to the same integer object The form of the message (its protocol) is identical in both cases What differs is the type of object on the right-hand side of these messages The former is an integer object (5) while the later is a floating point object (51) The receiver (1) appears (to other objects) to respond in the same way to both messages Internally however it knows that it must treat the two types of objects differently in order to obtain the same overall response

                                    9 What are instance variables

                                    These represent an objects private memory They are defined in an objects class

                                    18 What is a virtual member function

                                    A virtual function allows derived classes to replace the implementation provided by the base class The compiler makes sure the replacement is always called whenever the object in question is actually of the derived class even if the object is accessed by a base pointer rather than a derived pointer This allows algorithms in the base class to be replaced in the derived class even if users dont know about the derived class

                                    The derived class can either fully replace (override) the base class member function or the derived class can partially replace (augment) the base class member function The latter is accomplished by having the derived class member function call the base class member function if desired

                                    19 How can C++ achieve dynamic binding yet also static typing

                                    When you have a pointer to an object the object may actually be of a class that is derived from the class of the pointer (eg a Vehicle that is actually pointing to a Car object) Thus there are two types the (static) type of the pointer (Vehicle in this case) and the (dynamic) type of the pointed-to object (Car in this case)

                                    Static typing means that the legality of a member function invocation is checked at the earliest possible moment by the compiler at compile time The compiler uses the static type of the pointer to determine whether the member function invocation is legal If the type of the pointer can handle the member function certainly the pointed-to object can handle it as well Eg if Vehicle has a certain member function certainly Car also has that member function since Car is a kind-of Vehicle

                                    Dynamic binding means that the address of the code in a member function invocation is determined at the last possible moment based on the dynamic type of the object at run time It is called dynamic binding because the binding to the code that actually gets called is accomplished dynamically (at run time) Dynamic binding is a result of virtual functions

                                    20 Whats the difference between how virtual and non-virtual member functions are called

                                    Non-virtual member functions are resolved statically That is the member function is selected statically (at compile-time) based on the type of the pointer (or reference) to the object

                                    In contrast virtual member functions are resolved dynamically (at run-time) That is the member function is selected dynamically (at run-time) based on the type of the object not the type of the pointerreference to that object This is called dynamic binding Most compilers use some variant of the following technique

                                    if the object has one or more virtual functions the compiler puts a hidden pointer in the object called a virtual-pointer or v-pointer This v-pointer points to a global table called the virtual-table or v-table

                                    The compiler creates a v-table for each class that has at least one virtual function For example if class Circle has virtual functions for draw() and move() and resize() there would be exactly one v-table associated with class Circle even if there were a gazillion Circle objects and the v-pointer of each of those Circle objects would point to the Circle v-table The v-table itself has pointers to each of the virtual functions in the class For example the Circle v-table would have three pointers a pointer to Circledraw() a pointer to Circlemove() and a pointer to Circleresize()

                                    During a dispatch of a virtual function the run-time system follows the objects v-pointer to the classs v-table then follows the appropriate slot in the v-table to the method code

                                    The space-cost overhead of the above technique is nominal an extra pointer per object (but only for objects that will need to do dynamic binding) plus an extra pointer per method (but only for virtual methods) The time-cost overhead is also fairly nominal compared to a normal function call a virtual function call requires two extra fetches (one to get the value of the v-pointer a second to get the address of the method) None of this runtime activity happens with non-virtual functions since the compiler resolves non-virtual functions exclusively at compile-time based on the type of the pointer

                                    21 When should my destructor be virtual

                                    When you may delete a derived object via a base pointer

                                    virtual functions bind to the code associated with the class of the object rather than with the class of the pointerreference When you say delete basePtr and the base class has a virtual destructor the destructor that gets invoked is the one associated with the type of the object basePtr rather than the one associated with the type of the pointer This is generally A Good Thing

                                    TECHNO-GEEK WARNING PUT YOUR PROPELLER HAT ON Technically speaking you need a base classs destructor to be virtual if and only if you intend to allow someone to invoke an objects destructor via a base class pointer (this is normally done implicitly via delete) and the object being destructed is of a derived class that has a non-trivial destructor A class has a non-trivial destructor if it either has an explicit destructor or if it has a member object or a base class that has a non-trivial destructor (note that this is a recursive definition (eg a class has a non-trivial destructor if it has a member object (which has a base class (which has a member object (which has a base class (which has an explicit destructor)))))) END TECHNO-GEEK WARNING REMOVE YOUR PROPELLER HAT

                                    If you had a hard grokking the previous rule try this (over)simplified one on for size A class should have a virtual destructor unless that class has no virtual functions Rationale if you have any virtual functions at all youre probably going to be doing stuff to derived objects via a base pointer and some of the stuff you may do may include invoking a destructor (normally done implicitly via delete) Plus once youve put the first virtual function into a class youve already paid all the per-object space cost that youll ever pay (one pointer per object note that this is theoretically compiler-specific in practice everyone does it pretty much the same way) so making the destructor virtual wont generally cost you anything extra

                                    22 What is a virtual constructor

                                    An idiom that allows you to do something that C++ doesnt directly support

                                    You can get the effect of a virtual constructor by a virtual clone() member function (for copy constructing) or a virtual create() member function (for the default constructor)

                                    class Shape public virtual ~Shape() A virtual destructor virtual void draw() = 0 A pure virtual function virtual void move() = 0 virtual Shape clone() const = 0 Uses the copy constructor virtual Shape create() const = 0 Uses the default constructor class Circle public Shape public Circle clone() const return new Circle(this) Circle create() const return new Circle()

                                    In the clone() member function the new Circle(this) code calls Circles copy constructor to copy the state of this into the newly created Circle object In the create() member function the new Circle() code calls Circles default constructor

                                    Users use these as if they were virtual constructors

                                    void userCode(Shapeamp s) Shape s2 = sclone() Shape s3 = screate() delete s2 You probably need a virtual destructor here

                                    delete s3

                                    23 How do you link a C++ program to C functions

                                    By using the extern C linkage specification around the C function declarations

                                    24 Explain the scope resolution operator

                                    The scope resolution operator permits a program to reference an identifier in the global scope that has been hidden by another identifier with the same name in the local scope

                                    25 What are the differences between a C++ struct and C++ class

                                    The default member and base class access specifiers are different

                                    26 How many ways are there to initialize an int with a constant

                                    Two

                                    27 How does throwing and catching exceptions differ from using setjmp and longjmp

                                    The throw operation calls the destructors for automatic objects instantiated since entry to the try block

                                    28 How does throwing and catching exceptions differ from using setjmp and longjmp

                                    The throw operation calls the destructors for automatic objects instantiated since entry to the try block

                                    29 What is a default constructor

                                    A constructor that has no arguments or one where all the arguments have default argument values

                                    If you dont code a default constructor the compiler provides one if there are no other constructors If you are going to instantiate an array of objects of the class the class must have a default constructor

                                    30 What is a conversion constructor

                                    It is a constructor that accepts one argument of a different type

                                    The compiler uses this idiom as one way to infer conversion rules for a class A constructor with more than one argument and with default argument values can be interpreted by the compiler as a conversion constructor when the compiler is looking for an object of the type and sees an object of the type of the constructors first argument

                                    31 What is the difference between a copy constructor and an overloaded assignment operator

                                    A copy constructor constructs a new object by using the content of the argument object An overloaded assignment operator assigns the contents of an existing object to another existing object of the same class

                                    First you must know that a copy constructor is one that has only one argument which is a reference to the same type as the constructor The compiler invokes a copy constructor wherever it needs to make a copy of the object for example to pass an argument by value If you do not provide a copy constructor the compiler creates a member-by-member copy constructor for you

                                    You can write overloaded assignment operators that take arguments of other classes but that behavior is usually implemented with implicit conversion constructors If you do not provide an overloaded assignment operator for the class the compiler creates a default member-by-member assignment operator

                                    This discussion is a good place to get into why classes need copy constructors and overloaded assignment operators By discussing the requirements with respect to data member pointers that point to dynamically allocated resources you demonstrate a good grasp of the problem

                                    32 When should you use multiple inheritance

                                    There are three acceptable answers Never Rarely and When the problem domain cannot be accurately modeled any other way

                                    33 What is a virtual destructor

                                    The simple answer is that a virtual destructor is one that is declared with the virtual attribute

                                    The behavior of a virtual destructor is what is important If you destroy an object through a pointer or reference to a base class and the base-class destructor is not virtual the derived-class destructors are not executed and the destruction might not be complete

                                    34 Explain the ISA and HASA class relationships How would you implement each in a class design

                                    A specialized class is a specialization of another class and therefore has the ISA relationship with the other class An Employee ISA Person This relationship is best implemented with inheritance Employee is derived from Person A class may have an instance of another class For example an Employee has a Salary therefore the Employee class has the HASA relationship with the Salary class This relationship is best implemented by embedding an object of the Salary class in the Employee class

                                    The answer to this question reveals whether you have an understanding of the fundamentals of object-oriented design which is important to reliable class design

                                    There are other relationships The USESA relationship is when one class uses the services of another The Employee class uses an object (cout) of the ostream class to display the employees name onscreen for example But if you get ISA and HASA right you usually dont need to go any further

                                    35 When is a template a better solution than a base class

                                    When you are designing a generic class to contain or otherwise manage objects of other types when the format and behavior of those other types are unimportant to their containment or management and particularly when those other types are unknown (thus the genericity) to the designer of the container or manager class

                                    Prior to templates you had to use inheritance your design might include a generic List container class and an application-specific Employee class To put employees in a list a ListedEmployee class is multiply derived (contrived) from the Employee and List classes These solutions were unwieldy and error-prone Templates solved that problem

                                    Questions for ANSI-Knowledgeable Applicants

                                    There are six questions for those who profess knowledge of the progress of the ANSI committee If you claim to have that much interest in the language you should know the answers to all these questions

                                    1 What is a mutable member

                                    A mutable member is one that can be modified by the class even when the object of the class or the member function doing the modification is const

                                    Understanding this requirement implies an understanding of C++ const which many programmers do not have I have seen large class designs that do not employ the const qualifier anywhere Some of those designs are my own early C++ efforts One author suggests that some programmers find const to be such a bother that it is easier to ignore const than to try to use it meaningfully No

                                    wonder many programmers dont understand the power and implications of const Someone who claims to have enough interest in the language and its evolution to keep pace with the ANSI deliberations should not be ignorant of const however

                                    2 What is an explicit constructor

                                    A conversion constructor declared with the explicit keyword The compiler does not use an explicit constructor to implement an implied conversion of types Its purpose is reserved explicitly for construction

                                    3 What is the Standard Template Library

                                    It is a library of container templates approved by the ANSI committee for inclusion in the standard C++ specification

                                    4 Describe run-time type identification

                                    It is the ability to determine at run time the type of an object by using the typeid operator or the dynamic_cast operator

                                    5 What problem does the namespace feature solve

                                    Multiple providers of libraries might use common global identifiers causing a name collision when an application tries to link with two or more such libraries The name-space feature surrounds a librarys external declarations with a unique namespace that eliminates the potential for those collisions

                                    This solution assumes that two library vendors dont use the same namespace of course

                                    6 Are there any new intrinsic (built-in) data types

                                    Yes The ANSI committee added the bool intrinsic type and its true and false value keywords and the wchar_t data type to support character sets wider than eight bits

                                    SQL Server

                                    1 What is a foreign key

                                    A foreign key is a column or combination of columns used to establish and enforce a link (referential integrity) between the data in two tables A link is created between two tables by adding the column or columns that hold one tablersquos primary key values to the other table This column becomes a foreign key in the second table

                                    2 What is the difference between a primary key and unique key

                                    There can be only one primary key constrain on a table but there can be many unique key constraints in a table

                                    Primary key doesnrsquot allow null values but Unique allows 1 Null value

                                    3 What is an index

                                    Indexes are database objects which provides faster data access The index provides pointers to the data values stored in specified columns of

                                    the table and then orders those pointers according to the sort order you specify

                                    Different types of indexes are unique index clustered index and non-clustered index

                                    4 How to return multiple result set from a stored proc and capture it in ADO

                                    Use multiple Select statements to return multiple result sets Use ADOrsquos GetNextRecordset() method to get the second recordset during the

                                    execution of the stored proc

                                    • COMDCOM
                                    • Visual Basic
                                    • General Scripting Questions
                                    • Session and Application Variable Questions
                                      • Image Questions
                                      • Browser Questions
                                      • ActiveX Data Objects Questions
                                      • Form and Query String Questions
                                        • 18 What is a virtual member function
                                        • 19 How can C++ achieve dynamic binding yet also static typing
                                        • 20 Whats the difference between how virtual and non-virtual member functions are called
                                        • 21 When should my destructor be virtual
                                        • 22 What is a virtual constructor
                                        • Questions for ANSI-Knowledgeable Applicants

                                      There are two methods that you can use to retrieve the value from a SQL function or a SQL global variable You can either use an alias for the value or refer to the value by its ordinal position in the Recordset

                                      7 How do you retrieve an output parameter from a SQL stored procedure within an ASPScript

                                      You must use the ADO Command nad parameter objects

                                      Form and Query String Questions

                                      1 How do you accept file uploads in an HTML form

                                      ltlt Need an answer gtgt

                                      2 What causes the value of a form field to become truncated

                                      HTML uses quotation marks to mark the beginning and end of a value So If a variable contains question marks in its values the value of the variablewill be truncated when displayed

                                      3 How do you include spaces or other special characters in a query string

                                      URL encode the query string

                                      C++ Questions

                                      1 What is an object in C++

                                      An object is a package that contains related data and instructions The data relates to what the object represents while the instructions define how this object relates to other objects and itself

                                      2 What is a message

                                      A message is a signal from one object to another requesting that a computation take place It is roughly equivalent to a function call in other languages

                                      3 What is a class

                                      A class defines the characteristics of a certain type of object It defines what its members will remember the messages to which they will respond and what form the response will take

                                      4 What is an instance

                                      It is an individual object that is a member of some class

                                      5 What is a super-class

                                      Given a class a super-class is the basis of the class under consideration The given class is defined as a subset (in some respects) of the super-class All objects of the given class potentially posses all the characteristics belonging to objects of the super-class

                                      6 What is inheritance

                                      Inheritance is property such that a parent (or super) class passes the characteristics of itself to children (or sub) classes that are derived from it The sub-class has the option of modifying these characteristics in order to make a different but fundamentally related class from the super-class

                                      7 To what does message protocol refer

                                      An objects message protocol is the exact form of the set of messages to which the object can respond

                                      8 What is polymorphism

                                      Polymorphism refers to the ability of an object to respond in a logically identical fashion to messages of the same protocol containing differing types of objects Consider 1 + 5 and 1 + 51 In the former the message + 5 is sent to an object of class integer (1) In the later the message + 51 is sent to the same integer object The form of the message (its protocol) is identical in both cases What differs is the type of object on the right-hand side of these messages The former is an integer object (5) while the later is a floating point object (51) The receiver (1) appears (to other objects) to respond in the same way to both messages Internally however it knows that it must treat the two types of objects differently in order to obtain the same overall response

                                      9 What are instance variables

                                      These represent an objects private memory They are defined in an objects class

                                      18 What is a virtual member function

                                      A virtual function allows derived classes to replace the implementation provided by the base class The compiler makes sure the replacement is always called whenever the object in question is actually of the derived class even if the object is accessed by a base pointer rather than a derived pointer This allows algorithms in the base class to be replaced in the derived class even if users dont know about the derived class

                                      The derived class can either fully replace (override) the base class member function or the derived class can partially replace (augment) the base class member function The latter is accomplished by having the derived class member function call the base class member function if desired

                                      19 How can C++ achieve dynamic binding yet also static typing

                                      When you have a pointer to an object the object may actually be of a class that is derived from the class of the pointer (eg a Vehicle that is actually pointing to a Car object) Thus there are two types the (static) type of the pointer (Vehicle in this case) and the (dynamic) type of the pointed-to object (Car in this case)

                                      Static typing means that the legality of a member function invocation is checked at the earliest possible moment by the compiler at compile time The compiler uses the static type of the pointer to determine whether the member function invocation is legal If the type of the pointer can handle the member function certainly the pointed-to object can handle it as well Eg if Vehicle has a certain member function certainly Car also has that member function since Car is a kind-of Vehicle

                                      Dynamic binding means that the address of the code in a member function invocation is determined at the last possible moment based on the dynamic type of the object at run time It is called dynamic binding because the binding to the code that actually gets called is accomplished dynamically (at run time) Dynamic binding is a result of virtual functions

                                      20 Whats the difference between how virtual and non-virtual member functions are called

                                      Non-virtual member functions are resolved statically That is the member function is selected statically (at compile-time) based on the type of the pointer (or reference) to the object

                                      In contrast virtual member functions are resolved dynamically (at run-time) That is the member function is selected dynamically (at run-time) based on the type of the object not the type of the pointerreference to that object This is called dynamic binding Most compilers use some variant of the following technique

                                      if the object has one or more virtual functions the compiler puts a hidden pointer in the object called a virtual-pointer or v-pointer This v-pointer points to a global table called the virtual-table or v-table

                                      The compiler creates a v-table for each class that has at least one virtual function For example if class Circle has virtual functions for draw() and move() and resize() there would be exactly one v-table associated with class Circle even if there were a gazillion Circle objects and the v-pointer of each of those Circle objects would point to the Circle v-table The v-table itself has pointers to each of the virtual functions in the class For example the Circle v-table would have three pointers a pointer to Circledraw() a pointer to Circlemove() and a pointer to Circleresize()

                                      During a dispatch of a virtual function the run-time system follows the objects v-pointer to the classs v-table then follows the appropriate slot in the v-table to the method code

                                      The space-cost overhead of the above technique is nominal an extra pointer per object (but only for objects that will need to do dynamic binding) plus an extra pointer per method (but only for virtual methods) The time-cost overhead is also fairly nominal compared to a normal function call a virtual function call requires two extra fetches (one to get the value of the v-pointer a second to get the address of the method) None of this runtime activity happens with non-virtual functions since the compiler resolves non-virtual functions exclusively at compile-time based on the type of the pointer

                                      21 When should my destructor be virtual

                                      When you may delete a derived object via a base pointer

                                      virtual functions bind to the code associated with the class of the object rather than with the class of the pointerreference When you say delete basePtr and the base class has a virtual destructor the destructor that gets invoked is the one associated with the type of the object basePtr rather than the one associated with the type of the pointer This is generally A Good Thing

                                      TECHNO-GEEK WARNING PUT YOUR PROPELLER HAT ON Technically speaking you need a base classs destructor to be virtual if and only if you intend to allow someone to invoke an objects destructor via a base class pointer (this is normally done implicitly via delete) and the object being destructed is of a derived class that has a non-trivial destructor A class has a non-trivial destructor if it either has an explicit destructor or if it has a member object or a base class that has a non-trivial destructor (note that this is a recursive definition (eg a class has a non-trivial destructor if it has a member object (which has a base class (which has a member object (which has a base class (which has an explicit destructor)))))) END TECHNO-GEEK WARNING REMOVE YOUR PROPELLER HAT

                                      If you had a hard grokking the previous rule try this (over)simplified one on for size A class should have a virtual destructor unless that class has no virtual functions Rationale if you have any virtual functions at all youre probably going to be doing stuff to derived objects via a base pointer and some of the stuff you may do may include invoking a destructor (normally done implicitly via delete) Plus once youve put the first virtual function into a class youve already paid all the per-object space cost that youll ever pay (one pointer per object note that this is theoretically compiler-specific in practice everyone does it pretty much the same way) so making the destructor virtual wont generally cost you anything extra

                                      22 What is a virtual constructor

                                      An idiom that allows you to do something that C++ doesnt directly support

                                      You can get the effect of a virtual constructor by a virtual clone() member function (for copy constructing) or a virtual create() member function (for the default constructor)

                                      class Shape public virtual ~Shape() A virtual destructor virtual void draw() = 0 A pure virtual function virtual void move() = 0 virtual Shape clone() const = 0 Uses the copy constructor virtual Shape create() const = 0 Uses the default constructor class Circle public Shape public Circle clone() const return new Circle(this) Circle create() const return new Circle()

                                      In the clone() member function the new Circle(this) code calls Circles copy constructor to copy the state of this into the newly created Circle object In the create() member function the new Circle() code calls Circles default constructor

                                      Users use these as if they were virtual constructors

                                      void userCode(Shapeamp s) Shape s2 = sclone() Shape s3 = screate() delete s2 You probably need a virtual destructor here

                                      delete s3

                                      23 How do you link a C++ program to C functions

                                      By using the extern C linkage specification around the C function declarations

                                      24 Explain the scope resolution operator

                                      The scope resolution operator permits a program to reference an identifier in the global scope that has been hidden by another identifier with the same name in the local scope

                                      25 What are the differences between a C++ struct and C++ class

                                      The default member and base class access specifiers are different

                                      26 How many ways are there to initialize an int with a constant

                                      Two

                                      27 How does throwing and catching exceptions differ from using setjmp and longjmp

                                      The throw operation calls the destructors for automatic objects instantiated since entry to the try block

                                      28 How does throwing and catching exceptions differ from using setjmp and longjmp

                                      The throw operation calls the destructors for automatic objects instantiated since entry to the try block

                                      29 What is a default constructor

                                      A constructor that has no arguments or one where all the arguments have default argument values

                                      If you dont code a default constructor the compiler provides one if there are no other constructors If you are going to instantiate an array of objects of the class the class must have a default constructor

                                      30 What is a conversion constructor

                                      It is a constructor that accepts one argument of a different type

                                      The compiler uses this idiom as one way to infer conversion rules for a class A constructor with more than one argument and with default argument values can be interpreted by the compiler as a conversion constructor when the compiler is looking for an object of the type and sees an object of the type of the constructors first argument

                                      31 What is the difference between a copy constructor and an overloaded assignment operator

                                      A copy constructor constructs a new object by using the content of the argument object An overloaded assignment operator assigns the contents of an existing object to another existing object of the same class

                                      First you must know that a copy constructor is one that has only one argument which is a reference to the same type as the constructor The compiler invokes a copy constructor wherever it needs to make a copy of the object for example to pass an argument by value If you do not provide a copy constructor the compiler creates a member-by-member copy constructor for you

                                      You can write overloaded assignment operators that take arguments of other classes but that behavior is usually implemented with implicit conversion constructors If you do not provide an overloaded assignment operator for the class the compiler creates a default member-by-member assignment operator

                                      This discussion is a good place to get into why classes need copy constructors and overloaded assignment operators By discussing the requirements with respect to data member pointers that point to dynamically allocated resources you demonstrate a good grasp of the problem

                                      32 When should you use multiple inheritance

                                      There are three acceptable answers Never Rarely and When the problem domain cannot be accurately modeled any other way

                                      33 What is a virtual destructor

                                      The simple answer is that a virtual destructor is one that is declared with the virtual attribute

                                      The behavior of a virtual destructor is what is important If you destroy an object through a pointer or reference to a base class and the base-class destructor is not virtual the derived-class destructors are not executed and the destruction might not be complete

                                      34 Explain the ISA and HASA class relationships How would you implement each in a class design

                                      A specialized class is a specialization of another class and therefore has the ISA relationship with the other class An Employee ISA Person This relationship is best implemented with inheritance Employee is derived from Person A class may have an instance of another class For example an Employee has a Salary therefore the Employee class has the HASA relationship with the Salary class This relationship is best implemented by embedding an object of the Salary class in the Employee class

                                      The answer to this question reveals whether you have an understanding of the fundamentals of object-oriented design which is important to reliable class design

                                      There are other relationships The USESA relationship is when one class uses the services of another The Employee class uses an object (cout) of the ostream class to display the employees name onscreen for example But if you get ISA and HASA right you usually dont need to go any further

                                      35 When is a template a better solution than a base class

                                      When you are designing a generic class to contain or otherwise manage objects of other types when the format and behavior of those other types are unimportant to their containment or management and particularly when those other types are unknown (thus the genericity) to the designer of the container or manager class

                                      Prior to templates you had to use inheritance your design might include a generic List container class and an application-specific Employee class To put employees in a list a ListedEmployee class is multiply derived (contrived) from the Employee and List classes These solutions were unwieldy and error-prone Templates solved that problem

                                      Questions for ANSI-Knowledgeable Applicants

                                      There are six questions for those who profess knowledge of the progress of the ANSI committee If you claim to have that much interest in the language you should know the answers to all these questions

                                      1 What is a mutable member

                                      A mutable member is one that can be modified by the class even when the object of the class or the member function doing the modification is const

                                      Understanding this requirement implies an understanding of C++ const which many programmers do not have I have seen large class designs that do not employ the const qualifier anywhere Some of those designs are my own early C++ efforts One author suggests that some programmers find const to be such a bother that it is easier to ignore const than to try to use it meaningfully No

                                      wonder many programmers dont understand the power and implications of const Someone who claims to have enough interest in the language and its evolution to keep pace with the ANSI deliberations should not be ignorant of const however

                                      2 What is an explicit constructor

                                      A conversion constructor declared with the explicit keyword The compiler does not use an explicit constructor to implement an implied conversion of types Its purpose is reserved explicitly for construction

                                      3 What is the Standard Template Library

                                      It is a library of container templates approved by the ANSI committee for inclusion in the standard C++ specification

                                      4 Describe run-time type identification

                                      It is the ability to determine at run time the type of an object by using the typeid operator or the dynamic_cast operator

                                      5 What problem does the namespace feature solve

                                      Multiple providers of libraries might use common global identifiers causing a name collision when an application tries to link with two or more such libraries The name-space feature surrounds a librarys external declarations with a unique namespace that eliminates the potential for those collisions

                                      This solution assumes that two library vendors dont use the same namespace of course

                                      6 Are there any new intrinsic (built-in) data types

                                      Yes The ANSI committee added the bool intrinsic type and its true and false value keywords and the wchar_t data type to support character sets wider than eight bits

                                      SQL Server

                                      1 What is a foreign key

                                      A foreign key is a column or combination of columns used to establish and enforce a link (referential integrity) between the data in two tables A link is created between two tables by adding the column or columns that hold one tablersquos primary key values to the other table This column becomes a foreign key in the second table

                                      2 What is the difference between a primary key and unique key

                                      There can be only one primary key constrain on a table but there can be many unique key constraints in a table

                                      Primary key doesnrsquot allow null values but Unique allows 1 Null value

                                      3 What is an index

                                      Indexes are database objects which provides faster data access The index provides pointers to the data values stored in specified columns of

                                      the table and then orders those pointers according to the sort order you specify

                                      Different types of indexes are unique index clustered index and non-clustered index

                                      4 How to return multiple result set from a stored proc and capture it in ADO

                                      Use multiple Select statements to return multiple result sets Use ADOrsquos GetNextRecordset() method to get the second recordset during the

                                      execution of the stored proc

                                      • COMDCOM
                                      • Visual Basic
                                      • General Scripting Questions
                                      • Session and Application Variable Questions
                                        • Image Questions
                                        • Browser Questions
                                        • ActiveX Data Objects Questions
                                        • Form and Query String Questions
                                          • 18 What is a virtual member function
                                          • 19 How can C++ achieve dynamic binding yet also static typing
                                          • 20 Whats the difference between how virtual and non-virtual member functions are called
                                          • 21 When should my destructor be virtual
                                          • 22 What is a virtual constructor
                                          • Questions for ANSI-Knowledgeable Applicants

                                        1 What is an object in C++

                                        An object is a package that contains related data and instructions The data relates to what the object represents while the instructions define how this object relates to other objects and itself

                                        2 What is a message

                                        A message is a signal from one object to another requesting that a computation take place It is roughly equivalent to a function call in other languages

                                        3 What is a class

                                        A class defines the characteristics of a certain type of object It defines what its members will remember the messages to which they will respond and what form the response will take

                                        4 What is an instance

                                        It is an individual object that is a member of some class

                                        5 What is a super-class

                                        Given a class a super-class is the basis of the class under consideration The given class is defined as a subset (in some respects) of the super-class All objects of the given class potentially posses all the characteristics belonging to objects of the super-class

                                        6 What is inheritance

                                        Inheritance is property such that a parent (or super) class passes the characteristics of itself to children (or sub) classes that are derived from it The sub-class has the option of modifying these characteristics in order to make a different but fundamentally related class from the super-class

                                        7 To what does message protocol refer

                                        An objects message protocol is the exact form of the set of messages to which the object can respond

                                        8 What is polymorphism

                                        Polymorphism refers to the ability of an object to respond in a logically identical fashion to messages of the same protocol containing differing types of objects Consider 1 + 5 and 1 + 51 In the former the message + 5 is sent to an object of class integer (1) In the later the message + 51 is sent to the same integer object The form of the message (its protocol) is identical in both cases What differs is the type of object on the right-hand side of these messages The former is an integer object (5) while the later is a floating point object (51) The receiver (1) appears (to other objects) to respond in the same way to both messages Internally however it knows that it must treat the two types of objects differently in order to obtain the same overall response

                                        9 What are instance variables

                                        These represent an objects private memory They are defined in an objects class

                                        18 What is a virtual member function

                                        A virtual function allows derived classes to replace the implementation provided by the base class The compiler makes sure the replacement is always called whenever the object in question is actually of the derived class even if the object is accessed by a base pointer rather than a derived pointer This allows algorithms in the base class to be replaced in the derived class even if users dont know about the derived class

                                        The derived class can either fully replace (override) the base class member function or the derived class can partially replace (augment) the base class member function The latter is accomplished by having the derived class member function call the base class member function if desired

                                        19 How can C++ achieve dynamic binding yet also static typing

                                        When you have a pointer to an object the object may actually be of a class that is derived from the class of the pointer (eg a Vehicle that is actually pointing to a Car object) Thus there are two types the (static) type of the pointer (Vehicle in this case) and the (dynamic) type of the pointed-to object (Car in this case)

                                        Static typing means that the legality of a member function invocation is checked at the earliest possible moment by the compiler at compile time The compiler uses the static type of the pointer to determine whether the member function invocation is legal If the type of the pointer can handle the member function certainly the pointed-to object can handle it as well Eg if Vehicle has a certain member function certainly Car also has that member function since Car is a kind-of Vehicle

                                        Dynamic binding means that the address of the code in a member function invocation is determined at the last possible moment based on the dynamic type of the object at run time It is called dynamic binding because the binding to the code that actually gets called is accomplished dynamically (at run time) Dynamic binding is a result of virtual functions

                                        20 Whats the difference between how virtual and non-virtual member functions are called

                                        Non-virtual member functions are resolved statically That is the member function is selected statically (at compile-time) based on the type of the pointer (or reference) to the object

                                        In contrast virtual member functions are resolved dynamically (at run-time) That is the member function is selected dynamically (at run-time) based on the type of the object not the type of the pointerreference to that object This is called dynamic binding Most compilers use some variant of the following technique

                                        if the object has one or more virtual functions the compiler puts a hidden pointer in the object called a virtual-pointer or v-pointer This v-pointer points to a global table called the virtual-table or v-table

                                        The compiler creates a v-table for each class that has at least one virtual function For example if class Circle has virtual functions for draw() and move() and resize() there would be exactly one v-table associated with class Circle even if there were a gazillion Circle objects and the v-pointer of each of those Circle objects would point to the Circle v-table The v-table itself has pointers to each of the virtual functions in the class For example the Circle v-table would have three pointers a pointer to Circledraw() a pointer to Circlemove() and a pointer to Circleresize()

                                        During a dispatch of a virtual function the run-time system follows the objects v-pointer to the classs v-table then follows the appropriate slot in the v-table to the method code

                                        The space-cost overhead of the above technique is nominal an extra pointer per object (but only for objects that will need to do dynamic binding) plus an extra pointer per method (but only for virtual methods) The time-cost overhead is also fairly nominal compared to a normal function call a virtual function call requires two extra fetches (one to get the value of the v-pointer a second to get the address of the method) None of this runtime activity happens with non-virtual functions since the compiler resolves non-virtual functions exclusively at compile-time based on the type of the pointer

                                        21 When should my destructor be virtual

                                        When you may delete a derived object via a base pointer

                                        virtual functions bind to the code associated with the class of the object rather than with the class of the pointerreference When you say delete basePtr and the base class has a virtual destructor the destructor that gets invoked is the one associated with the type of the object basePtr rather than the one associated with the type of the pointer This is generally A Good Thing

                                        TECHNO-GEEK WARNING PUT YOUR PROPELLER HAT ON Technically speaking you need a base classs destructor to be virtual if and only if you intend to allow someone to invoke an objects destructor via a base class pointer (this is normally done implicitly via delete) and the object being destructed is of a derived class that has a non-trivial destructor A class has a non-trivial destructor if it either has an explicit destructor or if it has a member object or a base class that has a non-trivial destructor (note that this is a recursive definition (eg a class has a non-trivial destructor if it has a member object (which has a base class (which has a member object (which has a base class (which has an explicit destructor)))))) END TECHNO-GEEK WARNING REMOVE YOUR PROPELLER HAT

                                        If you had a hard grokking the previous rule try this (over)simplified one on for size A class should have a virtual destructor unless that class has no virtual functions Rationale if you have any virtual functions at all youre probably going to be doing stuff to derived objects via a base pointer and some of the stuff you may do may include invoking a destructor (normally done implicitly via delete) Plus once youve put the first virtual function into a class youve already paid all the per-object space cost that youll ever pay (one pointer per object note that this is theoretically compiler-specific in practice everyone does it pretty much the same way) so making the destructor virtual wont generally cost you anything extra

                                        22 What is a virtual constructor

                                        An idiom that allows you to do something that C++ doesnt directly support

                                        You can get the effect of a virtual constructor by a virtual clone() member function (for copy constructing) or a virtual create() member function (for the default constructor)

                                        class Shape public virtual ~Shape() A virtual destructor virtual void draw() = 0 A pure virtual function virtual void move() = 0 virtual Shape clone() const = 0 Uses the copy constructor virtual Shape create() const = 0 Uses the default constructor class Circle public Shape public Circle clone() const return new Circle(this) Circle create() const return new Circle()

                                        In the clone() member function the new Circle(this) code calls Circles copy constructor to copy the state of this into the newly created Circle object In the create() member function the new Circle() code calls Circles default constructor

                                        Users use these as if they were virtual constructors

                                        void userCode(Shapeamp s) Shape s2 = sclone() Shape s3 = screate() delete s2 You probably need a virtual destructor here

                                        delete s3

                                        23 How do you link a C++ program to C functions

                                        By using the extern C linkage specification around the C function declarations

                                        24 Explain the scope resolution operator

                                        The scope resolution operator permits a program to reference an identifier in the global scope that has been hidden by another identifier with the same name in the local scope

                                        25 What are the differences between a C++ struct and C++ class

                                        The default member and base class access specifiers are different

                                        26 How many ways are there to initialize an int with a constant

                                        Two

                                        27 How does throwing and catching exceptions differ from using setjmp and longjmp

                                        The throw operation calls the destructors for automatic objects instantiated since entry to the try block

                                        28 How does throwing and catching exceptions differ from using setjmp and longjmp

                                        The throw operation calls the destructors for automatic objects instantiated since entry to the try block

                                        29 What is a default constructor

                                        A constructor that has no arguments or one where all the arguments have default argument values

                                        If you dont code a default constructor the compiler provides one if there are no other constructors If you are going to instantiate an array of objects of the class the class must have a default constructor

                                        30 What is a conversion constructor

                                        It is a constructor that accepts one argument of a different type

                                        The compiler uses this idiom as one way to infer conversion rules for a class A constructor with more than one argument and with default argument values can be interpreted by the compiler as a conversion constructor when the compiler is looking for an object of the type and sees an object of the type of the constructors first argument

                                        31 What is the difference between a copy constructor and an overloaded assignment operator

                                        A copy constructor constructs a new object by using the content of the argument object An overloaded assignment operator assigns the contents of an existing object to another existing object of the same class

                                        First you must know that a copy constructor is one that has only one argument which is a reference to the same type as the constructor The compiler invokes a copy constructor wherever it needs to make a copy of the object for example to pass an argument by value If you do not provide a copy constructor the compiler creates a member-by-member copy constructor for you

                                        You can write overloaded assignment operators that take arguments of other classes but that behavior is usually implemented with implicit conversion constructors If you do not provide an overloaded assignment operator for the class the compiler creates a default member-by-member assignment operator

                                        This discussion is a good place to get into why classes need copy constructors and overloaded assignment operators By discussing the requirements with respect to data member pointers that point to dynamically allocated resources you demonstrate a good grasp of the problem

                                        32 When should you use multiple inheritance

                                        There are three acceptable answers Never Rarely and When the problem domain cannot be accurately modeled any other way

                                        33 What is a virtual destructor

                                        The simple answer is that a virtual destructor is one that is declared with the virtual attribute

                                        The behavior of a virtual destructor is what is important If you destroy an object through a pointer or reference to a base class and the base-class destructor is not virtual the derived-class destructors are not executed and the destruction might not be complete

                                        34 Explain the ISA and HASA class relationships How would you implement each in a class design

                                        A specialized class is a specialization of another class and therefore has the ISA relationship with the other class An Employee ISA Person This relationship is best implemented with inheritance Employee is derived from Person A class may have an instance of another class For example an Employee has a Salary therefore the Employee class has the HASA relationship with the Salary class This relationship is best implemented by embedding an object of the Salary class in the Employee class

                                        The answer to this question reveals whether you have an understanding of the fundamentals of object-oriented design which is important to reliable class design

                                        There are other relationships The USESA relationship is when one class uses the services of another The Employee class uses an object (cout) of the ostream class to display the employees name onscreen for example But if you get ISA and HASA right you usually dont need to go any further

                                        35 When is a template a better solution than a base class

                                        When you are designing a generic class to contain or otherwise manage objects of other types when the format and behavior of those other types are unimportant to their containment or management and particularly when those other types are unknown (thus the genericity) to the designer of the container or manager class

                                        Prior to templates you had to use inheritance your design might include a generic List container class and an application-specific Employee class To put employees in a list a ListedEmployee class is multiply derived (contrived) from the Employee and List classes These solutions were unwieldy and error-prone Templates solved that problem

                                        Questions for ANSI-Knowledgeable Applicants

                                        There are six questions for those who profess knowledge of the progress of the ANSI committee If you claim to have that much interest in the language you should know the answers to all these questions

                                        1 What is a mutable member

                                        A mutable member is one that can be modified by the class even when the object of the class or the member function doing the modification is const

                                        Understanding this requirement implies an understanding of C++ const which many programmers do not have I have seen large class designs that do not employ the const qualifier anywhere Some of those designs are my own early C++ efforts One author suggests that some programmers find const to be such a bother that it is easier to ignore const than to try to use it meaningfully No

                                        wonder many programmers dont understand the power and implications of const Someone who claims to have enough interest in the language and its evolution to keep pace with the ANSI deliberations should not be ignorant of const however

                                        2 What is an explicit constructor

                                        A conversion constructor declared with the explicit keyword The compiler does not use an explicit constructor to implement an implied conversion of types Its purpose is reserved explicitly for construction

                                        3 What is the Standard Template Library

                                        It is a library of container templates approved by the ANSI committee for inclusion in the standard C++ specification

                                        4 Describe run-time type identification

                                        It is the ability to determine at run time the type of an object by using the typeid operator or the dynamic_cast operator

                                        5 What problem does the namespace feature solve

                                        Multiple providers of libraries might use common global identifiers causing a name collision when an application tries to link with two or more such libraries The name-space feature surrounds a librarys external declarations with a unique namespace that eliminates the potential for those collisions

                                        This solution assumes that two library vendors dont use the same namespace of course

                                        6 Are there any new intrinsic (built-in) data types

                                        Yes The ANSI committee added the bool intrinsic type and its true and false value keywords and the wchar_t data type to support character sets wider than eight bits

                                        SQL Server

                                        1 What is a foreign key

                                        A foreign key is a column or combination of columns used to establish and enforce a link (referential integrity) between the data in two tables A link is created between two tables by adding the column or columns that hold one tablersquos primary key values to the other table This column becomes a foreign key in the second table

                                        2 What is the difference between a primary key and unique key

                                        There can be only one primary key constrain on a table but there can be many unique key constraints in a table

                                        Primary key doesnrsquot allow null values but Unique allows 1 Null value

                                        3 What is an index

                                        Indexes are database objects which provides faster data access The index provides pointers to the data values stored in specified columns of

                                        the table and then orders those pointers according to the sort order you specify

                                        Different types of indexes are unique index clustered index and non-clustered index

                                        4 How to return multiple result set from a stored proc and capture it in ADO

                                        Use multiple Select statements to return multiple result sets Use ADOrsquos GetNextRecordset() method to get the second recordset during the

                                        execution of the stored proc

                                        • COMDCOM
                                        • Visual Basic
                                        • General Scripting Questions
                                        • Session and Application Variable Questions
                                          • Image Questions
                                          • Browser Questions
                                          • ActiveX Data Objects Questions
                                          • Form and Query String Questions
                                            • 18 What is a virtual member function
                                            • 19 How can C++ achieve dynamic binding yet also static typing
                                            • 20 Whats the difference between how virtual and non-virtual member functions are called
                                            • 21 When should my destructor be virtual
                                            • 22 What is a virtual constructor
                                            • Questions for ANSI-Knowledgeable Applicants

                                          18 What is a virtual member function

                                          A virtual function allows derived classes to replace the implementation provided by the base class The compiler makes sure the replacement is always called whenever the object in question is actually of the derived class even if the object is accessed by a base pointer rather than a derived pointer This allows algorithms in the base class to be replaced in the derived class even if users dont know about the derived class

                                          The derived class can either fully replace (override) the base class member function or the derived class can partially replace (augment) the base class member function The latter is accomplished by having the derived class member function call the base class member function if desired

                                          19 How can C++ achieve dynamic binding yet also static typing

                                          When you have a pointer to an object the object may actually be of a class that is derived from the class of the pointer (eg a Vehicle that is actually pointing to a Car object) Thus there are two types the (static) type of the pointer (Vehicle in this case) and the (dynamic) type of the pointed-to object (Car in this case)

                                          Static typing means that the legality of a member function invocation is checked at the earliest possible moment by the compiler at compile time The compiler uses the static type of the pointer to determine whether the member function invocation is legal If the type of the pointer can handle the member function certainly the pointed-to object can handle it as well Eg if Vehicle has a certain member function certainly Car also has that member function since Car is a kind-of Vehicle

                                          Dynamic binding means that the address of the code in a member function invocation is determined at the last possible moment based on the dynamic type of the object at run time It is called dynamic binding because the binding to the code that actually gets called is accomplished dynamically (at run time) Dynamic binding is a result of virtual functions

                                          20 Whats the difference between how virtual and non-virtual member functions are called

                                          Non-virtual member functions are resolved statically That is the member function is selected statically (at compile-time) based on the type of the pointer (or reference) to the object

                                          In contrast virtual member functions are resolved dynamically (at run-time) That is the member function is selected dynamically (at run-time) based on the type of the object not the type of the pointerreference to that object This is called dynamic binding Most compilers use some variant of the following technique

                                          if the object has one or more virtual functions the compiler puts a hidden pointer in the object called a virtual-pointer or v-pointer This v-pointer points to a global table called the virtual-table or v-table

                                          The compiler creates a v-table for each class that has at least one virtual function For example if class Circle has virtual functions for draw() and move() and resize() there would be exactly one v-table associated with class Circle even if there were a gazillion Circle objects and the v-pointer of each of those Circle objects would point to the Circle v-table The v-table itself has pointers to each of the virtual functions in the class For example the Circle v-table would have three pointers a pointer to Circledraw() a pointer to Circlemove() and a pointer to Circleresize()

                                          During a dispatch of a virtual function the run-time system follows the objects v-pointer to the classs v-table then follows the appropriate slot in the v-table to the method code

                                          The space-cost overhead of the above technique is nominal an extra pointer per object (but only for objects that will need to do dynamic binding) plus an extra pointer per method (but only for virtual methods) The time-cost overhead is also fairly nominal compared to a normal function call a virtual function call requires two extra fetches (one to get the value of the v-pointer a second to get the address of the method) None of this runtime activity happens with non-virtual functions since the compiler resolves non-virtual functions exclusively at compile-time based on the type of the pointer

                                          21 When should my destructor be virtual

                                          When you may delete a derived object via a base pointer

                                          virtual functions bind to the code associated with the class of the object rather than with the class of the pointerreference When you say delete basePtr and the base class has a virtual destructor the destructor that gets invoked is the one associated with the type of the object basePtr rather than the one associated with the type of the pointer This is generally A Good Thing

                                          TECHNO-GEEK WARNING PUT YOUR PROPELLER HAT ON Technically speaking you need a base classs destructor to be virtual if and only if you intend to allow someone to invoke an objects destructor via a base class pointer (this is normally done implicitly via delete) and the object being destructed is of a derived class that has a non-trivial destructor A class has a non-trivial destructor if it either has an explicit destructor or if it has a member object or a base class that has a non-trivial destructor (note that this is a recursive definition (eg a class has a non-trivial destructor if it has a member object (which has a base class (which has a member object (which has a base class (which has an explicit destructor)))))) END TECHNO-GEEK WARNING REMOVE YOUR PROPELLER HAT

                                          If you had a hard grokking the previous rule try this (over)simplified one on for size A class should have a virtual destructor unless that class has no virtual functions Rationale if you have any virtual functions at all youre probably going to be doing stuff to derived objects via a base pointer and some of the stuff you may do may include invoking a destructor (normally done implicitly via delete) Plus once youve put the first virtual function into a class youve already paid all the per-object space cost that youll ever pay (one pointer per object note that this is theoretically compiler-specific in practice everyone does it pretty much the same way) so making the destructor virtual wont generally cost you anything extra

                                          22 What is a virtual constructor

                                          An idiom that allows you to do something that C++ doesnt directly support

                                          You can get the effect of a virtual constructor by a virtual clone() member function (for copy constructing) or a virtual create() member function (for the default constructor)

                                          class Shape public virtual ~Shape() A virtual destructor virtual void draw() = 0 A pure virtual function virtual void move() = 0 virtual Shape clone() const = 0 Uses the copy constructor virtual Shape create() const = 0 Uses the default constructor class Circle public Shape public Circle clone() const return new Circle(this) Circle create() const return new Circle()

                                          In the clone() member function the new Circle(this) code calls Circles copy constructor to copy the state of this into the newly created Circle object In the create() member function the new Circle() code calls Circles default constructor

                                          Users use these as if they were virtual constructors

                                          void userCode(Shapeamp s) Shape s2 = sclone() Shape s3 = screate() delete s2 You probably need a virtual destructor here

                                          delete s3

                                          23 How do you link a C++ program to C functions

                                          By using the extern C linkage specification around the C function declarations

                                          24 Explain the scope resolution operator

                                          The scope resolution operator permits a program to reference an identifier in the global scope that has been hidden by another identifier with the same name in the local scope

                                          25 What are the differences between a C++ struct and C++ class

                                          The default member and base class access specifiers are different

                                          26 How many ways are there to initialize an int with a constant

                                          Two

                                          27 How does throwing and catching exceptions differ from using setjmp and longjmp

                                          The throw operation calls the destructors for automatic objects instantiated since entry to the try block

                                          28 How does throwing and catching exceptions differ from using setjmp and longjmp

                                          The throw operation calls the destructors for automatic objects instantiated since entry to the try block

                                          29 What is a default constructor

                                          A constructor that has no arguments or one where all the arguments have default argument values

                                          If you dont code a default constructor the compiler provides one if there are no other constructors If you are going to instantiate an array of objects of the class the class must have a default constructor

                                          30 What is a conversion constructor

                                          It is a constructor that accepts one argument of a different type

                                          The compiler uses this idiom as one way to infer conversion rules for a class A constructor with more than one argument and with default argument values can be interpreted by the compiler as a conversion constructor when the compiler is looking for an object of the type and sees an object of the type of the constructors first argument

                                          31 What is the difference between a copy constructor and an overloaded assignment operator

                                          A copy constructor constructs a new object by using the content of the argument object An overloaded assignment operator assigns the contents of an existing object to another existing object of the same class

                                          First you must know that a copy constructor is one that has only one argument which is a reference to the same type as the constructor The compiler invokes a copy constructor wherever it needs to make a copy of the object for example to pass an argument by value If you do not provide a copy constructor the compiler creates a member-by-member copy constructor for you

                                          You can write overloaded assignment operators that take arguments of other classes but that behavior is usually implemented with implicit conversion constructors If you do not provide an overloaded assignment operator for the class the compiler creates a default member-by-member assignment operator

                                          This discussion is a good place to get into why classes need copy constructors and overloaded assignment operators By discussing the requirements with respect to data member pointers that point to dynamically allocated resources you demonstrate a good grasp of the problem

                                          32 When should you use multiple inheritance

                                          There are three acceptable answers Never Rarely and When the problem domain cannot be accurately modeled any other way

                                          33 What is a virtual destructor

                                          The simple answer is that a virtual destructor is one that is declared with the virtual attribute

                                          The behavior of a virtual destructor is what is important If you destroy an object through a pointer or reference to a base class and the base-class destructor is not virtual the derived-class destructors are not executed and the destruction might not be complete

                                          34 Explain the ISA and HASA class relationships How would you implement each in a class design

                                          A specialized class is a specialization of another class and therefore has the ISA relationship with the other class An Employee ISA Person This relationship is best implemented with inheritance Employee is derived from Person A class may have an instance of another class For example an Employee has a Salary therefore the Employee class has the HASA relationship with the Salary class This relationship is best implemented by embedding an object of the Salary class in the Employee class

                                          The answer to this question reveals whether you have an understanding of the fundamentals of object-oriented design which is important to reliable class design

                                          There are other relationships The USESA relationship is when one class uses the services of another The Employee class uses an object (cout) of the ostream class to display the employees name onscreen for example But if you get ISA and HASA right you usually dont need to go any further

                                          35 When is a template a better solution than a base class

                                          When you are designing a generic class to contain or otherwise manage objects of other types when the format and behavior of those other types are unimportant to their containment or management and particularly when those other types are unknown (thus the genericity) to the designer of the container or manager class

                                          Prior to templates you had to use inheritance your design might include a generic List container class and an application-specific Employee class To put employees in a list a ListedEmployee class is multiply derived (contrived) from the Employee and List classes These solutions were unwieldy and error-prone Templates solved that problem

                                          Questions for ANSI-Knowledgeable Applicants

                                          There are six questions for those who profess knowledge of the progress of the ANSI committee If you claim to have that much interest in the language you should know the answers to all these questions

                                          1 What is a mutable member

                                          A mutable member is one that can be modified by the class even when the object of the class or the member function doing the modification is const

                                          Understanding this requirement implies an understanding of C++ const which many programmers do not have I have seen large class designs that do not employ the const qualifier anywhere Some of those designs are my own early C++ efforts One author suggests that some programmers find const to be such a bother that it is easier to ignore const than to try to use it meaningfully No

                                          wonder many programmers dont understand the power and implications of const Someone who claims to have enough interest in the language and its evolution to keep pace with the ANSI deliberations should not be ignorant of const however

                                          2 What is an explicit constructor

                                          A conversion constructor declared with the explicit keyword The compiler does not use an explicit constructor to implement an implied conversion of types Its purpose is reserved explicitly for construction

                                          3 What is the Standard Template Library

                                          It is a library of container templates approved by the ANSI committee for inclusion in the standard C++ specification

                                          4 Describe run-time type identification

                                          It is the ability to determine at run time the type of an object by using the typeid operator or the dynamic_cast operator

                                          5 What problem does the namespace feature solve

                                          Multiple providers of libraries might use common global identifiers causing a name collision when an application tries to link with two or more such libraries The name-space feature surrounds a librarys external declarations with a unique namespace that eliminates the potential for those collisions

                                          This solution assumes that two library vendors dont use the same namespace of course

                                          6 Are there any new intrinsic (built-in) data types

                                          Yes The ANSI committee added the bool intrinsic type and its true and false value keywords and the wchar_t data type to support character sets wider than eight bits

                                          SQL Server

                                          1 What is a foreign key

                                          A foreign key is a column or combination of columns used to establish and enforce a link (referential integrity) between the data in two tables A link is created between two tables by adding the column or columns that hold one tablersquos primary key values to the other table This column becomes a foreign key in the second table

                                          2 What is the difference between a primary key and unique key

                                          There can be only one primary key constrain on a table but there can be many unique key constraints in a table

                                          Primary key doesnrsquot allow null values but Unique allows 1 Null value

                                          3 What is an index

                                          Indexes are database objects which provides faster data access The index provides pointers to the data values stored in specified columns of

                                          the table and then orders those pointers according to the sort order you specify

                                          Different types of indexes are unique index clustered index and non-clustered index

                                          4 How to return multiple result set from a stored proc and capture it in ADO

                                          Use multiple Select statements to return multiple result sets Use ADOrsquos GetNextRecordset() method to get the second recordset during the

                                          execution of the stored proc

                                          • COMDCOM
                                          • Visual Basic
                                          • General Scripting Questions
                                          • Session and Application Variable Questions
                                            • Image Questions
                                            • Browser Questions
                                            • ActiveX Data Objects Questions
                                            • Form and Query String Questions
                                              • 18 What is a virtual member function
                                              • 19 How can C++ achieve dynamic binding yet also static typing
                                              • 20 Whats the difference between how virtual and non-virtual member functions are called
                                              • 21 When should my destructor be virtual
                                              • 22 What is a virtual constructor
                                              • Questions for ANSI-Knowledgeable Applicants

                                            if the object has one or more virtual functions the compiler puts a hidden pointer in the object called a virtual-pointer or v-pointer This v-pointer points to a global table called the virtual-table or v-table

                                            The compiler creates a v-table for each class that has at least one virtual function For example if class Circle has virtual functions for draw() and move() and resize() there would be exactly one v-table associated with class Circle even if there were a gazillion Circle objects and the v-pointer of each of those Circle objects would point to the Circle v-table The v-table itself has pointers to each of the virtual functions in the class For example the Circle v-table would have three pointers a pointer to Circledraw() a pointer to Circlemove() and a pointer to Circleresize()

                                            During a dispatch of a virtual function the run-time system follows the objects v-pointer to the classs v-table then follows the appropriate slot in the v-table to the method code

                                            The space-cost overhead of the above technique is nominal an extra pointer per object (but only for objects that will need to do dynamic binding) plus an extra pointer per method (but only for virtual methods) The time-cost overhead is also fairly nominal compared to a normal function call a virtual function call requires two extra fetches (one to get the value of the v-pointer a second to get the address of the method) None of this runtime activity happens with non-virtual functions since the compiler resolves non-virtual functions exclusively at compile-time based on the type of the pointer

                                            21 When should my destructor be virtual

                                            When you may delete a derived object via a base pointer

                                            virtual functions bind to the code associated with the class of the object rather than with the class of the pointerreference When you say delete basePtr and the base class has a virtual destructor the destructor that gets invoked is the one associated with the type of the object basePtr rather than the one associated with the type of the pointer This is generally A Good Thing

                                            TECHNO-GEEK WARNING PUT YOUR PROPELLER HAT ON Technically speaking you need a base classs destructor to be virtual if and only if you intend to allow someone to invoke an objects destructor via a base class pointer (this is normally done implicitly via delete) and the object being destructed is of a derived class that has a non-trivial destructor A class has a non-trivial destructor if it either has an explicit destructor or if it has a member object or a base class that has a non-trivial destructor (note that this is a recursive definition (eg a class has a non-trivial destructor if it has a member object (which has a base class (which has a member object (which has a base class (which has an explicit destructor)))))) END TECHNO-GEEK WARNING REMOVE YOUR PROPELLER HAT

                                            If you had a hard grokking the previous rule try this (over)simplified one on for size A class should have a virtual destructor unless that class has no virtual functions Rationale if you have any virtual functions at all youre probably going to be doing stuff to derived objects via a base pointer and some of the stuff you may do may include invoking a destructor (normally done implicitly via delete) Plus once youve put the first virtual function into a class youve already paid all the per-object space cost that youll ever pay (one pointer per object note that this is theoretically compiler-specific in practice everyone does it pretty much the same way) so making the destructor virtual wont generally cost you anything extra

                                            22 What is a virtual constructor

                                            An idiom that allows you to do something that C++ doesnt directly support

                                            You can get the effect of a virtual constructor by a virtual clone() member function (for copy constructing) or a virtual create() member function (for the default constructor)

                                            class Shape public virtual ~Shape() A virtual destructor virtual void draw() = 0 A pure virtual function virtual void move() = 0 virtual Shape clone() const = 0 Uses the copy constructor virtual Shape create() const = 0 Uses the default constructor class Circle public Shape public Circle clone() const return new Circle(this) Circle create() const return new Circle()

                                            In the clone() member function the new Circle(this) code calls Circles copy constructor to copy the state of this into the newly created Circle object In the create() member function the new Circle() code calls Circles default constructor

                                            Users use these as if they were virtual constructors

                                            void userCode(Shapeamp s) Shape s2 = sclone() Shape s3 = screate() delete s2 You probably need a virtual destructor here

                                            delete s3

                                            23 How do you link a C++ program to C functions

                                            By using the extern C linkage specification around the C function declarations

                                            24 Explain the scope resolution operator

                                            The scope resolution operator permits a program to reference an identifier in the global scope that has been hidden by another identifier with the same name in the local scope

                                            25 What are the differences between a C++ struct and C++ class

                                            The default member and base class access specifiers are different

                                            26 How many ways are there to initialize an int with a constant

                                            Two

                                            27 How does throwing and catching exceptions differ from using setjmp and longjmp

                                            The throw operation calls the destructors for automatic objects instantiated since entry to the try block

                                            28 How does throwing and catching exceptions differ from using setjmp and longjmp

                                            The throw operation calls the destructors for automatic objects instantiated since entry to the try block

                                            29 What is a default constructor

                                            A constructor that has no arguments or one where all the arguments have default argument values

                                            If you dont code a default constructor the compiler provides one if there are no other constructors If you are going to instantiate an array of objects of the class the class must have a default constructor

                                            30 What is a conversion constructor

                                            It is a constructor that accepts one argument of a different type

                                            The compiler uses this idiom as one way to infer conversion rules for a class A constructor with more than one argument and with default argument values can be interpreted by the compiler as a conversion constructor when the compiler is looking for an object of the type and sees an object of the type of the constructors first argument

                                            31 What is the difference between a copy constructor and an overloaded assignment operator

                                            A copy constructor constructs a new object by using the content of the argument object An overloaded assignment operator assigns the contents of an existing object to another existing object of the same class

                                            First you must know that a copy constructor is one that has only one argument which is a reference to the same type as the constructor The compiler invokes a copy constructor wherever it needs to make a copy of the object for example to pass an argument by value If you do not provide a copy constructor the compiler creates a member-by-member copy constructor for you

                                            You can write overloaded assignment operators that take arguments of other classes but that behavior is usually implemented with implicit conversion constructors If you do not provide an overloaded assignment operator for the class the compiler creates a default member-by-member assignment operator

                                            This discussion is a good place to get into why classes need copy constructors and overloaded assignment operators By discussing the requirements with respect to data member pointers that point to dynamically allocated resources you demonstrate a good grasp of the problem

                                            32 When should you use multiple inheritance

                                            There are three acceptable answers Never Rarely and When the problem domain cannot be accurately modeled any other way

                                            33 What is a virtual destructor

                                            The simple answer is that a virtual destructor is one that is declared with the virtual attribute

                                            The behavior of a virtual destructor is what is important If you destroy an object through a pointer or reference to a base class and the base-class destructor is not virtual the derived-class destructors are not executed and the destruction might not be complete

                                            34 Explain the ISA and HASA class relationships How would you implement each in a class design

                                            A specialized class is a specialization of another class and therefore has the ISA relationship with the other class An Employee ISA Person This relationship is best implemented with inheritance Employee is derived from Person A class may have an instance of another class For example an Employee has a Salary therefore the Employee class has the HASA relationship with the Salary class This relationship is best implemented by embedding an object of the Salary class in the Employee class

                                            The answer to this question reveals whether you have an understanding of the fundamentals of object-oriented design which is important to reliable class design

                                            There are other relationships The USESA relationship is when one class uses the services of another The Employee class uses an object (cout) of the ostream class to display the employees name onscreen for example But if you get ISA and HASA right you usually dont need to go any further

                                            35 When is a template a better solution than a base class

                                            When you are designing a generic class to contain or otherwise manage objects of other types when the format and behavior of those other types are unimportant to their containment or management and particularly when those other types are unknown (thus the genericity) to the designer of the container or manager class

                                            Prior to templates you had to use inheritance your design might include a generic List container class and an application-specific Employee class To put employees in a list a ListedEmployee class is multiply derived (contrived) from the Employee and List classes These solutions were unwieldy and error-prone Templates solved that problem

                                            Questions for ANSI-Knowledgeable Applicants

                                            There are six questions for those who profess knowledge of the progress of the ANSI committee If you claim to have that much interest in the language you should know the answers to all these questions

                                            1 What is a mutable member

                                            A mutable member is one that can be modified by the class even when the object of the class or the member function doing the modification is const

                                            Understanding this requirement implies an understanding of C++ const which many programmers do not have I have seen large class designs that do not employ the const qualifier anywhere Some of those designs are my own early C++ efforts One author suggests that some programmers find const to be such a bother that it is easier to ignore const than to try to use it meaningfully No

                                            wonder many programmers dont understand the power and implications of const Someone who claims to have enough interest in the language and its evolution to keep pace with the ANSI deliberations should not be ignorant of const however

                                            2 What is an explicit constructor

                                            A conversion constructor declared with the explicit keyword The compiler does not use an explicit constructor to implement an implied conversion of types Its purpose is reserved explicitly for construction

                                            3 What is the Standard Template Library

                                            It is a library of container templates approved by the ANSI committee for inclusion in the standard C++ specification

                                            4 Describe run-time type identification

                                            It is the ability to determine at run time the type of an object by using the typeid operator or the dynamic_cast operator

                                            5 What problem does the namespace feature solve

                                            Multiple providers of libraries might use common global identifiers causing a name collision when an application tries to link with two or more such libraries The name-space feature surrounds a librarys external declarations with a unique namespace that eliminates the potential for those collisions

                                            This solution assumes that two library vendors dont use the same namespace of course

                                            6 Are there any new intrinsic (built-in) data types

                                            Yes The ANSI committee added the bool intrinsic type and its true and false value keywords and the wchar_t data type to support character sets wider than eight bits

                                            SQL Server

                                            1 What is a foreign key

                                            A foreign key is a column or combination of columns used to establish and enforce a link (referential integrity) between the data in two tables A link is created between two tables by adding the column or columns that hold one tablersquos primary key values to the other table This column becomes a foreign key in the second table

                                            2 What is the difference between a primary key and unique key

                                            There can be only one primary key constrain on a table but there can be many unique key constraints in a table

                                            Primary key doesnrsquot allow null values but Unique allows 1 Null value

                                            3 What is an index

                                            Indexes are database objects which provides faster data access The index provides pointers to the data values stored in specified columns of

                                            the table and then orders those pointers according to the sort order you specify

                                            Different types of indexes are unique index clustered index and non-clustered index

                                            4 How to return multiple result set from a stored proc and capture it in ADO

                                            Use multiple Select statements to return multiple result sets Use ADOrsquos GetNextRecordset() method to get the second recordset during the

                                            execution of the stored proc

                                            • COMDCOM
                                            • Visual Basic
                                            • General Scripting Questions
                                            • Session and Application Variable Questions
                                              • Image Questions
                                              • Browser Questions
                                              • ActiveX Data Objects Questions
                                              • Form and Query String Questions
                                                • 18 What is a virtual member function
                                                • 19 How can C++ achieve dynamic binding yet also static typing
                                                • 20 Whats the difference between how virtual and non-virtual member functions are called
                                                • 21 When should my destructor be virtual
                                                • 22 What is a virtual constructor
                                                • Questions for ANSI-Knowledgeable Applicants

                                              If you had a hard grokking the previous rule try this (over)simplified one on for size A class should have a virtual destructor unless that class has no virtual functions Rationale if you have any virtual functions at all youre probably going to be doing stuff to derived objects via a base pointer and some of the stuff you may do may include invoking a destructor (normally done implicitly via delete) Plus once youve put the first virtual function into a class youve already paid all the per-object space cost that youll ever pay (one pointer per object note that this is theoretically compiler-specific in practice everyone does it pretty much the same way) so making the destructor virtual wont generally cost you anything extra

                                              22 What is a virtual constructor

                                              An idiom that allows you to do something that C++ doesnt directly support

                                              You can get the effect of a virtual constructor by a virtual clone() member function (for copy constructing) or a virtual create() member function (for the default constructor)

                                              class Shape public virtual ~Shape() A virtual destructor virtual void draw() = 0 A pure virtual function virtual void move() = 0 virtual Shape clone() const = 0 Uses the copy constructor virtual Shape create() const = 0 Uses the default constructor class Circle public Shape public Circle clone() const return new Circle(this) Circle create() const return new Circle()

                                              In the clone() member function the new Circle(this) code calls Circles copy constructor to copy the state of this into the newly created Circle object In the create() member function the new Circle() code calls Circles default constructor

                                              Users use these as if they were virtual constructors

                                              void userCode(Shapeamp s) Shape s2 = sclone() Shape s3 = screate() delete s2 You probably need a virtual destructor here

                                              delete s3

                                              23 How do you link a C++ program to C functions

                                              By using the extern C linkage specification around the C function declarations

                                              24 Explain the scope resolution operator

                                              The scope resolution operator permits a program to reference an identifier in the global scope that has been hidden by another identifier with the same name in the local scope

                                              25 What are the differences between a C++ struct and C++ class

                                              The default member and base class access specifiers are different

                                              26 How many ways are there to initialize an int with a constant

                                              Two

                                              27 How does throwing and catching exceptions differ from using setjmp and longjmp

                                              The throw operation calls the destructors for automatic objects instantiated since entry to the try block

                                              28 How does throwing and catching exceptions differ from using setjmp and longjmp

                                              The throw operation calls the destructors for automatic objects instantiated since entry to the try block

                                              29 What is a default constructor

                                              A constructor that has no arguments or one where all the arguments have default argument values

                                              If you dont code a default constructor the compiler provides one if there are no other constructors If you are going to instantiate an array of objects of the class the class must have a default constructor

                                              30 What is a conversion constructor

                                              It is a constructor that accepts one argument of a different type

                                              The compiler uses this idiom as one way to infer conversion rules for a class A constructor with more than one argument and with default argument values can be interpreted by the compiler as a conversion constructor when the compiler is looking for an object of the type and sees an object of the type of the constructors first argument

                                              31 What is the difference between a copy constructor and an overloaded assignment operator

                                              A copy constructor constructs a new object by using the content of the argument object An overloaded assignment operator assigns the contents of an existing object to another existing object of the same class

                                              First you must know that a copy constructor is one that has only one argument which is a reference to the same type as the constructor The compiler invokes a copy constructor wherever it needs to make a copy of the object for example to pass an argument by value If you do not provide a copy constructor the compiler creates a member-by-member copy constructor for you

                                              You can write overloaded assignment operators that take arguments of other classes but that behavior is usually implemented with implicit conversion constructors If you do not provide an overloaded assignment operator for the class the compiler creates a default member-by-member assignment operator

                                              This discussion is a good place to get into why classes need copy constructors and overloaded assignment operators By discussing the requirements with respect to data member pointers that point to dynamically allocated resources you demonstrate a good grasp of the problem

                                              32 When should you use multiple inheritance

                                              There are three acceptable answers Never Rarely and When the problem domain cannot be accurately modeled any other way

                                              33 What is a virtual destructor

                                              The simple answer is that a virtual destructor is one that is declared with the virtual attribute

                                              The behavior of a virtual destructor is what is important If you destroy an object through a pointer or reference to a base class and the base-class destructor is not virtual the derived-class destructors are not executed and the destruction might not be complete

                                              34 Explain the ISA and HASA class relationships How would you implement each in a class design

                                              A specialized class is a specialization of another class and therefore has the ISA relationship with the other class An Employee ISA Person This relationship is best implemented with inheritance Employee is derived from Person A class may have an instance of another class For example an Employee has a Salary therefore the Employee class has the HASA relationship with the Salary class This relationship is best implemented by embedding an object of the Salary class in the Employee class

                                              The answer to this question reveals whether you have an understanding of the fundamentals of object-oriented design which is important to reliable class design

                                              There are other relationships The USESA relationship is when one class uses the services of another The Employee class uses an object (cout) of the ostream class to display the employees name onscreen for example But if you get ISA and HASA right you usually dont need to go any further

                                              35 When is a template a better solution than a base class

                                              When you are designing a generic class to contain or otherwise manage objects of other types when the format and behavior of those other types are unimportant to their containment or management and particularly when those other types are unknown (thus the genericity) to the designer of the container or manager class

                                              Prior to templates you had to use inheritance your design might include a generic List container class and an application-specific Employee class To put employees in a list a ListedEmployee class is multiply derived (contrived) from the Employee and List classes These solutions were unwieldy and error-prone Templates solved that problem

                                              Questions for ANSI-Knowledgeable Applicants

                                              There are six questions for those who profess knowledge of the progress of the ANSI committee If you claim to have that much interest in the language you should know the answers to all these questions

                                              1 What is a mutable member

                                              A mutable member is one that can be modified by the class even when the object of the class or the member function doing the modification is const

                                              Understanding this requirement implies an understanding of C++ const which many programmers do not have I have seen large class designs that do not employ the const qualifier anywhere Some of those designs are my own early C++ efforts One author suggests that some programmers find const to be such a bother that it is easier to ignore const than to try to use it meaningfully No

                                              wonder many programmers dont understand the power and implications of const Someone who claims to have enough interest in the language and its evolution to keep pace with the ANSI deliberations should not be ignorant of const however

                                              2 What is an explicit constructor

                                              A conversion constructor declared with the explicit keyword The compiler does not use an explicit constructor to implement an implied conversion of types Its purpose is reserved explicitly for construction

                                              3 What is the Standard Template Library

                                              It is a library of container templates approved by the ANSI committee for inclusion in the standard C++ specification

                                              4 Describe run-time type identification

                                              It is the ability to determine at run time the type of an object by using the typeid operator or the dynamic_cast operator

                                              5 What problem does the namespace feature solve

                                              Multiple providers of libraries might use common global identifiers causing a name collision when an application tries to link with two or more such libraries The name-space feature surrounds a librarys external declarations with a unique namespace that eliminates the potential for those collisions

                                              This solution assumes that two library vendors dont use the same namespace of course

                                              6 Are there any new intrinsic (built-in) data types

                                              Yes The ANSI committee added the bool intrinsic type and its true and false value keywords and the wchar_t data type to support character sets wider than eight bits

                                              SQL Server

                                              1 What is a foreign key

                                              A foreign key is a column or combination of columns used to establish and enforce a link (referential integrity) between the data in two tables A link is created between two tables by adding the column or columns that hold one tablersquos primary key values to the other table This column becomes a foreign key in the second table

                                              2 What is the difference between a primary key and unique key

                                              There can be only one primary key constrain on a table but there can be many unique key constraints in a table

                                              Primary key doesnrsquot allow null values but Unique allows 1 Null value

                                              3 What is an index

                                              Indexes are database objects which provides faster data access The index provides pointers to the data values stored in specified columns of

                                              the table and then orders those pointers according to the sort order you specify

                                              Different types of indexes are unique index clustered index and non-clustered index

                                              4 How to return multiple result set from a stored proc and capture it in ADO

                                              Use multiple Select statements to return multiple result sets Use ADOrsquos GetNextRecordset() method to get the second recordset during the

                                              execution of the stored proc

                                              • COMDCOM
                                              • Visual Basic
                                              • General Scripting Questions
                                              • Session and Application Variable Questions
                                                • Image Questions
                                                • Browser Questions
                                                • ActiveX Data Objects Questions
                                                • Form and Query String Questions
                                                  • 18 What is a virtual member function
                                                  • 19 How can C++ achieve dynamic binding yet also static typing
                                                  • 20 Whats the difference between how virtual and non-virtual member functions are called
                                                  • 21 When should my destructor be virtual
                                                  • 22 What is a virtual constructor
                                                  • Questions for ANSI-Knowledgeable Applicants

                                                delete s3

                                                23 How do you link a C++ program to C functions

                                                By using the extern C linkage specification around the C function declarations

                                                24 Explain the scope resolution operator

                                                The scope resolution operator permits a program to reference an identifier in the global scope that has been hidden by another identifier with the same name in the local scope

                                                25 What are the differences between a C++ struct and C++ class

                                                The default member and base class access specifiers are different

                                                26 How many ways are there to initialize an int with a constant

                                                Two

                                                27 How does throwing and catching exceptions differ from using setjmp and longjmp

                                                The throw operation calls the destructors for automatic objects instantiated since entry to the try block

                                                28 How does throwing and catching exceptions differ from using setjmp and longjmp

                                                The throw operation calls the destructors for automatic objects instantiated since entry to the try block

                                                29 What is a default constructor

                                                A constructor that has no arguments or one where all the arguments have default argument values

                                                If you dont code a default constructor the compiler provides one if there are no other constructors If you are going to instantiate an array of objects of the class the class must have a default constructor

                                                30 What is a conversion constructor

                                                It is a constructor that accepts one argument of a different type

                                                The compiler uses this idiom as one way to infer conversion rules for a class A constructor with more than one argument and with default argument values can be interpreted by the compiler as a conversion constructor when the compiler is looking for an object of the type and sees an object of the type of the constructors first argument

                                                31 What is the difference between a copy constructor and an overloaded assignment operator

                                                A copy constructor constructs a new object by using the content of the argument object An overloaded assignment operator assigns the contents of an existing object to another existing object of the same class

                                                First you must know that a copy constructor is one that has only one argument which is a reference to the same type as the constructor The compiler invokes a copy constructor wherever it needs to make a copy of the object for example to pass an argument by value If you do not provide a copy constructor the compiler creates a member-by-member copy constructor for you

                                                You can write overloaded assignment operators that take arguments of other classes but that behavior is usually implemented with implicit conversion constructors If you do not provide an overloaded assignment operator for the class the compiler creates a default member-by-member assignment operator

                                                This discussion is a good place to get into why classes need copy constructors and overloaded assignment operators By discussing the requirements with respect to data member pointers that point to dynamically allocated resources you demonstrate a good grasp of the problem

                                                32 When should you use multiple inheritance

                                                There are three acceptable answers Never Rarely and When the problem domain cannot be accurately modeled any other way

                                                33 What is a virtual destructor

                                                The simple answer is that a virtual destructor is one that is declared with the virtual attribute

                                                The behavior of a virtual destructor is what is important If you destroy an object through a pointer or reference to a base class and the base-class destructor is not virtual the derived-class destructors are not executed and the destruction might not be complete

                                                34 Explain the ISA and HASA class relationships How would you implement each in a class design

                                                A specialized class is a specialization of another class and therefore has the ISA relationship with the other class An Employee ISA Person This relationship is best implemented with inheritance Employee is derived from Person A class may have an instance of another class For example an Employee has a Salary therefore the Employee class has the HASA relationship with the Salary class This relationship is best implemented by embedding an object of the Salary class in the Employee class

                                                The answer to this question reveals whether you have an understanding of the fundamentals of object-oriented design which is important to reliable class design

                                                There are other relationships The USESA relationship is when one class uses the services of another The Employee class uses an object (cout) of the ostream class to display the employees name onscreen for example But if you get ISA and HASA right you usually dont need to go any further

                                                35 When is a template a better solution than a base class

                                                When you are designing a generic class to contain or otherwise manage objects of other types when the format and behavior of those other types are unimportant to their containment or management and particularly when those other types are unknown (thus the genericity) to the designer of the container or manager class

                                                Prior to templates you had to use inheritance your design might include a generic List container class and an application-specific Employee class To put employees in a list a ListedEmployee class is multiply derived (contrived) from the Employee and List classes These solutions were unwieldy and error-prone Templates solved that problem

                                                Questions for ANSI-Knowledgeable Applicants

                                                There are six questions for those who profess knowledge of the progress of the ANSI committee If you claim to have that much interest in the language you should know the answers to all these questions

                                                1 What is a mutable member

                                                A mutable member is one that can be modified by the class even when the object of the class or the member function doing the modification is const

                                                Understanding this requirement implies an understanding of C++ const which many programmers do not have I have seen large class designs that do not employ the const qualifier anywhere Some of those designs are my own early C++ efforts One author suggests that some programmers find const to be such a bother that it is easier to ignore const than to try to use it meaningfully No

                                                wonder many programmers dont understand the power and implications of const Someone who claims to have enough interest in the language and its evolution to keep pace with the ANSI deliberations should not be ignorant of const however

                                                2 What is an explicit constructor

                                                A conversion constructor declared with the explicit keyword The compiler does not use an explicit constructor to implement an implied conversion of types Its purpose is reserved explicitly for construction

                                                3 What is the Standard Template Library

                                                It is a library of container templates approved by the ANSI committee for inclusion in the standard C++ specification

                                                4 Describe run-time type identification

                                                It is the ability to determine at run time the type of an object by using the typeid operator or the dynamic_cast operator

                                                5 What problem does the namespace feature solve

                                                Multiple providers of libraries might use common global identifiers causing a name collision when an application tries to link with two or more such libraries The name-space feature surrounds a librarys external declarations with a unique namespace that eliminates the potential for those collisions

                                                This solution assumes that two library vendors dont use the same namespace of course

                                                6 Are there any new intrinsic (built-in) data types

                                                Yes The ANSI committee added the bool intrinsic type and its true and false value keywords and the wchar_t data type to support character sets wider than eight bits

                                                SQL Server

                                                1 What is a foreign key

                                                A foreign key is a column or combination of columns used to establish and enforce a link (referential integrity) between the data in two tables A link is created between two tables by adding the column or columns that hold one tablersquos primary key values to the other table This column becomes a foreign key in the second table

                                                2 What is the difference between a primary key and unique key

                                                There can be only one primary key constrain on a table but there can be many unique key constraints in a table

                                                Primary key doesnrsquot allow null values but Unique allows 1 Null value

                                                3 What is an index

                                                Indexes are database objects which provides faster data access The index provides pointers to the data values stored in specified columns of

                                                the table and then orders those pointers according to the sort order you specify

                                                Different types of indexes are unique index clustered index and non-clustered index

                                                4 How to return multiple result set from a stored proc and capture it in ADO

                                                Use multiple Select statements to return multiple result sets Use ADOrsquos GetNextRecordset() method to get the second recordset during the

                                                execution of the stored proc

                                                • COMDCOM
                                                • Visual Basic
                                                • General Scripting Questions
                                                • Session and Application Variable Questions
                                                  • Image Questions
                                                  • Browser Questions
                                                  • ActiveX Data Objects Questions
                                                  • Form and Query String Questions
                                                    • 18 What is a virtual member function
                                                    • 19 How can C++ achieve dynamic binding yet also static typing
                                                    • 20 Whats the difference between how virtual and non-virtual member functions are called
                                                    • 21 When should my destructor be virtual
                                                    • 22 What is a virtual constructor
                                                    • Questions for ANSI-Knowledgeable Applicants

                                                  The compiler uses this idiom as one way to infer conversion rules for a class A constructor with more than one argument and with default argument values can be interpreted by the compiler as a conversion constructor when the compiler is looking for an object of the type and sees an object of the type of the constructors first argument

                                                  31 What is the difference between a copy constructor and an overloaded assignment operator

                                                  A copy constructor constructs a new object by using the content of the argument object An overloaded assignment operator assigns the contents of an existing object to another existing object of the same class

                                                  First you must know that a copy constructor is one that has only one argument which is a reference to the same type as the constructor The compiler invokes a copy constructor wherever it needs to make a copy of the object for example to pass an argument by value If you do not provide a copy constructor the compiler creates a member-by-member copy constructor for you

                                                  You can write overloaded assignment operators that take arguments of other classes but that behavior is usually implemented with implicit conversion constructors If you do not provide an overloaded assignment operator for the class the compiler creates a default member-by-member assignment operator

                                                  This discussion is a good place to get into why classes need copy constructors and overloaded assignment operators By discussing the requirements with respect to data member pointers that point to dynamically allocated resources you demonstrate a good grasp of the problem

                                                  32 When should you use multiple inheritance

                                                  There are three acceptable answers Never Rarely and When the problem domain cannot be accurately modeled any other way

                                                  33 What is a virtual destructor

                                                  The simple answer is that a virtual destructor is one that is declared with the virtual attribute

                                                  The behavior of a virtual destructor is what is important If you destroy an object through a pointer or reference to a base class and the base-class destructor is not virtual the derived-class destructors are not executed and the destruction might not be complete

                                                  34 Explain the ISA and HASA class relationships How would you implement each in a class design

                                                  A specialized class is a specialization of another class and therefore has the ISA relationship with the other class An Employee ISA Person This relationship is best implemented with inheritance Employee is derived from Person A class may have an instance of another class For example an Employee has a Salary therefore the Employee class has the HASA relationship with the Salary class This relationship is best implemented by embedding an object of the Salary class in the Employee class

                                                  The answer to this question reveals whether you have an understanding of the fundamentals of object-oriented design which is important to reliable class design

                                                  There are other relationships The USESA relationship is when one class uses the services of another The Employee class uses an object (cout) of the ostream class to display the employees name onscreen for example But if you get ISA and HASA right you usually dont need to go any further

                                                  35 When is a template a better solution than a base class

                                                  When you are designing a generic class to contain or otherwise manage objects of other types when the format and behavior of those other types are unimportant to their containment or management and particularly when those other types are unknown (thus the genericity) to the designer of the container or manager class

                                                  Prior to templates you had to use inheritance your design might include a generic List container class and an application-specific Employee class To put employees in a list a ListedEmployee class is multiply derived (contrived) from the Employee and List classes These solutions were unwieldy and error-prone Templates solved that problem

                                                  Questions for ANSI-Knowledgeable Applicants

                                                  There are six questions for those who profess knowledge of the progress of the ANSI committee If you claim to have that much interest in the language you should know the answers to all these questions

                                                  1 What is a mutable member

                                                  A mutable member is one that can be modified by the class even when the object of the class or the member function doing the modification is const

                                                  Understanding this requirement implies an understanding of C++ const which many programmers do not have I have seen large class designs that do not employ the const qualifier anywhere Some of those designs are my own early C++ efforts One author suggests that some programmers find const to be such a bother that it is easier to ignore const than to try to use it meaningfully No

                                                  wonder many programmers dont understand the power and implications of const Someone who claims to have enough interest in the language and its evolution to keep pace with the ANSI deliberations should not be ignorant of const however

                                                  2 What is an explicit constructor

                                                  A conversion constructor declared with the explicit keyword The compiler does not use an explicit constructor to implement an implied conversion of types Its purpose is reserved explicitly for construction

                                                  3 What is the Standard Template Library

                                                  It is a library of container templates approved by the ANSI committee for inclusion in the standard C++ specification

                                                  4 Describe run-time type identification

                                                  It is the ability to determine at run time the type of an object by using the typeid operator or the dynamic_cast operator

                                                  5 What problem does the namespace feature solve

                                                  Multiple providers of libraries might use common global identifiers causing a name collision when an application tries to link with two or more such libraries The name-space feature surrounds a librarys external declarations with a unique namespace that eliminates the potential for those collisions

                                                  This solution assumes that two library vendors dont use the same namespace of course

                                                  6 Are there any new intrinsic (built-in) data types

                                                  Yes The ANSI committee added the bool intrinsic type and its true and false value keywords and the wchar_t data type to support character sets wider than eight bits

                                                  SQL Server

                                                  1 What is a foreign key

                                                  A foreign key is a column or combination of columns used to establish and enforce a link (referential integrity) between the data in two tables A link is created between two tables by adding the column or columns that hold one tablersquos primary key values to the other table This column becomes a foreign key in the second table

                                                  2 What is the difference between a primary key and unique key

                                                  There can be only one primary key constrain on a table but there can be many unique key constraints in a table

                                                  Primary key doesnrsquot allow null values but Unique allows 1 Null value

                                                  3 What is an index

                                                  Indexes are database objects which provides faster data access The index provides pointers to the data values stored in specified columns of

                                                  the table and then orders those pointers according to the sort order you specify

                                                  Different types of indexes are unique index clustered index and non-clustered index

                                                  4 How to return multiple result set from a stored proc and capture it in ADO

                                                  Use multiple Select statements to return multiple result sets Use ADOrsquos GetNextRecordset() method to get the second recordset during the

                                                  execution of the stored proc

                                                  • COMDCOM
                                                  • Visual Basic
                                                  • General Scripting Questions
                                                  • Session and Application Variable Questions
                                                    • Image Questions
                                                    • Browser Questions
                                                    • ActiveX Data Objects Questions
                                                    • Form and Query String Questions
                                                      • 18 What is a virtual member function
                                                      • 19 How can C++ achieve dynamic binding yet also static typing
                                                      • 20 Whats the difference between how virtual and non-virtual member functions are called
                                                      • 21 When should my destructor be virtual
                                                      • 22 What is a virtual constructor
                                                      • Questions for ANSI-Knowledgeable Applicants

                                                    A specialized class is a specialization of another class and therefore has the ISA relationship with the other class An Employee ISA Person This relationship is best implemented with inheritance Employee is derived from Person A class may have an instance of another class For example an Employee has a Salary therefore the Employee class has the HASA relationship with the Salary class This relationship is best implemented by embedding an object of the Salary class in the Employee class

                                                    The answer to this question reveals whether you have an understanding of the fundamentals of object-oriented design which is important to reliable class design

                                                    There are other relationships The USESA relationship is when one class uses the services of another The Employee class uses an object (cout) of the ostream class to display the employees name onscreen for example But if you get ISA and HASA right you usually dont need to go any further

                                                    35 When is a template a better solution than a base class

                                                    When you are designing a generic class to contain or otherwise manage objects of other types when the format and behavior of those other types are unimportant to their containment or management and particularly when those other types are unknown (thus the genericity) to the designer of the container or manager class

                                                    Prior to templates you had to use inheritance your design might include a generic List container class and an application-specific Employee class To put employees in a list a ListedEmployee class is multiply derived (contrived) from the Employee and List classes These solutions were unwieldy and error-prone Templates solved that problem

                                                    Questions for ANSI-Knowledgeable Applicants

                                                    There are six questions for those who profess knowledge of the progress of the ANSI committee If you claim to have that much interest in the language you should know the answers to all these questions

                                                    1 What is a mutable member

                                                    A mutable member is one that can be modified by the class even when the object of the class or the member function doing the modification is const

                                                    Understanding this requirement implies an understanding of C++ const which many programmers do not have I have seen large class designs that do not employ the const qualifier anywhere Some of those designs are my own early C++ efforts One author suggests that some programmers find const to be such a bother that it is easier to ignore const than to try to use it meaningfully No

                                                    wonder many programmers dont understand the power and implications of const Someone who claims to have enough interest in the language and its evolution to keep pace with the ANSI deliberations should not be ignorant of const however

                                                    2 What is an explicit constructor

                                                    A conversion constructor declared with the explicit keyword The compiler does not use an explicit constructor to implement an implied conversion of types Its purpose is reserved explicitly for construction

                                                    3 What is the Standard Template Library

                                                    It is a library of container templates approved by the ANSI committee for inclusion in the standard C++ specification

                                                    4 Describe run-time type identification

                                                    It is the ability to determine at run time the type of an object by using the typeid operator or the dynamic_cast operator

                                                    5 What problem does the namespace feature solve

                                                    Multiple providers of libraries might use common global identifiers causing a name collision when an application tries to link with two or more such libraries The name-space feature surrounds a librarys external declarations with a unique namespace that eliminates the potential for those collisions

                                                    This solution assumes that two library vendors dont use the same namespace of course

                                                    6 Are there any new intrinsic (built-in) data types

                                                    Yes The ANSI committee added the bool intrinsic type and its true and false value keywords and the wchar_t data type to support character sets wider than eight bits

                                                    SQL Server

                                                    1 What is a foreign key

                                                    A foreign key is a column or combination of columns used to establish and enforce a link (referential integrity) between the data in two tables A link is created between two tables by adding the column or columns that hold one tablersquos primary key values to the other table This column becomes a foreign key in the second table

                                                    2 What is the difference between a primary key and unique key

                                                    There can be only one primary key constrain on a table but there can be many unique key constraints in a table

                                                    Primary key doesnrsquot allow null values but Unique allows 1 Null value

                                                    3 What is an index

                                                    Indexes are database objects which provides faster data access The index provides pointers to the data values stored in specified columns of

                                                    the table and then orders those pointers according to the sort order you specify

                                                    Different types of indexes are unique index clustered index and non-clustered index

                                                    4 How to return multiple result set from a stored proc and capture it in ADO

                                                    Use multiple Select statements to return multiple result sets Use ADOrsquos GetNextRecordset() method to get the second recordset during the

                                                    execution of the stored proc

                                                    • COMDCOM
                                                    • Visual Basic
                                                    • General Scripting Questions
                                                    • Session and Application Variable Questions
                                                      • Image Questions
                                                      • Browser Questions
                                                      • ActiveX Data Objects Questions
                                                      • Form and Query String Questions
                                                        • 18 What is a virtual member function
                                                        • 19 How can C++ achieve dynamic binding yet also static typing
                                                        • 20 Whats the difference between how virtual and non-virtual member functions are called
                                                        • 21 When should my destructor be virtual
                                                        • 22 What is a virtual constructor
                                                        • Questions for ANSI-Knowledgeable Applicants

                                                      wonder many programmers dont understand the power and implications of const Someone who claims to have enough interest in the language and its evolution to keep pace with the ANSI deliberations should not be ignorant of const however

                                                      2 What is an explicit constructor

                                                      A conversion constructor declared with the explicit keyword The compiler does not use an explicit constructor to implement an implied conversion of types Its purpose is reserved explicitly for construction

                                                      3 What is the Standard Template Library

                                                      It is a library of container templates approved by the ANSI committee for inclusion in the standard C++ specification

                                                      4 Describe run-time type identification

                                                      It is the ability to determine at run time the type of an object by using the typeid operator or the dynamic_cast operator

                                                      5 What problem does the namespace feature solve

                                                      Multiple providers of libraries might use common global identifiers causing a name collision when an application tries to link with two or more such libraries The name-space feature surrounds a librarys external declarations with a unique namespace that eliminates the potential for those collisions

                                                      This solution assumes that two library vendors dont use the same namespace of course

                                                      6 Are there any new intrinsic (built-in) data types

                                                      Yes The ANSI committee added the bool intrinsic type and its true and false value keywords and the wchar_t data type to support character sets wider than eight bits

                                                      SQL Server

                                                      1 What is a foreign key

                                                      A foreign key is a column or combination of columns used to establish and enforce a link (referential integrity) between the data in two tables A link is created between two tables by adding the column or columns that hold one tablersquos primary key values to the other table This column becomes a foreign key in the second table

                                                      2 What is the difference between a primary key and unique key

                                                      There can be only one primary key constrain on a table but there can be many unique key constraints in a table

                                                      Primary key doesnrsquot allow null values but Unique allows 1 Null value

                                                      3 What is an index

                                                      Indexes are database objects which provides faster data access The index provides pointers to the data values stored in specified columns of

                                                      the table and then orders those pointers according to the sort order you specify

                                                      Different types of indexes are unique index clustered index and non-clustered index

                                                      4 How to return multiple result set from a stored proc and capture it in ADO

                                                      Use multiple Select statements to return multiple result sets Use ADOrsquos GetNextRecordset() method to get the second recordset during the

                                                      execution of the stored proc

                                                      • COMDCOM
                                                      • Visual Basic
                                                      • General Scripting Questions
                                                      • Session and Application Variable Questions
                                                        • Image Questions
                                                        • Browser Questions
                                                        • ActiveX Data Objects Questions
                                                        • Form and Query String Questions
                                                          • 18 What is a virtual member function
                                                          • 19 How can C++ achieve dynamic binding yet also static typing
                                                          • 20 Whats the difference between how virtual and non-virtual member functions are called
                                                          • 21 When should my destructor be virtual
                                                          • 22 What is a virtual constructor
                                                          • Questions for ANSI-Knowledgeable Applicants

                                                        SQL Server

                                                        1 What is a foreign key

                                                        A foreign key is a column or combination of columns used to establish and enforce a link (referential integrity) between the data in two tables A link is created between two tables by adding the column or columns that hold one tablersquos primary key values to the other table This column becomes a foreign key in the second table

                                                        2 What is the difference between a primary key and unique key

                                                        There can be only one primary key constrain on a table but there can be many unique key constraints in a table

                                                        Primary key doesnrsquot allow null values but Unique allows 1 Null value

                                                        3 What is an index

                                                        Indexes are database objects which provides faster data access The index provides pointers to the data values stored in specified columns of

                                                        the table and then orders those pointers according to the sort order you specify

                                                        Different types of indexes are unique index clustered index and non-clustered index

                                                        4 How to return multiple result set from a stored proc and capture it in ADO

                                                        Use multiple Select statements to return multiple result sets Use ADOrsquos GetNextRecordset() method to get the second recordset during the

                                                        execution of the stored proc

                                                        • COMDCOM
                                                        • Visual Basic
                                                        • General Scripting Questions
                                                        • Session and Application Variable Questions
                                                          • Image Questions
                                                          • Browser Questions
                                                          • ActiveX Data Objects Questions
                                                          • Form and Query String Questions
                                                            • 18 What is a virtual member function
                                                            • 19 How can C++ achieve dynamic binding yet also static typing
                                                            • 20 Whats the difference between how virtual and non-virtual member functions are called
                                                            • 21 When should my destructor be virtual
                                                            • 22 What is a virtual constructor
                                                            • Questions for ANSI-Knowledgeable Applicants

                                                          top related