HomeSubjectsUniversityBlogAbout

Input / Output Handling

Topic in Programming

210 total MCQsShowing 30 with explanations10 Easy10 Medium10 Hard

About This Topic

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.

Practice Questions

Each question below shows the correct answer with a full explanation. Use these to build conceptual understanding before attempting a timed quiz.

Input / Output HandlingEasy

Q1. What does I/O stand for in programming?

  1. A.Integer or Object
  2. B.Index with Order
  3. C.Internal Operations
  4. D.Input and Output✓ Correct

Explanation

I/O stands for Input/Output, referring to communication between a program and the outside world.

Report an error in this question

Input / Output HandlingEasy

Q2. Which function is used to display output in Python?

  1. A.echo()
  2. B.write()
  3. C.print()✓ Correct
  4. D.printf()

Explanation

In Python, the print() function is used to display output to the console.

Report an error in this question

Input / Output HandlingEasy

Q3. What is standard input (stdin)?

  1. A.A persistent network data connection
  2. B.The default input source like keyboard✓ Correct
  3. C.A database for storing program data
  4. D.A file stored on the hard disk drive

Explanation

Standard input (stdin) is the default input stream, usually connected to the keyboard for reading user input.

Report an error in this question

Input / Output HandlingEasy

Q4. What is standard output (stdout)?

  1. A.The default output destination like console✓ Correct
  2. B.A database for persisting program output
  3. C.A connected printer device only
  4. D.A file stored on persistent disk storage

Explanation

Standard output (stdout) is the default output stream, usually displaying output on the console screen.

Report an error in this question

Input / Output HandlingEasy

Q5. Which function reads a line of input from the user in Python?

  1. A.input()✓ Correct
  2. B.scanf()
  3. C.getLine()
  4. D.readLine()

Explanation

In Python, the input() function reads a line of text from standard input.

Report an error in this question

Input / Output HandlingEasy

Q6. What is a newline character?

  1. A.A whitespace character for horizontal spacing
  2. B.A tab character for indenting text in documents
  3. C.A special character that moves cursor to next line✓ Correct
  4. D.A backspace character that deletes previous input

Explanation

The newline character (\n) moves the cursor to the beginning of the next line in output.

Report an error in this question

Input / Output HandlingEasy

Q7. What does printf() do in C?

  1. A.Closes an open file descriptor handle
  2. B.Formats and prints output to the console✓ Correct
  3. C.Reads input from standard input stream
  4. D.Allocates dynamic memory on the heap

Explanation

printf() in C formats a string with specified format specifiers and prints it to standard output.

Report an error in this question

Input / Output HandlingEasy

Q8. What is a format specifier?

  1. A.A variable name in source code
  2. B.A placeholder defining value display format✓ Correct
  3. C.A counter used inside loop bodies
  4. D.A file type extension on disk

Explanation

Format specifiers like %d, %s, %f indicate the type and format of data to be printed in functions like printf().

Report an error in this question

Input / Output HandlingEasy

Q9. What is console output?

  1. A.Storing structured data in a database table
  2. B.Sending formatted data to a connected printer
  3. C.Displaying information on screen or terminal✓ Correct
  4. D.Writing data to a file on disk storage

Explanation

Console output refers to displaying text and data on the screen or terminal window.

Report an error in this question

Input / Output HandlingEasy

Q10. What does Scanner class do in Java?

  1. A.Compiles Java source code into bytecode
  2. B.Reads input from various sources like keyboard✓ Correct
  3. C.Scans the system for viruses and malware
  4. D.Writes formatted output to the console

Explanation

The Scanner class in Java is used to read input from sources like keyboard (System.in), files, and strings.

Report an error in this question

Input / Output HandlingMedium

Q11. What is buffered I/O?

  1. A.I/O that applies encryption to all data before transferring
  2. B.I/O that exclusively works with pre-allocated buffer arrays
  3. C.I/O that collects data in a buffer to reduce system calls✓ Correct
  4. D.I/O operations performed without any processing delays

