top of page

Top Programming Concepts and OOP Questions Commonly Asked in Placement Drives

Landing a job through campus or off-campus placement drives often hinges on your grasp of core programming concepts and Object-Oriented Programming (OOP). Recruiters use these topics to evaluate your problem-solving skills, coding ability, and understanding of software design principles. This post breaks down the most common programming and OOP questions you can expect, along with clear explanations and examples to help you prepare effectively.


Eye-level view of a laptop screen displaying code editor with programming concepts
Programming concepts and OOP questions on a laptop screen

Essential Programming Concepts Frequently Asked


Understanding fundamental programming concepts is crucial for any coding interview or placement test. These questions test your logic, syntax knowledge, and ability to write efficient code.


Variables and Data Types


Questions often start with basics like:


  • What are variables?

  • Different data types in languages like C++, Java, or Python.

  • How memory is allocated for different data types.


Example question:

Explain the difference between `int`, `float`, and `double`.


Answer:

`int` stores whole numbers without decimals, `float` stores decimal numbers with single precision, and `double` stores decimal numbers with double precision, offering more accuracy.


Control Structures


Interviewers check your understanding of decision-making and loops:


  • `if`, `else if`, `else` statements

  • `switch` cases

  • Loops like `for`, `while`, and `do-while`


Example question:

Write a program to print all even numbers between 1 and 50.


```c

for(int i = 2; i <= 50; i += 2) {

printf("%d ", i);

}

```


Functions and Recursion


Functions are building blocks of reusable code. Questions may include:


  • Defining and calling functions

  • Passing parameters by value or reference

  • Recursive functions and their base cases


Example question:

Write a recursive function to calculate the factorial of a number.


```python

def factorial(n):

if n == 0:

return 1

else:

return n * factorial(n-1)

```


Arrays and Strings


Handling collections of data is a common topic:


  • Declaring and initializing arrays

  • Accessing and modifying elements

  • String manipulation and common functions


Example question:

How do you reverse a string in place?


```java

public void reverseString(char[] s) {

int left = 0, right = s.length - 1;

while (left < right) {

char temp = s[left];

s[left++] = s[right];

s[right--] = temp;

}

}

```


Pointers and Memory Management (For C/C++)


Some companies test knowledge of pointers, dynamic memory, and references:


  • Pointer declaration and usage

  • Difference between pointer and reference

  • Memory allocation with `malloc` and `free`


Example question:

What is a dangling pointer? How can you avoid it?


Answer:

A dangling pointer points to memory that has been freed or deallocated. Avoid it by setting pointers to `NULL` after freeing memory.


Core Object-Oriented Programming Questions


OOP is a major part of many placement tests, especially for roles involving software development. Understanding OOP principles helps you design scalable and maintainable code.


Four Pillars of OOP


Interviewers expect you to explain and apply these concepts:


  • Encapsulation: Wrapping data and methods inside a class, restricting direct access.

  • Inheritance: Creating new classes from existing ones to reuse code.

  • Polymorphism: Ability to take many forms, mainly through method overriding and overloading.

  • Abstraction: Hiding complex implementation details and showing only essential features.


Example question:

Explain polymorphism with an example.


Answer:

Polymorphism allows methods to behave differently based on the object calling them. For example, a `draw()` method in a base class `Shape` can be overridden in subclasses like `Circle` and `Rectangle` to draw specific shapes.


```java

class Shape {

void draw() {

System.out.println("Drawing shape");

}

}


class Circle extends Shape {

void draw() {

System.out.println("Drawing circle");

}

}


class Rectangle extends Shape {

void draw() {

System.out.println("Drawing rectangle");

}

}

```


Classes and Objects


Basic questions include:


  • Defining classes and creating objects

  • Constructors and destructors

  • Access modifiers: `public`, `private`, `protected`


Example question:

What is the difference between a class and an object?


Answer:

A class is a blueprint or template for creating objects. An object is an instance of a class with actual values.


Method Overloading and Overriding


