Rust (programming language)/Rust Multiple Choice Questions Sample Test,Sample questions

Question:
Automatic copying in rust ______

1.inexpensive in terms of runtime performance

2.create “deep” copies of your data

3.hinders runtime performance

4.All of the above

Posted Date:-2022-08-09 11:52:54


Question:
Choose the correct scalar types in Rust

1.integers, signed numbers, Booleans, and String

2.integers, floating-point numbers, Booleans, and characters

3.integers, floating-point numbers and characters

4.integers, floating-point numbers and Booleans

Posted Date:-2022-08-09 11:16:04


Question:
Choose the valid variant of enum in Rust?

1.can have no data associated with it at all

2.includes an anonymous struct inside it

3.includes a single String

4.All of the above

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


Question:
Constants cant be defined in which scope

1.Global

2.Local

3.Method

4.None

Posted Date:-2022-08-09 11:14:01


Question:
From which source file does the Rust compiler start?

1.crate root

2.cargo root

3.root

4. use root

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


Question:
Identify the types which are not Copy in Rust?

1.char

2.bool

3.(i32, i32)

4. (i32, String)

Posted Date:-2022-08-09 11:53:48


Question:
In Tuple structs

1.only type of the fields is specified

2.names associated with their fields to be specified

3.start with the tuple keyword

4. cant destructure them into their individual pieces

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


Question:
Rust is

1.statically typed

2.dynamically typed

3.strongly typed

4.untyped

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


Question:
Rust is syntatically similar to which programming language?

1.C++

2.Python

3.C Sharp

4.Java

Posted Date:-2022-08-09 10:50:05


Question:
String literals are

1.not slices

2.static

3.mutable

4.immutable

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


Question:
What are associated functions?

1.defining functions within methods

2.associated with structs

3.return a new instance of the struct

4.cant be used for constructors

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


Question:
What are the result types in Rust?

1.structure

2.enumerations

3.class

4.union

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


Question:
What does & in the function signature of Rust indicate?

1.type of the parameter

2.address

3.pointer

4.reference

Posted Date:-2022-08-09 11:54:38


Question:
What does ::new indicates?

1.static method

2.abstract method

3. final method

4.main method

Posted Date:-2022-08-09 11:05:21


Question:
What does the below statements infer?

let s1 = String::from("example");
let s2 = s1;

1.a copy of the value in s1 is binded to s2

2.copy the data on the heap that the pointer in string refers to

3.copy the pointer, the length, and the capacity that are on the stack.

4.copy the data on the string pool that the pointer in string refers to

Posted Date:-2022-08-09 11:40:11


Question:
What does the String data type hold in Rust?

1.a pointer to the memory where String resides and its capacity

2.a pointer to the memory where String resides, a length, and a capacity

3.a string value and its length

4.a string value, a length, and a capacity

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


Question:
What is a way of naming an item, such as a struct, function, or module called?

1.Crates

2.Packages

3.Modules

4.Paths

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


Question:
What is the output of the following program snippet:

fn main() {
    let three = 3;

    if three {
        println!("number was three");
    }
}

1.number was three

2.unrecognised keyword println!

3.error mismatched types

4.3

Posted Date:-2022-08-09 11:33:33


Question:
What is the proper notation of Rust's range syntax?

1.let slice = &s[0..2];

2.let slice = &s[0-2];

3. let slice = s[0-2]

4. let slice = &s[0:2];

Posted Date:-2022-08-09 11:58:35


Question:
What is the use of unit-like structs?

1.Useful for generics.

2.If you don't want to store in the type itself.

3.behave similar to ().

4.All of the above

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


Question:
When does the data race occur in Rust?

1.Two or more pointers access the same data at the same time.

2.At least one of the pointers is being used to write to the data.

3.There’s no mechanism being used to synchronize access to the data

4.All of the above

Posted Date:-2022-08-09 11:55:53


Question:
Which among the following has a tree of modules that produces a library or executable?

1.Modules

2.Crates

3.Packages

4.Paths

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


Question:
Which among the following is false with respect to Option Enum in Rust?

1.encode the concept of a value being present or absent

2.compile checks whether all the cases are handled

3.prevent bugs

4.need to bring it into scope explicitly

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


Question:
Which among the following is false with respect to ownership rules?

1.each value in Rust has a variable which is the owner.

2.There can only be one owner at a time.

