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


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


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


Question:
Constants cant be defined in which scope

1.Global

2.Local

3.Method

4.None


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

1.crate root

2.cargo root

3.root

4. use root


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

1.char

2.bool

3.(i32, i32)

4. (i32, String)


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


Question:
Rust is

1.statically typed

2.dynamically typed

3.strongly typed

4.untyped


Question:
Rust is syntatically similar to which programming language?

1.C++

2.Python

3.C Sharp

4.Java


Question:
String literals are

1.not slices

2.static

3.mutable

4.immutable


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


Question:
What are the result types in Rust?

1.structure

2.enumerations

3.class

4.union


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

1.type of the parameter

2.address

3.pointer

4.reference


Question:
What does ::new indicates?

1.static method

2.abstract method

3. final method

4.main method


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


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


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


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


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


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


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


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

1.Modules

2.Crates

3.Packages

4.Paths


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


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


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

1.mut

2.impl

3.let

4. var


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


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


Question:
Which among the following is permitted by rust?

1.Null Pointers

2.let keyword

3.Data Races

4.Automated Garbage Collectors


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


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

1.loop

2.while

3.for

4.do while


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


Question:
Which brackets are used as placeholder in rust?

1.{ }

2. ( )

3.[ ]

4.< >


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

1.match

2.Packages

3.Option<T>

4.Modules


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

1.drop

2.deallocate

3.flush

4.clean


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

1.Paths

2.Crates

3.Modules

4.Packages


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


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 { }


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

1.option

2.match

3.control

4.self


Question:
Which keyword is used to create a method?

1.impl

2.method

3.fn

4.no keyword


Question:
Which keyword is used to specify Boolean type?

1.boolean

2.Boolean

3.bool

4.bl


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

1.fn

2.function

3.func

4.f


Question:
Which method is defined on Result types?

1.main

2.expect

3.handle

4. init


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


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


Question:
Which operator allows to use namespace?

1.::

2. :

3. .

4.!


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

1.:

2. ::

3.->

4. _


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

1.=>

2. ->

3.::

4._


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>


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

1.::

2.:

3.< >

4.->


Question:
Who designed Rust?

1.Doug Cutting

2.JetBrains

3.Graydon Hoare

4. Robert Griesemer


More MCQS

  1. Rust Programming Language Mcq
  2. Rust Programming Language (MCQ)
  3. Rust Multiple Choice Questions
Search
Olete Team
Online Exam TestTop Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on Online Exam Testwebsite 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!