A recruiter sent this simple set of interview questions for a programming position.
- How can you defined OOP?
- How can you use OOP in your projects/products/applications?
- What is copy constructor?
- How many types of copy constructor are there?
- What shallow copy constructor does/behaves?
- Does C++ support copy constructor?
- Does Java support copy constructor?
- (If the answer to the previous question was correct) Why doesn’t Java support copy constructor?
- What is software life cycle?
17 Comments on Programming interview questions
OOP stands for Object Oriented Programming. It is an object based approach for developing a software solution for a given problem/domain. In OOP everyting is modeled in the form of objects which model a real life entity present in a problem. OOP has three major characteristics:
1. Inheritance - This is the property by which an entity attains all attributes of its parent.
2. Encapsulation - This is the property by which an entity hides all details about itself from the outside world.
3. Polymorphism - This is the property by which an entity can exists in more than one form.
In OOP we use interfaces to define an abstraction of the functionalities needed, and we use hte concept of class to define a solid implementation of the functionalities defined by an interface the class implements. A class can choose not to implement certain methods defined in an interface or on its own, in such case such a class needs subclassing and is called an abstract class. The difference between an interface and an abstract class is that an interface just define the scope of functionalities needed and an abstract class define as well as optionally implement the scope of functionalities needed.
Answer to q#9: WEll the answer is that there are many phases, namely 5. The first is the Planning phase, in which the feaseablity testing and other plannings are done. The second is the designing part, in which each and every componnet is being designed. The third is the Coding part, where the desing is now converted to woking model by the coders. The fourth is the Testing part, the coding and he testing part may go hand in hand, this is to check the software for feasability, robustness, effeciency and quality. The final phase is the implementation and the maintainnance.
search all the answers in http://www.microsoft.com/msdn
All objects in Java are passed by reference, eliminating the need for the copy constructor used in C++.(In reality, all parameters are passed by value in Java. However, passing a copy of a reference variable makes it possible for code in the receiving method to access the object referred to by the variable, and possibly to modify the contents of that object. However, code in the receiving method cannot cause the original reference variable to refer to a different object.)
Is there anybody who knows how I can open a TIFF file with C++?
Suppose we want to use copy constructor to make a copy of an object that contains a pointer (not null). In case of shallow copy the newly created object’s pointer will also point to the same memory to which the parameter object’ pointer was pointing. This is because the constructor just copied the contents of the pointer variable which is logically wrong. The correct way i.e. deep copy is to allocate memory to the pointer of the newly created object and copy the memory contents(not the contents of the pointer variable) to the memory allocated to the new pointer.
The question I was asked once at the interview to Qualcomm, is what’s the difference between copy constructor and assignment operator?
So, the answer should be, that the copy costructor is called at initializing the object, while the assignment operator used to assign one object by another.
does java supports the concept of pointers and if not then what is the concept of copying the object reference from one object to another
can someone tell me how to declare a pointer to a single character?
Difference between global,static and local variable at class and file levels?????????
For the question #3 , the copy constructor is used in C++ for creating the copy of the class member when there is a string present in it. When a constructor is allocated the class object while created allocates only a pointer, but when the copy constructor is used the size for the data object is created and the object is created.
How will you identify a loop in a linked list?? How will be the traversal made with out a temporary pointer being used??
How will you remove the loop in the linked list??
I need to know about a 32 bit variable to produce only the following output 2,4,8,16,32. What is the masking element should we need to use.
For the question 9 , the answer is char *p;
core object oriented programming questions are required which includes classes, methods. different codes to implement inheritence and polymophism into your code in any language you work. need to know the basic OOP transactions.
Here is the answer of question 3
copy constructor is used ot initialize & declare object from onethor object
e.g
data I2(I1);
this statement would define object I2 & at a same time its value will be initialized with value of I1.
for the question 9 the answer is char *p.