0% found this document useful (0 votes)
8 views3 pages

Advanced Technical QA CPP JS

Uploaded by

Ritu Raj
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)
8 views3 pages

Advanced Technical QA CPP JS

Uploaded by

Ritu Raj
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

Advanced Technical Interview Questions & Answers

C++ Core + Intermediate to Advanced

Q: What is the difference between shallow copy and deep copy?

A: Shallow copy copies references to objects; deep copy copies entire objects recursively.

Q: What is the Rule of Three / Five in C++?

A: If a class defines one of destructor, copy constructor, or copy assignment, it should define all three (or five

including move versions).

Q: What are smart pointers? Difference between shared_ptr, unique_ptr, and weak_ptr?

A: Smart pointers manage memory automatically.

- shared_ptr: shared ownership.

- unique_ptr: sole ownership.

- weak_ptr: non-owning reference.

Q: What are function templates and class templates?

A: Templates allow generic programming. Function/class works with any data type.

Q: What is the difference between static and dynamic polymorphism?

A: Static: resolved at compile time (e.g., overloading). Dynamic: resolved at runtime (e.g., virtual functions).

Q: How does memory allocation happen in C++ (stack vs heap)?

A: Stack: automatic memory. Heap: dynamic memory via new/malloc.

Q: What are friend functions and friend classes?

A: They can access private/protected members of the class they are friend to.

Q: Explain RAII (Resource Acquisition Is Initialization).

A: A resource is acquired in a constructor and released in the destructor, ensuring no leaks.

Q: How does C++ handle multiple inheritance ambiguity?

A: Using virtual inheritance to prevent duplicate base class instances.

Q: How is std::vector implemented internally?


A: It uses a dynamic array that resizes when needed (typically doubling in size).

STL (Standard Template Library)

Q: Difference between map and unordered_map?

A: map is ordered (uses Red-Black tree), unordered_map is faster but unordered (uses hash table).

Q: How is a set different from a multiset?

A: Set stores unique elements, multiset allows duplicates.

Q: What is the underlying data structure of a priority_queue?

A: Typically a max heap implemented using a vector.

Q: Explain iterators and how they work in STL.

A: Iterators act like pointers to traverse containers.

Q: Write a program to sort a vector of pairs using sort() and a custom comparator.

A: sort(v.begin(), v.end(), [](auto &a, auto &b) { return a.second < b.second; });

JavaScript Core + React

Q: Explain closures with an example.

A: A closure is a function that retains access to its lexical scope. Example:

function outer() {

let count = 0;

return function() { count++; return count; }

Q: What is hoisting in JavaScript?

A: Declarations are moved to the top of their scope at compile time.

Q: Difference between == and ===?

A: == allows type coercion; === checks both type and value.

Q: What is the event loop?

A: A mechanism that handles asynchronous callbacks using a queue and call stack.

Q: Difference between var, let, and const?


A: var: function scope; let/const: block scope. const cannot be reassigned.

Q: Arrow functions vs regular functions?

A: Arrow functions don't have their own `this` or `arguments`.

Q: Difference between call(), apply(), and bind()?

A: call: invokes with arguments. apply: with array. bind: returns a bound function.

Q: Event delegation in DOM?

A: Attaching event listener to parent and catching child events via bubbling.

Q: JavaScript data types?

A: Primitive: string, number, boolean, null, undefined, symbol, bigint. Reference: object, array.

Q: Prototypal inheritance?

A: Objects inherit from other objects via prototype chain.

You might also like