بِسْمِ اللَّهِ الرَّحْمَنِ الرَّحِيم

 A code snippet illustrating a data structure concept on a computer screen.

Programming and Data Structures MCQs for NTS, CSS, PMS, KPPSC, PPSC, ETEA, SPSC, BPSC, and FPSC Tests

A solid foundation in Programming Fundamentals and Data Structures is essential for any computer science-related test, including those conducted by FPSC, NTS, and ETEA. This collection of 20 MCQs will help you review key concepts in C++, data structures, and object-oriented programming (OOP).


 

1. In C++, which symbol is used to terminate a statement?

  • Colon (:)
  • Semicolon (;)
  • Period (.)
  • Comma (,)

Answer: Semicolon (;)

 

2. What does 'OOP' stand for?

  • Object-Oriented Programming
  • Open-Object Programming
  • Oriented-Object Protocol
  • Optimal-Oriented Programming

Answer: Object-Oriented Programming

 

3. Which of the following is a linear data structure?

  • Tree
  • Graph
  • Array
  • Heap

Answer: Array

 

4. The 'LIFO' principle is followed by which data structure?

  • Queue
  • Stack
  • Linked List
  • Tree

Answer: Stack (Last-In, First-Out)

 

5. Which of the following is a feature of OOP?

  • Encapsulation
  • Inheritance
  • Polymorphism
  • All of the above

Answer: All of the above

 

6. A variable that holds a memory address is called a...?

  • Integer
  • Float
  • Pointer
  • Character

Answer: Pointer

 

7. A queue data structure operates on the principle of...?

  • LIFO (Last-In, First-Out)
  • FIFO (First-In, First-Out)
  • FILO (First-In, Last-Out)
  • LILO (Last-In, Last-Out)

Answer: FIFO (First-In, First-Out)

 

8. Which keyword is used to define a class in C++?

  • struct
  • class
  • object
  • define

Answer: class

 

9. The process of arranging data in a specific order is called...?

  • Searching
  • Sorting
  • Merging
  • Traversing

Answer: Sorting

 

10. In C++, the 'cout' object is used for...?

  • Input
  • Output
  • Error handling
  • File operations

Answer: Output

 

11. A function that calls itself is known as a...?

  • Looping function
  • Recursive function
  • Nested function
  • Inline function

Answer: Recursive function

 

12. Which data structure uses a 'head' and 'tail' pointer?

  • Stack
  • Array
  • Queue
  • Graph

Answer: Queue

 

13. The complexity of a binary search algorithm is...?

  • O(n)
  • O(log n)
  • O(n^2)
  • O(1)

Answer: O(log n)

 

14. What is the purpose of a constructor in a class?

  • To destroy an object
  • To initialize an object's state
  • To define the class methods
  • To perform a calculation

Answer: To initialize an object's state

 

15. Which of the following is not a primitive data type?

  • int
  • float
  • char
  • array

Answer: array

 

16. A node in a singly linked list contains a data part and a...?

  • Pointer to the previous node
  • Pointer to the next node
  • Pointer to the head node
  • Pointer to the tail node

Answer: Pointer to the next node

 

17. What is polymorphism?

  • The ability of a class to derive properties from another class
  • The ability to present the same interface for different data types
  • The wrapping of data and functions into a single unit
  • The ability to hide implementation details

Answer: The ability to present the same interface for different data types

 

18. Which header file is required for using 'cin' and 'cout' in C++?

  • <conio.h>
  • <stdio.h>
  • <iostream>
  • <math.h>

Answer: <iostream>

 

19. The process of inserting an element into a stack is called...?

  • Enqueue
  • Push
  • Pop
  • Insert

Answer: Push

 

20. Which sorting algorithm is known for its "divide and conquer" strategy?

  • Bubble Sort
  • Insertion Sort
  • Quick Sort
  • Selection Sort

Answer: Quick Sort

 

 

Related Posts

Comments

Comments sections will appear soon!