CS 2610 Exam #1
Modern web applications take advantage of APIs to maximize...
Scalability
What does "this" refer to when a function is called using the Method invocation pattern?
The object which the function is a property of
What is the controller in Django?
The part of Django which looks at an HTTP request and decides which view function to call in response (urls.py)
In which file do you write a list which tells Django what function to invoke to serve a request for a resource?
urls.py
What does the Function invocation pattern look like?
var result = f();
What does the Constructor invocation pattern look like?
var result = new f();
What does the Method invocation pattern look like?
var result = o.f()
In which Django file do you write the code which creates, on demand, a webpage which is presented to a visitor?
views.py
What is the view part of Django?
views.py and templates.py
Which Django template tag must you include at the top of your template to enable static content such as CSS files and images?
{% load static %}
When associating a JavaScript expression to a DOM element's HTML attribute such as onclick="..." or onchange="...", what does "this" mean?
"this" is a reference to the DOM element itself
Which features do Python dictionaries and JSON share in common?
-Both are a mapping of key-value pairs -Literal objects/dictionaries are delimited with curly braces -Keys may be any string -Each key must be unique -The values can be any value, including functions and other objects/dictionaries
Why might a modern web app use an API?
-Leverage 3rd-party services -Division of labor
In order to use an API, what information must a developer know?
-What information to put into the HTTP request -Which HTTP request types to use -Which URLs you can use
Which JavaScript method attaches a node to the DOM?
.appendChild()
How many results may Question.objects.filter() return?
0 or more
What is a template in Django?
A partially-formed webpage file with defined style and layout, containing regions to be filled in programatically
What comparison operator performs implicit type conversion if the data types are not the same
== (123 == '123' will be true)
What is a view in Django?
A Python function which takes an HTTP request and returns an HTTP Response
What's the difference between a project and app in Django?
A project contains one or more apps
The acronym API stands for...
Application Programming Interface
What kind of Python data is the context object passed by the view function to Django's template rendering system?
Dictionary
Why is Django an application framework?
Django provides a fundamental structure to support the development of applications in its specific environment
What does DOM mean?
Document Object Model
How many results will Question.object.get() return?
Exactly 1; any other quantity is treated as an error
T/F As its name implies, fetch() cannot be used to upload data to a server, as in a POST request.
False
T/F Django responds to an HTTP request by sending the contents of a file from the hard drive
False
T/F Functions in JavaScript are simple because they can be declared in only one way, and always behave the same regardless of how they are called.
False
T/F JavaScript is a statically-typed programming language
False
T/F JavaScript is an object-oriented programming language
False
T/F Only GET requests are appropriate to be used on an API
False
T/F Only input elements may respond to a mouse click
False
T/F The value of "this" within a function defined with the Arrow syntax depends upon the invocation pattern used at the time it is called.
False
T/F When a record is deleted from a database, its primary key ID will be reused by the next record that is created.
False
T/F When your website is hosted by a service offering "Static Hosting," this means that there is a database-driven system such as Django providing dynamic content
False
T/F print("Hello World"); will print "Hello World" to the console in JavaScript
False
What is the Django template entity which is placed within {{ }} and goes to the right of a | symbol?
Filter
What does the acronym "MVC" stand for?
Model View Controller
What does ORM mean?
Object Relational Mapper A code library that automates the transfer of data stored in relational databases tables into objects
How do you configure Django to serve static files in your app?
Open the project's settings.py file and add the name of the app's Config class to the list INSTALLED_APPS
APIs are primarily intended to be used by
Other programs
The first argument to fetch() is...
The URL to make a GET request of
What is a Django context object?
The data we send to the template renderer, packaged in a Python dictionary
What does "this" refer to when a function is called using the Function invocation pattern?
The global object, which is named "window" in a web browser
Why is it poor practice to let a user remain on the same webpage after they have submitted a POST request?
The user may accidentally re-POST by hitting the 'Refresh' button
T/F JavaScript is case-sensitive.
True
T/F A Promise in JavaScript is an object representing the eventual completion or failure of an asynchronous operation
True
T/F A database record we create in Django isn't permanently recorded on-disk until its .save() method is called
True
T/F A database table and a class in an object-oriented programming language are conceptually quite similar.
True
T/F A model in Django is a class which inherits from models.Model and its data members correspond to the columns contained within.
True
T/F Any DOM element may be made to respond to being clicked
True
T/F Arrays are basically glorified objects in JavaScript
True
T/F By returning a Promise object from the callback passed to the .then() method, and subsequently calling .then(), we can force asynchronous API calls into ordered synchronicity
True
T/F Semicolons are required by the JavaScript language, but the programmer isn't obligated to write them because the interpreter/compiler will automatically insert them where it thinks they are necessary.
True
T/F fetch() returns a Promise object
True
What is the result of the following JavaScript expression? typeof NaN === "number"
True
Why is the result of 123 == '123' true?
Using the == operator converts both operands to the same type before performing the comparison
What type of Django template entity is surrounded by double curly braces {{ }}?
Variable
fetch() is an alternative to which JavaScript feature?
XMLHttpRequest
How do you display "Hello World" in a pop-up window in the browser?
alert("Hello World")
How do you print the message "Hello World" to the browser's console?
console.log("Hello World")
How do I copy one node (and all of its children nodes) in the DOM (the "target") and place it elsewhere (the "destination")?
destination.appendChild(target.cloneNode(true));
What is the result of the following JavaScript expression? NaN == NaN
false
What sort of JavaScript language constructs should be assigned to a DOM element's .onXYZ properties in order to handle events?
functions
What is the model part of Django?
models.py
Command to start the development server in Django
python manage.py runserver
Command to create a new app within a Django project
python manage.py startapp newApp
What is the controller part of Django?
the URL patterns in Django