Q1. What does I/O stand for in programming?
- A.Integer or Object
- B.Index with Order
- C.Internal Operations
- D.Input and Output✓ Correct
Explanation
I/O stands for Input/Output, referring to communication between a program and the outside world.
Topic in Programming
Input/output handling covers how a program receives data from users, files, devices or networks and writes results back through streams and files. Basic MCQs check print and input functions, readline(), file modes such as read, write and append, and closing files safely with Python's with statement or try-with-resources. You should understand buffering and flushing, text versus binary files, seek operations for random access, and why all input needs validation. Systems-level questions compare blocking and non-blocking I/O, memory-mapped files, the Linux O_DIRECT flag, and readiness-based epoll against completion-based Windows IOCP for asynchronous I/O.
Below are 30 practice questions from a pool of 210 Input / Output Handling MCQs, one of 16 topics in Programming. Each shows the correct answer with an explanation; when you are ready, take a timed quiz to test recall under exam conditions.
Each question below shows the correct answer with a full explanation. Use these to build conceptual understanding before attempting a timed quiz.
Q1. What does I/O stand for in programming?
I/O stands for Input/Output, referring to communication between a program and the outside world.
Q2. Which function is used to display output in Python?
In Python, the print() function is used to display output to the console.
Q3. What is standard input (stdin)?
Standard input (stdin) is the default input stream, usually connected to the keyboard for reading user input.
Q4. What is standard output (stdout)?
Standard output (stdout) is the default output stream, usually displaying output on the console screen.
Q5. Which function reads a line of input from the user in Python?
In Python, the input() function reads a line of text from standard input.
Q6. What is a newline character?
The newline character (\n) moves the cursor to the beginning of the next line in output.
Q7. What does printf() do in C?
printf() in C formats a string with specified format specifiers and prints it to standard output.
Q8. What is a format specifier?
Format specifiers like %d, %s, %f indicate the type and format of data to be printed in functions like printf().
Q9. What is console output?
Console output refers to displaying text and data on the screen or terminal window.
Q10. What does Scanner class do in Java?
The Scanner class in Java is used to read input from sources like keyboard (System.in), files, and strings.
Q11. What is buffered I/O?
Buffered I/O accumulates data in a memory buffer and performs actual I/O operations in larger chunks, reducing the overhead of frequent system calls.
Q12. What is the difference between print() and println() in Java?
System.out.println() appends a newline after the output, while System.out.print() does not, keeping the cursor on the same line.
Q13. What is file I/O?
File I/O involves reading data from files and writing data to files stored on persistent storage.
Q14. What is serialization?
Serialization converts an object's state into a byte stream that can be stored in a file or sent over a network, and later deserialized back.
Q15. What does the flush() method do in I/O?
flush() forces any data held in the output buffer to be written to the underlying stream immediately, without waiting for the buffer to fill.
Q16. What is the difference between text mode and binary mode in file I/O?
Text mode performs newline translations, while binary mode reads and writes bytes exactly as they are.
Q17. What is standard error (stderr)?
stderr is a separate output stream specifically for error messages, allowing errors to be redirected independently from normal output.
Q18. What is the purpose of the 'with' statement for file I/O in Python?
The 'with' statement creates a context manager that automatically closes the file when the block exits, even if an error occurs.
Q19. What is CSV and how is it used in I/O?
CSV (Comma-Separated Values) is a simple text format where each line is a record and fields are separated by commas, commonly used for data exchange.
Q20. What is piping in command-line I/O?
Piping connects the stdout of one command to the stdin of another, enabling data to flow between programs.
Q21. What is memory-mapped I/O?
Memory-mapped I/O maps files or devices into a process's virtual address space, allowing file access through memory read/write operations instead of explicit I/O calls.
Q22. What is the difference between blocking and non-blocking I/O?
Blocking I/O suspends the thread until the operation finishes, while non-blocking I/O returns immediately, allowing the program to continue and check results later.
Q23. What is asynchronous I/O?
Asynchronous I/O initiates an operation and continues executing; the program is notified when the operation completes.
Q24. What is the purpose of the select() system call?
select() allows a program to monitor multiple file descriptors simultaneously, waiting until one or more become ready for reading, writing, or have errors.
Q25. What is zero-copy I/O?
Zero-copy I/O transfers data directly between kernel buffer and the destination without intermediate copies to user space, improving performance.
Q26. What is the reactor pattern in I/O?
The reactor pattern uses an event loop to demultiplex I/O events from multiple sources and dispatch them to appropriate event handlers, as used in Node.js.
Q27. What are I/O multiplexing mechanisms like epoll and kqueue?
epoll (Linux) and kqueue (BSD) are efficient kernel mechanisms for monitoring large numbers of file descriptors, overcoming the scalability limits of select().
Q28. What is the difference between character devices and block devices?
Character devices handle data one byte at a time, while block devices handle data in fixed-size blocks with buffering.
Q29. What is Direct Memory Access (DMA) in the context of I/O?
DMA enables hardware devices to transfer data directly to/from main memory without CPU involvement, freeing the CPU for other tasks during I/O operations.
Q30. What is scatter-gather I/O (vectored I/O)?
Scatter-gather I/O uses readv/writev to perform I/O with multiple buffers in one system call, avoiding the need to concatenate buffers or make multiple calls.
Practice MCQs with explanations
Practice MCQs with explanations
Practice MCQs with explanations
Practice MCQs with explanations
Practice MCQs with explanations
Practice MCQs with explanations
Take a timed quiz drawn from 210+ questions on this topic. No signup required — your progress saves in your browser.
Start Input / Output Handling Quiz