3.When the owner goes out of scope, the value will be dropped.

4.owner never goes out of scope

Posted Date:-2022-08-09 11:37:11


Question:
Which among the following is not a valid keyword in Rust?

1.mut

2.impl

3.let

4. var

Posted Date:-2022-08-09 10:52:02


Question:
Which among the following is not a valid rule for references in Rust?

1.References must always be valid

2.one mutable reference

3.the compiler guarantees that references will never be dangling references

4.immutable references are not to be used

Posted Date:-2022-08-09 11:57:19


Question:
Which among the following is not true regarding if let in Rust?

1.else can be included within if let

2.if let takes a pattern and an expression separated by an = sign

3.if let takes a pattern and an expression separated by an => sign

4.matches one pattern and ignoring the rest

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


Question:
Which among the following is permitted by rust?

1.Null Pointers

2.let keyword

3.Data Races

4.Automated Garbage Collectors

Posted Date:-2022-08-09 10:51:04


Question:
Which among the following is true with respect to Multiple impl blocks?

1.Each struct is allowed to have multiple impl blocks

2.each method in its own impl block

3.first parameter is always self

4.All of the above

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


Question:
Which among the following loop is not supported by Rust?

1.loop

2.while

3.for

4.do while

Posted Date:-2022-08-09 11:34:42


Question:
Which are the two primitive compound types supported by Rust?

1.tuples and arrays

2.tuples and lists

3. lists and arrays

4.maps and arrays

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


Question:
Which brackets are used as placeholder in rust?

1.{ }

2. ( )

3.[ ]

4.< >

Posted Date:-2022-08-09 11:13:04


Question:
Which Cargo feature helps to build, test, and share crates?

1.match

2.Packages

3.Option<T>

4.Modules

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


Question:
Which function assists in cleaning up the heap memory in Rust?

1.drop

2.deallocate

3.flush

4.clean

Posted Date:-2022-08-09 11:41:15


Question:
Which helps in controlling the organization, scope and Paths privacy?

1.Paths

2.Crates

3.Modules

4.Packages

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


Question:
Which is not a valid declaration of an array?

1.let a: [i32; 5] = [1, 2, 3, 4, 5];

2.let a = [3; 5];

3.let a: = [3; 5];

4.let a = [1, 2, 3, 4, 5];

Posted Date:-2022-08-09 11:29:57


Question:
Which is not true with respect to structs in Rust?

1.flexible than tuples

2.order of the data is important to access the values

3.dot notation is used to specify the value from a struct

4.key: value pairs to be specified inside { }

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


Question:
Which is the control flow operator used for pattern matching in Rust?

1.option

2.match

3.control

4.self

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


Question:
Which keyword is used to create a method?

1.impl

2.method

3.fn

4.no keyword

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


Question:
Which keyword is used to specify Boolean type?

1.boolean

2.Boolean

3.bool

4.bl

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


Question:
Which keyword is used to write a function in rust?

1.fn

2.function

3.func

4.f

Posted Date:-2022-08-09 10:55:14


Question:
Which method is defined on Result types?

1.main

2.expect

3.handle

4. init

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


Question:
Which of the following are Result variants in Rust?

1.success and err

2.Success and Error

3.Ok and Error

4.Ok and Err

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


Question:
Which of the following is false with respect to tuples?

1.tup is the keyword used to declare tuples

2.Tuples have a fixed length

3.tuple element can be accessed by using dot (.)

4.every element of a tuple must have the same type

Posted Date:-2022-08-09 11:27:37


Question:
Which operator allows to use namespace?

1.::

2. :

3. .

4.!

Posted Date:-2022-08-09 11:38:03


Question:
Which operator is used as placeholder in Rust for pattern matching?

1.:

2. ::

3.->

4. _

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


Question:
Which operator separates the pattern and the code to be executed?

1.=>

2. ->

3.::

4._

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


Question:
Which standard library type helps to use the type system in order to prevent errors in Rust?

1.Option<T>

2.Cargo

3.Crate

4.Vec<T>

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


Question:
Which symbol is used to declare the functions with return values?

1.::

2.:

3.< >

4.->

Posted Date:-2022-08-09 11:32:06


Question:
Who designed Rust?

1.Doug Cutting

2.JetBrains

3.Graydon Hoare

4. Robert Griesemer

Posted Date:-2022-08-09 10:48:52


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!