HCLTech
10+ Crescon Projects & Services Interview Questions and Answers
Q1. Singleton class creation (code) what is use of it ?
Singleton class ensures only one instance of a class is created and provides a global point of access to it.
Ensures only one instance of a class is created
Provides a global point of access to the instance
Useful for managing global resources or settings
Q2. what's function pointer and what's it's signature
A function pointer is a variable that stores the address of a function. Its signature includes the return type and parameter types of the function.
Function pointers allow for dynamic function calls based on the stored address
Syntax: return_type (*pointer_name)(parameter_types)
Example: void (*funcPtr)(int) = &someFunction;
Q3. Implementation of STL libraries any container class ex:- Vector
STL libraries provide efficient and easy-to-use container classes like Vector for storing and manipulating data.
STL Vector is a dynamic array that can resize itself automatically.
It provides random access to elements, similar to arrays.
Vector supports various operations like push_back, pop_back, insert, erase, etc.
Example: std::vector<int> numbers = {1, 2, 3, 4, 5};
Q4. Copy one string to another without using any standard function
Use a loop to copy characters from one string to another
Create two character arrays to store the strings
Use a loop to iterate through each character of the source string and copy it to the destination string
Add a null terminator at the end of the destination string to mark the end of the copied string
Q5. Write code to delete node from linked list
To delete a node from a linked list, update the pointers of the previous node to skip the node to be deleted.
Traverse the linked list to find the node to be deleted
Update the pointers of the previous node to skip the node to be deleted
Free the memory allocated to the node to be deleted
Q6. Overload + operator to add two complex numbers
Overload + operator to add two complex numbers in C++.
Define a class for complex numbers with real and imaginary parts.
Overload the + operator as a member function of the class.
Return a new complex number with the sum of real and imaginary parts.
Q7. What's compile time polymorphism
Compile time polymorphism is achieved through function overloading and templates in C++.
Compile time polymorphism allows for different functions to be called based on the arguments provided at compile time.
Function overloading is a form of compile time polymorphism where multiple functions have the same name but different parameters.
Templates in C++ allow for generic programming and compile time polymorphism by creating functions or classes that can work with any data type.
Co...read more
Q8. What is the use of Mutex
Mutex is used in multithreading to prevent multiple threads from accessing shared resources simultaneously.
Mutex stands for mutual exclusion and is used to synchronize access to shared resources in multithreaded programs.
It allows only one thread to access the shared resource at a time, preventing data corruption or race conditions.
Mutexes are typically used in critical sections of code where data integrity is important.
Example: Protecting a shared variable in a multithreaded...read more
Q9. Bit shift 1 by 4 position from LSB
Bit shift 1 by 4 positions from LSB results in 16
Use the left shift operator (<<) to shift the bits by 4 positions
1 << 4 = 16
Q10. Runtime polymorphism with example
Runtime polymorphism allows objects of different classes to be treated as objects of a common superclass.
Use virtual functions in base class and override them in derived classes
Use pointers or references of base class to call derived class methods
Example: Animal class with virtual function 'makeSound', Dog and Cat classes overriding 'makeSound'
Q11. What's polymorphism
Polymorphism is the ability of a function to behave differently based on the object it is called with.
Polymorphism allows objects of different classes to be treated as objects of a common superclass.
There are two types of polymorphism: compile-time (function overloading) and runtime (virtual functions).
Example: A base class Animal with a virtual function 'makeSound'. Subclasses Dog and Cat override 'makeSound' to bark and meow respectively.
Q12. Explain oops concepts
OOP is a programming paradigm based on the concept of objects, which can contain data and code to manipulate that data.
OOP focuses on creating objects that interact with each other to solve complex problems.
Encapsulation: Objects encapsulate data and behavior within a single unit.
Inheritance: Objects can inherit attributes and methods from other objects.
Polymorphism: Objects can take on different forms or have multiple behaviors.
Example: A 'Car' object can have attributes lik...read more
Interview Process at Crescon Projects & Services
Reviews
Interviews
Salaries
Users/Month