Praxis Computer Science study materials
Praxis Computer Science study resources

Praxis Computer Science practice questions

One question at a time. Build your Praxis Computer Science understanding.

First 50 of 200 questions. Each one lists the choices, the correct answer, and an explanation. The checker at the top of this page saves progress in this browser when it is available.

Continue in the practice tool above to load more questions, 50 at a time.

Question 1Computer Systems and Organization

What is the 8-bit two's complement representation of decimal -5?

  1. 11111011 Correct answer.
  2. 11111010
  3. 10000101
  4. 00000101

Explanation

In 8-bit two's complement, start with +5 as 00000101, invert all bits to get 11111010, and add 1 to obtain 11111011. The leading 1 indicates a negative value.

Question 2Computer Systems and Organization

What is the hexadecimal equivalent of the binary number 1011 0110?

  1. 0xCB
  2. 0xB6 Correct answer.
  3. 0x6B
  4. 0xB4

Explanation

Group the binary digits into nibbles: 1011 is B and 0110 is 6, so the hexadecimal value is 0xB6. Each hexadecimal digit represents exactly four binary bits.

Question 3Computer Systems and Organization

Which CPU component performs arithmetic and logical operations?

  1. ALU Correct answer.
  2. Program counter
  3. Cache
  4. Control unit

Explanation

The arithmetic logic unit, or ALU, executes operations such as addition, subtraction, AND, and OR. The control unit directs execution, while the program counter and cache serve different roles.

Question 4Computer Systems and Organization

During the fetch phase of the instruction cycle, the CPU places the next instruction into which register?

  1. Memory address register
  2. Instruction register Correct answer.
  3. Program counter
  4. Accumulator

Explanation

The fetch phase reads the instruction at the address in the program counter and loads it into the instruction register. The instruction is then decoded and executed.

Question 5Computer Systems and Organization

Which storage is typically the fastest for a CPU to access?

  1. Solid-state drive
  2. CPU registers Correct answer.
  3. Main memory
  4. L1 cache

Explanation

CPU registers are located on the processor and are faster than cache, main memory, or secondary storage. The memory hierarchy trades capacity for speed as you move away from the CPU.

Question 6Computer Systems and Organization

An AND gate produces an output of 1 under which condition?

  1. At least one input is 1
  2. Both inputs are 1 Correct answer.
  3. Both inputs are 0
  4. The inputs differ

Explanation

An AND gate outputs 1 only when every input is 1. If either input is 0, the output is 0.

Question 7Computer Systems and Organization

What is the decimal ASCII code for the uppercase letter 'A'?

  1. 65 Correct answer.
  2. 48
  3. 64
  4. 97

Explanation

In standard ASCII, uppercase 'A' has decimal value 65. The codes for '0' and lowercase 'a' are 48 and 97, respectively.

Question 8Computer Systems and Organization

Which bus carries memory addresses from the CPU to memory?

  1. Data bus
  2. Address bus Correct answer.
  3. Power bus
  4. Control bus

Explanation

The address bus transmits the location of a memory word or I/O device that the CPU wants to access. The data bus carries the actual contents, and the control bus carries timing and control signals.

Question 9Computer Systems and Organization

A program loops through an array and accesses consecutive elements in order. Which type of locality does this pattern primarily exploit?

  1. Spatial locality Correct answer.
  2. Branch locality
  3. Semantic locality
  4. Temporal locality

Explanation

Spatial locality is the tendency to access memory locations near recently accessed addresses. Sequential array access brings nearby elements into the same cache blocks, so later iterations often hit in cache.

Question 10Computer Systems and Organization

An instruction needs a register value that the immediately preceding instruction has not yet written back. What type of pipeline hazard is this?

  1. Structural hazard
  2. Control hazard
  3. Memory hazard
  4. Data hazard Correct answer.

Explanation

A data hazard occurs when an instruction depends on a result that is not yet available. Forwarding or stalling can resolve it. Structural hazards involve hardware resource conflicts, and control hazards involve branches.

