Computer Programmer (BPS-17) — 2025 · Solved Past Paper
Question 1 Computer
Which protocol assigns IP address to the client connected in the internet?
- A. DHPP
- B. DHHP
- C. DHCP ✓ Correct answer
- D. None of these
Why each option?
A. Wrong: there is no networking protocol called DHPP; it is a made-up distractor.
B. Wrong: there is no networking protocol called DHHP.
C. Correct: DHCP (Dynamic Host Configuration Protocol) automatically assigns IP addresses (and subnet mask, gateway and DNS settings) to clients when they join a network.
D. Wrong: DHCP is among the options and is correct.
Question 2 Computer
Which data structure uses LIFO (Last In, First Out) principle?
- A. Stack ✓ Correct answer
- B. Queue
- C. Linked List
- D. None of these
Why each option?
A. Correct: a stack is Last In, First Out — the last item pushed on is the first one popped off, like a pile of plates.
B. Wrong: a queue is FIFO (First In, First Out) — the first item in is the first one out.
C. Wrong: a linked list is a chain of nodes; it does not by itself impose LIFO or FIFO order — the order depends on how it is used.
D. Wrong: the stack is among the options and is correct.
Question 3 Computer
Which sorting algorithm is the fastest in the average case?
- A. Quick Sort ✓ Correct answer
- B. Merge Sort
- C. Bubble Sort
- D. None of these
Why each option?
A. Correct: Quick Sort averages O(n log n) and, with its small constants and good cache behaviour, is the fastest of the three in practice on average — the standard textbook answer.
B. Wrong here: Merge Sort is also O(n log n) on average, but it is slower in practice than Quick Sort because it needs extra memory and does more data movement.
C. Wrong: Bubble Sort averages O(n²), far slower than either Quick Sort or Merge Sort.
D. Wrong: Quick Sort is among the options and is correct.
Question 4 Computer
Which data structure is used for recursion?
- A. Graph
- B. Queue
- C. Stack ✓ Correct answer
- D. None of these
Why each option?
A. Wrong: a graph models relationships between nodes; it is not the structure that runs recursion.
B. Wrong: a queue is FIFO and is used for breadth-first search and scheduling, not for recursion.
C. Correct: every recursive call is pushed onto the call stack (with its return address and local variables) and popped when it returns — recursion runs on a stack.
D. Wrong: the stack is among the options and is correct.
Question 5 Mathematics
What is the result of (13 × 17) mod 5?
- A. 3
- B. 2
- C. 1 ✓ Correct answer
- D. None of these
Why each option?
A. Wrong: 13 × 17 = 221, and 221 divided by 5 leaves remainder 1, not 3.
B. Wrong: the remainder of 221 ÷ 5 is 1, not 2.
C. Correct: 13 × 17 = 221, and 221 = 44 × 5 + 1, so (13 × 17) mod 5 = 1.
D. Wrong: 1 is among the options and is correct.
Question 6 Mathematics
If a geometric sequence has first term 3 and common ratio 2, what is the 5th term?
- A. 12
- B. 24
- C. 48 ✓ Correct answer
- D. None of these
Why each option?
A. Wrong: 12 is the 3rd term (3, 6, 12), not the 5th.
B. Wrong: 24 is the 4th term (3, 6, 12, 24), not the 5th.
C. Correct: the nth term is 3 × 2^(n−1), so the 5th term is 3 × 2^4 = 3 × 16 = 48.
D. Wrong: 48 is among the options and is correct.
Question 7 Mathematics
How many ways can you choose 2 elements from a set of 5?
- A. 25
- B. 5
- C. 10 ✓ Correct answer
- D. None of these
Why each option?
A. Wrong: 25 is 5², the number of ordered pairs WITH repetition — not the number of 2-element choices.
B. Wrong: 5 is the size of the set, not the number of ways to choose 2 from it.
C. Correct: the number of combinations is C(5,2) = 5! ÷ (2! × 3!) = 120 ÷ 12 = 10.
D. Wrong: 10 is among the options and is correct.
Question 8 Mathematics
How many ways can you arrange 4 distinct books on a shelf?
- A. 256
- B. 16
- C. 24 ✓ Correct answer
- D. None of these
Why each option?
A. Wrong: 256 is 4^4, the count if each position could hold any of the 4 books with repetition — but each book is used once.
B. Wrong: 16 is 4², not the number of arrangements of 4 distinct books.
C. Correct: the number of permutations of 4 distinct books is 4! = 4 × 3 × 2 × 1 = 24.
D. Wrong: 24 is among the options and is correct.
Question 9 Computer
A connected graph with n vertices and n-1 edges is always a _____?
- A. Eulerian Graph
- B. Cycle
- C. Tree ✓ Correct answer
- D. None of these
Why each option?
A. Wrong: an Eulerian graph is one with a circuit that uses every edge exactly once (all vertices of even degree); that is a different property from having n−1 edges.
B. Wrong: a cycle on n vertices has n edges, not n−1, and a cycle is not a tree.
C. Correct: a connected graph with n vertices and exactly n−1 edges is a tree — connected and acyclic, with no redundant edge.
D. Wrong: a tree is among the options and is correct.
Question 10 Computer
A graph with no cycles is called a _____?
- A. Weighted Graph
- B. Tree ✓ Correct answer
- C. Bipartite Graph
- D. None of these
Why each option?
A. Wrong: "weighted" means the edges carry numbers (weights); it says nothing about cycles.
B. Picked: the standard textbook answer — a tree is the acyclic graph, and in exam usage "a graph with no cycles" is answered "tree".
C. Wrong: bipartite means the vertices split into two sets with edges only between the sets; a bipartite graph can still contain cycles (of even length).
D. Defensible on the strict reading (an acyclic graph is a forest unless it is connected), but the intended answer is B, so B is picked.
Question 11 Computer
Which of the following is an equivalence relation? Transitive, Reflexive, Symmetric, All of them
- A. Transitive
- B. Reflexive
- C. Symmetric
- D. All of them ✓ Correct answer
Why each option?
A. Wrong on its own: transitivity is only ONE of the three properties an equivalence relation needs.
B. Wrong on its own: reflexivity is only ONE of the three properties.
C. Wrong on its own: symmetry is only ONE of the three properties.
D. Correct: an equivalence relation is a relation that is reflexive (every element relates to itself), symmetric (if a relates to b then b relates to a) AND transitive (if a relates to b and b relates to c then a relates to c) — all three together.
Question 12 Computer
Which of the following is a reflexive relation? (1,2), (2,3) (1,1), (2,2), (3,3) (1,2), (2,1) All of them
- A. (1,2), (2,3)
- B. (1,1), (2,2), (3,3) ✓ Correct answer
- C. (1,2), (2,1)
- D. All of them
Why each option?
A. Wrong: a reflexive relation must contain every element paired with itself; this set has no self-pairs at all.
B. Correct: reflexivity means every element is related to itself, and here 1 relates to 1, 2 to 2 and 3 to 3.
C. Wrong: this pair is symmetric-looking (1 relates to 2 and 2 relates to 1), but it has no self-pairs, so it is not reflexive.
D. Wrong: only B is reflexive; A and C are not.
Question 13 Computer
Which logical operator represents "AND"?
- A. ~
- B. V
- C. A
- D. & ✓ Correct answer
Why each option?
A. Wrong: ~ is the NOT operator (negation), not AND.
B. Wrong: V is evidently ∨, the OR operator, not AND.
C. Defensible: printed "A" is evidently ∧, the logic symbol for AND — but in this programming paper the intended AND operator is D.
D. Picked: & is the AND operator in programming languages (bitwise AND in C/C++/Java, and the root of the logical &&), the answer this paper asks for.
Question 14 Computer
Which of the following is a proposition? What time is it?, 2 + 2, X + 5 = 10, Today is Monday
- A. What time is it?
- B. 2 + 2
- C. X + 5 = 10
- D. Today is Monday ✓ Correct answer
Why each option?
A. Wrong: a proposition must be a declarative statement that is either true or false; a question has no truth value.
B. Wrong: this is an expression, not a complete statement — it asserts nothing, so it has no truth value.
C. Wrong: this is an open sentence — its truth depends on the value of the variable X, so it is not a proposition until X is fixed.
D. Correct: this is a declarative sentence that is either true or false on any given day — exactly what a proposition is.
Question 15 Computer
Which term is used to write an object to disk?
- A. Tokenization
- B. Serialization ✓ Correct answer
- C. De-serialization
- D. None of these
Why each option?
A. Wrong: tokenization splits text into tokens (words or symbols) for processing; it does not write objects to disk.
B. Correct: serialization converts an in-memory object into a storable form (a byte stream) so it can be written to disk or sent over a network.
C. Wrong: de-serialization is the REVERSE process — reading a stored byte stream back into an object.
D. Wrong: serialization is among the options and is correct.
Question 16 Computer
How is dynamically allocated memory de allocated in C++?
- A. Using erase()
- B. Automatically
- C. Using delete ✓ Correct answer
- D. None of these
Why each option?
A. Wrong: erase() is a container method (e.g. for std::vector or std::map) that removes elements; it does not free memory allocated with new.
B. Wrong: C++ has no garbage collector for memory allocated with new — it must be freed by the programmer.
C. Correct: memory allocated with new is released with delete (and new[] with delete[]) — failing to do so leaks memory.
D. Wrong: delete is among the options and is correct.
Question 17 Computer
Which catch block should be written first when handling multiple exceptions?
- A. Order Irrelevant
- B. General
- C. Specific ✓ Correct answer
- D. None of these
Why each option?
A. Wrong: the order of catch blocks matters — a catch that matches first wins, so a general catch placed first would swallow every exception.
B. Wrong: the general (base-class) catch must come LAST, as a fallback for exceptions no specific catch handled.
C. Correct: the most specific (most derived) exception types are caught first, with more general catches after them, so each exception is handled by the best-matching block.
D. Wrong: the specific catch is among the options and is correct.
Question 18 Computer
Which keyword is used to define an exception block?
- A. Finally
- B. Catch
- C. Try ✓ Correct answer
- D. Throw
Why each option?
A. Wrong: finally defines the cleanup block that runs whether or not an exception occurred; it is not the exception block itself.
B. Wrong: catch defines the HANDLER that runs when an exception is thrown; the guarded block itself is the try block.
C. Correct: the try block defines the block of code that is monitored for exceptions — the exception block.
D. Wrong: throw RAISES (throws) an exception; it does not define a block.
Question 19 Computer
When overriding function which of following should be the same in base and derived class?
- A. Function name
- B. Return type
- C. Both A and B ✓ Correct answer
- D. Parameter list
Why each option?
A. Only part of the answer: the overriding function must keep the same name, but the name alone is not the whole requirement.
B. Only part of the answer: the return type must be the same (or covariant in C++), but that alone is not the whole requirement.
C. Correct: when a derived class overrides a base-class function it keeps the same function name and the same (or covariant) return type — the named pair the question asks for. Note the parameter list must also match (in C++ the signature must be identical), which is why D alone is not the answer.
D. Must also be the same, but it is not the pair the question names; C is the intended, most complete answer among the options.
Question 20 Computer
When overloading functions which of the following must be different?
- A. Function name
- B. Return type
- C. Both A and B
- D. Parameter list ✓ Correct answer
Why each option?
A. Wrong: overloaded functions must have the SAME name — that is the point of overloading.
B. Wrong: the return type alone CANNOT distinguish two overloads; two functions that differ only in return type are a compile error.
C. Wrong: the function name must be the same, and the return type alone cannot differ to make an overload.
D. Correct: overloaded functions are distinguished by their parameter list — a different number, type or order of parameters.
Question 21 Computer
When overloading functions which of the following should be the same?
- A. Function name ✓ Correct answer
- B. Return type
- C. Both A and B
- D. Parameter list
Why each option?
A. Correct: overloading means several functions sharing ONE name, distinguished by their parameters.
B. Wrong: the return type need not be the same across overloads (and differing only in return type does not make an overload).
C. Wrong: only the name must be the same; the return type need not be.
D. Wrong: the parameter list must be DIFFERENT between overloads — that is what distinguishes them.
Question 22 Computer
Which feature simplifies complexity by emphasizing high-level design?
- A. Polymorphism
- B. Abstraction ✓ Correct answer
- C. Inheritance
- D. All of them
Why each option?
A. Wrong: polymorphism lets one interface take many forms; it does not hide complexity by emphasising high-level design.
B. Correct: abstraction hides low-level detail and shows only the essential, high-level view — that is how it simplifies complexity.
C. Wrong: inheritance reuses a base class's features in a derived class; it is about reuse, not about hiding detail.
D. Wrong: only abstraction fits the description.
Question 23 Computer
Feature which enables objects of different classes to respond differently to the same message?
- A. Polymorphism ✓ Correct answer
- B. Abstraction
- C. Inheritance
- D. All of them
Why each option?
A. Correct: polymorphism ("many forms") means the same message (method call) makes objects of different classes respond in their own way — e.g. draw() behaves differently for a Circle and a Square.
B. Wrong: abstraction hides detail; it does not make different classes respond differently to one message.
C. Wrong: inheritance lets a class reuse another's features; the different-response behaviour is polymorphism.
D. Wrong: only polymorphism fits the description.
Question 24 Computer
Which of the following deals with protecting an object's internal data by controlling access?
- A. Polymorphism
- B. Encapsulation ✓ Correct answer
- C. Inheritance
- D. All of them
Why each option?
A. Wrong: polymorphism is about different responses to the same message, not about protecting data.
B. Correct: encapsulation bundles data with the methods that use it and hides the internals behind controlled access (private data, public getters/setters).
C. Wrong: inheritance is about reusing a base class; it does not by itself protect internal data.
D. Wrong: only encapsulation fits the description.
Question 25 Computer
Which scheduling algorithm is least prone to starvation?
- A. FCFS ✓ Correct answer
- B. Round Robin
- C. Shortest Job Next
- D. None of these
Why each option?
A. Picked: First-Come-First-Served serves in arrival order with no favouritism, so no process can be overtaken forever — every process eventually reaches the front.
B. Also starvation-free (each process gets a fixed time slice in turn), which is why this is a pick-one; the exam's intended answer is A.
C. Wrong: it is the most starvation-prone — long jobs can wait indefinitely while short jobs keep arriving.
D. Wrong: FCFS (and Round Robin) are starvation-free.
Question 26 Computer
Which scheduling algorithm is most prone to starvation?
- A. FCFS
- B. Round Robin
- C. Shortest Job Next ✓ Correct answer
- D. None of these
Why each option?
A. Wrong: FCFS serves strictly in arrival order, so no process can starve — every process eventually reaches the front.
B. Wrong: Round Robin gives every process a fixed time slice in turn, so no process starves.
C. Correct: SJF always picks the shortest waiting job, so a long job can be passed over again and again while short jobs keep arriving — the classic starvation case.
D. Wrong: Shortest Job Next is among the options and is correct.
Question 27 Computer
Which of the following is necessary condition for deadlock?
- A. Circular Wait
- B. Mutual Exclusion
- C. Hold and Wait
- D. All of them ✓ Correct answer
Why each option?
A. Only one of the four: a cycle of processes each waiting for a resource held by the next — necessary, but not the whole set.
B. Only one of the four: a resource can be held by only one process at a time — necessary, but not the whole set.
C. Only one of the four: a process holds resources while waiting for more — necessary, but not the whole set.
D. Correct: deadlock needs all four Coffman conditions together — mutual exclusion, hold and wait, no preemption, and circular wait — so each of A, B and C is a necessary condition.
Question 28 Computer
Which is not a necessary condition for deadlock? Preemption, Mutual Exclusion, Hold and Wait, Circular Wait
- A. Preemption ✓ Correct answer
- B. Mutual Exclusion
- C. Hold and Wait
- D. Circular Wait
Why each option?
A. Correct: the fourth Coffman condition is NO preemption — resources cannot be forcibly taken away. Preemption is the OPPOSITE of a necessary condition; allowing preemption BREAKS deadlocks.
B. Wrong: mutual exclusion IS a necessary condition for deadlock (a resource held by only one process at a time).
C. Wrong: hold and wait IS a necessary condition (holding resources while waiting for more).
D. Wrong: circular wait IS a necessary condition (a cycle of processes waiting on each other).
Question 29 Computer
Which algorithm is used for deadlock detection?
- A. LRU
- B. Banker's Algorithm ✓ Correct answer
- C. FIFO
- D. None of these
Why each option?
A. Wrong: LRU (Least Recently Used) is a page-replacement algorithm for virtual memory, nothing to do with deadlock.
B. Picked: the intended answer — Dijkstra's algorithm for safe resource allocation, whose safety check is the machinery deadlock detection uses for multiple-instance resources.
C. Wrong: FIFO is a scheduling / page-replacement policy, not a deadlock-detection algorithm.
D. Defensible strictly (Banker's is avoidance, not detection), but the intended answer is B, so B is picked.
Question 30 Computer
Which method ensures mutual exclusion in concurrency control?
- A. RAID
- B. Paging
- C. Mutex ✓ Correct answer
- D. None of these
Why each option?
A. Wrong: RAID (Redundant Array of Independent Disks) protects data against disk failure; it does not control concurrent access.
B. Wrong: paging is a memory-management technique (dividing memory into fixed-size pages); it does not ensure mutual exclusion.
C. Correct: a mutex (mutual-exclusion lock) is held by only one thread at a time, so only the thread holding it can enter the critical section.
D. Wrong: the mutex is among the options and is correct.
Question 31 Computer
Which scheduling policy gives each process a fixed time slot?
- A. Round Robin ✓ Correct answer
- B. FCFS
- C. SJF
- D. None of these
Why each option?
A. Correct: Round Robin gives every process in the ready queue a fixed time slice (quantum) in turn, preempting it when the slice ends.
B. Wrong: FCFS runs each process to completion with no time slot — a long job can hold the CPU indefinitely.
C. Wrong: SJF runs the shortest job next, to completion; it gives no fixed time slot.
D. Wrong: Round Robin is among the options and is correct.
Question 32 Computer
In which type of operating system is response time critical?
- A. Multi tasking
- B. Real time ✓ Correct answer
- C. Batch processing
- D. None of these
Why each option?
A. Wrong: a multi-tasking OS runs several programs at once, but it has no hard deadline on response time.
B. Correct: a real-time OS must respond within a strict deadline (e.g. flight controls, medical monitors) — missing the deadline is a failure.
C. Wrong: a batch OS runs jobs without interaction and optimises throughput, not response time.
D. Wrong: the real-time OS is among the options and is correct.
Question 33 Computer
Which type of operating system has a very limited user interface?
- A. Multi tasking
- B. Real time
- C. Batch processing
- D. Embedded ✓ Correct answer
Why each option?
A. Wrong: multi-tasking operating systems (Windows, Linux, macOS) have rich graphical user interfaces.
B. Wrong: a real-time OS may have a full interface; its defining feature is deadlines, not a limited UI.
C. Wrong: a batch OS has no interactive interface at all rather than a "very limited" one, and the textbook answer for a minimal UI is the embedded system.
D. Correct: an embedded OS (in a washing machine, microwave, car controller) has a very limited interface — a few buttons or a tiny display — because it runs one dedicated job.
Question 34 Computer
The software that contains the core components of the operating system is called _____?
- A. Middle
- B. Function
- C. Component
- D. Kernel ✓ Correct answer
Why each option?
A. Wrong: "middle" is not a name for any part of an operating system.
B. Wrong: a function is a block of code, not the core of an operating system.
C. Wrong: "component" is a vague generic word; it is not the name of the OS core.
D. Correct: the kernel is the core of the operating system — it manages the CPU, memory, devices and system calls, and everything else runs on top of it.
Question 35 Computer
Which class of IP address provides the most host addresses per network?
- A. Class D
- B. Class A ✓ Correct answer
- C. Class B
- D. None of these
Why each option?
A. Wrong: Class D is reserved for multicast groups; it provides no host addresses per network at all.
B. Correct: a Class A network keeps 24 bits for hosts (8 bits for the network), giving about 16.7 million host addresses per network — the most of any class.
C. Wrong: a Class B network keeps 16 bits for hosts, giving 65,534 hosts per network — far fewer than Class A.
D. Wrong: Class A is among the options and is correct.
Question 36 Computer
Which protocol is commonly used for secure remote access to a network device?
- A. FTP
- B. SSH ✓ Correct answer
- C. Telnet
- D. None of these
Why each option?
A. Wrong: FTP transfers files and sends passwords in plain text; it is not a secure remote-access protocol.
B. Correct: SSH (Secure Shell) gives encrypted remote login and command access to a network device.
C. Wrong: Telnet does give remote access, but it sends everything — including passwords — in plain text, so it is not SECURE remote access.
D. Wrong: SSH is among the options and is correct.
Question 37 Computer
Which of the following is NOT a function of the Network Layer? Addressing, Routing, Error Detection, Packet Forwarding
- A. Addressing
- B. Routing
- C. Error Detection ✓ Correct answer
- D. Packet Forwarding
Why each option?
A. Wrong as the answer: logical addressing (IP addresses) IS a network-layer function.
B. Wrong as the answer: routing packets across networks IS a network-layer function.
C. Correct: error detection (checksums, CRC on frames) is a DATA-LINK-layer job, not a network-layer one — the network layer (IP) does not guarantee error-free delivery.
D. Wrong as the answer: forwarding packets toward their destination IS a network-layer function.
Question 38 Computer
Which layer in the OSI model is responsible for end-to-end communication and error recovery?
- A. Session
- B. Network
- C. Transport ✓ Correct answer
- D. None of these
Why each option?
A. Wrong: the session layer manages sessions and dialogues between applications; it does not do end-to-end delivery or error recovery.
B. Wrong: the network layer routes packets between networks, but it offers no end-to-end reliability or error recovery (IP is best-effort).
C. Correct: the transport layer (TCP) provides end-to-end communication, segmentation, retransmission and error recovery between the two endpoints.
D. Wrong: the transport layer is among the options and is correct.
Question 39 Computer
Which testing type ensures changes don't introduce new defects?
- A. System
- B. Integration
- C. Regression ✓ Correct answer
- D. None of these
Why each option?
A. Wrong: system testing checks the whole finished system against its requirements; it is not the testing done after a change to catch new defects.
B. Wrong: integration testing checks that modules work together; it is not the re-testing done after a change.
C. Correct: regression testing re-runs earlier tests after a change, precisely to make sure the change did not break anything that used to work.
D. Wrong: regression testing is among the options and is correct.
Question 40 Computer
Which testing technique involves testing the internal structure of the code?
- A. System
- B. Black box
- C. White box ✓ Correct answer
- D. None of these
Why each option?
A. Wrong: system testing tests the whole system from the outside, against requirements — it does not look at internal code structure.
B. Wrong: black-box testing checks behaviour from inputs and outputs only, WITHOUT looking inside the code.
C. Correct: white-box (glass-box) testing uses knowledge of the internal structure — statements, branches and paths — to design test cases.
D. Wrong: white-box testing is among the options and is correct.
Question 41 Computer
Which of the following are common non functional requirements?
- A. Usability
- B. Performance
- C. Security
- D. All of them ✓ Correct answer
Why each option?
A. A non-functional requirement (how easy the system is to use), but only one of the three listed.
B. A non-functional requirement (how fast the system responds), but only one of the three listed.
C. A non-functional requirement (how well the system resists attack), but only one of the three listed.
D. Correct: usability, performance and security are ALL non-functional requirements — they describe HOW the system behaves, not WHAT it does (functional requirements describe what it does).
Question 42 Computer
Which software development practice involves continuous integration and continuous delivery?
- A. Prototyping
- B. Waterfall
- C. Agile/DevOps ✓ Correct answer
- D. None of these
Why each option?
A. Wrong: prototyping builds an early working model to explore requirements; it is not the practice of continuous integration and delivery.
B. Wrong: Waterfall moves through sequential phases (requirements, design, code, test) with one big delivery at the end — the opposite of continuous delivery.
C. Correct: continuous integration (merging and testing code frequently) and continuous delivery (releasing small changes often) are core Agile/DevOps practices.
D. Wrong: Agile/DevOps is among the options and is correct.
Question 43 Computer
User stories are derived from which of the following diagrams?
- A. Sequence diagram
- B. Class diagram
- C. Use case diagram ✓ Correct answer
- D. None of these
Why each option?
A. Wrong: a sequence diagram shows the order of messages between objects over time; user stories are not derived from it.
B. Wrong: a class diagram shows classes, attributes and relationships; user stories are not derived from it.
C. Correct: a use case diagram shows actors and the goals (use cases) they want from the system — each use case is the source of user stories ("As a [actor], I want [goal]...").
D. Wrong: the use case diagram is among the options and is correct.
Question 44 Computer
Which type of pointer can store the address of any data type?
- A. float*
- B. int*
- C. void* ✓ Correct answer
- D. None of these
Why each option?
A. Wrong: a float* can only hold the address of a float; assigning another type's address is a type error.
B. Wrong: an int* can only hold the address of an int.
C. Correct: a void* is a generic pointer — it can hold the address of ANY data type (it must be cast before dereferencing).
D. Wrong: void* is among the options and is correct.
Question 45 Computer
Which operator is used to access the value at a pointer's address?
- A. []
- B. * ✓ Correct answer
- C. &
- D. None of these
Why each option?
A. Wrong: [] is the subscript/index operator (used to index arrays, or to access an element through a pointer with an offset) — not the operator that dereferences a pointer to its value.
B. Correct: the * (dereference) operator accesses the value stored at the address a pointer holds — e.g. *p gives the value p points to.
C. Wrong: & is the address-of operator — it does the OPPOSITE, giving the address of a variable.
D. Wrong: * is among the options and is correct.
Question 46 Computer
Where is dynamically allocated memory stored?
- A. Array
- B. Stack
- C. Heap ✓ Correct answer
- D. None of these
Why each option?
A. Wrong: an array is a data structure, not a region of memory — and an array itself may live on the stack or the heap.
B. Wrong: the stack holds automatic storage — local variables, parameters and return addresses — which is freed when a function returns.
C. Correct: memory allocated with new/malloc lives on the heap (free store) and stays until it is freed with delete/free.
D. Wrong: the heap is among the options and is correct.
Question 47 Computer
Stack memory stores which of the following when a function is called _____?
- A. Return addresses
- B. Local variables
- C. Parameters
- D. All of them ✓ Correct answer
Why each option?
A. Stored on the stack, but only one of the three: the address to return to when the function finishes.
B. Stored on the stack, but only one of the three: the function's automatic variables live in its stack frame.
C. Stored on the stack, but only one of the three: the function's arguments are passed in its stack frame.
D. Correct: a function's stack frame holds its return address, its parameters and its local variables — all three.
Question 48 Computer
Most convenient loop to use when working with 2D arrays?
- A. Do while
- B. For ✓ Correct answer
- C. While
- D. All of them
Why each option?
A. Wrong here: a do-while loop checks its condition at the end and always runs at least once; it is not the natural fit for walking rows and columns with known bounds.
B. Correct: nested for loops map directly onto a 2D array — the outer loop walks the rows, the inner loop walks the columns, with the bounds known up front.
C. Wrong here: a while loop CAN walk a 2D array, but it is less convenient than for when the row and column counts are known in advance.
D. Wrong: all three loops can do the job, but "most convenient" is the for loop — the others are not equally convenient.
Question 49 Computer
When the number of iterations are not known in advance which loop is most suitable?
- A. Do while
- B. For
- C. While ✓ Correct answer
- D. All of them
Why each option?
A. Wrong here: a do-while loop also handles an unknown count, but it always executes the body at least once — the while loop is the standard choice when the loop may need to run zero times.
B. Wrong: a for loop is best when the number of iterations IS known (or bounded) in advance — its initialisation, condition and update fit a counted loop.
C. Correct: a while loop repeats as long as a condition holds, with no fixed count — the standard choice when the number of iterations is not known in advance (e.g. reading input until a sentinel value).
D. Wrong: the for loop does not fit an unknown iteration count, so "all of them" cannot be the answer.
Question 50 Computer
Which branching statement can easily handle complicated nested decisions?
- A. Switch ✓ Correct answer
- B. If else
- C. Else if
- D. All of them
Why each option?
A. Correct: a switch gives clean multi-way branching on one value — each case is a branch — so a complicated set of nested decisions on one variable is handled in one readable block instead of a deep if-else ladder.
B. Wrong here: if-else CAN nest decisions, but deep nesting gets hard to read and maintain — it is not the statement that "easily handles" complicated nested decisions.
C. Wrong here: an else-if chain handles a list of conditions, but it grows into the same hard-to-read ladder as nested if-else.
D. Wrong: only the switch is the intended "easily handles" answer for complicated multi-way decisions.
Question 51 Computer
Which of the following is not a standard builtin data type in C? Bool, Long, Int, Char
- A. Bool ✓ Correct answer
- B. Long
- C. Int
- D. Char
Why each option?
A. Correct: plain C has no built-in `bool` type — C99 added the keyword `_Bool`, and `bool` is only a macro from <stdbool.h>; long, int and char are all standard built-in types.
B. Wrong: long is a standard built-in integer type in C.
C. Wrong: int is the standard built-in integer type in C.
D. Wrong: char is a standard built-in character type in C.
Question 52 Computer
Most widely used method for representing signed integers in modern computers?
- A. Excess 127
- B. 1's complement
- C. 2's complement ✓ Correct answer
- D. None of these
Why each option?
A. Wrong: excess-127 (biased) notation is used for floating-point exponents, not for signed integers.
B. Wrong: 1's complement was used in some early machines, but it has two representations of zero (+0 and −0) and awkward arithmetic, so it lost out.
C. Correct: 2's complement is the standard in virtually all modern computers — one zero, and addition/subtraction work with the same hardware as unsigned arithmetic.
D. Wrong: 2's complement is among the options and is correct.
Question 53 Computer
Data type int occupies 4 bytes in memory, writing unsigned before int increases its ______?
- A. Range ✓ Correct answer
- B. Size
- C. Both A and B
- D. None of them
Why each option?
A. Correct: an unsigned int still occupies 4 bytes, but its range shifts from −2,147,483,648…2,147,483,647 to 0…4,294,967,295 — the top of the range doubles (the negative half is traded for a larger positive half).
B. Wrong: unsigned int still occupies 4 bytes; the size does not change.
C. Wrong: only the range changes; the size stays 4 bytes.
D. Wrong: the range does increase, so A is correct.
Question 54 Computer
What is the time complexity of inserting an element in a binary heap?
- A. O(n log n)
- B. O(1)
- C. O(log n) ✓ Correct answer
- D. None of these
Why each option?
A. Wrong: O(n log n) is the cost of building a heap by inserting n elements one by one — not the cost of a single insertion.
B. Wrong: inserting is not constant time — the new element may have to bubble up the whole height of the tree.
C. Correct: insertion adds the element at the bottom and bubbles it up at most the height of the tree, which is log n for a heap of n elements.
D. Wrong: O(log n) is among the options and is correct.
Question 55 Computer
Which algorithm is used to find the shortest path in a graph?
- A. Decision Tree
- B. Dijkstra's Algorithm ✓ Correct answer
- C. K-Nearest Neighbors
- D. None of these
Why each option?
A. Wrong: a decision tree is a machine-learning classifier; it does not find shortest paths in graphs.
B. Correct: Dijkstra's algorithm finds the shortest path from a source to all other vertices in a weighted graph with non-negative edge weights.
C. Wrong: K-Nearest Neighbors is a machine-learning classifier that votes among the nearest training examples; it does not find graph paths.
D. Wrong: Dijkstra's Algorithm is among the options and is correct.
Question 56 Computer
Which of the following data structures does not allow duplicate elements?
- A. Linked List
- B. Stack
- C. Hash Set ✓ Correct answer
- D. None of these
Why each option?
A. Wrong: a linked list happily stores the same value in several nodes — duplicates are allowed.
B. Wrong: a stack can hold the same value many times — duplicates are allowed.
C. Correct: a set stores each value once — inserting a duplicate is ignored, so no duplicates exist.
D. Wrong: the hash set is among the options and is correct.
Question 57 Computer
Which of the following is a self-balancing binary search tree?
- A. AVL Tree ✓ Correct answer
- B. Binary Heap
- C. Hash Table
- D. None of these
Why each option?
A. Correct: an AVL tree is a binary search tree that rebalances itself (by rotations) after every insert/delete, keeping its height logarithmic.
B. Wrong: a binary heap is a priority structure (parent smaller/larger than children), not a binary SEARCH tree, and it is not "self-balancing" in the BST sense.
C. Wrong: a hash table is a key-to-bucket lookup structure, not a tree at all.
D. Wrong: the AVL tree is among the options and is correct.
Question 58 Computer
Which data structure is best for implementing a priority queue?
- A. Hash Table
- B. Heap ✓ Correct answer
- C. Stack
- D. None of these
Why each option?
A. Wrong: a hash table gives fast lookup by key, but it has no ordering by priority — it cannot hand back the highest-priority element efficiently.
B. Correct: a (binary) heap keeps the highest-priority element at the root, with O(log n) insert and remove — the standard priority-queue implementation.
C. Wrong: a stack is LIFO and ignores priority entirely.
D. Wrong: the heap is among the options and is correct.
Question 59 Computer
Which data structure provides constant-time lookup using keys?
- A. Hash Table ✓ Correct answer
- B. Array
- C. Stack
- D. None of these
Why each option?
A. Correct: a hash table maps each key to a bucket by its hash, giving average O(1) lookup by key.
B. Wrong: an array gives O(1) access by INDEX, not by key — finding a value by its key needs a search, which is O(n).
C. Wrong: a stack only gives access to its top element; there is no key lookup at all.
D. Wrong: the hash table is among the options and is correct.
Question 60 Computer
A Queue follows which of the following principle?
- A. FIFO ✓ Correct answer
- B. LIFO
- C. SJF
- D. None of them
Why each option?
A. Correct: a queue is First In, First Out — the first element added is the first one removed, like a line at a counter.
B. Wrong: LIFO (Last In, First Out) is the principle of a STACK, not a queue.
C. Wrong: SJF (Shortest Job First) is a CPU-scheduling policy, not a queue principle.
D. Wrong: FIFO is among the options and is correct.
Question 61 Computer
Which diagram is primarily used for designing database's logical schema?
- A. ERD ✓ Correct answer
- B. Flowchart
- C. Data flow
- D. None of these
Why each option?
A. Correct: an Entity-Relationship Diagram (ERD) shows entities, their attributes and the relationships between them — the blueprint of a database's logical schema.
B. Wrong: a flowchart shows the steps and decisions of a program's flow, not a database schema.
C. Wrong: a data-flow diagram shows how data moves between processes and stores; it does not design the logical schema.
D. Wrong: the ERD is among the options and is correct.
Question 62 Computer
Which of the following refers to virtual table based on a query?
- A. Trigger
- B. Index
- C. View ✓ Correct answer
- D. None of these
Why each option?
A. Wrong: a trigger is code that runs automatically when an event (INSERT, UPDATE, DELETE) happens; it is not a virtual table.
B. Wrong: an index is a lookup structure that speeds up queries; it is not a virtual table.
C. Correct: a view is a virtual table defined by a stored query — it looks and behaves like a table but stores no data of its own.
D. Wrong: the view is among the options and is correct.
Question 63 Computer
What term describes the logical structure of a database?
- A. Database schema ✓ Correct answer
- B. Data instance
- C. Data file
- D. None of these
Why each option?
A. Correct: the schema is the logical structure of a database — its tables, fields, data types and relationships.
B. Wrong: a data instance is the actual data stored in the database at one moment in time, not its structure.
C. Wrong: a data file is the physical storage on disk, not the logical structure.
D. Wrong: the database schema is among the options and is correct.
Question 64 Computer
Which database object is automatically executed in response to specific events?
- A. Function
- B. Index
- C. Trigger ✓ Correct answer
- D. None of these
Why each option?
A. Wrong: a function runs only when it is explicitly called; it does not fire on its own in response to an event.
B. Wrong: an index is a passive lookup structure; nothing "executes" it in response to an event.
C. Correct: a trigger is a stored procedure that the database fires automatically when a specified event (INSERT, UPDATE or DELETE on a table) occurs.
D. Wrong: the trigger is among the options and is correct.
Question 65 Computer
Which of the following enhances query performance by dividing large tables into smaller ones?
- A. Replication
- B. Partitioning ✓ Correct answer
- C. Normalization
- D. None of these
Why each option?
A. Wrong: replication copies the same data to other servers for availability; it does not divide a table into smaller pieces.
B. Correct: partitioning splits a large table into smaller partitions (by range, list or hash), so a query scans only the relevant partitions and runs faster.
C. Wrong: normalization removes redundancy by splitting a table into related tables, but its purpose is data integrity, not query speed — and it is not the "dividing large tables into smaller ones" performance technique.
D. Wrong: partitioning is among the options and is correct.
Question 66 Computer
Which SQL aggregate function ignores NULL values?
- A. Max()
- B. Sum()
- C. Avg()
- D. All of them ✓ Correct answer
Why each option?
A. Ignores NULLs, but only one of the three: MAX() skips NULL values when finding the largest value.
B. Ignores NULLs, but only one of the three: SUM() adds only the non-NULL values.
C. Ignores NULLs, but only one of the three: AVG() averages only the non-NULL values (and divides by their count, not by all rows).
D. Correct: MAX(), SUM() and AVG() — like all standard SQL aggregate functions except COUNT(*) — ignore NULL values.
Question 67 Computer
Which locking strategy is most effective at minimizing the occurrence of deadlocks?
- A. Exclusive
- B. Pessimistic
- C. Optimistic ✓ Correct answer
- D. None of these
Why each option?
A. Wrong: an exclusive lock is a lock MODE (one holder, no sharing) — holding exclusive locks while waiting for more is exactly how deadlocks form, not how they are minimised.
B. Wrong: pessimistic locking locks data up front and holds the locks while working, so two transactions can easily end up waiting on each other's locks — the deadlock-prone strategy.
C. Correct: optimistic locking takes NO locks while working (it checks for conflicts only at commit time), so transactions almost never wait on each other's locks — deadlocks become rare.
D. Wrong: optimistic locking is among the options and is correct.
Question 68 Computer
Which of the following is an example of a column-oriented NoSQL database?
- A. Neo4j
- B. MongoDB
- C. Cassandra ✓ Correct answer
- D. None of these
Why each option?
A. Wrong: Neo4j is a GRAPH database (nodes and relationships), not a column-oriented one.
B. Wrong: MongoDB is a DOCUMENT database (JSON-like documents), not a column-oriented one.
C. Correct: Cassandra is a wide-column (column-family) NoSQL database — data is stored in column families, in the Bigtable tradition.
D. Wrong: Cassandra is among the options and is correct.
Question 69 Computer
A clustered index primarily affects _____?
- A. Data backups
- B. Query speed only
- C. Physical data order ✓ Correct answer
- D. None of these
Why each option?
A. Wrong: a clustered index does not change how backups work; backups copy the data regardless of index type.
B. Wrong: a clustered index does speed up some queries, but "query speed only" misses its defining effect — it physically orders the table's rows.
C. Correct: a clustered index dictates the physical order in which the table's rows are stored on disk (in clustered-index key order); there can be only one per table for that reason.
D. Wrong: physical data order is among the options and is correct.
Question 70 Computer
Which normalization form addresses transitive dependencies?
- A. 1NF
- B. 2NF
- C. 3NF ✓ Correct answer
- D. None of these
Why each option?
A. Wrong: First Normal Form requires atomic values and no repeating groups; it does not deal with transitive dependencies.
B. Wrong: Second Normal Form removes PARTIAL dependencies (non-key attributes depending on part of a composite key); transitive dependencies remain.
C. Correct: Third Normal Form requires that every non-key attribute depends on the key, the whole key, and nothing but the key — it removes transitive dependencies, where a non-key attribute depends on another non-key attribute.
D. Wrong: 3NF is among the options and is correct.
