Cpos MCQ Bank
Cpos MCQ Bank
Concept Of Programming
2. Which component is responsible for compiling Java source code into bytecode?
a) JDK (Java Development Kit)
b) JRE (Java Runtime Environment)
c) JVM (Java Virtual Machine)
d) Eclipse IDE (Integrated Development Environment)
Answer: a) JDK (Java Development Kit)
4. Which component of the Java development environment is required to run Java applications on your
system?
a) JDK (Java Development Kit)
b) JRE (Java Runtime Environment)
c) JVM (Java Virtual Machine)
d) Eclipse IDE (Integrated Development Environment)
Answer: b) JRE (Java Runtime Environment)
6. Which Java development component contains the tools necessary for Java application development,
including the compiler?
a) JRE (Java Runtime Environment)
b) JVM (Java Virtual Machine)
c) JDK (Java Development Kit)
d) Eclipse IDE (Integrated Development Environment)
Answer: c) JDK (Java Development Kit)
8. Which component of the Java development environment is responsible for interpreting and
executing Java bytecode?
a) JRE (Java Runtime Environment)
b) JVM (Java Virtual Machine)
c) JDK (Java Development Kit)
d) Eclipse IDE (Integrated Development Environment)
Answer: b) JVM (Java Virtual Machine)
9. What is the minimum requirement for setting up the Java development environment?
a) JRE (Java Runtime Environment)
b) JDK (Java Development Kit)
c) JVM (Java Virtual Machine)
d) Eclipse IDE (Integrated Development Environment)
Answer: b) JDK (Java Development Kit)
10. Which component of the Java development environment provides a graphical user interface for
Java programming?
a) JRE (Java Runtime Environment)
b) JDK (Java Development Kit)
c) JVM (Java Virtual Machine)
d) Eclipse IDE (Integrated Development Environment)
Answer: d) Eclipse IDE (Integrated Development Environment)
2. Which access modifier is commonly used for the `main()` method in Java?
a) public
b) private
c) protected
d) static
Answer: public
2. How many bytes does the `double` data type occupy in memory in Java?
a) 4 bytes
b) 8 bytes
c) 16 bytes
d) It varies depending on the platform.
Answer: b) 8 bytes
4. What is the default value of the `int` data type in Java if it is not explicitly initialized?
a) 0
b) 0.0
c) null
d) It does not have a default value.
Answer: a) 0
2. What is the result of the following expression: `int a = 10; double b = 3.5; double c = a + b;` ?
a) 13
b) 13.0
c) Compilation error
d) Runtime exception
Answer: b) 13.0
3. What is the process of converting a data type of higher range to a data type of lower range called in
Java?
a) Upcasting
b) Downcasting
c) Typecasting
d) Narrowing
Answer: d) Narrowing
4. What is the correct way to cast a double variable `d` to an int in Java?
a) int result = (int)d;
b) int result = int(d);
c) int result = convertToInt(d);
d) int result = int(d);
Answer: a) int result = (int)d;
5. What happens if you try to cast a value that is too large for the target data type?
a) The value is automatically rounded to the nearest integer.
b) The compiler will automatically perform the necessary conversion.
c) The value will be truncated, and the result may be incorrect.
d) Java does not allow casting of values that are too large.
Answer: c) The value will be truncated, and the result may be incorrect.
1. Can a static method in one class access a static variable in another class directly?
a) Yes
b) No
c) Only if both classes are in the same package
d) Only if the method is declared as private
Answer: a) Yes
1. What does the `final` keyword signify when used with variables in Java?
a) The variable cannot be modified once it is assigned a value.
b) The variable cannot be accessed from outside the class.
c) The variable cannot be declared in any other class.
d) The variable cannot be declared inside a static method.
Answer: a) The variable cannot be modified once it is assigned a value.
4. In Java, can a `final` variable have different values for different instances of the same class?
a) Yes
b) No
c) Only if the variable is marked as private
d) Only if the variable is marked as static
Answer: a) Yes
3. Operators
**1. Arithmetic Operator**
2. Which arithmetic operator is used for division in Java, resulting in an integer quotient?
a) /
b) %
c) *
d) //
Answer: a) /
4. Which relational operator checks if one value is greater than another in Java?
a) >
b) <
c) >=
d) <=
Answer: a) >
3. Can the ternary operator be used as a replacement for if-else statements in Java?
a) Yes, in all cases
b) No, the ternary operator can only be used with boolean expressions
c) No, the ternary operator can only be used with integer expressions
d) Yes, but only for simple conditions
Answer: a) Yes, in all cases
4. Can the assignment operator be used to assign values to multiple variables simultaneously in Java?
a) Yes, using commas to separate the variables.
b) Yes, using semicolons to separate the variables.
c) No, the assignment operator can only assign a value to one variable at a time.
d) No, multiple assignments are not allowed in Java.
Answer: a) Yes, using commas to separate the variables.
5. What is the result of the expression `x = y = 10;` in Java, assuming both x and y are integer variables?
a) x and y are assigned the value 10.
b) x and y are compared for equality.
c) Compilation error due to incorrect syntax.
d) The expression is invalid and will throw a runtime error.
Answer: a) x and y are assigned the value 10.
2. What is the difference between "if" and "else if" statements in Java?
a) "else if" can only be used after an "if" statement.
b) "if" can only be used after an "else if" statement.
c) "else if" can be used independently without an "if" statement.
d) There is no difference; they are the same in functionality.
Answer: c) "else if" can be used independently without an "if" statement.
1. In a "for" loop, where is the initialization of the loop variable usually performed?
a) Before the loop starts
b) At the end of the loop
c) At the middle of the loop
d) It can be done anywhere inside the loop.
Answer: a) Before the loop starts
3. How many expressions can be used in the initialization part of a "for" loop?
a) One
b) Two
c) Three
d) It varies depending on the loop requirement.
Answer: c) Three
5. How can you exit a "for" loop prematurely before its natural termination?
a) Using the "break" statement
b) Using the "continue" statement
c) Using the "exit" keyword
d) It is not possible to exit a "for" loop prematurely.
Answer: a) Using the "break" statement
3. What is the difference between the "while" loop and the "for" loop in Java?
a) The "while" loop requires an initialization statement.
b) The "while" loop allows only
1. What is the main difference between a "do-while" loop and a "while" loop in Java?
a) The "do-while" loop has a loop variable, while the "while" loop does not.
b) The "do-while" loop executes the loop body at least once, while the "while" loop may not execute
at all.
c) The "do-while" loop does not support a loop condition, while the "while" loop does.
d) The "do-while" loop does not allow an update statement, while the "while" loop does.
Answer: b) The "do-while" loop executes the loop body at least once, while the "while" loop may not
execute at all.
4. How many times will a "do-while" loop execute its loop body if the loop condition is initially false?
a) Zero times
b) One time
c) Infinitely
d) It depends on the update statement.
Answer: a) Zero times
5. What is the advantage of using a "do-while" loop over a "while" loop in Java?
a) "do-while" loops are more efficient in terms of execution speed.
b) "do-while" loops are easier to read and understand.
c) "do-while" loops always execute the loop body at least once.
d) "do-while" loops support multiple loop variables.
Answer: c) "do-while" loops always execute the loop body at least once.
**6. Recursion**
3. What is the advantage of using recursion over iterative approaches in some cases?
a) Recursion always results in faster execution.
b) Recursion uses less memory compared to iterative approaches.
c) Recursion is easier to implement and debug.
d) Recursion can lead to simpler and cleaner code for certain problems.
Answer: d) Recursion can lead to simpler and cleaner code for certain problems.
4. In Java, can a recursive method call other methods within its body?
a) Yes, but only if the other methods are also recursive.
b) Yes, recursive methods can call any other methods.
c) No, recursive methods cannot call any other methods.
d) Only if the other methods are declared as static.
Answer: b) Yes, recursive methods can call any other methods.
5. Lecture: Objects
**1. Reference variables and methods**
3. What is the main difference between a static method and an instance method in Java?
a) A static method cannot access instance variables, while an instance method can.
b) A static method cannot be overridden, while an instance method can.
c) A static method can only be called on objects, while an instance method can be called on the class
directly.
d) There is no difference; they can be used interchangeably.
Answer: a) A static method cannot access instance variables, while an instance method can.
4. Can multiple objects of the same class have different values for an instance member reference
variable?
a) Yes, the value of an instance member reference variable is unique for each object.
b) No, all objects of the same class share the same value for an instance member reference variable.
c) Yes, but only if the variable is declared as "final".
d) No, instance member reference variables cannot have different values for different objects.
Answer: a) Yes, the value of an instance member reference variable is unique for each object.
5. How is an instance member reference variable different from a static variable in Java?
a) An instance member reference variable can only be accessed using the class name.
b) An instance member reference variable can be accessed globally without creating an object.
c) An instance member reference variable is unique for each object, while a static variable is shared
among all objects of the class.
d) An instance member reference variable cannot be used as a method argument.
Answer: c) An instance member reference variable is unique for each object, while a static variable is
shared among all objects of the class.
4. What happens when you concatenate two String objects in Java using the "+" operator?
a) The two objects are added together as numbers.
b) A compile-time error occurs.
c) The two objects are joined to form a new String object.
d) The two objects are compared for equality.
Answer: c) The two objects are joined to form a new String object.
5. What is the purpose of the "length" method of the String class in Java?
a) To get the number of characters in the string.
b) To get the number of words in the string.
c) To get the memory address of the string.
d) To get the maximum size of the string.
Answer: a) To get the number of characters in the string.
6. Lecture: Arrays
**1. Initializing an Array in Java**
2. What happens if you try to access an array element that is out of bounds in Java?
a) The program will throw a compile-time error.
b) The program will throw a runtime exception (ArrayIndexOutOfBoundsException).
c) The program will silently ignore the incorrect access.
d) The program will automatically resize the array to accommodate the access.
Answer: b) The program will throw a runtime exception (ArrayIndexOutOfBoundsException).
4. What is the default initial value for elements in an integer array in Java?
a) 0
b) 1
c) -1
d) null
Answer: a) 0
4. What is the number of rows and columns in the following two-dimensional array declaration?
int[][] arr = new int[4][2];
a) 2 rows, 4 columns
b) 4 rows, 2 columns
c) 4 rows, 4 columns
d) 2 rows, 2 columns
Answer: b) 4 rows, 2 columns
3. How can you access the variable arguments inside the method body?
a) By using the "args" keyword directly.
b) By accessing the arguments as an array using the "args" parameter name.
c) By using the "params" keyword inside the method body.
d) By passing the arguments individually to a separate method.
Answer: b) By accessing the arguments as an array using the "args" parameter name.
4. Can a Java method have other parameters along with variable arguments?
a) No, a method can only have either regular parameters or variable arguments, not both.
b) Yes, a method can have both regular parameters and variable arguments.
c) Yes, but only if the variable arguments are declared as "final."
d) No, variable arguments must be the only parameters in a method.
Answer: b) Yes, a method can have both regular parameters and variable arguments.
4. What happens if you try to read an element from an array using an index that is out of bounds?
a) The program will throw a runtime exception (ArrayIndexOutOfBoundsException).
b) The program will throw a compile-time error.
c) The program will return null for reference type elements or 0 for primitive type elements.
d) The program will automatically resize the array to accommodate the access.
Answer: a) The program will throw a runtime exception (ArrayIndexOutOfBoundsException).
2. What is the time complexity of the quicksort algorithm used by the "sort" method in Java?
a) O(n)
b) O(n log n)
c) O(n^2)
d) O(log n)
Answer: b) O(n log n)
4. What is the time complexity of the linear search algorithm used to find an element in an array?
a) O(n)
b) O(n log n)
c) O(n^2)
d) O(log n)
Answer: a) O(n)
1. How can you convert a Java String array to a single String with elements separated by a delimiter?
a) By using the "convertToString" method provided by the String class.
b) By using the "join" method provided by the Arrays class.
c) By using the "toString" method provided by the String class.
d) By manually concatenating each element with the delimiter.
Answer: b) By using the "join" method provided by the Arrays class.
2. What is the purpose of using a delimiter when converting a String array to a single String?
a) Delimiters are used to specify the length of the resulting String.
b) Delimiters are used to indicate the start and end of the String.
c) Delimiters are used to separate individual elements in the resulting String.
d) Delimiters are used to specify the data type of the elements in the array.
Answer: c) Delimiters are used to separate individual elements in the resulting String.
3. Which character(s) can be used as a delimiter in the "join" method for a String array?
a) Only commas (,)
b) Only spaces ( )
c) Any character or sequence of characters
d) Only semicolons (;)
Answer: c) Any character or sequence of characters
4. If a String array contains elements ["apple", "banana", "orange"], and the delimiter is "-", what will
be the resulting String?
a) "apple-banana-orange"
b) "apple,banana,orange"
c) "applebananaorange"
d) "apple/banana/orange"
Answer: a) "apple-banana-orange"
5. Can you specify an empty delimiter when using the "join" method on a String array?
a) No, the delimiter must always be a non-empty character or sequence.
b) Yes, an empty delimiter is allowed and will result in no separation between elements.
c) Yes, but only if the array is empty as well.
d) No, the "join" method does not allow delimiters for String arrays.
Answer: b) Yes, an empty delimiter is allowed and will result in no separation between elements.
2. When using the "copyOf" method to copy an array, do both arrays have the same memory address?
a) Yes, they both point to the same memory location.
b) No, the copied array is a shallow copy with a different memory address.
c) No, the copied array is a deep copy with a different memory address.
d) Yes, but only if the copied array is smaller in size than the original array.
Answer: b) No, the copied array is a shallow copy with a different memory address.
3. What happens if the "copyOf" method is used with a negative length parameter?
a) The method will throw a compile-time error.
b) The method will throw a runtime exception (NegativeArraySizeException).
c) The method will create an empty array with a length of 0.
d) The method will create an array with the absolute value of the length parameter.
Answer: b) The method will throw a runtime exception (NegativeArraySizeException).
5. What is the main difference between a shallow copy and a deep copy of an array in Java?
a) A shallow copy maintains the same memory address for both arrays, while a deep copy creates a
new memory address for the copied array.
b) A shallow copy creates a new array with the same elements as the original array, while a deep
copy creates an empty array.
c) A shallow copy duplicates the original array, while a deep copy only duplicates the elements.
d) There is no difference; both terms refer to the same process of copying arrays.
Answer: a) A shallow copy maintains the same memory address for both arrays, while a deep copy
creates a new memory address for the copied array.
Concepts of Operating System
1. Lecture: Introduction to OS
**1. What is OS; How is it different from other application software; Why is it hardware dependent**
6. What is the role of the BIOS (Basic Input/Output System) in computer organization for the OS?
a) It manages the computer's internal memory and ensures efficient data storage.
b) It provides a user-friendly interface for interacting with the OS.
c) It initializes hardware components and boots the operating system during startup.
d) It performs arithmetic and logical operations for the OS.
Answer: c) It initializes hardware components and boots the operating system during startup.
7. Which component of the OS is responsible for managing the execution of multiple processes and
allocating CPU time to each process?
a) File System
b) CPU Scheduler
c) Device Manager
d) Memory Allocator
Answer: b) CPU Scheduler
2. Which component of the OS is responsible for managing memory and ensuring efficient memory
allocation to processes?
a) File System
b) Memory Manager
c) CPU Scheduler
d) Device Manager
Answer: b) Memory Manager
4. Which component of the OS is responsible for controlling and coordinating the activities of
hardware devices?
a) File System
b) CPU Scheduler
c) Device Manager
d) Memory Allocator
Answer: c) Device Manager
1. What is the role of the BIOS (Basic Input/Output System) in computer organization for the OS?
a) It manages the computer's internal memory and ensures efficient data storage.
b) It provides a user-friendly interface for interacting with the OS.
c) It initializes hardware components and boots the operating system during startup.
d) It performs arithmetic and logical operations for the OS.
Answer: c) It initializes hardware components and boots the operating system during startup.
2. What is the purpose of the Central Processing Unit (CPU) in computer organization for the OS?
a) To store data and programs permanently.
b) To manage and execute instructions stored in the computer's memory.
c) To provide a visual display of the OS interface on the screen.
d) To connect the computer to external devices like printers and scanners.
Answer: b) To manage and execute instructions stored in the computer's memory.
5. What is the purpose of the motherboard in computer organization for the OS?
a) To manage the computer's internal memory and ensure efficient data storage.
b) To provide a user-friendly interface for interacting with the OS.
c) To connect the computer's hardware components and facilitate communication between them.
d) To perform arithmetic and logical operations for the OS.
Answer: c) To connect the computer's hardware components and facilitate communication between
them.
6. Which of the following components of a computer system is responsible for long-term storage of
data and programs?
a) CPU (Central Processing
Unit)
b) RAM (Random Access Memory)
c) Hard Disk Drive (HDD)
d) Motherboard
Answer: c) Hard Disk Drive (HDD)
7. What is the role of the Random Access Memory (RAM) in computer organization for the OS?
a) To store data and programs permanently.
b) To manage and execute instructions stored in the computer's memory.
c) To provide a visual display of the OS interface on the screen.
d) To connect the computer to external devices like printers and scanners.
Answer: b) To manage and execute instructions stored in the computer's memory.
**4. Examples of well-known OS including mobile OS, embedded system OS, Real Time OS, desktop
OS, server machine OS, etc.; How are these different from each other and why**
3. What is the main difference between a Real-Time Operating System (RTOS) and a desktop
operating system?
a) RTOS is designed for real-time data processing, while desktop OS is not.
b) Desktop OS is used in embedded systems, while RTOS is used in personal computers.
c) RTOS is designed for running desktop applications, while desktop OS is designed for real-time
processing.
d) Desktop OS is a type of RTOS designed specifically for graphics-intensive applications.
Answer: a) RTOS is designed for real-time data processing, while desktop OS is not.
4. How is a server machine operating system different from a desktop operating system?
a) Server OS is designed for real-time data processing, while desktop OS is not.
b) Server OS is optimized for managing network resources and handling multiple requests, while
desktop OS is optimized for individual user tasks.
c) Server OS is used only in data centers, while desktop OS is used on personal computers.
d) Server OS is open-source, while desktop OS is proprietary.
Answer: b) Server OS is optimized for managing network resources and handling multiple requests,
while desktop OS is optimized for individual user tasks.
6. What is the main difference between a mobile operating system and a desktop operating system?
a) Mobile OS is designed for real-time data processing, while desktop OS is not.
b) Mobile OS is optimized for touch-screen devices, while desktop OS is optimized for mouse and
keyboard input.
c) Mobile OS is used in servers, while desktop OS is used on personal computers.
d) Mobile OS is open-source, while desktop OS is proprietary.
Answer: b) Mobile OS is optimized for touch-screen devices, while desktop OS is optimized for
mouse and keyboard input.
8. Which of the following operating systems is commonly used in servers to manage network resources
and handle multiple requests?
a) Android
b) Windows
c) macOS
d) Linux
Answer: d) Linux
**5. Functions of OS**
3. Which function of the Operating System ensures fair and efficient utilization of the CPU among
multiple processes?
a) Memory Management
b) File Management
c) CPU Scheduling
d) Device Management
Answer: c) CPU Scheduling
5. What function of the Operating System handles the communication and data transfer between the
computer and external devices like printers and scanners?
a) CPU Scheduling
b) Memory Management
c) File Management
d) Device Management
Answer: d) Device Management
6. Which function of the Operating System is responsible for allocating and deallocating memory for
processes to ensure efficient memory utilization?
a) Memory Management
b) CPU Scheduling
c) File Management
d) Device Management
Answer: a) Memory Management
8. Which of the following functions of the Operating System is responsible for handling user requests
and providing a graphical user interface?
a) Memory Management
b) CPU Scheduling
c) File Management
d) User Interface
Answer: d) User Interface
**6. User and Kernel space and mode; Interrupts and system calls**
2. In which mode does the CPU execute the user applications and non-privileged code in the Operating
System?
a) User mode
b) Kernel mode
c) Real mode
d) Protected mode
3. In which mode does the CPU execute the core operating system functions and privileged instructions?
a) User mode
b) Kernel mode
c) Real mode
d) Protected mode
Answer: b) Kernel mode
4. Which of the following is responsible for switching the CPU between User mode and Kernel mode?
a) System calls
b) Interrupts
c) CPU scheduler
d) Device drivers
Answer: a) System calls
6. Which of the following is used by the CPU to handle hardware interrupts and perform context
switches?
a) System calls
b) CPU scheduler
c) Interrupt controller
d) Device drivers
Answer: c) Interrupt controller
2. Which of the following is NOT a basic operation supported by the file system?
a) Create
b) Modify
c) Move
d) Print
Answer: d) Print
5. Which file system feature helps prevent data loss by keeping track of data changes before they are
permanently written to disk?
a) File encryption
b) File compression
c) Journaling
d) File indexing
Answer: c) Journaling
**2. Commands associated with files/directories & other basic commands. Operators like redirection,
pipe**
1. What is the purpose of the ">" operator in the context of command-line redirection?
a) It redirects the input of a command from a file.
b) It redirects the output of a command to a new file, overwriting the file if it exists.
c) It redirects the output of a command to a new file, appending the output if the file exists.
d) It combines the output of multiple commands into a single file.
Answer: b) It redirects the output of a command to a new file, overwriting the file if it exists.
d) touch filename
Answer: d) touch filename
4. How can you change file permissions in Linux/Unix using the "chmod" command?
a) chmod new_permissions file_name
b) chmod file_name new_permissions
c) chmod permissions new_file_name
d) chmod file_name permissions
Answer: a) chmod new_permissions file_name
6. How are file permissions displayed when using the "ls -l" command in Linux/Unix?
a) A series of numbers representing the permissions.
b) A combination of letters (r, w, x) representing the permissions.
c) A series of dashes and letters (r, w, x) representing the permissions.
d) A series of symbols (+, -, =) representing the permissions.
Answer: c) A series of dashes and letters (r, w, x) representing the permissions.
8. How can you set the read and write permissions for the owner of a file in Linux/Unix using the
"chmod" command?
a) chmod rw file_name
b) chmod u+rw file_name
c) chmod +rw file_name
d) chmod u=rw file_name
Answer: b) chmod u+rw file_name
**4. Permissions (chmod, chown, etc); access control list; network commands (telnet, ftp, ssh, sftp,
finger)**
5. How can you grant read and write permissions to the owner and the group for a file named "data.txt"
in Linux/Unix?
a) chmod u+rw,g+rw data.txt
b) chmod ug+rw data.txt
c) chmod u=rw,g=rw data.txt
d) chmod rw,grw data.txt
Answer: a) chmod u+rw,g+rw data.txt
7. Which network command is used for secure remote login and execution of commands in Linux/Unix?
a) telnet
b) ftp
c) ssh
d) finger
Answer: c) ssh
**5. System variables like – PS1, PS2, etc. How to set them**
2. Which system variable is used to define the primary command prompt in the Linux/Unix shell?
a) PS1
b) PS2
c) PS3
d) PS4
Answer: a) PS1
4. Which command is used to view the current values of system variables in Linux/Unix?
a) env
b) ls
c) set
d) echo
Answer: a) env
5. How can you set the value of a system variable like "PS1" in Linux/Unix?
a) Using the "export" command followed by the variable name and its value.
b) By modifying the system configuration file.
c) By creating a new user account with the desired variable settings.
d) By running the "source" command followed by the variable name and its value.
Answer: a) Using the "export" command followed by the variable name and its value.
7. Which system variable is used to define the prompt used by the shell when reading a line with the
"read" command?
a) PS1
b) PS2
c) PS3
d) PS4
Answer: c) PS3
8. How can you set the value of a system variable like "PS2" permanently in Linux/Unix?
a) By modifying the system configuration file.
b) By running the "export" command followed by the variable name and its value.
c) By creating a new user account with the desired variable settings.
d) By using the "unset" command to remove the current value of the variable.
Answer: a) By modifying the system configuration file.
3. Shell Programming
4. Which shell is known for its enhanced features and improved command-line editing capabilities?
a) Bash
b) Csh
c) Zsh
d) Ksh
Answer: c) Zsh
6. Which shell is designed to be compatible with the Bourne shell (sh) and includes additional features?
a) Bash
b) Csh
c) Zsh
d) Ksh
Answer: a) Bash
8. Which shell is considered a C-like shell and was developed as an alternative to the Bourne shell?
a) Bash
b) Csh
c) Zsh
d) Ksh
Answer: b) Csh
9. How can you switch to a different shell in a Linux terminal?
a) Run the "shell" command and specify the desired shell name.
b) Modify the system configuration file to set the default shell.
c) Install the new shell using the package manager and then restart the terminal.
d) Use the "chsh" command to change the default shell for the current user.
Answer: d) Use the "chsh" command to change the default shell for the current user.
4. Which symbol is used as a wildcard to represent any character in Linux/Unix shell commands?
a) *
b) #
c) !
d) @
Answer: a) *
5. What does the wildcard symbol "?" represent in Linux/Unix shell commands?
a) It represents zero or more characters.
b) It represents one or more characters.
c) It represents any single character.
d) It represents the current user's home directory.
Answer: c) It represents any single character.
6. Which wildcard symbol is used to match any sequence of characters, including none?
a) ?
b) *
c) !
d) @
Answer: b) *
8. What is the purpose of the wildcard symbol "[" in Linux/Unix shell commands?
a) It represents any single character.
b) It is used to enclose command options.
c) It is used to enclose command arguments.
d) It is used to define a character range for matching.
Answer: d) It is used to define a character range for matching.
2. Which meta character is used to redirect the output of a command to a file in Linux/Unix?
a) >
b) &
c) |
d) $
Answer: a) >
shell script?
a) input
b) read
c) user
d) fetch
Answer: b) read
8. Which meta character is used to pipe the output of one command as input to another command in
Linux/Unix?
a) >
b) <
c) |
d) &
Answer: c) |
**4. Decision loops (if else, test, nested if else, case controls, while...until, for)**
1. Which control structure allows a program to execute a set of statements repeatedly as long as a
certain condition is true?
a) if else loop
b) while loop
c) nested loop
d) for loop
Answer: b) while loop
2. What is the purpose of the "else" statement in the if-else control structure?
a) It allows the program to execute a set of statements repeatedly.
b) It allows the program to perform different actions based on a condition.
c) It specifies the condition to be tested in the loop.
d) It executes a set of statements if the condition in the "if" part is false.
Answer: d) It executes a set of statements if the condition in the "if" part is false.
4. Which control structure is used to perform different actions based on the value of a variable or an
expression?
a) if else loop
b) test control
c) nested if else
d) case control
Answer: d) case control
6. Which control structure is used to execute a set of statements repeatedly until a certain condition
becomes true?
a) while loop
b) until loop
c) for loop
d) nested loop
Answer: b) until loop
7. How many times will a "for" loop iterate if the loop condition is false initially?
a) Zero times
b) One time
c) Infinite times
d) It depends on the loop body statements.
Answer: a) Zero times
4. Which type of process scheduling allows processes to be interrupted and moved between the running
and ready state?
a) Preemptive process scheduling
b) Non-preemptive process scheduling
c) Priority-based process scheduling
d) Round-robin process scheduling
Answer: a) Preemptive process scheduling
5. What is the main advantage of preemptive process scheduling over non-preemptive scheduling?
a) It allows for a higher degree of parallelism.
b) It reduces context switching overhead.
c) It provides fairness among all processes.
d) It allows for better response time in a multi-programmed environment.
Answer: d) It allows for better response time in a multi-programmed environment.
7. What happens to a process that is in the running state when it gets preempted?
a) It moves to the waiting state.
b) It moves to the ready state.
c) It moves to the terminated state.
d) It moves to the new state.
Answer: b) It moves to the ready state.
2. In the process life cycle, which state represents a process that has been created but not yet admitted
to the main memory?
a) New state
b) Ready state
c) Running state
d) Terminated state
Answer: a) New state
3. Which state in the process life cycle represents a process that is currently executing on the CPU?
a) New state
b) Ready state
c) Running state
d) Terminated state
Answer: c) Running state
4. What happens to a process in the ready state when it gets selected by the scheduler to run on the
CPU?
a) It moves to the new state.
b) It moves to the waiting state.
c) It moves to the running state.
d) It moves to the terminated state.
Answer: c) It moves to the running state.
5. In the process life cycle, what does the terminated state represent?
a) The process has completed its execution successfully.
b) The process has encountered an error and terminated prematurely.
c) The process is waiting for an event to occur.
d) The process is waiting for a resource to be released.
Answer: a) The process has completed its execution successfully.
6. How does a process in the waiting state move to the ready state?
a) When its time slice expires in a round-robin scheduling algorithm.
b) When it is preempted by a higher-priority process.
c) When it completes its execution.
d) When the event it is waiting for occurs.
Answer: d) When the event it is waiting for occurs.
7. What is the main purpose of the process life cycle in an operating system?
a) To ensure that all processes get an equal share of CPU time.
b) To manage the creation and termination of processes efficiently.
c) To allow processes to communicate with each other.
d) To prevent processes from entering the waiting state.
Answer: b) To manage the creation and termination of processes efficiently.
**3. What are schedulers – Short term, Medium term and Long term.**
1. What is the role of the short-term scheduler (CPU scheduler) in the process scheduling hierarchy?
a) It selects processes from the job queue to be loaded into main memory.
b) It selects processes from the ready queue to run on the CPU.
c) It selects processes from the blocked queue to be moved to the ready queue.
d) It selects processes from the new queue to be moved to the job queue.
Answer: b) It selects processes from the ready queue to run on the CPU.
2. Which scheduler is responsible for determining the order in which processes are executed in a multi-
programmed environment?
a) Short-term scheduler
b) Medium-term scheduler
c) Long-term scheduler
d) High-level scheduler
Answer: a) Short-term scheduler
6. Which scheduler is responsible for determining which processes should be admitted into the main
memory from the job queue?
a) Short-term scheduler
b) Medium-term scheduler
c) Long-term scheduler
d) High-level scheduler
Answer: c) Long-term scheduler
7. In the process scheduling hierarchy, what is the role of the long-term scheduler (job scheduler)?
a) To allocate CPU time equally to all processes.
b) To select processes from the ready queue to run on the CPU.
c) To determine the priority of processes.
d) To select processes from the job queue to be loaded into main memory.
Answer: d) To select processes from the job queue to be loaded into main memory.
**4. Process scheduling algorithms – FCFS, Shortest Job First, Priority, RR, Queue. Belady’s
Anomaly**
1. Which process scheduling algorithm allocates the CPU to the process that arrives first in the ready
queue?
a) FCFS (First-Come, First-Served)
b) SJF (Shortest Job First)
c) Priority scheduling
d) Round-robin scheduling
Answer: a) FCFS (First-Come, First-Served)
2. What is the main disadvantage of the FCFS (First-Come, First-Served) scheduling algorithm?
a) It can lead to starvation of low-priority processes.
b) It may result in poor average waiting time for processes.
c) It does not allow for process preemption.
d) It does not support multi-programming.
Answer: b) It may result in poor average waiting time for processes.
3. In the Shortest Job First (SJF) scheduling algorithm, which process gets selected to run on the CPU?
a) The process with the highest priority.
b) The process with the shortest burst time.
c) The process with the largest burst time.
d) The process with the longest waiting time.
Answer: b) The process with the shortest burst time.
4. What is the main advantage of the SJF (Shortest Job First) scheduling algorithm?
a) It guarantees that all processes get an equal share of CPU time.
b) It provides the highest priority to interactive processes.
c) It reduces context switching overhead.
d) It minimizes the average waiting time for processes.
Answer: d) It minimizes the average waiting time for processes.
5. What is the criteria used to select the process to run in priority scheduling?
a) The process with the shortest burst time.
b) The process with the highest priority value.
c) The process with the largest burst time.
d) The process with the lowest priority value.
Answer: b) The process with the highest priority value.
7. What is Belady’s Anomaly in the context of the FIFO (First-In-First-Out) page replacement
algorithm?
a) The page fault rate increases with the increase in the number of frames.
b) The page fault rate decreases with the increase in the number of frames.
c) The page fault rate remains constant regardless of the number of frames.
d) The page fault rate fluctuates randomly with the number of frames.
Answer: a) The page fault rate increases with the increase in the number of frames.
**5. Examples associated with scheduling algorithms to find turnaround time to find the better
performing scheduler.**
1. Which scheduling algorithm typically has the shortest turnaround time for a mix of long and short
CPU burst time processes?
a) FCFS (First-Come, First-Served)
b) SJF (Shortest Job First)
c) Priority scheduling
d) Round-robin scheduling
Answer: b) SJF (Shortest Job First)
2. Consider three processes P1, P2, and P3 with burst times of 4, 7, and 2 units, respectively. Which
scheduling algorithm results in the shortest average turnaround time?
a) FCFS (First-Come, First-Served)
b) SJF (Shortest Job First)
c) Priority scheduling
d) Round-robin scheduling
Answer: b) SJF (Shortest Job First)
3. Which scheduling algorithm is most suitable for time-sharing systems where interactive processes
require quick response time?
a) FCFS (First-Come, First-Served)
b) SJF (Shortest Job First)
c) Priority scheduling
d) Round-robin scheduling
Answer: d) Round-robin scheduling
4. Consider three processes P1, P2, and P3 with burst times of 8, 3, and 5 units, respectively, and a time
quantum of 4 units for the Round-Robin scheduling algorithm. What is the turnaround time for process
P1?
a) 5 units
b) 8 units
c) 10 units
d) 12 units
Answer: d) 12 units
5. In priority scheduling, what happens if two processes have the same priority value?
a) The process with the longest burst time gets selected.
b) The process that arrives first in the ready queue gets selected.
c) The process with the shortest burst time gets selected.
d) The process with the largest burst time gets selected.
Answer: b) The process that arrives first in the ready queue gets selected.
6. Consider three processes P1, P2, and P3 with burst times of 6, 4, and 8 units, respectively, and
priorities of 3, 2, and 1, respectively. Which scheduling algorithm results in the shortest average
turnaround time?
a) FCFS (First-Come, First-Served)
b) SJF (Shortest Job First)
c) Priority scheduling
d) Round-robin scheduling
Answer: c) Priority scheduling
7. In priority scheduling, which process gets selected to run on the CPU if all processes have the same
priority value?
a) The process with the longest burst time.
b) The process that arrives first in the ready queue.
c) The process with the shortest burst time.
d) The process with the largest burst time.
Answer: b) The process that arrives first in the ready queue.
**6. Process creation using fork; waitpid and exec system calls; Examples on process creation; Parent
and child processes**
3. Which system call is used to wait for a specific child process to terminate in Linux/Unix?
a) fork
b) waitpid
c) exec
d) create
Answer: b) waitpid
5. In process creation using the fork system call, what is the relationship between the parent and child
processes?
a) The parent and child processes are independent of each other.
b) The parent process terminates before the child process starts executing.
c) The parent and child processes share the same memory space.
d) The parent process executes after the child process completes its execution.
Answer: c) The parent and child processes share the same memory space.
6. In process creation using the fork system call, how many processes are created after the fork call?
a) Only one process is created.
b) Two processes are created - the parent and the child.
c) Three processes are created - the parent, the child, and the grandchild.
d) The number of processes created depends on the number of fork calls.
Answer: b) Two processes are created - the parent and the child.
7. In process creation using the fork system call, what is the value returned by the fork call in the parent
process?
a) 0
b) 1
c) The process ID of the child process
d) The process ID of the parent process
Answer: c) The process ID of the child process.
4. In Unix-like operating systems, how is a process notified when a signal is delivered to it?
a) The process receives a message through a special communication channel.
b) The process checks its mailbox for new signals.
c) The operating system sets a flag in the process control block.
d) The operating system transfers control to a signal handler function.
Answer: d) SIGTERM
6. What is the default action of the SIGTERM signal in most operating systems?
a) Terminate the process without any cleanup.
b) Suspend the process temporarily.
c) Ignore the signal.
d) Execute a signal handler function.
Answer: b) SIGSEGV
8. What is the purpose of the SIGINT signal in Unix-like operating systems?
a) To interrupt the execution of a process.
b) To suspend a process temporarily.
c) To terminate a process immediately.
d) To handle arithmetic exceptions.
9. In Unix-like operating systems, which command is used to send a signal to a process using its
process ID (PID)?
a) kill
b) signal
c) terminate
d) interrupt
Answer: a) kill
12. In Unix-like operating systems, which signal is typically used to stop the execution of a process
temporarily?
a) SIGSTOP
b) SIGINT
c) SIGTERM
d) SIGKILL
Answer: a) SIGSTOP
Answer: c) By a process using the kill system call to send a signal to another process.
4. When a signal is sent to a process, how does the operating system determine which action to take?
a) The operating system executes the default action for all signals.
b) The process explicitly specifies the action when it receives the signal.
c) The operating system checks the signal handling table of the process.
d) The signal handler function is invoked based on the signal number.
Answer: c) The operating system checks the signal handling table of the process.
5. What happens if a process does not handle a signal that is sent to it?
a) The process is terminated immediately.
b) The signal is sent to the parent process.
c) The signal is queued, and the process handles it later.
d) The process ignores the signal and continues its execution.
Answer: d) The process ignores the signal and continues its execution.
6. In the context of signal handling, what is the purpose of the sigaction system call?
a) To send a signal to another process.
b) To change the default action of a signal.
c) To specify the action to be taken when a signal is received.
d) To block a specific signal from being delivered to a process.
7. How can a process temporarily block the delivery of a specific signal in Unix-like operating systems?
a) By changing the signal name in the process table entry.
b) By setting a flag in the process control block.
c) By executing a signal handler function.
d) By using the sigprocmask system call to set the signal mask.
Answer: d) By using the sigprocmask system call to set the signal mask.
8. Which signal is commonly used to terminate a process forcefully, without allowing it to perform any
cleanup tasks?
a) SIGKILL
b) SIGINT
c) SIGTERM
d) SIGSTOP
Answer: a) SIGKILL
Answer: d) By using the kill system call with its own PID.
11. In Unix-like operating systems, how can a process send a signal to another process with a specific
PID?
a) By using the fork system call.
b) By modifying the process control block of the target process.
c) By using the sigaction system call.
d) By using the kill system call with the target PID.
Answer: d) By using the kill system call with the target PID.
12. Which signal is commonly used to suspend the execution of a process temporarily?
a) SIGKILL
b) SIGSTOP
c) SIGINT
d) SIGTERM
Answer: b) SIGSTOP
5. Threads
**1. What are threads; user and kernel threads; how threads are different from processes**
3. What is the main difference between a user-level thread and a kernel-level thread?
a) User-level threads are faster than kernel-level threads.
b) Kernel-level threads are managed by the operating system, while user-level threads are managed
by the application.
c) User-level threads use shared memory, while kernel-level threads use virtual memory.
d) Kernel-level threads are more scalable than user-level threads.
Answer: b) Kernel-level threads are managed by the operating system, while user-level threads are
managed by the application.
Answer: a) Threads share the same memory space, while processes have separate memory spaces.
5. Which of the following statements is true about thread creation compared to process creation?
a) Thread creation is slower than process creation.
b) Thread creation requires more system resources than process creation.
c) Thread creation is faster than process creation.
d) Thread creation requires a separate program.
Answer: c) To ensure that threads do not interfere with each other's execution.
7. What is the term used for a situation where multiple threads try to access and modify the same
shared resource simultaneously?
a) Thread deadlock
b) Thread race condition
c) Thread context switch
d) Thread priority inversion
Answer: b) Thread race condition
10. Which type of thread is more efficient in terms of context switching: user-level threads or kernel-
level threads?
a) User-level threads
b) Kernel-level threads
c) Both types have the same efficiency in context switching.
d) Efficiency depends on the number of threads.
11. How do kernel-level threads improve system responsiveness compared to user-level threads?
a) Kernel-level threads have lower overhead in thread management.
b) Kernel-level threads are more lightweight than user-level threads.
c) Kernel-level threads can run concurrently on multiple processors.
d) Kernel-level threads are managed by the application, not the operating system.
12. Which of the following statements is true about the use of threads in a program?
a) Threads always execute sequentially and cannot overlap.
b) Threads are primarily used to create separate processes.
c) Threads can be used to achieve parallelism and improve performance.
d) Threads are used to enforce strict separation of concerns between different parts of a program.
2. In C/C++ programming, which header file should be included to use the pthread library?
a) <thread>
b) <pthread.h>
c) <sync>
d) <sync.h>
Answer: b) <pthread.h>
6. How are thread-specific data (TSD) variables created and accessed in a multi-threaded program?
a) TSD variables are created automatically for each thread by the pthread library.
b) TSD variables are accessed using mutex locks.
c) TSD variables are accessed using global pointers.
d) TSD variables are created and accessed using special pthread functions.
Answer: d) TSD variables are created and accessed using special pthread functions.
7. In the context of pthread library, what is the purpose of the pthread_mutex_lock() function?
a) To create a new mutex object.
b) To unlock a mutex and allow access to a shared resource.
c) To block a thread until the specified mutex is unlocked.
d) To check the status of a mutex.
Answer: c) Mutexes
10. How can a thread yield the CPU to another thread in a multi-threaded program?
a) By calling the pthread_sleep() function.
b) By calling the pthread_yield() function.
c) By calling the sleep() function.
d) By calling the yield() function.
11. Which of the following statements is true about thread cancellation in a multi-threaded program?
a) Thread cancellation is always immediate and cannot be controlled.
b) Thread cancellation is always deferred until the thread reaches a cancellation point.
c) Thread cancellation can only be initiated by the calling thread.
d) Thread cancellation can only be initiated by the operating system.
Answer: b) Thread cancellation is always deferred until the thread reaches a cancellation point.
12. How can a thread be canceled explicitly using the pthread library?
a) By calling the pthread_cancel() function with the thread ID.
b) By setting a cancel flag in the thread control block.
c) By calling the pthread_exit() function from another thread.
d) By calling the kill() function with the thread ID.
1. Which of the following types of memory is directly accessible by the CPU for storing data and
instructions?
a) Secondary memory
b) Cache memory
c) Virtual memory
d) Tertiary memory
3. Which type of memory is non-volatile and used for long-term data storage even when the computer
is powered off?
a) RAM (Random Access Memory)
b) Cache memory
c) ROM (Read-Only Memory)
d) Virtual memory
5. In a computer system, which type of memory is typically the fastest but also the smallest in capacity?
a) RAM (Random Access Memory)
b) Cache memory
c) Virtual memory
d) ROM (Read-Only Memory)
Answer: c) It limits the number of processes that can be loaded into memory.
Answer: d) Segmentation
3. What is the primary advantage of dynamic memory allocation over fixed memory allocation?
a) It reduces memory fragmentation.
b) It allows more efficient use of memory.
c) It improves CPU performance.
d) It eliminates the need for virtual memory.
4. In dynamic memory allocation, what happens if a process requests more memory than the available
free space?
a) The operating system terminates the process.
b) The process is put on hold until memory becomes available.
c) The operating system compacts memory to create a larger free block.
d) The operating system allocates memory from the secondary storage.
5. Which memory allocation method requires maintaining a table to keep track of allocated and free
memory blocks?
a) Fixed partitioning
b) Dynamic partitioning
c) Paging
d) Segmentation
1. Which memory allocation algorithm searches for the first free memory block that is large enough to
accommodate a process?
a) First Fit
b) Best Fit
c) Worst Fit
d) Quick Fit
2. What is the main advantage of the Best Fit memory allocation algorithm over the First Fit algorithm?
a) It reduces memory fragmentation.
b) It is faster in finding a free block for a process.
c) It allows larger processes to be allocated more efficiently.
d) It guarantees better overall memory utilization.
3. In the context of memory allocation, which algorithm places a process in the largest available free
block?
a) First Fit
b) Best Fit
c) Worst Fit
d) Quick Fit
4. How does the Best Fit memory allocation algorithm choose a free block for a process?
a) It selects the first free block that is large enough.
b) It selects the smallest free block that is large enough.
c) It selects the largest free block that is large enough.
d) It selects a free block randomly.
5. Which memory allocation algorithm may result in the most internal fragmentation?
a) First Fit
b) Best Fit
c) Worst Fit
d) Quick Fit
**4. Compaction**
2. When does memory compaction typically occur in a system using dynamic memory allocation?
a) After every process terminates
b) At regular intervals
c) When there is not enough free memory to allocate a new process
d) When the system is rebooted
5. Which type of memory management technique is most likely to benefit from memory compaction?
a) Fixed partitioning
b) Dynamic partitioning
c) Paging
d) Segmentation
Answer: d) Segmentation
Answer: a) It is the unused memory space within a memory block allocated to a process.
Answer: d) It is the unused memory space scattered across the memory space.
Answer: c) Paging
Answer: b) It stores the mapping between logical addresses and physical addresses.
**7. Paging – What is paging; hardware required for paging; paging table; Translation look-aside
buffer**
Answer: d) It is the process of dividing memory into fixed-size blocks called pages.
Answer: b) It stores the mapping between logical addresses and physical addresses.
Answer: b) It stores the mapping between logical addresses and physical addresses.
Answer: c) It indicates that a memory page needs to be cleaned or updated before being evicted from
memory.
2. How is the dirty bit set for a memory page in a computer system?
a) It is set by the operating system when the page is loaded into memory.
b) It is set by the CPU when the page is accessed.
c) It is set by the user application when the page is modified.
d) It is set by the memory controller based on a predefined algorithm.
3. What is the significance of the dirty bit during the process of page replacement in virtual memory?
a) It is used to determine the least recently used page for eviction.
b) It is used to determine the page with the lowest priority for eviction.
c) It is used to determine the page with the highest priority for eviction.
d) It is used to determine the most recently used page for eviction.
Answer: d) It is used to determine the most recently used page for eviction.
4. How does the dirty bit affect the page replacement policy in virtual memory?
a) Pages with the dirty bit set are more likely to be evicted.
b) Pages with the dirty bit set are less likely to be evicted.
c) Pages with the dirty bit set are evicted first.
d) Pages with the dirty bit set are never evicted.
Answer: a) Pages with the dirty bit set are more likely to be evicted.
Answer: a) It allows multiple threads to execute the same code without interfering with each other.
**10. Throttling**
Answer: a) It is the process of limiting the number of processes that can be loaded into memory.
4. What factors are typically considered when implementing throttling in memory management?
a) CPU speed and memory size
b) Process priority and memory usage
c) Disk space and network bandwidth
d) Graphics processing unit (GPU) capabilities
Answer: c) To extend the physical memory of the system using secondary storage.
Answer: d) A combination of physical memory and secondary storage used as if it were RAM.
4. What happens when a program accesses a memory address that is not currently in physical memory?
a) The program crashes.
b) The operating system terminates the program.
c) A page fault occurs.
d) The program continues execution with an error message.
5. Which type of memory is used to store the virtual memory mapping table in a computer system?
a) RAM (Random Access Memory)
b) Cache memory
c) ROM (Read-Only Memory)
d) Hard disk
Answer: b) It allows running larger programs than what can fit in physical memory.
8. In a computer system with virtual memory, what is the role of the page table entry?
a) It contains the contents of a memory page.
b) It stores the virtual addresses of all processes.
c) It contains information about the location of a page in secondary storage.
d) It stores information about the mapping between virtual and physical addresses.
Answer: d) It stores information about the mapping between virtual and physical addresses.
9. Which memory management technique is used when the demand for memory exceeds the available
physical memory?
a) Paging
b) Segmentation
c) Swapping
d) Thrashing
Answer: c) Swapping
10. What is the size of a memory page in a computer system using virtual memory?
a) Fixed and equal to the size of the physical memory
b) Fixed and equal to the size of the secondary storage
c) Variable and determined by the operating system
d) Variable and determined by the size of the RAM
Answer: c) A technique for loading pages into memory only when they are needed.
2. In demand paging, which pages are initially loaded into physical memory?
a) All pages of the process
b) Only the first page of the process
c) Only the last page of the process
d) None of the pages
Answer: b) The operating system loads the required page from secondary storage into physical memory.
6. What is the advantage of demand paging over pre-loading all pages of a process into physical
memory?
a) It reduces memory overhead.
b) It eliminates the need for page replacement algorithms.
c) It allows for faster context switches between processes.
d) It
7. In demand paging, what is the role of the page table entry for a page that is not in physical memory?
a) It contains the contents of the page.
b) It stores the virtual address of the page in secondary storage.
c) It stores the physical address of the page in secondary storage.
d) It stores information about the location of the page in physical memory.
8. How does demand paging affect the overall performance of a computer system?
a) It improves performance by reducing memory access time.
b) It has no significant impact on performance.
c) It may slow down performance due to page faults and loading from secondary storage.
d) It improves performance by increasing the size of the page file.
Answer: c) It may slow down performance due to page faults and loading from secondary storage.
2. What typically causes a page fault to occur in a computer system using virtual memory?
a) The CPU running at full capacity.
b) A user application exceeding its allocated memory space.
c) A page being evicted from physical memory.
d) A process accessing a page not present in physical memory.
3. When a page fault occurs, what action does the operating system take?
a) It terminates the process that caused the page fault.
b) It allocates a new page to the process from secondary storage.
c) It swaps out a page from another process to make room for the requested page.
d) It loads the required page from secondary storage into physical memory.
Answer: d) It loads the required page from secondary storage into physical memory.
4. What is the typical response time for handling a page fault in a computer system?
a) A few microseconds
b) A few milliseconds
c) A few seconds
d) A few minutes
5. How can a high rate of page faults affect the performance of a computer system?
a) It leads to faster execution of processes.
b) It may cause the system to become unresponsive and slow down.
c) It reduces the need for page replacement algorithms.
d) It improves the cache hit rate.
Answer: b) It may cause the system to become unresponsive and slow down.
6. What is the primary cause of excessive page faults in a computer system using virtual memory?
a) Insufficient physical memory to hold all active pages of processes.
b) Page replacement algorithms being too aggressive.
c) The excessive use of shared memory.
d) Hardware failure in the memory module.
8. What is the significance of the page fault rate in performance monitoring of a computer system?
a) It indicates the average time taken to handle a page fault.
b) It reflects the efficiency of the page replacement algorithm.
c) It measures the rate at which processes are being terminated.
d) It is used to calculate the amount of physical memory in use.
1. What is the main goal of page replacement algorithms in virtual memory management?
a) To increase the page size in virtual memory.
b) To reduce the number of page faults in the system.
c) To allocate memory for running processes.
d) To compress memory contents to save space.
Answer: a) It replaces the page that has been in memory the longest.
4. Which page replacement algorithm is considered the most efficient in terms of minimizing the
number of page faults?
a) Optimal Page Replacement
b) Least Recently Used (LRU)
c) First-In-First-Out (FIFO)
d) Random Page Replacement
5. How does the Optimal Page Replacement algorithm make its replacement decision?
a) It replaces the page that has been in memory the longest.
b) It replaces the page that will not be used for the longest period.
c) It replaces a random page from memory.
d) It replaces the page that has been accessed the most.
Answer: b) It replaces the page that will not be used for the longest period.
6. What is the drawback of using the Optimal Page Replacement algorithm in real systems?
a) It is computationally expensive and may not be practical.
b) It does not effectively reduce the number of page faults.
c) It requires a large page table to store information about future page accesses.
d) It is only suitable for systems with a small number of processes.
7. Which page replacement algorithm approximates the optimal algorithm by tracking the least recently
used pages?
a) Least Recently Used (LRU)
b) First-In-First-Out (FIFO)
c) Optimal Page Replacement
d) Random Page Replacement
8. How does the Least Recently Used (LRU) page replacement algorithm work?
a) It replaces the page that has been in memory the longest.
b) It replaces the page that has been accessed the most recently.
c) It replaces a random page from memory.
d) It replaces the page that has the highest priority.
Answer: b) It replaces the page that has been accessed the most recently.
9. Lecture: Deadlock
2. In the context of deadlock, what does the "mutual exclusion" condition mean?
a) A process must wait for the release of a resource held by another process.
b) A resource can be accessed by multiple processes simultaneously.
c) A process can access multiple resources at the same time.
d) A resource can be preempted and reallocated to another process.
3. Which condition ensures that a process must wait for a resource that is held by another process,
leading to deadlock?
a) Mutual exclusion
b) Resource preemption
c) Hold and wait
d) Circular wait
Answer: c) A process waits for a resource that is held by another process in a circular chain.
6. If a system satisfies all the necessary conditions for deadlock, will deadlock always occur?
a) Yes, deadlock is unavoidable in such a system.
b) No, deadlock can still be avoided by careful resource allocation and scheduling.
c) Yes, but deadlock can be resolved automatically by the operating system.
d) No, deadlock can only occur if the system is in an unstable state.
Answer: b) No, deadlock can still be avoided by careful resource allocation and scheduling.
7. Which of the following conditions ensures that a process releases all its resources before requesting
new ones?
a) Mutual exclusion
b) Resource preemption
c) Hold and wait
d) Circular wait
Answer: d) Circular wait
Answer: b) Restricting access to resources in such a way that deadlock cannot occur.
2. Which technique ensures that the system will never enter a deadlocked state by carefully allocating
resources to processes?
a) Deadlock avoidance
b) Deadlock detection
c) Deadlock recovery
d) Deadlock prevention
Answer: c) Identifying deadlock-prone situations and avoiding them by careful resource allocation.
4. Which resource allocation technique uses a resource allocation graph to avoid deadlock?
a) Deadlock avoidance
b) Deadlock detection
c) Deadlock recovery
d) Deadlock prevention
5. In the context of deadlock avoidance, what does a resource allocation graph represent?
a) Processes and their resource requests.
b) Processes and their resource releases.
c) Processes and their dependencies.
d) Processes and their priorities.
**3. Semaphore**
Answer: c) It maintains a count of available resource instances and blocks processes if the count
reaches zero.
d) Increments the semaphore count and blocks the calling process if the count is zero.
Answer: a) Increments the semaphore count and signals waiting processes.
7. Which operation is used to decrement a semaphore and potentially block the calling process?
a) V operation
b) Increment operation
c) P operation
d) Signal operation
Answer: c) P operation
**4. Mutex**
Answer: d) It grants exclusive access to the critical section to one process at a time.
Answer: a) Grants exclusive access to the critical section to the calling process.
6. What is the purpose of using a mutex to protect shared resources in concurrent programming?
a) To ensure that all processes execute in parallel.
b) To increase the efficiency of the system by allowing multiple processes to access shared resources
simultaneously.
c) To prevent race conditions and data corruption when multiple processes access shared resources.
d) To allocate a fixed amount of CPU time to each process.
Answer: c) To prevent race conditions and data corruption when multiple processes access shared
resources.
7. Which operation is used to release a mutex and allow other processes to access the critical section?
a) Lock operation
b) Lock and Unlock operation
c) Unlock operation
d) Unlock and Lock operation
Answer: b) A synchronization problem involving the sharing of a bounded buffer by multiple processes.
Answer: c) Synchronizing the access to the shared buffer to avoid race conditions.
Answer: a) Semaphore
Answer: b) It synchronizes the access to the shared buffer by allowing only one process to access it at a
time.
7. In the context of the producer-consumer problem, what does the "empty" semaphore represent?
a) The number of empty slots in the buffer where items can be produced.
b) The number of items currently present in the buffer.
c) The number of producer processes waiting to add items to the buffer.
d) The number of consumer processes waiting to consume items from the buffer.
Answer: a) The number of empty slots in the buffer where items can be produced.
8. How does the producer-consumer problem illustrate the importance of synchronization in concurrent
programming?
a) It demonstrates the need for preemptive scheduling algorithms.
b) It shows how processes can be created and terminated dynamically.
c) It highlights the challenges of resource allocation.
d) It exemplifies the need to coordinate the execution of multiple processes.
Answer: d) It exemplifies the need to coordinate the execution of multiple processes.
systems?
a) A situation where a process cannot proceed because it is waiting for a resource held by another
process.
b) A situation where two or more processes are blocked, each waiting for the other to release a
resource.
c) A situation where a process consumes all available resources and prevents other processes from
executing.
d) A situation where a process is terminated prematurely.
Answer: b) A situation where two or more processes are blocked, each waiting for the other to release a
resource.
Answer: d) A situation where a process is unable to obtain the resources it needs to make progress.
Answer: a) Deadlock involves processes waiting for resources, while starvation involves a process
being unable to obtain resources.
Answer: c) Deadlock can be resolved by increasing resource allocation, while starvation can be
resolved by resource preemption.
6. How can an operating system handle the issue of starvation in resource allocation?
a) By terminating processes that cause starvation.
b) By granting resources based on the first-come-first-serve principle.
c) By increasing the priority of processes that have been waiting for a long time.
d) By allocating resources fairly to all processes.
Answer: c) By increasing the priority of processes that have been waiting for a long time.
Answer: b) Mutual exclusion, resource preemption, hold and wait, and absence of resource waiting.
8. How can deadlock and starvation impact the performance of an operating system?
a) Deadlock and starvation lead to system crashes.
b) Deadlock and starvation increase the overall efficiency of the system.
c) Deadlock can halt the entire system, while starvation causes low resource utilization.
d) Deadlock and starvation can be resolved by increasing the number of available resources.
Answer: c) Deadlock can halt the entire system, while starvation causes low resource utilization.
10. Lecture: Inter-process communication
11.
**1. Message queues**
Answer: c) A data structure for storing messages that can be accessed by multiple processes.
Answer: c) They can be used for both one-to-one and one-to-many communication.
4. In message queuing, what happens if a process tries to read from an empty queue?
a) The process waits until a message is available in the queue.
b) The process receives an error message.
c) The queue automatically creates a new message for the process to read.
d) The process sends a signal to other processes.
6. Which IPC mechanism is best suited for exchanging large volumes of data between processes?
a) Shared memory
b) Message queues
c) Pipes
d) FIFO
7. How do message queues ensure that messages are processed in the order they are received?
a) By assigning priority levels to processes.
b) By using round-robin scheduling.
c) By using first-in-first-out (FIFO) order.
d) By allowing processes to choose the order in which they process messages.
10. Which IPC mechanism allows processes to communicate by writing and reading from a common
buffer?
a) Message queues
b) Shared memory
c) Pipes
d) FIFO
4. In shared memory communication, what happens if multiple processes try to access the shared
memory simultaneously?
a) The operating system assigns priority to processes based on their IDs.
b) The processes enter into a deadlock and block each other.
c) The operating system schedules processes to access the shared memory one at a time.
d) The processes use semaphores to synchronize access to the shared memory.
Answer: d) The processes use semaphores to synchronize access to the shared memory.
5. What is the role of shared memory in inter-process communication?
a) To control the execution of processes in a multi-core system.
b) To buffer data transmitted between processes.
c) To synchronize the access to shared resources.
d) To allocate memory for running processes.
6. Which IPC mechanism is best suited for high-performance data sharing between processes?
a) Message queues
b) Shared memory
c) Pipes
d) FIFO
9. How are processes prevented from overwriting each other's data in shared memory?
a) By using message identifiers to differentiate between messages from different processes.
b) By using semaphores to control access to shared memory.
c) By allocating separate memory regions for each process.
d) By using message queues to buffer data.
10. Which IPC mechanism allows processes to communicate by writing and reading from a common
buffer?
a) Message queues
b) Shared memory
c) Pipes
d) FIFO
**3. Pipes**
between processes.
c) A one-way communication channel between two related processes.
d) A technique for transferring data between threads.
Answer: c) A one-way communication channel between two related processes.
Answer: b) Pipes can only be used for one-to-one communication between processes.
6. Which IPC mechanism is best suited for simple communication between two related processes?
a) Message queues
b) Shared memory
c) Pipes
d) FIFO
Answer: c) Pipes
10. Which IPC mechanism allows processes to communicate by writing and reading from a common
buffer?
a) Message queues
b) Shared memory
c) Pipes
d) FIFO
Answer: c) Pipes
**4. FIFO**
Answer: d) By using file descriptors to read and write from a common buffer.
Answer: b) FIFOs can only be used for one-to-one communication between processes.
6. Which IPC mechanism is best suited for communication between unrelated processes?
a) Message queues
b) Shared memory
c) Pipes
d) FIFO
Answer: d) FIFO
10. Which IPC mechanism allows processes to communicate by writing and reading from a common
buffer?
a) Message queues
b) Shared memory
c) Pipes
d) FIFO
Answer: d) FIFO