Rust (programming language)/Rust Programming Language (MCQ) Sample Test,Sample questions

Question:
 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

Posted Date:-2022-08-09 09:13:00


Question:
 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

Posted Date:-2022-08-09 09:04:56


Question:
 In Rust, which keyword is used to define a boolean?

1.bool

2.Boolean

3.boolean

4.:boolean

Posted Date:-2022-08-09 09:20:39


Question:
 What is Cargo in Rust?

1.Build system

2.Build system and package manager

3.Collection of Rust libraries

4.Package manager

Posted Date:-2022-08-09 08:50:44


Question:
Among const and static in Rust, which one has low memory requirement?

1.same for both

2.static

3.depends on datatype

4.const

Posted Date:-2022-08-09 07:59:11


Question:
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

Posted Date:-2022-08-09 08:03:01


Question:
Does Rust guarantee Tail Call Optimization?

1.Depends on recursion

2.On using safe block

3.No

4.Yes

Posted Date:-2022-08-09 08:51:39


Question:
Does Rust support "Move Constructors"

1.yes

2.Only for primitive data type

3.Yes, if Move() is implemented

4.No

Posted Date:-2022-08-09 09:00:08


Question:
From which code does the compilation of a Rust project begin

1.cargo root

2.carte root

3.root

4.root use

Posted Date:-2022-08-09 09:15:44


Question:
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();

Posted Date:-2022-08-09 09:06:04


Question:
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

Posted Date:-2022-08-09 09:03:16


Question:
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

Posted Date:-2022-08-09 08:52:49


Question:
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

Posted Date:-2022-08-09 09:17:06


Question:
In OOP in Rust, which keyword is used to define Interfaces?

1.pub

2. impl

3.trait

4.fn

Posted Date:-2022-08-09 07:51:23


Question:
In Rust, how is a macro from the above Rust code snippet used?

1.foo!()

2.#foo

3.foo

4.foo(x)

Posted Date:-2022-08-09 08:45:54


Question:
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

Posted Date:-2022-08-09 08:06:50


Question:
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

Posted Date:-2022-08-09 08:57:42


Question:
Is Rust Garbage Collected by default?

1.Only when pointers are used

2.Depends on memory usage

3.No

4.Yes

Posted Date:-2022-08-09 09:01:55


Question:
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

Posted Date:-2022-08-09 07:53:39


Question:
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

Posted Date:-2022-08-09 08:05:43


Question:
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

Posted Date:-2022-08-09 08:00:59


Question:
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

Posted Date:-2022-08-09 09:09:09


Question:
The above code outputs the size of variable a. What is the output (in bytes)?

1.4

2.2

3.o

4.1

Posted Date:-2022-08-09 09:10:54


Question:
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

Posted Date:-2022-08-09 09:07:26


Question:
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

Posted Date:-2022-08-09 08:58:59


Question:
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

Posted Date:-2022-08-09 08:04:00


Question:
What bracket is used as a placeholder in Rust?

1.()

2.{}

3.[]

4.::()::

Posted Date:-2022-08-09 09:24:02


Question:
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

Posted Date:-2022-08-09 08:45:01


Question:
What is the impl keyword used in Rust?

1.For Interfaces

2.For Inheritance

3.Define a class

4.Implement functionality on types

Posted Date:-2022-08-09 07:54:39


Question:
What is the output of the above code?

1.32

2.undefined

3.44

4.21

Posted Date:-2022-08-09 09:12:08


Question:
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

Posted Date:-2022-08-09 08:47:38


Question:
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

Posted Date:-2022-08-09 08:08:22


Question:
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

Posted Date:-2022-08-09 08:54:51


Question:
What will be the output of the above Rust code?

1.54

2.66

3.Compilation error

4.Runtime error

Posted Date:-2022-08-09 09:10:15


Question:
When is unwrap() used in Rust?

1.For loop optimizations

2.To make code linear

3.Compiler optimizations

4.For debugging

Posted Date:-2022-08-09 08:53:44


Question:
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();

Posted Date:-2022-08-09 07:55:58


Question:
Which command is used to compile a Rust code?

1.rustc code.rs

2.code

3.gcc code.rs

4.gcrust code.rs

Posted Date:-2022-08-09 07:58:21


Question:
Which company controls Rust Programming Language?

1.LLVM

2.Mozilla

3.Google

4.The Rust Foundation

Posted Date:-2022-08-09 08:55:49


Question:
Which function in Rust helps to clean heap memory?

1.flush

2.deallocate

3.clean

4.Drop

Posted Date:-2022-08-09 09:14:22


Question:
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];

Posted Date:-2022-08-09 09:27:58


Question:
Which keyword is used to define a variable in Rust

1.const

2.let

3.f32

4.mul

Posted Date:-2022-08-09 07:44:58


Question:
Which library does Rust use for memory allocation?

1.mimalloc

2.jemalloc

3.ptmalloc

4.tcmalloc

Posted Date:-2022-08-09 08:48:42


Question:
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

Posted Date:-2022-08-09 07:45:51


Question:
Who designed Rust from scratch in 2006?

1.Graydon Hoare

2.David Flanagan

3.Yukihiro Matsumoto

4.Guido van Rossum

Posted Date:-2022-08-09 08:49:45


More MCQS

  1. Rust Programming Language Mcq
  2. Rust Programming Language (MCQ)
  3. Rust Multiple Choice Questions
Search
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!