These concepts test your understanding of compile-time and runtime polymorphism.


  • Overloading: Same method name with different parameters in the same class.

  • Overriding: Subclass provides a specific implementation of a method already defined in its superclass.


Example question:

How does method overriding differ from method overloading?


Answer:

Overloading happens within the same class with different parameter lists, while overriding involves redefining a superclass method in a subclass.


Interfaces and Abstract Classes


Questions may ask you to differentiate or use these concepts:


  • Abstract classes can have both abstract and concrete methods.

  • Interfaces declare methods that implementing classes must define.


Example question:

When would you use an interface instead of an abstract class?


Answer:

Use an interface when you want to define a contract that multiple unrelated classes can implement. Abstract classes are used when classes share a common base with some shared implementation.


Exception Handling


Handling errors gracefully is vital in programming:


  • Try-catch blocks

  • Checked vs unchecked exceptions

  • Finally block usage


Example question:

What happens if an exception is not caught?


Answer:

If an exception is not caught, the program terminates abruptly and may display an error message or stack trace.


Sample OOP and Programming Questions from Placement Drives


Here are some real-world examples of questions asked in placement tests:


  • Write a program to implement a simple bank account with deposit and withdrawal methods.

  • Explain the difference between shallow copy and deep copy.

  • How does garbage collection work in Java?

  • Implement a class hierarchy for vehicles with common and specific attributes.

  • Write a program to find the largest element in an array using recursion.

  • What is the output of the following code snippet involving inheritance and method overriding?


Tips to Prepare for Programming and OOP Questions


  • Practice coding problems on platforms like HackerRank, LeetCode, or CodeChef.

  • Understand the theory behind OOP principles and be ready to explain with examples.

  • Write code by hand to simulate interview conditions.

  • Review common data structures like linked lists, stacks, and queues.

  • Study language-specific features and syntax for your target job role.


A. PROGRAMMING FUNDAMENTALS & OOPs (Questions with Answers)


Q1. (ACTUAL 2025) What is the output?

c#include <stdio.h>

int main() {

int arr[] = {10, 20, 30, 40};

printf("%d", *(arr + 2));

return 0;

}


a) 10

b) 20

c) 30 ✓

d) 40


Explanation: *(arr + 2) points to third element (index 2) which is 30


Q2. (ACTUAL 2025) What will be the output?

javapublic class Main {

public static void main(String[] args) {

int a = 10, b = 20;

System.out.println(a + b + "Hello" + a + b);

}

}


a) 30Hello1020 ✓

b) 30Hello30

c) 10201020

d) Compilation error


Explanation: 10+20=30, then concatenation starts: "30Hello", then "30Hello10", then "30Hello1020"


Q3. (ACTUAL 2025) In C++, which operator cannot be overloaded?


a) +

b) :: ✓ (scope resolution)

c) []

d) ()



Q4. (ACTUAL 2025) What is the size of empty class in C++?


a) 0 bytes

b) 1 byte ✓

c) 4 bytes

d) Depends on compiler


Explanation: To ensure each object has unique address


Q5. (ACTUAL 2025) What is the output?

pythonlist1 = [1, 2, 3]

list2 = list1

list2[0] = 100

print(list1[0])


a) 1

b) 100 ✓

c) Error

d) None


Explanation: list2 = list1 creates reference, not copy


Q6. (ACTUAL 2025) Can we call a non-static method from a static method in Java?


a) Yes, directly

b) No, we need object reference ✓

c) Only if method is public

d) Only in same package



Q7. (ACTUAL 2025) What is the output?

javapublic class Test {

static int count = 0;

public Test() {

count++;

}

public static void main(String[] args) {

Test t1 = new Test();

Test t2 = new Test();

System.out.println(count);

}

}


a) 0

b) 1

c) 2 ✓

d) Compilation error



Q8. (ACTUAL 2025) Which of these is NOT a type of constructor?


a) Default constructor

b) Parameterized constructor

c) Copy constructor

d) Static constructor ✓



Q9. (ACTUAL 2025) What is the output?

cint x = 5;

printf("%d %d %d", x, ++x, x++);


a) 5 6 6

