1/17
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
|---|
No study sessions yet.
In many simple cases, Rust allows you to omit explicit lifetime annotations in function signatures. What is this feature called?
Lifetime Elision
What is the main difference between a struct and a class in C++?
The default member access: struct members are public by default, while class members are private by default.
How would you define a Point struct that can hold x and y coordinates of any single generic type?
struct Point<T> { x: T, y: T }
Is it possible to use collections like Vec and String in a no_std embedded Rust application?
Yes, by using the alloc crate and defining a global allocator, though it introduces the risk of heap fragmentation.
Which of the following variable names follows the "Camel Case" convention?
myVariableName
What happens if you call .unwrap() on an Option<T> that holds the None variant?
The program will panic.
Which feature distinguishes std::deque from std::vector?
Efficient insertion and deletion at the front of the container. (A std::deque (double-ended queue) is similar to a vector but with the key difference that it provides efficient (amortized constant time) insertions and deletions at both the beginning and the end of the container. A vector is only efficient for insertions/deletions at the end.)
What is the key difference between the smart pointers Rc and Arc?
Arc<T> is for thread-safe shared ownership, while Rc<T> is for single-threaded shared ownership.
Which statement accurately describes the reliability of TCP and UDP?
TCP is reliable (guaranteed delivery and order), while UDP is unreliable (no guarantees).
What is a "function object" or "functor" in C++?
An object of a class that has an overloaded function call operator operator()).
How does Rust primarily handle errors that can be reasonably expected, such as a file not being found?
By using the Result and Option enum types for clear and explicit handling. Rust's approach to error handling is explicit and aims to make code more robust.
Why is overriding useful in a class hierarchy?
It allows specific behaviour for subclasses through a common interface. Overriding allows different subclasses to implement behaviour tailored to their needs.
What is the safest way to access an element at a specific index in a Vec<T> that avoids causing a panic if the index is out of bounds?
Using the .get() method, which returns an Option<&T>.
What is the primary function of the ? operator in Rust error handling?
To propagate errors by returning early from a function if a Result is Err or an Option is None.
Why is accessing or modifying a static mut variable considered unsafe in Rust?
It creates a risk of data races, as multiple threads could access and modify the global state concurrently.
What does multiple inheritance allow a class to do in C++?
Inherit from two or more base classes simultaneously.
Which of the following classes and/or methods must be used directly by a programmer in every Java AWT GUI application?
Frame, A main function.
In shared state concurrency, what is the primary purpose of a std::sync::Mutex?
To ensure that only one thread can access the data (T) at a time, preventing simultaneous writes.