Olete.in
Articles
Mock Tests
đź§Ş Rust (programming language) MCQ Quiz Hub
Rust Programming Language Mcq
Choose a topic to test your knowledge and improve your Rust (programming language) skills
1. The ioctl() function is used to interact with which of the following?
Disk Drives
Virtual TTY lines
Special character devices
None of the above
2. Which of the following best describes the purpose of the unlink() call?
Removes the file from its directory
Sets the file’s Inode count to one (1)
Moves the file in from one directory to another
All of the above
3. Which of the following is the result of a process calling UNIX exec()?
A new process is created
The process becomes executable
The process is completely overwritten
The process blocks waiting for another process to run
4. CORBA's DII allows a client to do which one of the following?
Generate client-side stubs for interfaces
Dynamically link with cross-platform libs
Connect with proxy objects across platforms
Discover new objects and interfaces at runtime
5. The result of calling kill(6003, 0) is which of the following?
Process 6003 terminates
The signal 0 is sent to process 6003
The signal 6003 is sent to process 0
The existence of process 6003 is checked
6. Which of the following techniques can help keep system programs secure?
Encrypt every process’ executable
Setuid important processes to the root user
Limit system calls to administrators
Check all system calls for error conditions
7. Which of the following could the fork() command return to the child process?
-1
2054
19456
0
8. Which of the following is correct for the standard file descriptors that are automatically opened in UNIX?
STDIN_FILENO = 0, STDOUT_FILENO = 1, STDERR_FILENO = 2
STDOUT_FILENO = 0, STDERR_FILENO = 1, STDERR_FILENO = 2
STDERR_FILENO = 0, STDOUT_FILENO = 1, STDIN_FILENO = 2
STDIN_FILENO = 0, STDERR_FILENO = 1, STDOUT_FILENO = 2
9. When a new process is created using fork(), which of the following describes the state of open file descriptors?The child inherits the parent’s
The child inherits the parent’s
The child overwrites the parent’s
The child has distinct copies of the parent’s
The child always has an empty set of closed descriptors
10. An orphan process occurs as a result of which of the following conditions?
Parent and child process terminate simultaneously
Child process terminates before its parent process
Parent process terminates before its child process
None of these
11. Race conditions are caused by which of the following conditions in a multi threaded system?
Proper program function requires all threads to run quickly
Proper program function requires that all threads run at the same speed
Proper program function is dependent on the execution sequence and timing of
None of These
12. You want to listen on a port for some user-defined data stream. Would you use port 80?
No, it is a 'well-defined' or reserved port.
No, it is best to use three or four digit port numbers.
Yes, it is as good as any other port number.
Yes, it is best to use low numbers for port numbers
13. The purpose of the poll() and select() system calls is to perform which of the following functions?
Watch a set of file descriptors to see which are ready
Frequently check email and other network services
Sample system process information for use by the top command
None of these
14. Which of the following provides the most random seed source for a pseudo random number generator?
C rand() function
/dev/random
both (a) and (b)
None of these
15. Which type cast preserves the mathematical value in all cases?
I64 as i32
Usize as u64
I32 as i64
F64 as f32
16. Which choice is not a scalar data type?
Integer
Float
Boolean
Tuple
17. _ cannot be destructured.
Traits
Tuples
Enums
Structs
18. Which cargo command checks a program for error without creating a binary executable?
Cargo
--version
Cargo
init
19. The term box and related phrases such as boxing a value are often used when relating to memory layout. What does box refer to?
It's creating a pointer on the heap that points to a value on the stack.
It's creating a pointer on the stack that points to a value on the heap.
It's creating a memory guard around values to prevent illegal access.
It's an abstraction that refers to ownership.
20. Using the ? operator at the end of an expression is equivalent to
A match pattern that branches into True or False
Calling ok_error()
Calling panic!()
A match pattern that may result an early return
21. Which is valid syntax for defining an array of i32 values?
Array::with_capacity(10)
[i32] Array::new(10)
[i32; 10]
None of the above
22. The smart pointers Rc and Arc provide reference counting. What is the API for incrementing a reference count?
.add()
incr
clone
increment
23. What happens when an error occurs that is being handled by the question mark (?) operator?
The error is reported and execution continues.
An exception is raised. The effect(s) of the exception are defined by the error! macro
The program panics immediately.
Rust attempts to convert the error to the local function's error type and return it as Result::Err. If that fails, the program panics.
24. Which comment syntax is not legal?
/*
#
//!
//
25. In matching patterns, values are ignored with _.
.ignore()
An underscore (_)
..
Skip
26. Defining a _ requires a lifetime parameter.
Function that ends the lifetime of one of its arguments
Struct that contains a reference to a value
Function with a generic argument
Struct that contains a reference to a boxed value
27. Which statement about lifetimes is false?
Lifetimes were redundantly specified in previous version of Rust.
Lifetimes are specified when a struct is holding a reference to a value.
Lifetimes are specified when certain values must outlive others.
Lifetimes are always inferred by the compiler.
28. When used as a return type, which Rust type plays a similar role to Python's None, JavaScript's null, or the void type in C/C++?
!
None
Null
()
29. Which statement about the Clone and Copy traits is false?
Copy is enabled for primitive, built-in types.
Without Copy, Rust applies move semantics to a type's access.
When using Clone, copying data is explicit.
Until a type implements either Copy or Clone, its internal data cannot be copied
30. What smart pointer is used to allow multiple ownership of a value in various threads?
Arc
Box
Both Arc and Rc are multithread safe.
Rc
31. Which types are not allowed within an enum variant's body?
Zero-sized types
Structs
Trait objects
Floating-point numbers
32. Your application requires a single copy of some data type T to be held in memory that can be accessed by multiple threads. What is the thread-safe wrapper type?
Mutex>
Rc>
Arc>
Mutex>
33. Which choice is not valid loop syntax?
Loop
For
While
Do
34. Which statement about enums is false?
Enums are useful in matching patterns.
Option is an enum type.
Enum variants can have different types with associated data.
The term enum is short for enummap
35. What does an underscore (_) indicate when used as pattern?
It matches everything.
It matches underscores.
It matches any value that has a length of 1.
It matches nothing
36. What is a safe operation on a std::cell:UnsafeCell?
A &mut T reference is allowed. However it may not cpexists with any other references. and may be created only in single-threaded code.
UnsafeCell provides thread-safety. Therefore, creating &T references from multiple threads is safe.
The only safe operation is the .get() method, which returns only a raw pointer.
Non. UnsafeCell only allows code that would otherwise need unsafe blocks to be written in safe code.
37. Generics are useful when you _.
Need to reduce code duplication by concretizing values and restricting parameters in functions
Need to reduce code duplication by abstracting values further, such as in function parameters
Need a supertrait
Are not sure if you need a specific kind of trait
38. How do you create a Rust project on the command-line?
Cargo new
Rustup init
Cargo start
Rust new-project
Submit