Quiz
Web App Midterm
This quiz has question types that open in the usual player.
Questions in this quiz (42)
1Package names are all lowercase, with consecutive words simply concatenated together (no underscores) E.g. com.example.deepspace
Class and interface names are written in: UpperCamelCase
Method names: are lowerCamelCase (verbs, phrases e.g. sendMessage().
Variable names: are lowerCamelCase
Constant names CONSTANT_CASE: BUTTER_FACE- ATrue
- BFalse
2Components of a web application:
client computer(web browser) ---internet connection--- server computer(web server/database server)- ATrue
- BFalse
3How do static webpages process requests?
- Athe database server sends HTTP response back to browser
- Bclient browser makes a HTTP request to the WEB SERVER. Web server accesses HTML file and returns information as a HTTP response.
4How do DYNAMIC webpages process requests?
- AThe client browser sends a HTTP request to the web server --> WEB APPLICATION --> DATABASE SERVER. These send HTTP response back to the browser.
- BThe database server and application server send a HTTP request to the client to retrieve data on user side
5What are some common web application approaches in JAVA?
- ASERVLET + JSP
lower-level API does LESS work for programmer. Higher control over HTML/JS/CSS - BJSF
more work for programmer, but less control over HTML/CSS?JS - CSPRING FRAMEWORK
best of both, support and control over HTML/CSS/JS - DBOOTSTRAP THYMELEAF FRAMEWORK
- ASERVLET + JSP
6[blank_start]The Java Standard Edition ( Java SE )[blank_end]
includes the Java Development Kit
(JDK) and the Java Runtime Environment (JRE).
[blank_start]The Java Enterprise Edition ( Java EE )[blank_end]
specification describes how web servers can interact with all Java web technologies.
[blank_start]Servlets[blank_end] store the Java code that does the server
-
side processing.
[blank_start]JavaServer Pages ( JSP )[blank_end]
store the HTML and dynamically defines the user
interface.
[blank_start]JavaServer Faces ( JSF )[blank_end]
is a higher
-
level API that can be used instead of
both servlets and JSPs.
[blank_start]Java Persistence API ( JPA )[blank_end]
is a powerful and convenient API for working with databases- AThe Java Standard Edition ( Java SE )
- BThe Java Enterprise Edition ( Java EE )
- CServlets
- DJavaServer Pages ( JSP )
- EJavaServer Faces ( JSF )
- FJava Persistence API ( JPA )
7In a SERVLET/JSP web app. The client browser makes a HTTP REQUEST to server that houses the WEB SERVER/JSP ENGINE, JDK AND DATABASE SERVER
- ATrue
- BFalse
8IN multi-tier architecture what layers are present?
- APRESENTATION (html, jsp)
- BBUSINESS RULES ( servlet, javabeans)
- CDATA ACCESS (db, text files, binary files)
- DDATA SETUP
9Which are popular webservers?
- ATOMCAT
- BGLASSFISH
- CWILDFLY
- DBUTTERFLY
- EJAMMY
- FJETTY
- GORACLE WEBLOGIC
10METHOD NAME: getFirstName
PROPERTY NAME: remove get firstName, number (getNumber), getSIN SIN
Otherwise: crash at the runtime with
PropertyNotFoundException- ATrue
- BFalse
11In a Model two or MVC project which of the following apply
- AServlet acts as CONTROLLER/DISPATCHER
- BJavaBeans as Controller/dispatcher
- CJavaBeans as Model
- DHTML as views
12The code, inserted into
processRequest
method by NetBeans, is useful
only for very initial checkups, in particular, to check if the servlet mapping
works; this code is not useful for anything else and has to be removed rather quickly. The generated
doGet
method overrides the base class method and calls
processRequest method- ATrue
- BFalse
13HttpServletRequest objects contain
- AIP address of the browser
- Bpreviously set cookies
- Cdata submitted with an input form
- Dbrowser information
- Ebrowser language settings,
- Fnew cookies
- Gerror codes
14HttpServletResponse objects contain:
- Abrowser information
- Bgenerated webpages
- Cnew cookies
- Derror codes
- Eredirects
- Fip address of browser
15JavaBeans are instantiated in SERVLETS, NOT JSPs as in Model1. UseBean tag not used.
- ATrue
- BFalse
16What is true regarding JSPs?
- AJSP only choice for implementing views in MVC
- BJSPs are used only as templates to
display
data that were previously
received, generated and processed elsewhere - Ca JSP has to do any computations, the computations should be used only
for displaying the data. For example, JSPs may contain:
loops for displaying tables and lists - Dlocated in the "hidden" folder
/WEB-INF/jsp/
17In the web.xml file the servlet-name and url-pattern in servlet and servlet-mapping should match. E.g CardServlet. The <welcome-file> allows to set up on default address
- ATrue
- BFalse
18Which are true regarding forwarding?
- AForwarding happens entirely on the server side
- BForwarding happens entirely on the browser side
- CBrowsers are NOT involved in forwarding in any sense or know that it happened
- DBrowsers obtain the pages, printed by JSPs, as the pages come directly from
the servlet
19What are three ways to map a servlet? Also remember: Do
not
use more than one way of mapping for the same Servlet (in the same
program). Using more than one way of mapping for the same Servlet
causing program malfunctions or crashing when started.- Ausing @WebServlet annotation in corresponding Servlet Java File
- Busing XML: <servlet> and <servlet-mapping> in web.xml file
- Cusing XML: <servlet> and <servlet-mapping> in index.html file
- Dconfiguring dynamically using API calls in java code
20inside webservlet one way to map servlet: @WebServlet(urlPatterns = {"/input", "/process"} )
- ATrue
- BFalse
21Important, the “*” symbol in mapping patterns
must be either the first or the last symbol of the patterns.
Patterns like “
*.action
” and “
/actions/*
” are alright.
Patterns like “
/actions/*.do
” are
not
allowed- ATrue
- BFalse
22Servlet mapping via API calls does not require “
web.xml” file. In fact, many modern web apps dont have "web.xml" files at all- ATrue
- BFalse
23In the MVC design the model:
- APresent the outputs to the user
- BEncapsulates core data and logic
- CIndependent from views
- DModel can be implemented with JavaBeans and other classes
24In the MVC design the VIEWS:
- APresent the outputs to the user
- BAssociated with a controller
- CPresent the outputs to the browser
- DCan be implemented with JSPs and other options
- Ereceives input from user
25In the MVC pattern the controller:
- ACan be implemented with JSPs and other options
- BReceives inputs from the user
- CProcesses the inputs translating them to model API
- DConnects model data to views and dispatches the views
- ECan be implemented with servlets or filters
- Fencapsulates core data and logic
26f all the program logic is contained within the helper class and the servlet
does only tedious mechanical work, the helper class is called controller, but
the servlet is called dispatcher.- ATrue
- BFalse
27Servlet initialization parameters are
not global and must be set in jsp- ATrue
- BFalse
28Global application parameters:
- At is possible to define global application parameters in web.xml, they are
Servlet Context Parameters. - BServlet Context Parameters are available in all servlets, JSPs, listeners, and
filters. - Care available in other classes and objects such as JavaBeans
- DThese parameters are
not
available in other classes and objects; for
example, they are
not
available in JavaBeans.
- At is possible to define global application parameters in web.xml, they are
29 Form Action: The action attribute of a form is always the address where the form sends the data.
In Model 2 (MVC), it is always a servlet's address,
nota JSP's address; browsers are not even able to send data to a JSP's address, since JSPs are in the hidden from Web
/WEB-INF/jsp/ folder.- ATrue
- BFalse
30In forms input id matches label for "first" "first"
RadioButtons in same group should have same group name <input name="programYear"- ATrue
- BFalse
31Http GET method is the default method to submit form data, but it is usually
specified in forms anyway, for clarity.
GET does
not
cause warnings before the data is resubmitted by browsers
when the receiver page is reloaded with "reload" browser buttons.
GET should
not
be used when resubmission of the data may cause
undesired side effects, for example, duplicates in stored data (duplicate
shopping orders, etc.).
Clicking links also invokes GET method. Sending request parameter key
-
value pairs through link addresses is a common practice in Web application
programming.
GET method sends form data through the address.
The submitted data appears in browser address lines.- ATrue
- BFalse
32POST can be used to send confidential form data, such as passwords, since
the data is not displayed in the address line. Warning: POST does not encrypt
anything by default, the data is not displayed in the address line, but it is still
sent through the network unencrypted.- ATrue
- BFalse
33Retrieving Input Data in servlet:
instantiate the JavaBean:
StudentForm form = new StudentForm();
form.setFirstName(request.getParameter("firstName"));
form.setLastName(request.getParameter("lastName"));- ATrue
- BFalse
34All Maven projects, using JSTL, must have this JSTL dependency
copy
-
pasted into the Project Object Model (POM) file,
pom.xml
.
The pom.xml
file is in "Project Files" folder of NetBeans projects.
Almost any project that uses JSP also uses JSTL.- ATrue
- BFalse
35Displaying error lists in JSTL As the general rule, inserting a bean value requires
${ }. E.g. errors from java in jsp file.- ATrue
- BFalse
36Post Redirect Get pattern is used to avoid accidental resubmission of the
data when a site visitor presses the browser reload button. What three steps are involed in POST REDIRECT GET pattern?- APost
–
The data is submitted to the server with post. The server
processes the data, stores the data on the server side. - BRedirect
–
The server sends a new address (redirection address) to the
browser, usually, with some data id in the address. - CGet
–
The browser retrieves the confirmation page, using the redirection
address. - DPost
–
The browser retrieves the confirmation page, using the redirection
address.
- APost
37Design patterns
are sets of industry
standards and best practices for
solving
repeating
problems Advantages of using design patterns include:- AImproves software
reusability. - BFaster development cycle.
- CMore
readable and
maintainable code. - DOverall efficiency of software development.
- EProvides common vocabulary to describe problems
and solutions
- AImproves software
38[blank_start]Design principles[blank_end] are guidelines on right
ways of designing applications. Design principles always talk about what to do instead of how to do it.
[blank_start]Design patterns[blank_end]
are generic and reusable
solutions for commonly occurring problems.- ADesign principles
- BDesign patterns
39What two starting principles improve software architecture?
- ALow Coupling: L
ow dependency of components on
each other by their lower
structures,
instead of their
interfaces - BHigh Coupling: e
component should perform one and only one well
-
defined
job - CMiddle Ground Coupling
- ALow Coupling: L
40What are the solid principles?
- ASRP: Single RESPONSIBILITY Principle
similar to high cohesion, name of module exposes functionality, in charge of one responsibility - BOCP: OPEN CLOSED PRINCIPLE
new features should be added by EXTENSION not modification. Abstraction not required, but can be used. - CLSP: LISKOV SUBSTITUTION PRINCIPLE
Module A can be replaced by Module B iff B is a subtype of A. Best to have well defined interfaces. - DISP: INTERFACE SEGREGATION PRINCIPLE
client models should not have to deal with UNUSED inteface features. Empty methods, inconsistent naming are bad - EDIP: DEPENDENCY INVERSION PRINCIPLE
High
-
level
modules should not
directly
depend
on low
-
level modules for
their responsibilities. Both should depend on
abstractions (interfaces).
- ASRP: Single RESPONSIBILITY Principle
41How is the Dependency Inversion principle implemented by Inversion of control?
- AInverting
the
interface
Make
sure the high
-
level module defines the interface,
and low
-
level modules follow it - BInverting object creation
Change
the creation of dependency from your main
modules to some other program or
framework - Cnverting flow
Change
the
application flow
- AInverting
42IoC is done through
- Afactories
- Bservice locators
- Cdependency injection:
is a design pattern whose core principle is to
separate
dependency resolution from program code
Information
- Description
- Quiz on Web App Midterm, created by Upma Sharma on 21/02/2019.
- Author
- Upma Sharma
- Language
- English
- Views
- 0
- Rating
- No ratings yet Rate this quiz