0% found this document useful (0 votes)
7 views5 pages

C++ Interview Detailed QA Guide

The document provides a comprehensive overview of various technical topics including C++ programming principles, Linux commands, Python scripting, Git and CI/CD practices, and behavioral interview questions. Key concepts such as object-oriented programming, memory management, process management, and version control are explained with examples. Additionally, it covers strategies for handling interview questions effectively.

Uploaded by

Sonu Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views5 pages

C++ Interview Detailed QA Guide

The document provides a comprehensive overview of various technical topics including C++ programming principles, Linux commands, Python scripting, Git and CI/CD practices, and behavioral interview questions. Key concepts such as object-oriented programming, memory management, process management, and version control are explained with examples. Additionally, it covers strategies for handling interview questions effectively.

Uploaded by

Sonu Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

1.

C++ Interview Questions - Explained

Q1: What are the major principles of Object-Oriented Programming in C++?


A1:
- Encapsulation: Bundling data and methods that operate on it within a class. It hides internal
details.
- Abstraction: Showing only necessary features and hiding the complexity.
- Inheritance: One class can inherit properties and methods from another, promoting code reuse.
- Polymorphism: Same function or operator behaves differently in different contexts (e.g., function
overriding).

Q2: What is the difference between 'new' and 'malloc'?


A2:
- 'new' is a C++ operator that creates an object and calls its constructor.
- 'malloc' is a C function that just allocates memory (no constructor call).
- 'new' also returns the correct data type, while 'malloc' returns void* (needs casting).

Q3: What is a virtual function?


A3:
- A virtual function allows a subclass to override a function in the base class.
- This ensures the correct version of the function is called based on the object, not pointer type
(used in polymorphism).

Q4: What are smart pointers?


A4:
- Smart pointers manage memory automatically.
- Types:
- unique_ptr: owns and deletes the object when done.
- shared_ptr: multiple smart pointers can own the same object.
- weak_ptr: doesn’t affect the reference count; used to break circular references.

Q5: What is deep copy vs shallow copy?


A5:
- Shallow Copy: Copies object and references to the same memory (not safe if memory is
modified).
- Deep Copy: Creates a completely new copy with its own memory.

Q6: Why use 'const' in C++?


A6:
- To prevent accidental modification of data.
- It can be used with variables, pointers, function parameters, and return types.
2. Linux & Shell - Explained

Q1: How to see running processes?


A1:
- Use `ps -aux` to list all processes.
- Use `top` or `htop` to see real-time usage.

Q2: How to make a shell script executable?


A2:
- Use `chmod +x filename.sh` to give execute permission.

Q3: How to search inside files?


A3:
- Use `grep 'text' filename` to search a word inside a file.

Q4: What is the difference between hard and soft links?


A4:
- Hard Link: Points to the same inode, acts like the original file.
- Soft Link (Symbolic): A shortcut that points to another file.

Q5: How to find disk usage?


A5:
- `df -h`: Total disk space usage.
- `du -sh foldername`: Space used by a folder.
3. Python/Scripting - Explained

Q1: What are lists and dictionaries?


A1:
- List: A collection of ordered items (e.g., [1, 2, 3]).
- Dictionary: Stores key-value pairs (e.g., {'name': 'Alice'}).

Q2: How do you open a file in Python?


A2:
- Use `with open("file.txt", "r") as f:` to read a file.

Q3: Common Python use cases in DevOps?


A3:
- Automating tasks (file management, log parsing).
- Working with APIs (e.g., REST).
- Writing monitoring tools.

Q4: How to schedule scripts?


A4:
- Use cron jobs with `crontab -e` to run scripts at specific times.

Q5: Exception handling in Python?


A5:
- Use try-except blocks:
```python
try:
# risky code
except Exception as e:
print("Error:", e)
```
4. Git & CI/CD - Explained

Q1: What is the difference between merge and rebase?


A1:
- Merge: Combines code from two branches, keeps history.
- Rebase: Moves changes from one branch on top of another, creates cleaner history.

Q2: What is a Pull Request?


A2:
- A request to merge code changes from one branch to another (usually reviewed by teammates).

Q3: CI/CD Tools used?


A3:
- Jenkins, GitLab CI, GitHub Actions: Automate build, test, deploy tasks.

Q4: What is a Jenkinsfile?


A4:
- A text file with pipeline stages that tells Jenkins what to do (like a recipe).

Q5: What is Continuous Integration?


A5:
- Frequently integrating code to catch issues early.
- Automated builds and tests ensure nothing is broken.
5. Behavioral Questions - Explained

Q1: Tell me about a challenging bug.


A1:
- Use STAR: Situation, Task, Action, Result.
- Example: "We had a memory leak. I used Valgrind to find the source, patched the code, and it
reduced crashes by 90%."

Q2: How do you handle pressure?


A2:
- Break work into smaller tasks, communicate status clearly, focus on high-priority items.

Q3: Agile experience?


A3:
- Daily stand-ups, sprint planning, retrospectives.
- I used JIRA to manage tasks and collaborate with team.

Q4: Team collaboration?


A4:
- Clear communication (Slack, meetings), reviewing code, helping juniors, documenting properly.

Q5: Why are you a good fit?


A5:
- I have strong C++ and scripting skills, love problem-solving, and am proactive in learning and
contributing.

You might also like