Ten Technical Interview Aptitude Questions: Set 5
C++ and OOP technical interview questions on pointers, classes, function overloading, abstract classes, and friend functions, with verified interview-ready answers.
C++ and OOP concept questions make up a predictable portion of first-round technical interviews at TCS, Infosys, and Wipro for CSE students, and the answers are defined by precision, not length.
This is set 5 in the series. The 10 questions below cover object-oriented fundamentals, pointer mechanics, and key C++ function types. Each answer has been verified from first principles against the C++ specification, not carried over from legacy prep material.
What Technical Interviewers Are Actually Testing
These questions test three areas, in order of frequency across campus interview reports:
- Core OOP concepts: objects, classes, structs, and abstract classes
- Pointer mechanics: what a pointer stores, and how null and void pointers differ
- C++ function features: overloading, friend access, and inline expansion
Knowing data structures and common algorithm questions alongside these OOP answers gives you the coverage most technical rounds at service-sector companies require.
Questions 1 to 4: OOP Fundamentals
Pass by Value and Pass by Reference
- Q1: What is the difference between pass by value and pass by reference?
- Answer: Pass by value sends a copy of the argument’s data to the called function. The original variable in the caller is unchanged regardless of what the function does to its parameter. Pass by reference sends the memory address of the argument. The called function operates on the actual variable, so any modifications it makes persist in the caller after the function returns.
Objects, Classes, and the Struct Distinction
-
Q2: What is an object?
-
Answer: An object is a runtime instance of a class. It has state, which is the current set of values held by its data members, and behaviour, defined by the member functions declared in its class.
-
Q3: What is a class?
-
Answer: A class is a user-defined data type in C++. It groups related data members and member functions under a single name. Defining a class does not allocate memory; creating an object of that class does.
-
Q4: What is the difference between a class and a struct in C++?
-
Answer: In C, a struct could only bundle data members of different types. C++ extended struct to also allow member functions. In C++, the only functional difference between struct and class is the default access modifier: all members of a struct are public by default; all members of a class are private by default. Either can be overridden using explicit
public:orprivate:labels.
Questions 5 and 6: Pointers and Memory
What a Pointer Is
- Q5: What is a pointer?
- Answer: A pointer is a variable that stores the memory address of another variable rather than a direct value. Declaring
int *p;creates a pointer that can hold the address of any integer. Assigningp = &x;makesppoint to the variablex; writing*pthen reads or writes the value at that address.
Null vs Void Pointer
- Q6: What is the difference between a null pointer and a void pointer?
- Answer: A null pointer holds the value 0 (written as
NULLornullptrin modern C++), signalling that it points to no valid memory address. A void pointer is a generic pointer that can store the address of any data type but carries no type information; you must cast a void pointer to a specific type before using the value it points to. The distinction in one line: null means “no address”; void means “address of unknown type.”
According to cppreference.com, dereferencing a null pointer is undefined behaviour in C++. This is why checking for null before every dereference operation matters in production code.
Questions 7 to 9: C++ Function Features
Function Overloading
- Q7: What is function overloading?
- Answer: Function overloading allows multiple functions in the same scope to share a name, provided they differ in their parameter lists. The compiler determines which version to call at compile time, based on the number, types, or order of arguments. Return type alone is not sufficient to differentiate overloaded functions.
- Example:
int add(int a, int b)handles two integers.double add(double a, double b)handles two doubles.- Calling
add(3, 4)resolves to the first version;add(3.0, 4.0)resolves to the second.
Friend Functions
- Q8: What is a friend function?
- Answer: A friend function is declared inside a class using the
friendkeyword but is not a member of that class. It can access the class’s private and protected members directly, which a non-member function ordinarily cannot. The class controls which external functions are its friends by naming them explicitly in the declaration.
The C++ FAQ on isocpp.org notes that friend does not violate encapsulation when used with intent: the class grants access; it is not bypassed.
Inline Functions
- Q9: What is an inline function?
- Answer: An inline function carries the
inlinekeyword as a request to the compiler. When the compiler honours it, it substitutes the function’s body at each call site instead of generating a standard function call. This removes the overhead of setting up a call stack frame. The trade-off is a potentially larger binary when the function is called in many places. The compiler is not obligated to inline a function just because it is marked as such.
Question 10: Abstract Classes
- Q10: What is an abstract class?
- Answer: An abstract class is a class that cannot be instantiated directly. It provides a common interface for a set of derived classes but leaves at least one method unimplemented. In C++, a class becomes abstract by containing at least one pure virtual function, declared with
= 0:
class Shape {
public:
virtual double area() = 0; // pure virtual function
};
Any derived class must override area() before its objects can be created. Abstract classes are the basis of runtime polymorphism in C++.
Working through coding problems like finding the smallest and largest element in an array helps build the C++ coding fluency that makes these concepts feel applied rather than memorised.
Preparing for Technical Rounds
A 30-minute first technical round at most service-sector companies includes 4 to 6 OOP concept questions alongside questions on algorithms or arrays. The 10 questions in this set cover the most frequently tested subset.
A useful framing for each answer: pair the definition with its real-world consequence. If you confuse pass by value and pass by reference, function calls produce unexpected side effects. If you confuse null and void pointers, dereferencing at runtime crashes the program. Answers that include the consequence signal that you understand the purpose, not just the vocabulary.
Knowing all 10 definitions is the theory. Writing and running code that demonstrates them is what converts preparation into confidence. TinkerLLM lets you build small C++ programs that call functions by value and by reference, define class hierarchies with abstract base classes, and trace pointer behaviour at ₹299, without local environment overhead. The next interviewer who asks you to explain pass by reference will get a cleaner answer from someone who has run the code.
Primary sources
Frequently asked questions
What is the difference between pass by value and pass by reference in C++?
Pass by value copies the argument; the called function cannot modify the original variable. Pass by reference passes the memory address; changes inside the function affect the original variable in the caller.
What is the key difference between a class and a struct in C++?
In C++, both can hold data and member functions. The only difference is the default access modifier: struct members are public by default, while class members are private by default.
What is a pure virtual function and what does it make a class?
A pure virtual function is declared with = 0 in a base class and has no implementation there. Any class with at least one pure virtual function is abstract and cannot be instantiated directly.
When are OOP concept questions asked in technical interviews?
TCS, Infosys, and Wipro technical rounds for CSE and IT students typically include 4 to 6 OOP concept questions. Expect them in first-round interviews alongside basic data structures and algorithm questions.
What is function overloading in C++?
Function overloading allows multiple functions to share the same name as long as their parameter lists differ in number, type, or order. The compiler selects the correct version at compile time based on the argument types used in the call.
A self-paced playground for building with LLMs.
TinkerLLM is FACE Prep's sister property. A guided environment for shipping real LLM applications, the kind of project that earns a paragraph on your resume, not a line.
Try TinkerLLM (₹299 launch)