Technical Questions

Technical Placement Questions with Answers (CS / IT)

Data structures, algorithms, C, Java and Python basics, OOP, DBMS and SQL, operating systems and computer networks. Try each question first, then open Show answer to check your work.

Q1. What is the time complexity of binary search on a sorted array of n elements?

  1. O(n)
  2. O(log n)
  3. O(n log n)
  4. O(1)
Show answer

Answer: B. O(log n)
Each step halves the search space, so it takes about log2(n) steps.

Q2. Which data structure works on the LIFO (last in, first out) principle?

  1. Queue
  2. Stack
  3. Linked list
  4. Heap
Show answer

Answer: B. Stack
In a stack the last element pushed is the first one popped.

Q3. What is the worst-case time complexity of quicksort?

  1. O(n log n)
  2. O(n)
  3. O(n^2)
  4. O(log n)
Show answer

Answer: C. O(n^2)
When the pivot is always the smallest or largest element, partitions are unbalanced and it takes O(n^2).

Q4. In C, what is the value of sizeof(char)?

  1. 1
  2. 2
  3. 4
  4. Depends on the compiler
Show answer

Answer: A. 1
The C standard defines sizeof(char) as 1.

Q5. What does print(7 // 2) output in Python 3?

  1. 3.5
  2. 3
  3. 4
  4. 3.0
Show answer

Answer: B. 3
// is floor division, so 7 // 2 = 3.

Q6. Which of these is NOT a pillar of object-oriented programming?

  1. Encapsulation
  2. Inheritance
  3. Polymorphism
  4. Compilation
Show answer

Answer: D. Compilation
The pillars are encapsulation, abstraction, inheritance and polymorphism. Compilation is not one.

Q7. Which SQL command removes all rows from a table but keeps the table structure?

  1. DROP
  2. TRUNCATE
  3. ALTER
  4. REMOVE
Show answer

Answer: B. TRUNCATE
TRUNCATE empties the table; DROP deletes the table itself.

Q8. Which is true of a primary key?

  1. It can hold duplicate values
  2. It can hold NULL values
  3. Its values must be unique and not NULL
  4. A table can have several primary keys
Show answer

Answer: C. Its values must be unique and not NULL
A primary key uniquely identifies each row, so it must be unique and not NULL.

Q9. Which normal form removes transitive dependencies?

  1. 1NF
  2. 2NF
  3. 3NF
  4. None of these
Show answer

Answer: C. 3NF
Third normal form (3NF) removes transitive dependencies on the key.

Q10. Which OSI layer is responsible for routing packets between networks?

  1. Data link
  2. Network
  3. Transport
  4. Session
Show answer

Answer: B. Network
Routing and logical (IP) addressing belong to the network layer (layer 3).

Q11. What is the default port number for HTTPS?

  1. 80
  2. 21
  3. 443
  4. 8080
Show answer

Answer: C. 443
HTTPS uses port 443; plain HTTP uses port 80.

Q12. Which of these is NOT one of the necessary conditions for deadlock?

  1. Mutual exclusion
  2. Hold and wait
  3. Circular wait
  4. Preemption
Show answer

Answer: D. Preemption
The conditions are mutual exclusion, hold and wait, NO preemption and circular wait.

Q13. Which keyword does a Java class use to inherit from another class?

  1. implements
  2. extends
  3. inherits
  4. super
Show answer

Answer: B. extends
A class uses "extends" for a class and "implements" for an interface.

Q14. Which of these sorting algorithms is stable?

  1. Quick sort
  2. Heap sort
  3. Merge sort
  4. Selection sort
Show answer

Answer: C. Merge sort
Merge sort keeps equal elements in their original order.

Q15. How many edges does a tree with n nodes have?

  1. n
  2. n - 1
  3. n + 1
  4. 2n
Show answer

Answer: B. n - 1
A tree is connected and acyclic, which needs exactly n - 1 edges.

Q16. What is 25 in binary?

  1. 11001
  2. 10101
  3. 11010
  4. 10011
Show answer

Answer: A. 11001
25 = 16 + 8 + 1, which is 11001 in binary.

Q17. What does len([1, [2, 3], 4]) return in Python?

  1. 4
  2. 3
  3. 2
  4. Error
Show answer

Answer: B. 3
The nested list counts as one element, so there are 3 elements.

Q18. In C, what is the value of 5 / 2 when both operands are int?

  1. 2.5
  2. 2
  3. 3
  4. 2.0
Show answer

Answer: B. 2
Integer division drops the fractional part, giving 2.

Q19. Which of these is a non-linear data structure?

  1. Array
  2. Stack
  3. Queue
  4. Tree
Show answer

Answer: D. Tree
Trees are hierarchical; arrays, stacks and queues are linear.

Q20. Which protocol finds the MAC address for a given IP address?

  1. DNS
  2. ARP
  3. DHCP
  4. ICMP
Show answer

Answer: B. ARP
ARP (Address Resolution Protocol) maps an IP address to a MAC address on a local network.

Ready for a real timed test?

Take a free full-length placement mock with a timer, score and detailed analysis on TestMyIndia.

Take the free placement mock

These are original practice questions written by Intmat Edtech in the style of campus placement tests. They are not copied from any company's question paper.

Get In Touch

INTMAT EDTECH (OPC) PRIVATE LIMITED
No - 16, Javaraiahna Doddi, Mysore Road,
Bengaluru Urban, BENGALURU,
Karnataka 560098, India

contact@intmatedtech.com

TestMyIndia All India Rank