Technical Round 1(1 hr):
- Default functions provided by compiler in empty class? https://www.geeksforgeeks.org/default-methods-in-c-with-examples/amp/
- Which data structure you will use to represent a directory structure? Tree
Write program to count files with a given name like “abc.txt”
- What are static variables, where are they stored? Data segment area
- Detect cycle in directed graph. Told DFS approach
- What is reference in C++.
Find out mistakes in below code.
C++int
main() {
int
x=5;
int
&ptr=x;
++ptr;
cout<<ptr;
//what will be printed?
delete
ptr;
//compilation error
return
0;
}
- New and delete operator syntax related question, also checked for memory leak scenario when variables are allocated dynamically
- Delete 4th item from single linked list
- What are Dynamic and static linked libraries? Do you know about .so files?
- How to make global variables accessible in different classes? Using extern variable
- What is heap memory.
- What are function pointers and why are they used?
- What design patterns do you know? Design pattern you have used in your code.
- Use runtime polymorphisms in your code. Why it is required?
Technical round 2(1 hr):
- Pros and cons of both C and C++ over each other.
- One problem with sorting. Given following class:
C++
class
Apple{
private
:
int
weight;
enum
color ;
//black, green , red
};
You have a bunch of apples, need to sort them with these criteria.
1) Red Good apples – Heavy to lighter
2) Green apples – Heavy to lighter
3) Bad – Heavy to lighter
- Provided some code and asked if it’s copy constructor or assignment function call
- What will happen if we don’t return anything from assignment operator?
https://stackoverflow.com/questions/42335200/assignment-operator-overloading-returning-void-versus-returning-reference-param
Also asked about rvalue concept.
- What is STL? How many types of iterators in C++?
- Difference b/w vector and list?
Director Round(1 hr):
- Coin Puzzle: https://stackoverflow.com/questions/34057683/strategy-to-win-game-if-players-can-take-upto-4-coins
I told answer. Then he asked me to pick coins accordingly and checked at each step how many coins are picked by me.
- Variation in question 1, player who picks last coin loses the game.
- Given a file, read that file and print last 10 lines of file. Suppose file having 25 lines. Print lines from 16 to 25. Told queue approach
- Why do you want to switch?