Computer Science MCQs · Django In Django templates, what is the difference between {{ }} and {% %}? A {{ }} outputs variables; {% %} runs tags like for/if Correct answer B Both are comments that the browser never shows C Both output variables, with different formatting D {{ }} runs tags like for/if; {% %} outputs variables MCQSEXAM Show answer Read explanation
Computer Science MCQs · Django Which database does a new Django project use by default? A MySQL B MongoDB C SQLite Correct answer D PostgreSQL MCQSEXAM Show answer Read explanation
Computer Science MCQs · Django What is the advantage of Product.objects.update(stock=F('stock') - 1) over reading, changing and saving in Python? A It skips the database and edits a cache B The database updates it atomically Correct answer C It works only when DEBUG is set to True D It loads every product into memory first MCQSEXAM Show answer Read explanation
Computer Science MCQs · Django Which Django signal can run code automatically after a model instance is saved? A post_migrate B post_save Correct answer C pre_delete D request_started MCQSEXAM Show answer Read explanation
Computer Science MCQs · Django What happens if Model.objects.get() matches more than one row? A It silently returns None instead B It raises MultipleObjectsReturned Correct answer C It returns a list of all the rows D It returns the first matching row MCQSEXAM Show answer Read explanation
Computer Science MCQs · Django What does get_object_or_404(Product, pk=5) do if no matching product exists? A Raises Http404 (Not Found) Correct answer B Returns the first product instead C Returns None without any error D Creates a new product with pk 5 MCQSEXAM Show answer Read explanation
Computer Science MCQs · Django When DEBUG = False in Django settings, which setting must list the domains the site may serve? A INSTALLED_APPS B STATIC_ROOT C ALLOWED_HOSTS Correct answer D SECRET_KEY MCQSEXAM Show answer Read explanation
Computer Science MCQs · Django In Django, when does a QuerySet such as Book.objects.filter(author='Ali') actually query the database? A When the Django server first starts B Only when the migrate command runs C When it is evaluated, for example iterated Correct answer D As soon as the filter line is written MCQSEXAM Show answer Read explanation
Computer Science MCQs · HTML What does the defer attribute do on an external <script> tag? A Runs it after parsing, in order Correct answer B Runs it only when the user scrolls C Prevents the script from ever running D Runs it immediately and blocks parsing MCQSEXAM Show answer Read explanation
Computer Science MCQs · HTML Which element provides a caption for content inside a <figure>? A <legend> B <caption> C <figcaption> Correct answer D <summary> MCQSEXAM Show answer Read explanation
Computer Science MCQs · HTML What is the purpose of the srcset attribute on an <img> element? A To offer image files for different screen sizes Correct answer B To load several images as a slideshow C To set the image's colour profile D To list backup URLs if the server is down MCQSEXAM Show answer Read explanation
Computer Science MCQs · HTML What does loading="lazy" on an <img> element do? A Prevents the image from being cached B Loads the image at a lower resolution C Loads the image only after a user clicks it D Delays loading until the image nears the viewport Correct answer MCQSEXAM Show answer Read explanation
Computer Science MCQs · HTML Which attribute makes a table cell span across three columns? A cols="3" B colspan="3" Correct answer C span="3" D rowspan="3" MCQSEXAM Show answer Read explanation
Computer Science MCQs · HTML What does <meta name="viewport" content="width=device-width, initial-scale=1"> do? A Hides the page from search engine results B Sets the page title shown in the browser tab C Makes the page scale correctly on mobile screens Correct answer D Prevents users from zooming on any device MCQSEXAM Show answer Read explanation
Computer Science MCQs · HTML Which attribute prevents a form from being submitted while a field is empty? A notnull B mandatory C validate D required Correct answer MCQSEXAM Show answer Read explanation
Computer Science MCQs · HTML What does <input type="email"> provide over type="text"? A Encryption of the typed address B Automatic sending of an email C A list of the user's contacts D Built-in email format validation Correct answer MCQSEXAM Show answer Read explanation
Computer Science MCQs · HTML How is a <label> correctly linked to an input with id="email"? A <label id="email"> B <label for="email"> Correct answer C <label href="email"> D <label name="email"> MCQSEXAM Show answer Read explanation
Computer Science MCQs · HTML Why is rel="noopener" added to links that use target="_blank"? A To block access to window.opener Correct answer B To prevent search engines following it C To speed up loading of the linked page D To make the link open in the same tab MCQSEXAM Show answer Read explanation
Computer Science MCQs · HTML What does <!DOCTYPE html> at the start of a page do? A It links the page to a JavaScript file B It loads the default CSS stylesheet C It enables HTML5 standards mode Correct answer D It creates the page's main heading MCQSEXAM Show answer Read explanation
Computer Science MCQs · HTML What is the main purpose of the alt attribute on an <img> element? A To set the width and height of the image B To add a border around the image C To describe the image for screen readers Correct answer D To link the image to another web page MCQSEXAM Show answer Read explanation
Computer Science MCQs · PHP Which function, added in PHP 8.0, checks whether a string contains a given substring? A str_contains() Correct answer B str_has() C in_string() D contains() MCQSEXAM Show answer Read explanation
Computer Science MCQs · PHP Which function helps prevent XSS attacks when printing user input into HTML? A urlencode_html() B htmlspecialchars() Correct answer C mysqli_escape() D strip_tags_all() MCQSEXAM Show answer Read explanation
Computer Science MCQs · PHP In PHP, what does the spaceship operator expression 3 <=> 7 return? A 1 B 0 C false D -1 Correct answer MCQSEXAM Show answer Read explanation
Computer Science MCQs · PHP How does PHP 8's match expression differ from a switch statement? A It works only with integer conditions B It needs a break after every case arm C It uses strict comparison and returns a value Correct answer D It uses loose comparison and falls through MCQSEXAM Show answer Read explanation
Computer Science MCQs · PHP In PHP 7+, what does $name = $_GET['name'] ?? 'Guest'; do? A Throws an error when the key is missing B Compares the two values for equality C Always overwrites the value with 'Guest' D Uses 'Guest' if the key is missing or null Correct answer MCQSEXAM Show answer Read explanation