0% found this document useful (0 votes)
79 views9 pages

100 Rust, Solana & Full Stack Quiz MCQs

The document contains 100 multiple-choice questions (MCQs) divided into three sections: Rust Fundamentals, Axum Web Framework, and Solana Blockchain. Each section covers various topics such as variables, functions, error handling, and web routing for Rust, as well as blockchain concepts for Solana. The questions are designed to test knowledge and understanding of these technologies.

Uploaded by

vanshchitransh32
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
79 views9 pages

100 Rust, Solana & Full Stack Quiz MCQs

The document contains 100 multiple-choice questions (MCQs) divided into three sections: Rust Fundamentals, Axum Web Framework, and Solana Blockchain. Each section covers various topics such as variables, functions, error handling, and web routing for Rust, as well as blockchain concepts for Solana. The questions are designed to test knowledge and understanding of these technologies.

Uploaded by

vanshchitransh32
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

100 Quiz MCQs for Rust, Solana & Full Stack

RUST FUNDAMENTALS (Questions 1-35)


Variables & Data Types
1. How do you declare a mutable variable in Rust? A) var x = 5 B) let mut x = 5 C) let x = 5 D) const x
= 5 Answer: B) let mut x = 5
2. What's the default integer type in Rust? A) i32 B) i64 C) u32 D) int Answer: A) i32
3. Which is Rust's owned string type? A) &str B) String C) str D) char Answer: B) String
4. How do you create a string literal in Rust? A) "hello" B) 'hello' C) String::new("hello") D)
str("hello") Answer: A) "hello"
5. What does let x = 5; create? A) A mutable variable B) An immutable variable C) A constant D) A
reference Answer: B) An immutable variable
Functions
6. How do you define a function that returns an integer? A) function getValue() -> int B) fn
get_value() -> i32 C) def get_value() -> i32 D) func getValue() -> int Answer: B) fn get_value() ->
i32
7. What's the correct way to return a value from a function? A) return 5; B) return 5 C) 5 D) Both B
and C Answer: D) Both B and C
8. How do you define a function with no return value? A) fn hello() -> void B) fn hello() -> () C) fn
hello() D) Both B and C Answer: D) Both B and C
9. What does async fn create? A) A synchronous function B) An asynchronous function C) A parallel
function D) A thread function Answer: B) An asynchronous function
Structs & Enums
10. How do you define a struct in Rust? A) struct Point { x: i32, y: i32 } B) struct Point(i32, i32) C)
class Point { x: i32, y: i32 } D) Both A and B Answer: D) Both A and B
11. What does #[derive(Serialize)] do? A) Makes struct printable B) Enables JSON serialization C)
Creates a constructor D) Makes struct comparable Answer: B) Enables JSON serialization
12. How do you create an instance of a struct? A) Point { x: 1, y: 2 } B) new Point(1, 2) C)
Point::new(1, 2) D) Point(1, 2) Answer: A) Point { x: 1, y: 2 }
13. What's the correct enum syntax? A) enum Color { Red, Green, Blue } B) enum Color = { Red,
Green, Blue } C) enum Color: Red, Green, Blue D) enum Color -> Red | Green | Blue Answer: A) enum
Color { Red, Green, Blue }
Error Handling
14. What does Result<T, E> represent? A) Success or failure B) True or false C) Some or none D)
Left or right Answer: A) Success or failure
15. What does the ? operator do? A) Makes a value optional B) Returns early on error C) Creates a
question D) Checks if value exists Answer: B) Returns early on error
16. How do you handle a Result with match? A) match result { Ok(x) => x, Err(e) => panic!() } B)
match result { Success(x) => x, Failure(e) => panic!() } C) match result { Some(x) => x, None => panic!
() } D) match result { True(x) => x, False(e) => panic!() } Answer: A) match result { Ok(x) => x, Err(e)
=> panic!() }
17. What does Option<T> represent? A) Success or failure B) Some value or no value C) True or
false D) Left or right Answer: B) Some value or no value
18. How do you unwrap a Result unsafely? A) [Link]() B) [Link]() C) [Link]() D)
[Link]() Answer: B) [Link]()
Conversions
19. How do you convert a string to an integer? A) [Link]::<i32>() B) i32::from(string) C)
string.to_i32() D) convert(string, i32) Answer: A) [Link]::<i32>()
20. What trait enables from_str() conversion? A) Convert B) Parse C) FromStr D) ToString Answer:
C) FromStr
21. How do you convert an integer to string? A) num.to_string() B) String::from(num) C) [Link]()
D) Both A and B Answer: D) Both A and B
Ownership & Borrowing (Basic)
22. What does & create? A) A pointer B) A reference C) A copy D) A move Answer: B) A reference
23. What's the difference between String and &str ? A) String is owned, &str is borrowed B) String
is borrowed, &str is owned C) No difference D) String is mutable, &str is immutable Answer: A) String
is owned, &str is borrowed
24. What happens when you pass a value to a function? A) It's always copied B) It's moved by
default C) It's always borrowed D) It depends on the type Answer: B) It's moved by default
Macros & Printing
25. How do you print to console? A) print("hello") B) println!("hello") C) [Link]("hello") D)
printf("hello") Answer: B) println!("hello")
26. What's the difference between println! and print! ? A) No difference B) println! adds a newline
C) print! is faster D) println! is for errors Answer: B) println! adds a newline
27. How do you print a variable? A) println!(x) B) println!("{}", x) C) println!("{x}") D) Both B and C
Answer: D) Both B and C
Collections (Basic)
28. How do you create a vector? A) vec![1, 2, 3] B) Vector::new([1, 2, 3]) C) [1, 2, 3].to_vec() D) Both
A and C Answer: D) Both A and C
29. How do you create a HashMap? A) HashMap::new() B) hash_map!{} C) {} D) Map::new()
Answer: A) HashMap::new()
30. How do you access vector elements? A) vec[0] B) [Link](0) C) [Link](0) D) Both A and B
Answer: D) Both A and B
Pattern Matching
31. What's the basic match syntax? A) switch value { case x => result } B) match value { pattern =>
result } C) if value { pattern => result } D) when value { pattern => result } Answer: B) match value {
pattern => result }
32. What does _ mean in match? A) Wildcard/catch-all B) Previous value C) Underscore literal D)
Empty pattern Answer: A) Wildcard/catch-all
33. How do you match multiple patterns? A) pattern1 | pattern2 => result B) pattern1 || pattern2 =>
result C) pattern1 & pattern2 => result D) pattern1, pattern2 => result Answer: A) pattern1 | pattern2
=> result
Control Flow
34. How do you write an if statement? A) if (condition) { } B) if condition { } C) if condition then { } D)
if condition: { } Answer: B) if condition { }
35. How do you write a for loop over a vector? A) for item in vec { } B) for item of vec { } C) for (item
in vec) { } D) forEach(vec, item => { }) Answer: A) for item in vec { }
AXUM WEB FRAMEWORK (Questions 36-55)
36. How do you create a basic Axum router? A) Router::new() B) Axum::router() C) new Router() D)
create_router() Answer: A) Router::new()
37. How do you add a GET route? A) [Link]("/path", handler) B) [Link]("/path", get(handler))
C) router.add_route("GET", "/path", handler) D) [Link]("/path").get(handler) Answer: B)
[Link]("/path", get(handler))
38. What's the correct handler function signature? A) fn handler() -> String B) async fn handler() -
> String C) async fn handler() -> impl IntoResponse D) function handler() -> Response Answer: C)
async fn handler() -> impl IntoResponse
39. How do you return JSON from a handler? A) Json(data) B) json!(data) C) Response::json(data)
D) return_json(data) Answer: A) Json(data)
40. How do you extract query parameters? A) Query(params): Query<HashMap<String, String>> B)
QueryParams(params) C) ExtractQuery(params) D) Params(params) Answer: A) Query(params):
Query<HashMap<String, String>>
41. How do you handle POST requests? A) [Link]("/path", post(handler)) B)
[Link]("/path", handler) C) router.handle_post("/path", handler) D) [Link]("/path", POST,
handler) Answer: A) [Link]("/path", post(handler))
42. How do you extract JSON body? A) Json(payload): Json<MyStruct> B) Body(payload) C)
Extract(payload) D) JsonBody(payload) Answer: A) Json(payload): Json<MyStruct>
43. How do you return an error status? A) StatusCode::INTERNAL_SERVER_ERROR B)
HttpError::500 C) ErrorStatus::InternalError D) Status::Error(500) Answer: A)
StatusCode::INTERNAL_SERVER_ERROR
44. How do you enable CORS? A) .layer(CorsLayer::permissive()) B) .enable_cors() C) .add_cors() D)
.with_cors() Answer: A) .layer(CorsLayer::permissive())
45. How do you start the Axum server? A) axum::serve(listener, app).await B) [Link](port).await
C) server::start(app, port) D) run_server(app, address) Answer: A) axum::serve(listener, app).await
46. What port does the example use by default? A) 8080 B) 3000 C) 8000 D) 5000 Answer: B)
3000
47. How do you bind to all interfaces? A) "localhost:3000" B) "[Link]:3000" C) "[Link]:3000" D)
"*:3000" Answer: C) "[Link]:3000"
48. What's the purpose of #[tokio::main] ? A) Starts a thread B) Enables async runtime C) Creates
main function D) Handles errors Answer: B) Enables async runtime
49. How do you serve static files? A) .route_service("/static", ServeDir::new("assets")) B)
.static_files("/static", "assets") C) .serve_dir("/static", "assets") D) .add_static("/static", "assets")
Answer: A) .route_service("/static", ServeDir::new("assets"))
50. What does impl IntoResponse mean? A) Function implements response B) Return type can be
converted to HTTP response C) Response is implemented D) Function returns interface Answer: B)
Return type can be converted to HTTP response
51. How do you extract path parameters? A) Path(id): Path<String> B) PathParam(id) C)
ExtractPath(id) D) RouteParam(id) Answer: A) Path(id): Path<String>
52. How do you handle middleware? A) .layer(middleware) B) .use(middleware) C)
.add_middleware(middleware) D) .with(middleware) Answer: A) .layer(middleware)
53. What's the correct way to import Axum routing? A) use axum::routing::{get, post}; B) use
axum::{get, post}; C) use axum::routes::{get, post}; D) use axum::http::{get, post}; Answer: A) use
axum::routing::{get, post};
54. How do you create a nested router? A) Router::new().nest("/api", api_router) B)
router.add_subrouter("/api", api_router) C) [Link]("/api", api_router) D) [Link]("/api",
api_router) Answer: A) Router::new().nest("/api", api_router)
55. What does .await do? A) Waits for async operation to complete B) Pauses execution C) Creates
a delay D) Synchronizes threads Answer: A) Waits for async operation to complete
SOLANA BLOCKCHAIN (Questions 56-75)
56. What's Solana's native cryptocurrency? A) ETH B) BTC C) SOL D) ADA Answer: C) SOL
57. What's the smallest unit of SOL? A) Wei B) Satoshi C) Lamport D) Gwei Answer: C) Lamport
58. How many lamports equal 1 SOL? A) 1,000,000 B) 1,000,000,000 C) 100,000,000 D)
1,000,000,000,000 Answer: B) 1,000,000,000
59. What's Solana's development network called? A) Testnet B) Devnet C) Mainnet D) Localnet
Answer: B) Devnet
60. How do you create an RPC client? A) RpcClient::new(url) B) SolanaClient::connect(url) C)
Client::new(url) D) new RpcClient(url) Answer: A) RpcClient::new(url)
61. What's the devnet RPC URL? A) [Link] B) [Link] C)
[Link] D) [Link] Answer: A)
[Link]
62. How do you get account balance? A) client.get_balance(pubkey) B) [Link](pubkey) C)
client.fetch_balance(pubkey) D) client.account_balance(pubkey) Answer: A)
client.get_balance(pubkey)
63. What type represents a Solana address? A) Address B) Pubkey C) PublicKey D) SolanaAddress
Answer: B) Pubkey
64. How do you create a Pubkey from string? A) Pubkey::from_str(string) B) Pubkey::parse(string)
C) Pubkey::new(string) D) string.to_pubkey() Answer: A) Pubkey::from_str(string)
65. What does an account contain? A) Only balance B) Balance, owner, data, executable flag C) Only
owner and data D) Only balance and owner Answer: B) Balance, owner, data, executable flag
66. How do you get account information? A) client.get_account(pubkey) B)
client.account_info(pubkey) C) client.fetch_account(pubkey) D) client.get_account_info(pubkey)
Answer: A) client.get_account(pubkey)
67. What's the system program address? A) 11111111111111111111111111111111 B)
11111111111111111111111111111112 C) 00000000000000000000000000000000 D)
22222222222222222222222222222222 Answer: B) 11111111111111111111111111111112
68. What does RPC stand for? A) Remote Procedure Call B) Real-time Protocol Communication C)
Rapid Processing Client D) Request Processing Center Answer: A) Remote Procedure Call
69. How do you handle Solana RPC errors? A) try-catch B) Result<T, E> and match C) error
callbacks D) exception handling Answer: B) Result<T, E> and match
70. What's a Solana program? A) A smart contract B) A client application C) A wallet D) A node
Answer: A) A smart contract
71. Where do programs execute? A) Client-side B) On-chain C) Server-side D) Browser Answer: B)
On-chain
72. What format does Solana use for transactions? A) JSON B) Binary C) XML D) YAML Answer: B)
Binary
73. How do you convert lamports to SOL? A) lamports / 1_000_000_000.0 B) lamports *
1_000_000_000.0 C) SOL::from_lamports(lamports) D) lamports.to_sol() Answer: A) lamports /
1_000_000_000.0
74. What's a Solana cluster? A) A group of validators B) A single node C) A wallet group D) A
program collection Answer: A) A group of validators
75. How do you check if an account is executable? A) account.is_executable B) [Link]
C) account.can_execute D) [Link] Answer: B) [Link]
FULL STACK / WEB DEVELOPMENT (Questions 76-100)
76. What does HTTP stand for? A) HyperText Transfer Protocol B) High Transfer Text Protocol C)
HyperText Transport Protocol D) High Text Transfer Protocol Answer: A) HyperText Transfer
Protocol
77. What's the default HTTP port? A) 8080 B) 3000 C) 80 D) 443 Answer: C) 80
78. What HTTP method retrieves data? A) POST B) GET C) PUT D) DELETE Answer: B) GET
79. What HTTP method sends data? A) GET B) POST C) RETRIEVE D) SEND Answer: B) POST
80. What's the success HTTP status code? A) 200 B) 404 C) 500 D) 300 Answer: A) 200
81. What's the "not found" status code? A) 400 B) 500 C) 404 D) 403 Answer: C) 404
82. What's the server error status code? A) 400 B) 404 C) 500 D) 200 Answer: C) 500
83. What format is commonly used for API responses? A) XML B) JSON C) CSV D) HTML Answer:
B) JSON
84. What does CORS stand for? A) Cross-Origin Resource Sharing B) Client-Origin Request System
C) Cross-Origin Request Security D) Client-Origin Resource System Answer: A) Cross-Origin
Resource Sharing
85. What's a REST API? A) A database type B) An architectural style for web services C) A
programming language D) A web framework Answer: B) An architectural style for web services
86. What does URL stand for? A) Universal Resource Locator B) Uniform Resource Locator C)
Universal Reference Link D) Uniform Reference Locator Answer: B) Uniform Resource Locator
87. What's a query parameter? A) A URL path segment B) A key-value pair in URL after ? C) A
request header D) A response body Answer: B) A key-value pair in URL after ?
88. How do you pass data in a GET request? A) Request body B) Query parameters C) Headers only
D) POST data Answer: B) Query parameters
89. How do you pass data in a POST request? A) Query parameters only B) Request body C) URL
path D) Headers only Answer: B) Request body
90. What's localhost? A) A remote server B) Your local machine C) A domain name D) A cloud service
Answer: B) Your local machine
91. What does API stand for? A) Application Programming Interface B) Advanced Programming
Interface C) Application Protocol Interface D) Advanced Protocol Interface Answer: A) Application
Programming Interface
92. What's the purpose of middleware? A) Process requests before handlers B) Store data C)
Render HTML D) Handle errors only Answer: A) Process requests before handlers
93. What does deployment mean? A) Writing code B) Testing code C) Making code available online
D) Debugging code Answer: C) Making code available online
94. What's ngrok used for? A) Code editing B) Exposing local servers to internet C) Database
management D) File storage Answer: B) Exposing local servers to internet
95. What does TCP stand for? A) Transfer Control Protocol B) Transmission Control Protocol C)
Transport Control Protocol D) Transfer Communication Protocol Answer: B) Transmission Control
Protocol
96. What's a web server? A) A database B) Software that serves web content C) A programming
language D) A web browser Answer: B) Software that serves web content
97. What does async/await do? A) Creates threads B) Handles asynchronous operations C) Speeds
up code D) Handles errors Answer: B) Handles asynchronous operations
98. What's the difference between HTTP and HTTPS? A) No difference B) HTTPS is encrypted C)
HTTP is faster D) HTTPS is older Answer: B) HTTPS is encrypted
99. What's a JSON object? A) { "key": "value" } B) [ "item1", "item2" ] C) "string" D) 123 Answer: A) {
"key": "value" }
100. What's the purpose of Cargo in Rust? A) Package manager and build tool B) Web framework C)
Database D) Testing tool Answer: A) Package manager and build tool
QUICK REFERENCE SUMMARY
Key Rust Patterns to Memorize:
Variables: let (immutable), let mut (mutable)
Functions: fn name() -> return_type
Structs: struct Name { field: Type }
Error handling: Result<T, E> , ? operator
JSON: #[derive(Serialize)]
Key Axum Patterns:
Router: Router::new().route("/path", get(handler))
Handler: async fn handler() -> Json<Response>
JSON response: Json(data)
Query params: Query(params): Query<HashMap<String, String>>
Key Solana Facts:
Currency: SOL
Smallest unit: Lamport (1 SOL = 1,000,000,000 lamports)
RPC client: RpcClient::new(url)
Address type: Pubkey
Convert address: Pubkey::from_str(string)
Key Web Concepts:
Success: 200, Not Found: 404, Server Error: 500
GET: retrieve data, POST: send data
API responses: JSON format
Query params: /path?key=value

You might also like