C++ Questions:
1. What is the default return type of the main function?
Int
2. How many arguments takes main function and what are they?
2 , argc and argv
3. what is pointer and advantages?
We can directly access the memory directly.
4. How many bytes takes the empty class and why?
1 byte, generally the compiler allocates the memory for the objects based on the datas of the class. If suppose we creates the empty class, we can able to create the instance. For that reason the empty class holds the one byte.
5. how many bytes take creating of pointer of char and int?
2bytes and 4 bytes. (based on the processor type)
6. OOPS concepts with real time examples
1. Class
Class is the blue print of the object creations. Eg. vehicles
2. Object
Object is the instance of the class, Eg. Bike car scooter
3. Polymorphism and its types
One interface multiple methods. Types, static and dynamic.
Static : overloading
Dynamic: virtual function
4. Inheritance
To create/derive a subclass from the base class. (we can extends the properties from base class to the derived classs).
5. Abstract class
A class contains atleast one pure virtual functions. We cant able to instantiate the object for the abstract class.
6. Pure virtual functions
If a virtual function is defined with the 0 then its pure virtual function/ (i.e) a virtual function with no body and initialized with 0)
Why u need pure virtual function?
If suppose we want to force the derived class to define the basic and common functions that time we need to create the pure virtual functions.
7. what is bindings and its types?
connection bw the function call and the actual code executed (YK book).
Static or earlier and dynamic or late.
Static : normal function call resolved at compile time
Dynamic : virtual functions.
8. what is virtual class and virtual constructor and virtual destructor
virtual constructor: there is no virtual constructor
virtual destructor: yes its available, its used to call all the destructor in the hiereachy of the class in which we derived.
Virtual class:
Its used for to avoid the ambiguity..
9. what is copy constructor and why this concept advantages?
To create a new copy of the object of the existing one.
Type : shallow and deep
Shallow – shallow shares the reference and pointers of existing object
Deep - deep will create and use its own memory of the existing ones copy.
Advantage:
10. difference between structure and class?
Default access specifier in structure is public , and for class private.
11. what is the difference between c and c++?
C is a procedure oriented and c++ is object oriented.
C doesn’t have the overloading concepts
(top and bottom appraich)
in c structure we must use the struct keyword while gets the object but c++ not in necessity
C C++
DATA IS NOT SECURED SECURED
TOP DOWN BOTTOM-UP
FOCUS ON PROCEDURES FOCUS ON DATA
PROGRAMS ARE DECOMPOSED INTO OBJECTS
INTO FUNCTIONS
allocation is done NEW OPERATOR
with malloc statement
UNOINS AND ENUMS AVALIABLE
ARE NOT AVALIABLE
DOES NOT PROVIDE PROVIDES
DEFAULT ARGUMENTS
12. What is friend function?
Its used to access the private data of the base class.
Uses:
Its used to access the private data of the base class.
Improves the versatile of the operator overloading.
13. what is friend class and its use?
We can share everything between any class while declare the class as friend..
14. what are all the operators that cant be overloaded?
.* , ?: , :: , . sizeof
15. what is overloading and overriding?
Overloading : same function name with may have different type or no of arguments, or different return type.
Overriding : same prototype will be used in the base and derived class.
16. different types of type casting.
Implicit – Implicit Conversion do not require any operator like int,double,float
Explicit - Explicit Conversion must require operator like int,double,float
Dynamic_cast - dynamic_cast can be used only with pointers and references to objects. Its purpose is to ensure that the result of the type conversion is a valid complete object of the requested class.
class CBase { };
class CDerived: public CBase { };
CBase b; CBase* pb;
CDerived d; CDerived* pd;
pb = dynamic_cast
pd = dynamic_cast
Static_cast - static_cast can perform conversions between pointers to related classes, not only from the derived class to its base, but also from a base class to its derived
Reinterpret_cast - reinterpret_cast converts any pointer type to any other pointer type, even of unrelated classes.
Constructor`
A constructor is a special member function which will construct an object with user defined values whenever object is created OR A constructor is a special member function which will be called automatically to initialize the data member of a class whenever object is instantiated.
when can we use copy constructor?
A copy constructor is used in 3 cases.They are listed below:
a)When an object is created from another object of the same
type.
b)When an object is passed by value as a parameter to a
function.
c)When an object is returned from a pointer.
no virtual constructor y?
A constructor cant be virtual. Bcoz at a time when the constructor is invoked from the virtual table wouldn’t be available in memory.
Virtual function is slow y?
Because if we use the virtual functions then the vtable is created and when we call the virtual functions it will refere the vtable vptr for the first two bytes of the object that contains.
So that acess of the vtable causes the slow processing.
stack , queue
stack:
Inserting and deleting the element using TOP. This is Last In First Out.(LIFO)
Queue:
Insert the element using Front and Deleting the Element using Rear. This is First In First Out(FIFO)
virtual functions is slow, why?
malloc calloc new
malloc:]
default memory value is Garbage
calloc:
default memory value is zero.
New :
When we use the new operator the constructor is call
VC++
1. What is the base class for all classes in the mfc?
CObject
CObject does not support multiple inheritance. Your derived classes can have only one CObject base class, and that CObject must be leftmost in the hierarchy. It is permissible, however, to have structures and non-CObject-derived classes in right-hand multiple-inheritance branches.
Its functionalities,
Serialization, - Storing/Restoring object to or from persistent storage such as disk drive.
Runtime class information – to identify the base class information at run time using CRunTime class.
Object diagnostic support – Assert(), Dump(), TRACE(), VERIFY(), DEBUG-NEW,
AfxDump, AfxMemDef, AfxCheckError.
http://msdn.microsoft.com/en-us/library/s8c29sw2%28VS.71%29.aspx
Compatablity with collection class. – Array , List, CStringArray, CByteArray, CMap
2. why CObject is the base class for almost all classes?
Ba abababababababaabba
3. how to achieve serialization?
File read write using CFile
CArchieve
4. Did you use any CObject method in ur class?
Yes, used. Like DYNA_CREATE, DECLARE_DYNAMIC, IMPLEMENT_DYNAMIC.
5. what is the difference between managed and unmanaged?
Manged – .Net (CLR)
Un managed - Native c++
6. How to find out either managed or unmanaged code?
7. What is the default method called in dialogbased application either ‘OnOK’ or ‘Oncancel’?
OnOK()
8. How OnOK get proceed as default?
9. what is model and modeless dialog?
In modal dialog we cant get focus to the parent while using the child window.
But in case of the modeless dialog we can able to access both dialogs.
10. How to create the modeless dialog?
Using Create() and ShowWindow().
11. if application opened two modeless dialog what is the default method called?
OnOK()
12. if I opened two modeless dialog then I close parent dialog and I want to close the its modeless dialog also, how to handle this?
DestroyWindow(). Store all the window handle with the list and destroy the individual child window before close the parent.
http://www.codeproject.com/KB/dialog/gettingmodeless.aspx
13. What is message map? How many arguments takes BEGIN_MESSAGE_MAP and why?
MessageMap is macro used to handle messages by calling appropriate functions.
Begin messagemap - > 2 arguments, class name, class base class…
Base class is needed because if that class doesn’t have that particular message defined then the base class message is to be processed. And its continues to find the message if suppose nothing found then the default should be called.
14. DodataExcahange ()
DoDataExcahange is used to map the datas and then the controls. We can manually call this witht the help of the UpdateData().
By default its arg is true. If its true – then values copied from the control to the member variable, and if its false then the member variable to the control is to be updated.
15. what is afx stands for?
Afx stands for Application Framework
16. Explain function prototype of the AfxMessageBox() and AfxBeginThread()?
AfxMessageBox(CString message,uint ntype, uint nhelpid);
MessageBox(CString strDisplayString, CString strTitle, UINT nType);
AfxBeginThread: (
CWinThread* AfxBeginThread(
AFX_THREADPROC pfnThreadProc,
LPVOID pParam,
int nPriority = THREAD_PRIORITY_NORMAL,
UINT nStackSize = 0,
DWORD dwCreateFlags = 0,
LPSECURITY_ATTRIBUTES lpSecurityAttrs = NULL
);
CWinThread* AfxBeginThread(
CRuntimeClass* pThreadClass,
int nPriority = THREAD_PRIORITY_NORMAL,
UINT nStackSize = 0,
DWORD dwCreateFlags = 0,
LPSECURITY_ATTRIBUTES lpSecurityAttrs = NULL
);
17. How many types of thread and what is the different?
Two types:
Worker Thread and user interface Thread.
Worker Thread can run with out user interaction.
User Interface Thread it can have user input.
18. How many classes gets created on dialog based application and what are they?
Dlg class and application class
Dlg class – CDialog base class
App class - CWinApp base class
19. How to check particular exe opened or not ? what method?
EnumProcess().
20. What is DefWndProc()? And how to handle messages
Sends the specified message to the default window procedure.
21. what is function overloading? And over riding?
Overloading – same functions with different types of arguments or no of arguments
Over riding- same function with same arguments and types of arguments.
This is involves in the inheritance concepts.
22. how many ways achieve the compile time polymorphism
Function Overloading and operator overloading.
23. What is the different between the sendmessage and postmessage?
Send Message :
The SendMessage function places a message in the
message queue waiting for the thread to process the message.
Post Message:
The PostMessage function places (posts) a message in the
message queue associated with the thread that created the
specified window and then returns without waiting for the
thread to process the message.
24. Whats the PreTranslateMessage and its use.?
25. what is smart pointer?
26. RTTI
Run time type identification
Used to identify the base class type for object. Using typeid or dynamic_cast().
27. Clistctrl and CListView
List ctrl we can use report and icon views
Listbox is normal like to store datas in list.
28. Function Pointer / call back
We can call the function with the address of that particular function.
Call back is calling a function using the function pointer
29. What is DC
30. CClientDC and CPaintDC
31. CDC and HDC
32. Handle to Window
33. Collection Classes.
COM
1. What is COM?
Component Object Model, It’s a language neutral.
Adv: Act as a interface between two different modules.
2. What are the methods available in COM? That is common for all interfaces?
AddRef – Reference count increase
Release – Decrease count, if =0 then release the object from memory.
QueryInterface – obtain the interface object.
3. What is the base interface?
IUnknown
4. How the com dll map the string from vb to vc++
5. Advantages of COM?
Adv: Act as a interface between two different modules.
Easily communicate between two modules.
6. How to obtain the object of the interface?
Using CoCreateInstance().
7. What is and the return type of the CoCreateInstance()?
HRESULT
.NET:
1. What is web service?
2. What is CLR?
Common Language Runtime
3. What type of architecture you used in your web service?
4. What is the base class of web service?
System.Service
5. How the web service get process the client request?
Data Base:
1. What is the Primary Key?
Uniquely identify the record.
Primary doesn’t allows not null but unique allows the null value.
Foreign key – creating keys for the two tables with the primary key of the first table.
2. What is Index?
Index created for the fast access to the data. For most cases the primary will be used for the index.
3. what is join? And advantages?
To obtain the details of records from two tables
Types:
Inner join
Outer join
Left outer
Right outer