• +91 9971497814
  • info@interviewmaterial.com

Computer Interview Questions Answers

CPlusPlus Interview Questions Answers

Question - 41 : - What is the software Life-Cycle?

Answer - 41 : - The software Life-Cycle are 1) Analysis and specification of the task 2) Design of the algorithms and data structures 3) Implementation (coding) 4) Testing 5) Maintenance and evolution of the system 6) Obsolescence

Question - 42 : - What is semaphore?

Answer - 42 : - Semaphore is a special variable, it has two methods: up and down. Semaphore performs atomic operations, which means ones a semaphore is called it can not be inturrupted. The internal counter (= #ups - #downs) can never be negative. If you execute the “down” method when the internal counter is zero, it will block until some other thread calls the “up” method. Semaphores are use for thread synchronization.

Question - 43 : - Describe one simple rehashing policy.

Answer - 43 : - The simplest rehashing policy is linear probing. Suppose a key K hashes to location i. Suppose other key occupies H[i]. The following function is used to generate alternative locations: rehash(j) = (j + 1) mod h where j is the location most recently probed. Initially j = i, the hash code for K. Notice that this version of rehash does not depend on K.  

Question - 44 : - Describe run-time type identification.

Answer - 44 : - The ability to determine at run time the type of an object by using the typeid operator or the dynamic_cast operator.

Question - 45 : - What is the difference between Mutex and Binary semaphore?

Answer - 45 : - semaphore is used to synchronize processes. where as mutex is used to provide synchronization between threads running in the same process.

Question - 46 : - What is a modifier?

Answer - 46 : - A modifier, also called a modifying function is a member function that changes the value of  at least one data member. In other words, an operation that modifies the state of an object. Modifiers are also known as ‘mutators’. Example: The function mod is a modifier in the following code snippet: class test { int x,y; public: test() { x=0; y=0; } void mod() { x=10; y=15; } };

Question - 47 : - What is friend function?

Answer - 47 : - As the name suggests, the function acts as a friend to a class. As a friend of a class, it can access its private and protected members. A friend function is not a member of the class. But it must be listed in the class definition.

Question - 48 : - What are the differences between a C++ struct and C++ class?

Answer - 48 : - The default member and base-class access specifier are different.

Question - 49 : - Write a Struct Time where integer m, h, s are its members

Answer - 49 : - struct Time { int m; int h; int s; };

Question - 50 : - How can you tell what shell you are running on UNIX system?

Answer - 50 : - You can do the Echo $RANDOM. It will return a undefined variable if you are from the C-Shell, just a return prompt if you are from the Bourne shell, and a 5 digit random numbers if you are from the Korn shell. You could also do a ps -l and look for the shell with the highest PID.

Computer Contributors

Rajeev Katiyar
Yes Baroda

Share your email for latest updates


Our partners