First 50 of 190 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 architecture, logic and data representation
On the 软考初级 程序员 计算机硬软件基础知识 paper, what is the decimal value of hexadecimal 0x2A?
- 32
- 40
- 42 Correct answer.
- 52
Explanation
Hexadecimal 0x2A means 2×16 + 10×1 = 32 + 10 = 42. Each hex digit is a 4-bit group, so 2 is 0010 and A is 1010, which is the same 8-bit pattern as decimal 42. 软考 程序员 papers expect this conversion without a calculator.
Question 2Computer architecture, logic and data representation
On 软考初级 程序员 计算机硬软件基础知识, convert the unsigned binary integer 10110 to decimal.
- 11
- 21
- 22 Correct answer.
- 26
Explanation
Place values from the right are 2^0 through 2^4. 10110 = 16 + 0 + 4 + 2 + 0 = 22. Only the 1-bits add: 16 + 4 + 2.
Question 3Computer architecture, logic and data representation
In 8-bit two's complement (补码), which bit pattern represents −1?
- 10000001
- 10000000
- 11111110
- 11111111 Correct answer.
Explanation
In two's complement, adding 1 to a bit pattern of all 1s overflows the 8-bit width and yields 0, so 11111111 is −1. Equivalently, start from +1 (00000001), invert to 11111110, and add 1 to obtain 11111111. This is a standard 软考 程序员 机内表示 fact.
Question 4Computer architecture, logic and data representation
Convert unsigned octal 157 to decimal, the kind of 数制转换 item 软考初级 程序员 tests.
- 87
- 111 Correct answer.
- 157
- 175
Explanation
Octal place values are powers of 8. 157₈ = 1×64 + 5×8 + 7×1 = 64 + 40 + 7 = 111₁₀. You can also map each octal digit to 3 bits (001 101 111) and convert that binary value.
Question 5Computer architecture, logic and data representation
What is the 8-bit two's-complement (补码) representation of −5?
- 00000101
- 10000101
- 11111010
- 11111011 Correct answer.
Explanation
Write +5 as 00000101. Invert every bit to get the ones' complement 11111010, then add 1 to obtain 11111011. The 原码 of −5 is 10000101 and the 反码 is 11111010; 补码 is 反码 plus one. Adding 11111011 + 00000101 yields 00000000 in 8 bits, which confirms −5 + 5 = 0.
Question 6Computer architecture, logic and data representation
An 8-bit register holds two's-complement value 10000001. What signed decimal integer is stored?
- −1
- −127 Correct answer.
- −128
- 129
Explanation
The leading 1 means the value is negative. Invert 10000001 to 01111110 and add 1, obtaining 01111111 = 127, so the original pattern is −127. Only 10000000 encodes −128 in 8-bit two's complement; 10000001 is one step toward zero from that minimum.
Question 7Computer architecture, logic and data representation
Compute the bitwise AND of the 8-bit patterns 10110100 and 11001100. What is the 8-bit result?
- 10000100 Correct answer.
- 11111100
- 00000000
- 10111100
Explanation
AND yields 1 only where both bits are 1. Align the bytes: 10110100 AND 11001100 = 10000100. Bitwise AND is the machine-level logic operation named in the 程序员 考试说明 (算术和逻辑运算).
Question 8Computer architecture, logic and data representation
In the CPU of a stored-program computer, which unit performs arithmetic (add, subtract) and logic (AND, OR, NOT) on data?
- Program counter (PC)
- Arithmetic logic unit (ALU) Correct answer.
- Instruction register (IR)
- Memory address register (MAR)
Explanation
The ALU (算术逻辑单元) executes arithmetic and logic operations. The 程序员 考试说明 asks candidates to understand major component roles: the ALU is the execution engine, while PC, IR, and MAR hold addresses or the current instruction rather than computing results.
Question 9Computer architecture, logic and data representation
After an ordinary sequential instruction is fetched, which register is typically updated to the address of the following instruction?
- Accumulator (AC)
- Instruction register (IR)
- Program counter (PC) Correct answer.
- Stack pointer (SP)
Explanation
The program counter stores the address of the next instruction. In a sequential flow it is incremented by the instruction length after fetch (or during fetch). IR holds the fetched instruction itself; AC is a data register; SP points at the stack, not the code stream.
Question 10Computer architecture, logic and data representation
The 程序员 考试说明 includes 排列组合. How many ways can a project lead choose 2 testers from 5 distinct testers if order does not matter?
- 5
- 10 Correct answer.
- 20
- 25
Explanation
That is the combination C(5,2) = 5×4 / 2×1 = 10. Order does not matter, so the permutation P(5,2)=20 would double-count each pair. 软考 applied-math items at this level use C(n,k) = n! / (k!(n−k)!).
Question 11Computer architecture, logic and data representation
What is the Hamming distance between the 7-bit strings 1100101 and 1010111?
- 1
- 2
- 3 Correct answer.
- 4
Explanation
Hamming distance is the number of positions that differ. Compare 1100101 with 1010111: positions 2 (1 vs 0), 3 (0 vs 1), and 6 (0 vs 1) differ, so the distance is 3. Error-detecting codes in 程序员 data-representation topics use this count to bound detectable flips.
Question 12Computer architecture, logic and data representation
In the memory hierarchy tested on 软考初级 程序员, what is the primary role of Cache?
- Provide non-volatile archival storage for files
- Hold a small, fast copy of recently used main-memory blocks for the CPU Correct answer.
- Translate virtual page numbers without using a page table
- Serialize all I/O through a single DMA controller
Explanation
Cache sits between the CPU and main memory. It stores copies of recently referenced blocks so most accesses hit a faster memory. Disks and SSDs provide non-volatile files; address translation is the MMU/page-table job; DMA is an I/O transfer method, not a cache.
Question 13Computer architecture, logic and data representation
A byte-addressable memory is decoded with 20 address lines and no extra chip-select banking. What is the maximum addressable capacity?
- 20 KB
- 160 KB
- 1 MB Correct answer.
- 2 MB
Explanation
n address lines distinguish 2^n distinct byte locations. 2^20 = 1,048,576 bytes = 1 MB. 20 KB would treat 20 as a kilobyte count; 2 MB would need 21 lines for bytes.
Question 14Computer architecture, logic and data representation
Compared with programmed I/O that transfers one word under CPU control, what is the distinctive advantage of DMA for a large disk block?
- The CPU executes an interrupt handler for every transferred byte
- A DMA controller moves the block between the device and memory with far less per-word CPU involvement Correct answer.
- DMA eliminates the need for main memory
- DMA is only used for keyboard character input
Explanation
Direct memory access lets a DMA controller steal the bus and copy a block between a device and memory. The CPU is interrupted mainly at completion (or on error), so large transfers waste fewer cycles than polling or per-byte interrupts. DMA still uses main memory; keyboards typically use interrupts, not bulk DMA.
Question 15Computer architecture, logic and data representation
A 5-stage instruction pipeline has a 2 ns clock. Ignoring stalls and assuming one instruction enters per cycle after fill, how long does it take to complete 200 instructions?
- 400 ns
- 408 ns Correct answer.
- 1000 ns
- 2000 ns
Explanation
Ideal pipeline latency is (k + n − 1) clock cycles for k stages and n instructions. Here (5 + 200 − 1) × 2 ns = 204 × 2 ns = 408 ns. The first instruction needs 5 cycles; each of the remaining 199 completes one cycle later. 2000 ns is the non-pipelined cost 200 × 5 × 2 ns.
Question 16Computer architecture, logic and data representation
In a typical floating-point format taught for 软考初级 程序员, which statement is correct?
- A longer exponent field mainly increases precision of the significand
- A longer mantissa (significand) field mainly increases precision, while a longer exponent field mainly widens the representable range Correct answer.
- The sign bit determines the magnitude of the exponent
- Normalized floating-point numbers never use an exponent field
Explanation
Range is governed by how large the exponent can be; precision is governed by how many fraction/mantissa bits are kept. 软考 textbooks state 阶码决定范围、尾数决定精度. The sign bit only selects the sign of the value, not the exponent's width.
Question 17Computer architecture, logic and data representation
A processor sees Cache hits in 90% of accesses. Cache access is 8 ns and a miss is satisfied from main memory in 80 ns (this 80 ns already includes the Cache miss path). What is the average memory access time?
- 8 ns
- 15.2 ns Correct answer.
- 80 ns
- 88 ns
Explanation
AMAT = hit_rate × hit_time + miss_rate × miss_time = 0.9 × 8 + 0.1 × 80 = 7.2 + 8.0 = 15.2 ns. This weighted average is the standard 程序员 performance-indicator calculation for a single-level Cache.
Question 18Computer architecture, logic and data representation
A CPU runs at 1 GHz with average CPI = 4. What is its instruction throughput in MIPS?
- 0.25
- 4
- 250 Correct answer.
- 4000
Explanation
MIPS = clock_frequency / (CPI × 10^6). With 1×10^9 Hz and CPI 4, MIPS = 10^9 / (4 × 10^6) = 250. Equivalently, 1 GHz means 1000 million cycles per second, and 4 cycles per instruction yield 250 million instructions per second.
Question 19Operating systems, translation and concurrency
According to the 程序员 考试说明 emphasis on operating-system basics, which set best names the classic OS resource-management functions?
- Process (processor) management, memory management, device management, and file management Correct answer.
- Only compilation and linking of source programs
- Only drawing windows for office software
- Only IP packet routing between autonomous systems
Explanation
A general-purpose OS manages the processor (processes/threads), memory, devices, and files (and often jobs/users). Compilation is a language-processing tool; GUI shells are one interface; routing is a network-layer function, not the OS function list taught at 初级 程序员.
Question 20Operating systems, translation and concurrency
In OS teaching used by 软考初级 程序员, how does a process differ from a program stored on disk?
- A program is an executing instance with a PCB, memory image, and scheduling state; a process is only a static file
- A process is a running instance of a program, with its own state, address space, and OS control block; a program is the static code (and data) image Correct answer.
- They are identical terms in every OS textbook
- A process cannot wait; only programs wait
Explanation
A program is a passive file of instructions. A process is that program in execution: it has a process control block, an address space, and states such as ready, running, and blocked. 软考 stems often test this static-versus-dynamic distinction.
Question 21Operating systems, translation and concurrency
Which language-processing program translates a complete high-level source file into object (or machine) code before the resulting program is run?
- Interpreter
- Compiler Correct answer.
- Loader only, with no translation
- Device driver
Explanation
A compiler (编译程序) translates high-level source into object/machine code ahead of execution. An interpreter executes source (or an intermediate form) more directly, typically without producing a standalone native object as the primary product. Loaders place already translated images in memory; drivers control devices.
Question 22Operating systems, translation and concurrency
Which CPU scheduling policy gives each ready process a fixed time quantum and then moves it to the tail of the ready queue if it has not finished?
- First-come, first-served (FCFS) with no preemption
- Shortest job first (SJF) non-preemptive
- Round-robin (时间片轮转) Correct answer.
- Priority scheduling that never preempts
Explanation
Round-robin uses a time slice (时间片). When the slice expires, the running process is preempted and queued at the end of the ready list. FCFS and non-preemptive SJF run a chosen job to completion (or until it blocks) without rotating equal slices.
Question 23Operating systems, translation and concurrency
Which four conditions are necessary for deadlock among processes competing for resources (Coffman conditions)?
- Mutual exclusion, hold-and-wait, no preemption, and circular wait Correct answer.
- Paging, segmentation, swapping, and DMA
- Compilation, assembly, linking, and loading
- Time-sharing, batch, real-time, and embedded
Explanation
Deadlock requires mutual exclusion, hold-and-wait, no preemption, and a circular wait. Breaking any one condition prevents deadlock. The other lists mix memory techniques, language-processing stages, or OS types, which are not the Coffman set.
Question 24Operating systems, translation and concurrency
What does virtual memory primarily enable on a paged system?
- Executing a process whose logical address space can be larger than currently allocated physical frames, using disk as backing store Correct answer.
- Eliminating the CPU cache
- Making every file permanently resident in registers
- Removing the need for page tables
Explanation
Virtual memory maps logical pages to physical frames (and to disk when pages are not resident). A process can therefore run with only a subset of pages in RAM. Page tables (and usually a TLB) remain essential; Cache and registers are separate hardware resources.
Question 25Operating systems, translation and concurrency
How does a classic interpreter differ from a compiler in the 程序员 language-processor model?
- An interpreter typically analyzes and executes source (or an intermediate form) statement by statement at run time, without requiring a separate full native compile step first Correct answer.
- An interpreter always produces a faster standalone .exe than a compiler
- A compiler can only translate assembly, never high-level languages
- Interpreters are used only for machine language
Explanation
Teaching texts contrast 编译 (translate all, then run) with 解释 (analyze and execute incrementally). Compiled native code often runs faster once built; compilers are the usual path from high-level languages to object code; machine code is already executed by hardware, not interpreted as a high-level language.
Question 26Operating systems, translation and concurrency
Which description matches machine language as used in 软考初级 程序员 language basics?
- Binary instruction encodings that the CPU can execute directly Correct answer.
- English comments in a design document
- SQL statements sent only to a database server
- A markup language used solely for web pages
Explanation
Machine language is the CPU's native binary instruction format. Comments, SQL, and HTML/XML are not the processor's instruction set. Assembly is a symbolic form of those instructions; machine code is the numeric encoding.
Question 27Operating systems, translation and concurrency
A process is waiting in the ready queue. What must happen for it to enter the running state?
- It must page-fault forever
- The scheduler must dispatch it to a CPU Correct answer.
- It must be deleted from the PCB list
- It must wait for a keyboard interrupt before any dispatch is allowed
Explanation
Ready means the process could run as soon as a processor is assigned. Dispatch (调度) moves it from ready to running. A page fault would typically send a running process toward blocked/waiting; deleting the PCB terminates the process.
Question 28Operating systems, translation and concurrency
In contiguous memory allocation, external fragmentation is best described as which situation?
- Unused space exists inside allocated blocks because the process is smaller than the partition
- Enough total free memory exists, but it is split into holes too small to satisfy a waiter's request Correct answer.
- The Cache hit rate is 100%
- Every process uses only registers
Explanation
External fragmentation is free memory that cannot be used because it is scattered. Internal fragmentation is leftover space inside an allocated partition. Paging was introduced partly to reduce external fragmentation.
Question 29Operating systems, translation and concurrency
Three processes arrive at time 0 with CPU bursts A=6, B=3, C=3. Using non-preemptive SJF (ties broken by name B then C then A), what is the average waiting time?
- 0
- 3 Correct answer.
- 5
- 9
Explanation
SJF runs shortest bursts first: B (3), then C (3), then A (6). Waiting times: B waits 0, C waits 3, A waits 3+3=6. Average = (0+3+6)/3 = 3. FCFS in order A,B,C would wait (0+6+9)/3 = 5, which is a common trap if you ignore SJF.
Question 30Operating systems, translation and concurrency
Pages are 1024 bytes. A logical address has page number 2 and offset 100. The page table maps page 0→4, 1→7, 2→1 (frame numbers). What is the physical address?
- 100
- 1124 Correct answer.
- 2148
- 2048
Explanation
Physical address = frame × page_size + offset. Page 2 maps to frame 1, so 1×1024 + 100 = 1124. Using the page number 2 as the frame (2×1024+100=2148) is the usual mistake when the page table is ignored.
Question 31Programming and Software Development
In C, after int x = 5; x = x + 1; what is the value of x?
- 4
- 5
- 6 Correct answer.
- 51
Explanation
The assignment reads the old value 5, adds 1, and stores 6. C uses integer arithmetic here; nothing concatenates digits to make 51.
Question 32Programming and Software Development
In C, if int a[4] = {10, 20, 30, 40}; which expression equals 20?
- a[0]
- a[1] Correct answer.
- a[2]
- a[4]
Explanation
C arrays are 0-based: a[0] is 10, a[1] is 20, a[2] is 30, a[3] is 40. a[4] is off the end of a 4-element array and is undefined, not a stored 20.
Question 33Programming and Software Development
In C, what marks the end of a string stored in a character array?
- The character 'Z'
- The null character '\0' Correct answer.
- A mandatory newline '\n' after every string
- The length stored in a[0] as in some Pascal strings
Explanation
C strings are null-terminated: functions such as strlen stop at '\0'. There is no hidden length in a[0] in the C string library model, and strings need not end with newline.
Question 34Programming and Software Development
How many times does the loop body of for (i = 0; i < 3; i++) { } execute in C?
- 0
- 2
- 3 Correct answer.
- 4
Explanation
i takes 0, 1, and 2. When i becomes 3 the condition i < 3 fails, so the body runs three times. Off-by-one errors (running to i <= 3) are a staple 程序员 C trap.
Question 35Programming and Software Development
In C, int a = 5, b = 2; int c = a++ + ++b; What is c?
- 7
- 8 Correct answer.
- 9
- 10
Explanation
a++ yields 5 and then increments a to 6. ++b increments b to 3 and yields 3. The sum stored in c is 5 + 3 = 8. The two operands are different objects, so this evaluation is the intended textbook trace.
Question 36Programming and Software Development
int a[] = {1, 2, 3, 4}; What does *(a + 2) evaluate to in C?
- 1
- 2
- 3 Correct answer.
- 4
Explanation
The array name a decays to a pointer to a[0]. a+2 points to a[2], and dereferencing yields 3. This array/pointer equivalence is required C for 软考 程序员.
Question 37Programming and Software Development
In C, what is sizeof("AB") (the size of the string literal, in bytes, assuming a C implementation where char is 1 byte)?
- 1
- 2
- 3 Correct answer.
- 8
Explanation
A string literal includes the terminating '\0'. "AB" is stored as 'A', 'B', '\0', so sizeof is 3. strlen("AB") would be 2; 8 would be a typical pointer width if someone wrote sizeof(char *).
Question 38Programming and Software Development
In C, what is the value of the int expression 7 / 2?
- 3 Correct answer.
- 3.5
- 4
- 7
Explanation
Integer division truncates toward zero in modern C for positive operands, so 7/2 is 3. A 3.5 result would require a floating-point operand such as 7.0/2.
Question 39Programming and Software Development
In C, if int x = 8; what is x << 2?
- 2
- 4
- 16
- 32 Correct answer.
Explanation
Left shift by 2 multiplies a positive value by 4 (when no overflow occurs): 8 × 4 = 32, or binary 1000 shifted to 100000. x >> 2 would be 2.
Question 40Programming and Software Development
int x = 1, y = 0; switch (x) { case 1: y += 1; case 2: y += 2; default: y += 4; } After this C fragment (no break statements), what is y?
- 1
- 3
- 5
- 7 Correct answer.
Explanation
C switch falls through without break. x matches case 1, so y becomes 1, then case 2 still runs (y=3), then default runs (y=7). This fall-through behavior is a frequent 程序设计 MCQ trap.
Question 41Programming and Software Development
In C++, a class typically groups data members with member functions that operate on them and can hide data behind private. What principle is that?
- Encapsulation Correct answer.
- Deadlock avoidance
- Two's-complement overflow
- Token-ring media access
Explanation
Encapsulation (封装) binds state and operations and hides representation. The 程序员 考试说明 requires C plus one of C++/Java/VB; C++ classes are the usual encapsulation example. Deadlock, 补码, and token ring are unrelated domains.
Question 42Programming and Software Development
In Java, after String s = "AB"; s.concat("C"); what is s?
- "ABC"
- "AB" Correct answer.
- "C"
- null
Explanation
Java String objects are immutable. concat returns a new String and does not modify s unless the result is assigned. Because the return value is discarded, s remains "AB". This is a standard second-language item beside C on 程序员 papers.
Question 43Programming and Software Development
Java source is typically compiled to bytecode that runs on which component?
- The Java Virtual Machine (JVM) Correct answer.
- The ALU without any runtime
- A Visual Basic form designer only
- The BIOS boot block
Explanation
javac produces bytecode for the JVM (or an equivalent runtime), which interprets or JIT-compiles it. That portability model is the Java side of the 考试说明 language choice. ALU, VB designers, and BIOS are not the Java execution engine.
Question 44Programming and Software Development
void inc(int x) { x = x + 1; } int a = 1; inc(a); After this C call, what is a?
- 0
- 1 Correct answer.
- 2
- Undefined because inc cannot be called
Explanation
C passes integers by value. inc receives a copy, increments the copy, and discards it; a in the caller stays 1. To modify the caller's object you pass a pointer (inc(int *p) with *p = *p + 1).
Question 45Programming and Software Development
After #define SQR(x) x*x the C preprocessor expands SQR(1+2). What is the value of that expanded expression?
- 3
- 5 Correct answer.
- 6
- 9
Explanation
Macros substitute text: SQR(1+2) becomes 1+2*1+2. Because * binds tighter than +, that is 1+(2*1)+2 = 5, not (1+2)×(1+2)=9. Safe macros write ((x)*(x)). This is a classic 程序员 preprocessor trap.
Question 46Programming and Software Development
int a[] = {2, 4, 6, 8, 10}; int *p = a + 4; What is p[-2] in C?
- 2
- 4
- 6 Correct answer.
- 10
Explanation
a+4 points at a[4] (value 10). p[-2] is defined as *(p-2), which is a[2], value 6. Negative subscripts are legal when the pointer still addresses an element of the same array.
Question 47Programming and Software Development
Visual Basic, listed in the 程序员 考试说明 as one allowed second language, is typically described as which kind of programming model for desktop forms?
- Event-driven: procedures run in response to user or system events such as a button click Correct answer.
- Only batch punch-card processing with no GUI
- Only kernel interrupt handlers in C
- Only SQL triggers inside a DBMS
Explanation
Classic VB teaching for 软考 presents form-based, event-driven code (Click, Load, Change). It is not limited to punch cards, OS kernels, or database triggers, even though VB can call other APIs.
Question 48Programming and Software Development
In C++ object construction for a derived class with public inheritance, which constructor order is correct?
- Derived constructor body runs fully, then the base constructor runs
- Base-class constructor runs before the derived-class constructor body Correct answer.
- Neither constructor ever runs
- Destructors run before any constructor
Explanation
C++ initializes the base subobject first, then derived members, then the derived constructor body. Destruction runs in reverse. Public inheritance models an is-a relationship required in 程序员 C++ coverage.
Question 49Programming and Software Development
int f(void) { static int n = 0; n++; return n; } What is f() + f() + f() in C?
- 0
- 3
- 6 Correct answer.
- 9
Explanation
A static local persists across calls and is initialized once. The three calls return 1, then 2, then 3, and 1+2+3=6. An automatic n would reset to 0 each time and yield 1+1+1=3.
Question 50Programming and Software Development
int a[3][2] = {{1, 2}, {3, 4}, {5, 6}}; What is a[2][0] + *(*(a + 1) + 1) in C?
- 5
- 7
- 9 Correct answer.
- 11
Explanation
a[2][0] is 5. *(a+1) points to row 1 {3,4}, so *(*(a+1)+1) is 4. 5+4=9. The expression *(*(a+1)+1) is the pointer form of a[1][1].