Q. What happens if set_body() is called with null body?

  • (A) Returns false
  • (B) Throws NullPointerException
  • (C) Ignores the call
  • (D) Creates empty body
πŸ’¬ Discuss
βœ… Correct Answer: (B) Throws NullPointerException
Explanation: It throws NullPointerException if the body is null.

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.

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.

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.

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.

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.

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.

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.

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.