Explanation

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.

Report an error in this question

Input / Output HandlingMedium

Q12. What is the difference between print() and println() in Java?

  1. A.There is no difference between them at all
  2. B.print() executes faster than println() does
  3. C.println() only prints numeric values to output
  4. D.println() adds a newline; print() does not✓ Correct

Explanation

System.out.println() appends a newline after the output, while System.out.print() does not, keeping the cursor on the same line.

Report an error in this question

Input / Output HandlingMedium

Q13. What is file I/O?

  1. A.Reading from and writing to disk files✓ Correct
  2. B.Reading data from the keyboard input
  3. C.Allocating memory for program variables
  4. D.Communicating over the internet network

Explanation

File I/O involves reading data from files and writing data to files stored on persistent storage.

Report an error in this question

Input / Output HandlingMedium

Q14. What is serialization?

  1. A.Encrypting data for secure network transmission
  2. B.Sorting data in ascending or descending order
  3. C.Converting an object into a byte stream for storage✓ Correct
  4. D.Compressing files to reduce their storage size

Explanation

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.

Report an error in this question

Input / Output HandlingMedium

Q15. What does the flush() method do in I/O?

  1. A.Deletes the entire output buffer contents
  2. B.Forces buffered output to be written immediately✓ Correct
  3. C.Clears the entire console screen display
  4. D.Reads all contents from the input buffer

Explanation

flush() forces any data held in the output buffer to be written to the underlying stream immediately, without waiting for the buffer to fill.

Report an error in this question

Input / Output HandlingMedium

Q16. What is the difference between text mode and binary mode in file I/O?

  1. A.Text mode processes files faster than binary mode does
  2. B.There is no functional difference between the two modes
  3. C.Text mode translates newlines; binary reads raw bytes✓ Correct
  4. D.Binary mode is exclusively used for image file formats

Explanation

Text mode performs newline translations, while binary mode reads and writes bytes exactly as they are.

Report an error in this question

Input / Output HandlingMedium

Q17. What is standard error (stderr)?

  1. A.A specialized tool used for debugging programs
  2. B.A separate output stream for error messages only✓ Correct
  3. C.An error that occurs in the standard input stream
  4. D.It is the same stream as standard output stdout

Explanation

stderr is a separate output stream specifically for error messages, allowing errors to be redirected independently from normal output.

Report an error in this question

Input / Output HandlingMedium

Q18. What is the purpose of the 'with' statement for file I/O in Python?

  1. A.It loops through all files in a given directory
  2. B.It reads binary files into memory as byte arrays
  3. C.It writes data to multiple files simultaneously
  4. D.It ensures the file is properly closed after use✓ Correct

Explanation

The 'with' statement creates a context manager that automatically closes the file when the block exits, even if an error occurs.

Report an error in this question

Input / Output HandlingMedium

Q19. What is CSV and how is it used in I/O?

  1. A.Comma-Separated Values, a text format for tabular data✓ Correct
  2. B.A relational database management system for queries
  3. C.A compiled programming language for systems work
  4. D.A binary file format for storing structured records

Explanation

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.

Report an error in this question

Input / Output HandlingMedium

Q20. What is piping in command-line I/O?

  1. A.A specialized type of network I/O communication
  2. B.Writing output data to a physical pipe file
  3. C.Redirecting one program output as another input✓ Correct
  4. D.Processing multiple data streams in parallel mode

Explanation

Piping connects the stdout of one command to the stdin of another, enabling data to flow between programs.

Report an error in this question

Input / Output HandlingHard

Q21. What is memory-mapped I/O?

  1. A.Mapping files into virtual memory address space✓ Correct
  2. B.Encrypting all I/O data during transfer
  3. C.Storing I/O data in the processor cache
  4. D.I/O that uses only RAM for data storage