b) 7 7 5

c) Undefined behavior ✓

d) 5 6 7



Explanation: Order of evaluation is not defined in C


Q10. (ACTUAL 2025) Can interface extend another interface in Java?


a) Yes ✓

b) No

c) Only if both are empty

d) Only in Java 8+


🚨Part 2: PROGRAMMING FUNDAMENTALS, OOPs & DATA STRUCTURES (Questions with Answers)


Q11. What is autoboxing in Java?


a) Automatic conversion of primitive to wrapper ✓

b) Automatic garbage collection

c) Automatic type casting

d) Automatic memory allocation


Example: int i = 5; Integer obj = i; (autoboxing)


Q12. What is the output?

javaString s1 = "Deloitte";

String s2 = "Deloitte";

System.out.println(s1 == s2);


a) true ✓

b) false

c) Compilation error

d) Runtime error


Explanation: String literals are stored in string pool, same reference


Q13. Which keyword is used to prevent inheritance in Java?


a) static

b) final ✓

c) private

d) abstract



Q14. What is the output?

cint arr[5] = {1, 2, 3};

printf("%d", arr[4]);


a) 0 ✓

b) Garbage value

c) 3

d) Compilation error


Explanation: Uninitialized elements are set to 0


Q15. Can we override private methods in Java?


a) Yes

b) No ✓

c) Only in same package

d) Only if declared final


Explanation: Private methods are not inherited, cannot be overridden


Q16. What is time complexity of accessing element in array by index?


a) O(1) ✓

b) O(n)

c) O(log n)

d) O(n²)



Q17. Which data structure is best for implementing LRU cache?


a) Array

b) Linked List

c) HashMap + Doubly Linked List ✓

d) Stack



Q18. In a max heap, where is the maximum element?


a) Root ✓

b) Leftmost leaf

c) Rightmost leaf

d) Any position



Q19. What is time complexity of inserting element in hash table (average case)?


a) O(1) ✓

b) O(n)

c) O(log n)

d) O(n²)



Q20. Which traversal gives sorted order in BST?


a) Preorder

b) Inorder ✓

c) Postorder

d) Level order


🚨Part 3: DATABASE MANAGEMENT SYSTEM, DATA STRUCTURES (Questions with Answers)


Q21. (ACTUAL 2025) What is auxiliary space complexity of Merge Sort?


a) O(1)

b) O(n) ✓

c) O(log n)

d) O(n²)



Q22. (ACTUAL 2025) Which data structure uses FIFO principle?


a) Stack

b) Queue ✓

c) Tree

d) Graph



Q23. (ACTUAL 2025) What is best case time complexity of Bubble Sort?


a) O(n) ✓ (when already sorted)

b) O(n²)

c) O(log n)

d) O(n log n)



Q24. (ACTUAL 2025) Which is NOT a application of stack?


a) Function call management

b) Expression evaluation

c) Undo operation in editor

d) FIFO scheduling ✓



Q25. (ACTUAL 2025) What is height of binary tree with n nodes (worst case)?


a) O(log n)

b) O(n) ✓ (skewed tree)

c) O(1)

d) O(n²)


Q26. (ACTUAL 2025) Which SQL command is used to change data in table?


a) INSERT

b) UPDATE ✓

c) ALTER

d) MODIFY



Q27. (ACTUAL 2025) What is primary key?


a) Unique identifier for each record ✓

b) Foreign key reference

c) Index column

d) Auto-increment field



Q28. (ACTUAL 2025) Which JOIN returns all records from both tables?


a) INNER JOIN

b) LEFT JOIN

c) RIGHT JOIN

d) FULL OUTER JOIN ✓



Q29. (ACTUAL 2025) What is purpose of GROUP BY clause?


a) Filter rows

b) Group rows with same values ✓

c) Sort data

d) Join tables



Q30. (ACTUAL 2025) Which is a DML command?


a) CREATE

b) DROP

c) INSERT ✓

d) ALTER

Comments

Rated 0 out of 5 stars.
No ratings yet

Add a rating
bottom of page