Question 11Computer Systems and Organization

What is a primary purpose of virtual memory?

  1. Add more physical RAM
  2. Provide isolated address spaces Correct answer.
  3. Remove the need for cache
  4. Increase disk throughput

Explanation

Virtual memory gives each process its own logical address space, which supports isolation and allows programs to use more virtual addresses than physical RAM. It does not increase the actual amount of installed RAM.

Question 12Computer Systems and Organization

Which fields make up an IEEE 754 single-precision floating-point value?

  1. Mantissa, exponent, parity
  2. Sign, exponent, checksum
  3. Sign, exponent, fraction Correct answer.
  4. Sign, integer, fraction

Explanation

A single-precision IEEE 754 value contains a sign bit, an 8-bit exponent, and a 23-bit fraction, also called the significand. The exponent is biased, and the fraction stores the significant digits.

Question 13Computer Systems and Organization

In the instruction LOAD R1, [R2], what addressing mode is used?

  1. Register indirect Correct answer.
  2. Indexed with displacement
  3. Direct address
  4. Immediate operand

Explanation

Brackets around a register indicate register indirect addressing: R2 holds the effective address of the operand. The CPU reads memory at the address stored in R2.

Question 14Computer Systems and Organization

Which resource is private to each thread within the same process?

  1. Stack Correct answer.
  2. Open files
  3. Heap
  4. Global variables

Explanation

Each thread has its own stack, registers, and program counter so it can execute independently. Threads in the same process share the heap, global variables, and open files.

Question 15Computer Systems and Organization

Which condition is one of the four necessary conditions for deadlock?

  1. Priority inversion
  2. Queue overflow
  3. Circular wait Correct answer.
  4. Resource starvation

Explanation

Deadlock requires mutual exclusion, hold-and-wait, no preemption, and circular wait. Circular wait means each process in a cycle waits for a resource held by another process in that cycle.

Question 16Computer Systems and Organization

How does a little-endian machine store the multi-byte integer 0x12345678?

  1. Most significant byte first
  2. Least significant byte first Correct answer.
  3. All bytes in reverse bit order
  4. ASCII characters first

Explanation

Little-endian storage places the least significant byte at the lowest memory address. For 0x12345678, the byte 0x78 is stored first, followed by 0x56, 0x34, and 0x12.

Question 17Computer Systems and Organization

How does an I/O device typically notify the CPU that it has completed a transfer?

  1. Interrupt Correct answer.
  2. DMA descriptor
  3. Polling loop
  4. System call

Explanation

An interrupt signals the CPU that a device needs attention, such as when an I/O operation finishes. The CPU then transfers control to an interrupt handler.

Question 18Computer Systems and Organization

A program spends 40 percent of its execution time in a section that can be made infinitely fast. What is the maximum possible overall speedup?

  1. 4.0
  2. 1.667 Correct answer.
  3. 1.4
  4. 2.5

Explanation

Amdahl's law limits speedup to 1 divided by the serial fraction. The serial fraction is 60 percent, or 0.6, so the maximum speedup is 1/0.6, about 1.667.

Question 19Computer Systems and Organization

Using Boolean algebra, what does A AND (A OR B) simplify to?

  1. A OR B
  2. B
  3. A AND B
  4. A Correct answer.

Explanation

This is an absorption law: A(A + B) = A. If A is 1, the expression is 1; if A is 0, the expression is 0, regardless of B.

Question 20Computer Systems and Organization

Which tool combines multiple object files into a single executable?

  1. Compiler
  2. Loader
  3. Assembler
  4. Linker Correct answer.

Explanation

The linker combines object files, resolves symbolic references between them, and produces an executable. The loader later places the executable into memory for execution.

Question 21Computer Systems and Organization

When adding two signed two's complement numbers, overflow occurs under which condition?

  1. Carry in and carry out differ Correct answer.
  2. The result is negative or zero
  3. Carry out of the sign bit is set
  4. The operands have opposite signs

Explanation