Explanation

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.

Report an error in this question

Input / Output HandlingHard

Q22. What is the difference between blocking and non-blocking I/O?

  1. A.Non-blocking I/O is always slower than blocking I/O overall
  2. B.There is no meaningful difference between the two modes
  3. C.Blocking I/O never waits for the operation to finish first
  4. D.Blocking waits until completion; non-blocking returns immediately✓ Correct

Explanation

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.

Report an error in this question

Input / Output HandlingHard

Q23. What is asynchronous I/O?

  1. A.I/O that continues without waiting, notified on completion✓ Correct
  2. B.I/O that is identical to synchronous blocking I/O
  3. C.I/O operations that execute in strict sequential order
  4. D.I/O operations that are always extremely fast

Explanation

Asynchronous I/O initiates an operation and continues executing; the program is notified when the operation completes.

Report an error in this question

Input / Output HandlingHard

Q24. What is the purpose of the select() system call?

  1. A.Selecting a record from a database table query
  2. B.Selecting files to delete from the file system
  3. C.Monitoring file descriptors for I/O readiness✓ Correct
  4. D.Choosing which thread the scheduler should run

Explanation

select() allows a program to monitor multiple file descriptors simultaneously, waiting until one or more become ready for reading, writing, or have errors.

Report an error in this question

Input / Output HandlingHard

Q25. What is zero-copy I/O?

  1. A.I/O operations that have zero financial cost
  2. B.I/O operations that transfer no data at all
  3. C.Deleting data as it is being transferred out
  4. D.Transferring data without copying between buffers✓ Correct

Explanation

Zero-copy I/O transfers data directly between kernel buffer and the destination without intermediate copies to user space, improving performance.

Report an error in this question

Input / Output HandlingHard

Q26. What is the reactor pattern in I/O?

  1. A.A nuclear-physics computing simulation pattern
  2. B.An event-driven dispatcher that demultiplexes I/O events✓ Correct
  3. C.A chemical reaction simulation programming model
  4. D.A simple loop-based sequential processing pattern

Explanation

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.

Report an error in this question

Input / Output HandlingHard

Q27. What are I/O multiplexing mechanisms like epoll and kqueue?

  1. A.Command-line utilities designed for copying files efficiently
  2. B.Multi-threaded I/O libraries for parallel data processing
  3. C.Mechanisms that duplicate I/O devices for redundancy
  4. D.Scalable kernel interfaces for monitoring many file descriptors✓ Correct

Explanation

epoll (Linux) and kqueue (BSD) are efficient kernel mechanisms for monitoring large numbers of file descriptors, overcoming the scalability limits of select().

Report an error in this question

Input / Output HandlingHard

Q28. What is the difference between character devices and block devices?

  1. A.Character devices transfer byte by byte; block in fixed chunks✓ Correct
  2. B.Block devices are exclusively used for text file operations
  3. C.There is no functional difference between device types
  4. D.Character devices are always faster than block-based devices

Explanation

Character devices handle data one byte at a time, while block devices handle data in fixed-size blocks with buffering.

Report an error in this question

Input / Output HandlingHard

Q29. What is Direct Memory Access (DMA) in the context of I/O?

  1. A.Hardware allowing device-to-memory transfer without CPU✓ Correct
  2. B.A software programming technique for data transfer
  3. C.A debugging method for diagnosing hardware I/O issues
  4. D.A specialized type of dynamic memory allocation method

Explanation

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.

Report an error in this question

Input / Output HandlingHard

Q30. What is scatter-gather I/O (vectored I/O)?

  1. A.Reading/writing multiple non-contiguous buffers at once✓ Correct
  2. B.Distributing I/O operations across network nodes
  3. C.Random I/O patterns across scattered disk sectors
  4. D.Fragmented file storage across multiple disk drives

Explanation

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.

Report an error in this question

Ready to test yourself on Input / Output Handling?

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