Tuesday, November 1, 2011

DLLs

Hey all,
This time I'd like to discuss about DLL. DLL - The most used term in Windows operating system.
+ Dynamic Link Libraries(DLL) can be shared across multiple process in windows OS.
+ They can be loaded at run time unlike static libraries and they can really create modular apps in windows.
+ They can be easily upgraded without affecting the complete app.

They have some cons as well:
- DLL and its client should use same and same version of compiler
- DLL and its client should use same version of CRT DLL
- When class is exported from DLL then its base class and member class also should be exported.

Here we see some interesting questions about DLL in job market:
1. Why DLL instead of static libraries ?
2. What is lib file and how it is used by app?
3. How do you export C++ class in DLL?
4. Can I share data from DLL across different process and DLLs? If yes then how?
5. How can you debug DLL?
6. When will you use module definition file and when will you use lib file?
7. How do you load different version of DLL without affecting the client APP?
8. Using what tool you can see the exported function details in windows?
9. What are the difference between DLL and EXE?
10. How do you differentiate overloaded functions using GetProcAddress() when explicit linking is used?
11. How to call C++ DLL functions from C app?


Wednesday, October 19, 2011

OOAD questions...

Hey all,
This time I would like to post some interesting questions on Object Oriented Analysis and Design(OOAD). Okay, what would be the difference between OOA and OOD? well, Object Oriented Analysis speaks about the problem space while Design speaks about the solution for the problem.

Now-a-days C++, JAVA and C# are mostly used OOPL (Object Oriented Programming Languages). OOPL really gives you most effective solution for your problem through its key features: Encapsulation, Abstraction, Inheritance and Polymorphism. OOAD gives the most the effective design for your solution. OOAD is mostly done using different tools like Rational Rose, MS Visio...etc. These tools invariably use UML(Unified Modelling Language) notation to denote classes and their relationship. Class design can be arrived through various phases using OOAD:
a. Identifying use cases
b. Identifying actor for your problem space
c. Creating sequence diagram
d. Creating class diagram
For ex: Design of ATM machine

When dealing with OOAD questions, follow these small tips:
1.Don't have any assumption since the interviewer ask you vague question to see whether you ask for the right input or not. Ask questions like why and what for this design is.
2. Identify the CORE objects for your design.
3. Establish proper relationship between them.
4. Have all methods and other classes to to work with your problem space. Okay, let's move to questions corner now:

1. What is the difference between association, aggregation and composition?
2. What is interface and why it is needed?
3. When will you go for interface and class?
4. What is the difference between abstract class and interface?
5. What is the difference between abstraction and encapsulation?
6. Design IRCTC website using classes
7. What are all the things you consider while designing your class?
8. How will you be sure that the given class is for inheritance or for composition?
9. Let's say you need to create objects based on platform your app runs. You also need to give support for forthcoming platforms as well but which case your library users shouldn't get affected. How will you design this?


Monday, October 3, 2011

Some interesting Win32 questions

Some interesting Win32 questions:
1. Difference between worker thread and UI thread
2. How window is created in windows?
3. How my Win32 applications get messages?
4. Difference between application and thread
5. Difference between Critical section and mutex?
6. When my app is closed abruptly how do you close all threads appropriately?
7. How to implement my 5 threads accessing a shared file in read mode and 1 thread accessing the file in write mode?
8. How can you achieve async IO in file operation?

Saturday, October 1, 2011

Interesting C Programming interview questions

Hello all,
Everyone of us in software development field would have started our career with C programming language which is the powerful and structured PL. Even today lots of system programming like device driver development, firmware development and embedded system programming uses the most efficient C Programming language. Here I'd like to list down some of the interesting questions in this subject.

Interesting C Programming interview questions:

1. What is the difference between char *p[10] and char (*p) [10]?

2. Why union is required and give me some examples where you used it?

3. What is function pointer and where did you use that in your project?

4. Why static variable shouldn't be used in union?

5. How will you add two numbers without using + or ++ operator?

6. How will you reset the bit in a given position from the byte?

7. How will you toggle all the bits in byte?



Monday, July 25, 2011

Programming interview questions

Hi,
As a software developer we would have came across so many challenges in our day to day work. It would be very helpful if we have the following attitude while solving any puzzle:

1. Be open for challenge
2. Try to synthesize the problem into smaller chunks
3. Write down the algorithm for the solution
4. Think out of the box
5. Don't restrict your capabilities
6. Be Honest in finding the solution