Signed overflow occurs when the carry into the sign bit differs from the carry out of the sign bit. This can happen only when adding two numbers of the same sign.

Question 22Computer Systems and Organization

A 32-bit byte-addressed system has 64-byte cache blocks and 256 sets in a direct-mapped cache. How many tag bits are needed?

  1. 16
  2. 18 Correct answer.
  3. 20
  4. 24

Explanation

The block offset needs log2(64) = 6 bits, and the set index needs log2(256) = 8 bits. The remaining address bits form the tag: 32 - 6 - 8 = 18 bits.

Question 23Computer Systems and Organization

A processor has a base CPI of 1.0 and no stalls except branch penalties. If 20 percent of instructions are branches and each branch costs 3 extra cycles, what is the average CPI?

  1. 1.2
  2. 1.6 Correct answer.
  3. 3.0
  4. 1.5

Explanation

The branch penalty adds 0.20 times 3, or 0.6 cycles per instruction on average. Adding this to the base CPI of 1.0 gives an average CPI of 1.6.

Question 24Computer Systems and Organization

What does a translation lookaside buffer (TLB) store?

  1. Stores complete pages
  2. Caches recent translations Correct answer.
  3. Replaces the entire page table
  4. Increases the page size

Explanation

The TLB is a small, fast cache of recent virtual-to-physical page translations. A TLB hit avoids accessing the page table in memory for that translation.

Question 25Computer Systems and Organization

Two threads repeatedly increment a shared counter without synchronization, and the final value is too low. What is the main cause?

  1. CPUs cannot add small integers
  2. The increment is not atomic Correct answer.
  3. Threads share one stack
  4. Caches reject shared writes

Explanation

An unsynchronized increment is a read-modify-write sequence that can interleave with another thread's increment. If both read the same old value before either writes, one update is lost. Making the increment atomic or using a lock prevents this race.

Question 26Computer Systems and Organization

What does the program counter (PC) hold during normal instruction execution?

  1. The base address of the active stack frame
  2. The address of the next instruction Correct answer.
  3. The result produced by the last ALU operation
  4. The number of instructions completed so far

Explanation

The program counter is a register that holds the address of the next instruction to be fetched. After a fetch, it is normally incremented, or it is loaded with a branch target when control flow changes.

Question 27Computer Systems and Organization

Which memory technology is typically used to build CPU cache because it is fast and does not require refresh?

  1. DRAM
  2. SRAM Correct answer.
  3. Flash memory
  4. Magnetic disk

Explanation

SRAM stores each bit in a flip-flop-like structure, so it keeps data as long as power is supplied and can be made very fast. DRAM stores bits as charge on capacitors and must be refreshed periodically, which makes it slower for cache use.

Question 28Computer Systems and Organization

What is the primary function of the arithmetic logic unit (ALU)?

  1. To decode instruction opcodes into control signals
  2. To perform arithmetic and bitwise logical operations Correct answer.
  3. To translate virtual addresses into physical addresses
  4. To store the contents of the stack during procedure calls

Explanation

The ALU performs integer arithmetic such as addition and subtraction, along with bitwise logic, shifts, and comparisons. Control decoding, stack storage, and address translation are handled by other parts of the system.

Question 29Computer Systems and Organization

Which binary sequence is equivalent to the hexadecimal value 0x5C?

  1. 0101 1100 Correct answer.
  2. 1100 0101
  3. 0101 1010
  4. 1010 1100

Explanation

Each hexadecimal digit corresponds to exactly four binary bits. The digit 5 is 0101 and the digit C is 1100, so 0x5C is 0101 1100.

Question 30Computer Systems and Organization

What is the 8-bit two's complement representation of -5?

  1. 0000 0101
  2. 1111 1011 Correct answer.
  3. 1000 0101
  4. 1111 1010

Explanation

Start with +5 as 0000 0101, invert all bits to get 1111 1010, and add 1 to obtain 1111 1011. Equivalently, -5 is 256 - 5 = 251, which is 0xFB.

Question 31Computer Systems and Organization

