Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

C++ INTERVIEW QUESTIONS

Duration 1 hour

1. All questions are mandatory.


2. Candidate must complete all the questions in 1 hour.
3. For descriptive questions please answer them in a concise and clear manner

SL NO Questions
1 const char* p = "Test";
What is output of expression *p++?
2 class Test {
public:
virtual ~Test() {}
};
Test t;
What is sizeof(t)?
3 void f(string & s) {}
f("test");
Comment on above code
4 int main() {
int x = 5;
delete &x;
}
Is above code safe?
5 Can Destructor throw exception?
6 Very large files size (size at multiple TB for example) need to be transferred from data
center A to data center B, each located to far off geographically from
each other. What are your thoughts on design of file transfer mechanism for such large
files?
7 Let MAX_POSITIVE_INT be the maximum positive integer on the system.

Assume integer is 4 bytes (32 bits)


int nums[MAX_POSITIVE_INT];

You are given array nums above which contains all positive integers (in range 1 to
MAX_POSITIVE_INT) some of which may be duplicates. Design an
algorithm to query if a given positive number exists in nums. There will be multiple
queries with different inputs, inputs being positive integers. You
can modify the array nums if needed and make your solution run time and memory
efficient.
8 Reverse bits of a 32-bit unsigned integer
9 Given a positive integer, return its corresponding column title as it appears in an Excel
sheet. For example:

1 -> A
2 -> B
3 -> C
...
26 -> Z
27 -> AA
28 -> AB
10 Given an array nums of n integers, are there elements a, b, c in nums such that a + b + c =
0? Find all unique triplets in the array which gives the sum of zero.

Note:
The solution set must not contain duplicate triplets.

Example:
Given array nums = [-1, 0, 1, 2, -1, -4],
solution set is:
[
[-1, 0, 1],
[-1, -1, 2]
]

You might also like