definitely the above approach will give you the cake walk solution against any terrible problem.
Okay let me give you some interesting programming questions I have come across:

Question 1: How could you determine if a linked list contains a cycle in it, and, at what node the cycle starts?
Answer 1:

NODE *p1 = *p2 = HEAD;
 do {  p1 = p1->next;  if(p2->next) p2 = p2->next->next; 
} while (p1 != p2);
if p1 and p2 is NULL then it is acyclic otherwise it is cyclic.

Q2: How will you reverse the singly linked list?

Q3: Write a program to remove duplicates in array?

Q4: How will you reverse the doubly linked list without swapping values?

Q5: How can you reset a bit from the given position of given number?

Q6. Insert a node in sorted doubly linked list

Q7. Construct a BST(Binary Search Tree) for the node 3, 1, 2

Q8. Write code to search a given element in BST

Q9. Write a code to find maximum depth of the BST

Q10. What are all the difference between STL map and set. Can I conver a map into set?

Q11. Why hash table and where it is used?

Cheers,
Rajan

Thursday, July 21, 2011

C++ interview questions

Everyone who works in software industry as developer or tester would have come across interview in C++ - The most powerful Object Oriented Programming Language. I would like to list some of the interesting C++ questions in this column which I have come across.

1. What is the size of below structures and how the size is calculated?
a. struct st{
int i;
char c;
double d;
};

b. struct st{ };


2. When will you use "static global" variable in a file?

3. Where initialized static and uninitialized extern variable stored in application memory layout?

4. Let's say your application is crashed before hitting main()'s breakpoint, what will be the possible reasons for crash?

5. What is the significance of using "const obj&" in copy constructor? Whyn't can I pass object in other ways?

6. What is the size of below structures and how the size is calculated?
a. class A{
virtual vfuc1() = 0;
};

class A1{
virtual void vfunc2(){printf("I'm class A1's vfunc2\n");}
};

b. class B : class A, class A1 {
virtual vfunc1() {printf("I'm class B's vfunc1\n");}
virtual vfunc2() {printf("I'm class B's vfunc2\n");}
};

7. How many vtptr(virtual table pointer) and vtable(virtual function table) would have been created for below definition?
A1 array[10]; // refer A1's declaration in Q8.

8. How virtual key in virtual destructor take care of calling derived class dtor(destructor) first then base dtor when the derived class object is deleted through base class pointer?

9. What is the size of below class B and why?
class A{ public: virtual void vfuc(){} };
class B: virtual class A {};

10. Give me some example when ctor has to be added explicitly for a class?

11. Give me some scenario why you need virtual functions?

12. What is the word 'virtual' significance in virtual base class?
say: class B: virtual class A {};

13. Do you achieve function overriding without virtual keyword?

14. What is deep-copy and how will you achieve it?

15. When will you implement your own Copy Ctor and assignment operator?

16. When copy ctor and assignment operator get called below?
class Fred {}
Fred obj1, obj2, obj3;
obj3 = obj1;
Fred obj3 = obj2;
Fred obj5(obj2);
Fred obj9();

18. When copy ctor will be called by compiler?

17. Why const &Ref is the parameter for copy ctor, why not const obj?


18. How to avoid my objects getting copied?

19. How can you avoid my objects getting copied with my object?

20. How do you know whether the given class is given for inheritance or not?

21. What are the things you consider while designing your class?

22. How do you decide whether your ctor has to be inline or not?

23. How do you avoid your object creation on stack?

24. Can your destructor be pure virtual to make your class ABC. If yes then does dtor should have body or not?

25. What is function object?

26. What are the differences between set and map?

27. Can I convert map into set?

28. What is association?

29. What is the difference between aggregation and composition?

30. why function overloading is not done using different return types in C++?

- to be continued




Thursday, July 7, 2011

Can I write overloaded function inside my DLL?

You cant do it.....GetProcAddress expects C linkage...no name decoration...therefore no overloading.......either use 2 function names or link via a lib file

Yes you can export objects, but it's not straight forward.

Normally, you export a function to create an instance of your object and return a pointer to it. You also need to export a function to destroy it.

In addition, if you want compatability between compilers, and/or between different versions of your DLL, you need to use pure virtual base classes and export pointers to these.

Here's some info:

www.bcbdev.com/articles/vcdll2.htm