A cache uses a write-through policy. What happens when the processor writes a value that hits in the cache?

  1. Only the cache block is updated, and main memory is updated when the block is evicted
  2. The cache block is updated and main memory is updated immediately Correct answer.
  3. The write is buffered until the next cache flush instruction
  4. The write bypasses the cache and is sent only to main memory

Explanation

Write-through means that every write updates both the cache and the next level of memory, often through a write buffer. Write-back, by contrast, delays the memory update until the dirty block is evicted.

Question 32Computer Systems and Organization

A processor executes a long stream of independent instructions using a 5-stage pipeline with no stalls. Compared with a single-cycle unpipelined datapath, what is the ideal throughput speedup?

  1. 1.25
  2. 25
  3. 5 Correct answer.
  4. 2

Explanation

After the pipeline fills, an ideal 5-stage pipeline can complete one instruction per clock cycle. An unpipelined datapath takes one instruction every 5 cycles, so the ideal throughput gain is about 5 times.

Question 33Computer Systems and Organization

What is the main advantage of using direct memory access (DMA) for a block transfer?

  1. It removes the need for memory-mapped I/O registers
  2. It encrypts each block before it reaches main memory
  3. It guarantees completion within a single clock cycle
  4. It frees the CPU to do other work during the transfer Correct answer.

Explanation

A DMA controller moves data between a device and memory without the CPU executing a load or store for every word. The CPU starts the transfer and can continue executing other work until an interrupt or status check signals completion.

Question 34Computer Systems and Organization

When a procedure is called, where is the return address typically saved?

  1. In the program counter
  2. In the memory data register
  3. In the instruction register
  4. On the stack Correct answer.

Explanation

A call instruction saves the address of the following instruction on the stack so that a return can restore execution there. The return instruction then pops that saved address back into the program counter.

Question 35Computer Systems and Organization

Which property is most characteristic of a RISC instruction set architecture?

  1. Most instructions execute in one cycle and use register operands Correct answer.
  2. Complex instructions are implemented directly in hardware microcode
  3. Instructions have variable length and many memory operands
  4. The architecture provides a small number of general-purpose registers

Explanation

RISC designs emphasize simple, fixed-length instructions, load/store memory access, and register-to-register operations that pipeline well. Many RISC instructions are intended to complete in a single cycle in an ideal pipeline.

Question 36Computer Systems and Organization

A program executes 2.0 × 10^9 instructions with an average CPI of 1.5 on a 3.0 GHz processor. What is the approximate execution time?

  1. 0.5 s
  2. 1.0 s Correct answer.
  3. 2.0 s
  4. 1.5 s

Explanation

CPU time equals instruction count times CPI divided by clock rate. Here that is (2.0 × 10^9 × 1.5) / (3.0 × 10^9) = 1.0 second.

Question 37Computer Systems and Organization

According to De Morgan's laws, which expression is equivalent to NOT (A AND B)?

  1. (NOT A) OR (NOT B) Correct answer.
  2. (NOT A) AND (NOT B)
  3. A OR B
  4. A AND (NOT B)

Explanation

De Morgan's law states that the negation of a conjunction is the disjunction of the negations. Therefore NOT (A AND B) equals (NOT A) OR (NOT B).

Question 38Computer Systems and Organization

A 32-bit virtual address space uses 4 KiB pages and 4-byte page-table entries. What is the size of a single-level page table for one process, assuming every entry is present?

  1. 4 GiB
  2. 4 MiB Correct answer.
  3. 4 KiB
  4. 1 MiB

Explanation

A 4 KiB page means the offset uses 12 bits, leaving 20 bits for the virtual page number. Thus there are 2^20 entries, and at 4 bytes each the table size is 4 MiB.

Question 39Computer Systems and Organization

A direct-mapped cache has 64 blocks. A program repeatedly accesses two arrays whose corresponding elements always map to the same cache block. What type of cache miss dominates this pattern?

  1. Capacity miss
  2. TLB miss
  3. Conflict miss Correct answer.
  4. Compulsory miss

