Study Tools

0.0(0)
studied byStudied by 0 people
0.0(0)
full-widthCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/17

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

18 Terms

1
New cards

In many simple cases, Rust allows you to omit explicit lifetime annotations in function signatures. What is this feature called?

Lifetime Elision

2
New cards

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.

3
New cards

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 }

4
New cards

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.

5
New cards

Which of the following variable names follows the "Camel Case" convention?

myVariableName

6
New cards

What happens if you call .unwrap() on an Option<T> that holds the None variant?

The program will panic.

7
New cards

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.)

8
New cards

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.

9
New cards

Which statement accurately describes the reliability of TCP and UDP?

TCP is reliable (guaranteed delivery and order), while UDP is unreliable (no guarantees).

10
New cards

What is a "function object" or "functor" in C++?

An object of a class that has an overloaded function call operator operator()).

11
New cards

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.

12
New cards

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.

13
New cards

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>.

14
New cards

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.

15
New cards

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.

16
New cards

What does multiple inheritance allow a class to do in C++?

Inherit from two or more base classes simultaneously.

17
New cards

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.

18
New cards

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.