This is the course header. This will be added on top of every page. Go to DoDAO.io to know more.
```
fn main() {
let x = 12;
println!("The value of x is: {x}");
x = 8;
println!("The value of x is: {x}");
}
```
- The value of x is: 8
- Error: the variable x is mutable
- The value of x is: 12
- Error: the variable x is immutable
Hint: NoHint
Explanation: Error would occur, because the variable x isn't set as mutable so it's value can't be changed.
Sub Topics: variables
- 1 byte
- 4 bytes
- 8 bytes
- 16 bytes
Hint: It doesn't use ASCII values
Explanation: Rust's char type is four bytes in size and represents a Unicode Scalar Value, which means it can represent a lot more than just ASCII.
Sub Topics: value-types
- True
- False
Hint: Does the compiler need to know the data type at compile time?
Explanation: It is statically typed
Sub Topics: typed_language
- let mut x: u32 = 20;
- let mut x: i32 = -20;
- let mut x: u32 = -20;
- let mut x = 20;
Hint: NoHint
Explanation: It is declared as an unsigned integer, but the value is negative
Sub Topics: variables
Suppose you declared a variable as u8 and then assigned it a value of "257". What would be the output if it’s compiled with a "“--release” flag?
"
- 257
- Error: Integer Overflow
- 0
- 1
Hint: NoHint
Explanation: After 255 the digits start rolling back to 0, 1 and so on
Sub Topics: bit-manupilation
"Eg:-"
let tup: (i32, f64, bool) = (500, 6.4, true);
- Yes
- No
Hint: NoHint
Explanation: No explanation
Sub Topics: value-types
"a. “Strings” are immutable in nature and cannot be modified. " "b. “&str” is a primitive data type, whereas “String” is implemented in the standard library." "c. To read a file into the strings, we use the read_to_string() method."
- Only a
- Both a & b
- Both b & c
- None of the above
Hint: NoHint
Explanation: Strings are mutable in nature
Sub Topics: strings
- let
- var
- impl
- mut
Hint: NoHint
Explanation: var is not a keyword in rust
Sub Topics: keywords
- {}
- [ ]
- ( )
- < >
Hint: NoHint
Explanation: No explanation
Sub Topics: variables
- Global
- Method
- Local
- All of the above
Hint: NoHint
Explanation: No explanation
Sub Topics: variables
- integers, floating-point numbers, booleans, characters
- integers, signed numbers, unsigned numbers, booleans, characters
- integers, strings, signed numbers, unsigned numbers, booleans
- integers, floating-point numbers, strings, booleans
Hint: NoHint
Explanation: No explanation
Sub Topics: value-types
- Arrays, Lists, Red-Black Trees
- Arrays, Lists, Vectors
- Arrays, Tuples
- Arrays, Maps
Hint: NoHint
Explanation: No explanation
Sub Topics: value-types
let mut arr : {i64, 3} = [2,3,5];
let mut arr : {3,3};
let mut arr = [2,3,5];
- Both a & b
- Both b & c
- Only a
- All a, b, & c
Hint: Look for the wrong declaration format, you may or may not find it
Explanation: No explanation
Sub Topics: value-types, variables
- const
- static
- depends upon the data type
- both have the same memory usage
Hint: How many of these can we update?
Explanation: Constant doesn't uses any extra heap memory to update
Sub Topics: variables
- Arrays & Tuples
- List all the data types
- Sized
- Dynamic-Sized variables not supported in rust
Hint: No hint
Explanation: No explanation
Sub Topics: value-types, variables
- used for dynamic-sized data type
- used to create a template
- used for user-defined data type
- used to set an alias of another type
Hint: Used for another types.
Explanation: Sets an alias of another type.
Sub Topics: keywords
- Collection of rust libraries
- Modules Package manager
- Build system and Package manager
- Used to create and build UI projects in rust
Hint: What is npm used for?
Explanation: No explanation
Sub Topics: package-manager
-
std::any::type_name
-
variable.type_name()
-
std::intrisic::type_name
-
std::variable::type_name
Hint: NoHint
Explanation: No explanation
Sub Topics: value-types, variables
- i32 as i64
- i64 as i32
- usize as u64
- f64 as f32
Hint: NoHint
Explanation: Because they can handle both signed and unsigned values, and are typecasted in one data type only.
Sub Topics: value-types, bit-manupilation
- Tuples
- Traits
- Arrays
- Structs
Hint: Think of the structures they're built upon
Explanation: No explanation
Sub Topics: value-types
- <//>
- /* */
- //!
- //
Hint: NoHint
Explanation: No explanation
Sub Topics: variables
- True
- False
Hint: NoHint
Explanation: Values can be updated, but can't be deleted
Sub Topics: value-types
-
let mut arr : {i32;5} = {5;0};
-
let mut arr : {i32;5} = {0;5};
-
let mut arr : {5;i32} = {5;0};
-
let mut arr : {5;i32} = {0;5};
Hint: Look at the declarations, don't get confused by the order while declaring
Explanation: The first argument is the integer you want to initialize an element with, and the second argument tells the end posistion till where you want to pre-initialize.
Sub Topics: value-types, variables
- finite heterogeneous compound data types
- finite homogeneous compound data types
- infinite heterogeneous compound data types
- infinite homogeneous compound data types
Hint: NoHint
Explanation: They can handle and store different data types
Sub Topics: value-types
Fn main( ) {
let mut dodao_io = (""Do"", 69, ""DAO"", 420);
println!(""{} "", dodao_io );
println!(""at 0 index = {} "", gfg.0 );
}
- ("Do", 69, "DAO", 420) & Do
- ("Do", 69, "DAO", 420) only
- Compilation Error
- ("Do", 69, "DAO", 420) & “Do”
Hint: No Hint
Explanation: The first print statement should've had {;?}
Sub Topics: value-types, variables
- Pseudo-mutability
- Foreshadowing
- Shadowing
- Overshadowing
Hint: NoHint
Explanation: No explantion
Sub Topics: variables
- let a_int: i64 = 20;
- let a_int = i6420;
- let a_int = 20i64;
- None of the above
Hint: NoHint
Explanation: No explanation
Sub Topics: value-types, variables
B. println!("1 - 2 = {}", 1u32 + 2);
- Only A compiles
- Only B compiles
- Both A & B compile
- None of them complies
Hint: Solution being Positive or Negative might make a difference
Explanation: Here, when initialized, 1 is set as unsigned 32 integer u32. In statement A, it works because 1+2=3, and it's positive. But, 1-2=(-1) and as they were unsigned integers, so they cannot hold a negative value, so this statement doesn't compile
Sub Topics: value-types
"println!("{}", 1_00u32 + 2_0);
"
- Compilation Error
- Runtime Error
- 3
- 120
Hint: NoHint
Explanation: 1_000u32 is similar as 100 of u32 type.
Sub Topics: value-types
- True
- False
Hint: NoHint
Explanation: No explanation
Sub Topics: strings
fn main() {
let first_string = "This is some string ".to_string();
let second_string = "Let's add some Data";
let final_string = first_string + &second_string;
println!("First string is: {}", first_string);
println!("Second string is: {}", second_string);
println!("Finally we have: {}", final_string);
}
- Only 1st print statement shows an output
- Only 1st and 2nd print statement shows an output
- All the 3 string statements show an output
- Error occurs
Hint: NoHint
Explanation: Syntatical Error in the code snippet
Sub Topics: strings, variables
-
&
-
%
-
#
-
*
Hint: NoHint
Explanation: No explanation
Sub Topics: strings
- Once you get a string slice from a string, then you cannot really modify that String anymore
- Using slices to work with Strings allows us to add an extra security measure.
- If you attempt to create a string slice in the middle of a multibyte character, your program will exit with an error
- String Slice mutably borrows the String itself
Hint: Nohint
Explanation: No explanation
Sub Topics: strings
- Panic and crashes the program
- Garbage values will be output
- Those values are ignored and the output is as expected
- Overflow is handled already by rust, so it doesn’t occur
Hint: NoHint
Explanation: The memory stack is full and overflows, so a default panic occurs and the program crashes
Sub Topics: value-types, variables
Character literals are specified using double quotes, as opposed to single quotes which stand for string literals.
- True
- False
Hint: NoHint
Explanation: No explanation
Sub Topics: strings, value-types
- True
- False
Hint: noHint
Explanation: explanation
Sub Topics: strings
fn main() {
let mut x = 2.0;
x: i32= 3.0;
}
- The code compiles without errors
- The code has errors because of immutability
- The code has errors because of illegal type conversion
- The code has errors because of no print and return statements
Hint: type declaration
Explanation: i32 is intialized as a float data type
Sub Topics: value-types, variables
If you want to store boolean values with the provision of adding more values at runtime, the most suitable way would be to use
- Arrays
- Tuples
- Vectors
- bool type Variables
Hint: Statically and Dynamic in nature
Explanation: Vector is a Dynamic nature
Sub Topics: value-types
- True
- False
Hint: NoHint
Explanation: No explanation
Sub Topics: value-types
- Weak
- Strict
- Reserved
- All of the above
Hint: NoHint
Explanation: No explanation
Sub Topics: keywords
- crate
- match
- await
- tuple
Hint: NoHint
Explanation: Rest are keywords in rust
Sub Topics: variables, keywords
- async, await, where, use
- Move, return, mut, while
- union, dyn, try, abstract
- become, box, do, incur
Hint: noHint
Explanation: explanation
Sub Topics: keywords
- Letter, underscore
- Letter, digits
- Underscore, digits
- All of the above
Hint: noHint
Explanation: explanation
Sub Topics: variables
- A positive number
- A negative number
- An unsigned number
- None of the above
Hint: noHint
Explanation: explanation
Sub Topics: value-types
In Rust, every value has its data type. The data type tells the compiler what kind of value it is and how to use it.
- True
- False
Hint: noHint
Explanation: No explanation
Sub Topics: typed_language