Explanation

In a direct-mapped cache, each memory block can occupy only one cache block. Two frequently used addresses that map to the same cache block repeatedly evict each other, which is a conflict miss.

Question 40Computer Systems and Organization

In IEEE 754 single precision, the significand has 23 explicit fraction bits. If the value 1.0 is stored, adding 2^-24 to it and rounding to nearest even produces what result?

  1. 1.0 + 2^-23
  2. 2.0
  3. 1.0 Correct answer.
  4. The result is NaN

Explanation

Near 1.0, single-precision numbers are spaced 2^-23 apart, so 2^-24 is exactly half an ULP. Round-to-nearest-even chooses the representable value with an even significand, which is 1.0 rather than 1.0 + 2^-23.

Question 41Programming and Algorithms

In a language where both operands are integers, what is the value of the expression 7 / 2?

  1. 3 Correct answer.
  2. 1
  3. 4
  4. 3.5

Explanation

When both operands have an integer type, the division operator performs integer division and discards the fractional part, so 7 / 2 evaluates to 3.

Question 42Programming and Algorithms

Following standard operator precedence, what is the value of 4 + 3 * 2?

  1. 10 Correct answer.
  2. 24
  3. 14
  4. 9

Explanation

Multiplication binds more tightly than addition, so 3 * 2 is evaluated first and its result, 6, is then added to 4.

Question 43Programming and Algorithms

In Java, C, C++, and Python, what is the index of the first element of an array or list?

  1. The length of the array
  2. 1
  3. -1
  4. 0 Correct answer.

Explanation

These languages use zero-based indexing, so the first element sits at index 0 and the last valid index is one less than the length.

Question 44Programming and Algorithms

How many times does the body of this loop execute? for (int i = 1; i <= 4; i++) { ... }

  1. 3
  2. 0
  3. 4 Correct answer.
  4. 5

Explanation

The counter starts at 1 and the loop continues while i <= 4, so i takes the values 1, 2, 3, and 4 before the condition fails.

Question 45Programming and Algorithms

What does a return statement do inside a function?

  1. It prints the value to the standard output console
  2. It permanently stores the value in a file on disk
  3. It returns a value to the caller Correct answer.
  4. It restarts the function from its first statement

Explanation

A return statement ends execution of the current function and hands a value back to the code that called it, where the call expression evaluates to that value.

Question 46Programming and Algorithms

A while loop's condition is false the very first time it is tested. How many times does the loop body execute?

  1. Exactly once
  2. Zero times Correct answer.
  3. An infinite number of times
  4. Exactly twice

Explanation

A while loop tests its condition before every iteration, so if the condition is already false, control skips the body entirely.

Question 47Programming and Algorithms

In a language that uses + for string concatenation, what does the expression "3" + "4" produce?

  1. "34" Correct answer.
  2. 12
  3. A type error is raised
  4. "7"

Explanation

When both operands are strings, the + operator concatenates them, joining the characters into the single two-character string "34".

Question 48Programming and Algorithms

Which data structure processes elements in first-in, first-out order?

  1. Stack
  2. Hash table
  3. Binary search tree
  4. Queue Correct answer.

Explanation

A queue inserts at the rear and removes from the front, so the element that has waited longest is the first one out.

Question 49Programming and Algorithms

What precondition must hold before binary search can be applied to an array?

  1. The array must be sorted Correct answer.
  2. The array must contain only unique values
  3. The array must be stored as a linked list
  4. The array must have an odd number of elements

Explanation

Binary search discards half of the remaining range after each comparison, and that deduction is valid only when the elements are in sorted order.

Question 50Programming and Algorithms

A recursive function that never reaches a base case is executed. What happens?

  1. The compiler inserts a base case during optimization
  2. It returns 0 automatically when the argument reaches 1
  3. It runs exactly twice and then stops
  4. It recurses until the call stack overflows Correct answer.

Explanation

A recursive function needs a base case that returns without making another call; without one, each call pushes a new frame until the call stack is exhausted and the program fails.