Programming MCQs Feed

📊 Trishul API
Q. Which method provides access to HTTP headers?
  • (A) headers()
  • (B) header()
  • (C) getHeaders()
  • (D) fetchHeaders()
💬 Discuss
✅ Correct Answer: (B) header()

Explanation: header() returns the Header object.

📊 Trishul API
Q. Which method is used internally to set headers?
  • (A) assign_header
  • (B) header_set
  • (C) set_header
  • (D) update_header
💬 Discuss
✅ Correct Answer: (C) set_header

Explanation: set_header() is used internally to assign headers.

📊 Trishul API
Q. Which method returns the Session object?
  • (A) get_session
  • (B) session
  • (C) session_data
  • (D) fetch_session
💬 Discuss
✅ Correct Answer: (B) session

Explanation: session() returns the Session object.

📊 Trishul API
Q. Which method sets cookies internally?
  • (A) set_cookie
  • (B) assign_cookie
  • (C) cookie_set
  • (D) update_cookie
💬 Discuss
✅ Correct Answer: (A) set_cookie

Explanation: set_cookie() assigns the Cookie object.

📊 Trishul API
Q. What is passed to the constructor of Request?
  • (A) HTTP method
  • (B) URL
  • (C) Headers
  • (D) Body
💬 Discuss
✅ Correct Answer: (B) URL

Explanation: The constructor accepts a URL string.

📊 Trishul API
Q. Which method sets path variables internally?
  • (A) set_path
  • (B) assign_path
  • (C) path_set
  • (D) update_path
💬 Discuss
✅ Correct Answer: (A) set_path

Explanation: set_path() assigns path variables.

📊 Trishul API
Q. What is a key design note of the Request class?
  • (A) Properties are instance-based
  • (B) Properties are static
  • (C) Immutable design
  • (D) Thread-safe by default
💬 Discuss
✅ Correct Answer: (B) Properties are static

Explanation: All properties are static, meaning shared across instances.

📊 Trishul API
Q. How should request data be accessed?
  • (A) Direct property access
  • (B) Using getter methods
  • (C) Using global variables
  • (D) Using constants
💬 Discuss
✅ Correct Answer: (B) Using getter methods

Explanation: The class enforces access through getter methods.

📊 Trishul API
Q. What is the main purpose of the Response class?
  • (A) Handle routing
  • (B) Construct and send HTTP responses
  • (C) Manage database
  • (D) Handle middleware
💬 Discuss
✅ Correct Answer: (B) Construct and send HTTP responses

Explanation: Response class is responsible for HTTP response creation and sending.

📊 Trishul API
Q. Which method creates a JSON response object?
  • (A) out()
  • (B) json()
  • (C) send()
  • (D) response()
💬 Discuss
✅ Correct Answer: (B) json()

Explanation: json() creates response object without sending it.