From previous question, we know increment and decrement operators does not exist in Rust. What will be the output of the above code?
1.2
2.option3
3.option2
4.option4
How to print data type of a variable in Rust?
1.what_is_this()
2.std::any::type_name
3.variable.type_name()
4.std::intrinsic::type_name
In Rust, which keyword is used to define a boolean?
1.bool
2.Boolean
3.boolean
4.:boolean
What is Cargo in Rust?
1.Build system
2.Build system and package manager
3.Collection of Rust libraries
4.Package manager
Among const and static in Rust, which one has low memory requirement?
1.same for both
2.static
3.depends on datatype
4.const
Arbitrary casting is one of the most dangerous feature of Rust. Which keyword is used for it?
1. as
2.(data_type) variable
3.static
4.transmute
Does Rust guarantee Tail Call Optimization?
1.Depends on recursion
2.On using safe block
3.No
4.Yes
Does Rust support "Move Constructors"
1.yes
2.Only for primitive data type
3.Yes, if Move() is implemented
4.No
From which code does the compilation of a Rust project begin
1.cargo root
2.carte root
3.root
4.root use
How to convert a String to an Integer (int) in Rust?
1.my_string.parse()
2.int(my_string)
3.my_string.to_int()
4.my_string.parse().unwrap();
How to disable warnings in Rust about unused code segments?
1.what_is_this()
2.std::any::type_name
3.variable.type_name()
4.std::intrinsic::type_name
In a function declaration, we can use &self, self and &mul. When is self used?
1.Value consumed by function
2.Read only reference to value needed
3.Value mutated by function
4.Refer to local variable
In a Rust code, what does & denote in a function signature?
1.Reference of parameter
2.type of parameter
3.Pointer of parameter
4.Address of parameter
In OOP in Rust, which keyword is used to define Interfaces?
1.pub
2. impl
3.trait
4.fn
In Rust, how is a macro from the above Rust code snippet used?
1.foo!()
2.#foo
3.foo
4.foo(x)
In Rust, unsafe function and block allows 3 features. Which one feature is not allowed in Rust "unsafe" ?
1.Call unsafe functions
2.Dereference a raw pointer
3.turn off the borrow checker
4.Access or update a static mutable variable
Is Rust an Object Oriented Programming (OOP) Language?
1.Yes, it is OOP
2.No, it is multi paradigm
3.No, it is Procedural
4.No, it is functional
Is Rust Garbage Collected by default?
1.Only when pointers are used
2.Depends on memory usage
3.No
4.Yes
pub is used to define public in Rust. Are the data members in the structure public or private
1.private
2.public
3.depends on function
4.undefined
Raw pointers are unsafe pointers in Rust. What is the main use of Raw pointers in Rust?
1.C type implementation
2.Low level memory control
3.Get address of variables
4.Foreign Function Interface
Rust is known to be memory safe. Which feature is the main reason for the memory safety of Rust?>
1.ownership
2.borrowing
3.reference
4.lifetimes
Rust supports many tools officially like Rustup and Rustfmt. What is Clippy tool in Rust?
1.Code cleanup
2.Linter
3.Code formatter
4.Code compressor
The above code outputs the size of variable a. What is the output (in bytes)?
1.4
2.2
3.o
4.1
There are 3 different ways to return an iterator in Rust: into_itr, itr and itr_mul. What is the yield of the returned iterator for itr?
1.&T
2.T
3.&mut T
4.mut T
There are many string data types in Rust like Slice, OsStr, str, CStr, Owned, String, OsString and CString. Which one is a primitive data type in Rust?
1.Owned
2.CString
3.str
4.String
To support Dynamic Sized variables, what should we use in place of "f32"?
1.?Sized
2.list all data-types
3.Not supported in Rust
4.Use array
What bracket is used as a placeholder in Rust?
1.()
2.{}
3.[]
4.::()::
What is "Drop" in Rust used for?
1.option4
2.Run code and drop it if error comes
3.Run code as multi-threaded
4.Run code when variable is out of scope
What is the impl keyword used in Rust?
1.For Interfaces
2.For Inheritance
3.Define a class
4.Implement functionality on types
What is the output of the above code?
1.32
2.undefined
3.44
4.21
What is the predefined macro "unreachable!" in Rust used for?
1.warning if code not executed
2.un-implemented code snippet
3.sample code for unexpect path
4.code should never execute
What is the use of "type" keyword in Rust?
1.User defined data type
2.dynamic sized datatype
3.template
4.alias of another type
What is the version of the latest Rust release (As of late 2021)?
1.1.31.1
2.2.0.0
3.1.55.0
4.1.1.0
What will be the output of the above Rust code?
1.54
2.66
3.Compilation error
4.Runtime error
When is unwrap() used in Rust?
1.For loop optimizations
2.To make code linear
3.Compiler optimizations
4.For debugging
Which code statement in Rust is used to define a BTreeMap object?
1.let mut btm = BTreeMap::new();
2.let btm = BTreeMap::new();
3.BTreeMap btm = std::collections::BTreeMap::new();
4.BTreeMap btm = BTreeMap.new();
Which command is used to compile a Rust code?
1.rustc code.rs
2.code
3.gcc code.rs
4.gcrust code.rs
Which company controls Rust Programming Language?
1.LLVM
2.Mozilla
3.Google
4.The Rust Foundation
Which function in Rust helps to clean heap memory?
1.flush
2.deallocate
3.clean
4.Drop
Which is the following is a correct Rust syntax?
1.let slice = &s[0..5];
2.let slice = s[0->5];
3.let slice = &s[0->5];
4.let slice = s[0..5];
Which keyword is used to define a variable in Rust
1.const
2.let
3.f32
4.mul
Which library does Rust use for memory allocation?
1.mimalloc
2.jemalloc
3.ptmalloc
4.tcmalloc
Which of the following is immutable by default in Rust but can be made mutable
1.Depends on usage
2.user defined object
3.const
4.variable
Who designed Rust from scratch in 2006?
1.Graydon Hoare
2.David Flanagan
3.Yukihiro Matsumoto
4.Guido van Rossum