JavaBean technology and JSP development model exercises


"JavaBean Technology and JSP Development Model Exercises"

JavaBean technology and JSP development model

multiple choice

1.
The JSP Model2 model is the MVC design pattern, in which the role of the controller is ()

A、JSP

B、JS

C、Servlet

D、JavaBean

Reference answer :
C
answer explanation :
The JSP Model2 model is the MVC (Model-View-Controller, Model-View-Controller) design pattern, in which the Servlet acts as the controller. It first receives the request sent by the browser, and then according to the request The information instantiates the JavaBean object, the JavaBean object completes the database operation and encapsulates the operation result, and finally selects the corresponding JSP page to display the response result in the browser
2.
Among the following options, the advantage of the MVC design pattern is ( ).

A. The structure is clear.

B. Easy to maintain

C. Conducive to software engineering management

D. takes up less resources

Reference answer :
D
Answer explanation :
The functional modules in the MVC design pattern are independent of each other, and the software using this pattern has extremely high maintainability, scalability and reusability
3.
The JSP Model2 model is MVC (Model-View -Controller, model-view-controller) design pattern, in which the view role is implemented by ()

A、JSP

B、HTML

C、JavaBean

D、Servlet

Reference answer :
A
Answer Explanation :
JSP Model2 Architecture Model The role of the controller is realized by Servlet, the role of the view is realized by the JSP page, and the role of the model is realized by JavaBean.
4.
Which of the following is not an integral part of MVC is ( ).

A、Model

B、Controller

C、View

D、DLL

Reference answer :
D
Answer explanation :
The MVC design pattern divides the software program into three core modules: model (Model), view (View) and controller (Controller)
5.
Read the following classes: public class Book { private double price; public double getPrice() { return price; } public void setPrice(double price) { this.price = price; } } For the above class, the following statement is correct ()

A. Comply with the javaBean specification

B. Does not conform to the javaBean specification

C. There is no construction method, so it does not conform to the javaBean specification

D. None of the above statements are correct

Reference answer :
A
answer description :
JavaBean conforming to the javaBean specification usually has the following characteristics: JavaBean must have a no-argument constructor. Properties must be privatized. Private properties must be exposed to other programs through methods of public type, and the naming of methods must also comply with certain naming conventions
6.
Regarding JavaBean, the error in the following description is ( )

A. The JavaBean class must be concrete and public, and have a parameterless constructor

B. The class properties of JavaBean are private and must be accessed through public methods

C. JavaBean, like Servlet, must be registered in the project's web.xml before use

D. JavaBean properties and form control names can be well coupled to get the parameters submitted by the form

Reference answer :
C
Answer explanation :
JavaBean does not need to be registered in the project's web.xml before using
7.
In the following description of the characteristics of the MVC design pattern, the error is ( ).

A. Conducive to the division of labor in development

B. Enhance the coupling of the program structure

C. Facilitate the reuse of components

D. The MVC design pattern is one of the current mainstream design patterns

Reference answer :
B
Answer explanation :
The characteristics of the MVC pattern include: it is conducive to the division of labor in development, it is conducive to the reuse of components, and the MVC design pattern is one of the current mainstream design patterns.
8.
In the MVC pattern, the module responsible for interacting with users and displaying data in the model is ()

A. Model

B. Presentation layer (View)

C. View (View)

D. Controller

Reference answer :
C
Answer explanation :
View (View) is responsible for interacting with users. It obtains data from the model to display to users, and can also pass user requests to the controller for processing.
9.
The object declared by jsp:useBean is valid by default The range is ( ).

A、page

B、session

C、application

D、request

Reference answer : Answer explanation
of A:The default effective scope of the object declared by jsp:useBean is page10.When calling JavaBean in JSP, the identifier that will not be used is ( ).



A、

B、jsp:useBean

C、jsp:setProperty

D、jsp:getProperty

Reference answer :
A
answer description :
jsp:useBean tag is used to obtain the instance of the class jsp:setProperty tag sets the properties in the JavaBean jsp:getProperty tag gets the properties in the JavaBean
11.
When using the jsp:getProperty tag in JSP, it will not appear The property of is ( ).

A、name

B、property

C、value

D. None of the above will appear

Reference answer :
C
answer description :
use jsp:getProperty in JSP, the name attribute is the Javabean instance name, and the property attribute is the attribute name.
12.
The JSP Model2 model is the MVC (Model-View-Controller, Model-View-Controller) design pattern, in which the role of the model is ().

A、JSP

B、HTML

C、JavaBean

D、Servlet

Reference answer :
C
Answer explanation :
The JSP Model2 model is the MVC (Model-View-Controller, Model-View-Controller) design pattern, in which the role of the controller is realized by the Servlet, the role of the view is realized by the JSP page, and the role of the model is Implemented by JavaBean.
13.
The following statement about the controller is wrong ().

A. The controller is responsible for the part of the application that handles user interaction

B. The controller reads data from the view

C. The controller obtains data from the model and displays it to the user

D. The controller sends data to the model

Reference answer :
C
Answer explanation :
The controller (Controller) is responsible for the part of the application that handles user interaction. It reads data from the view, controls user input, and sends data to the model.
14.
Regarding the statement about JavaBean, the correct one is ().

A. JavaBean is a public class

B. Referencing beans in JSP files is actually using the jsp:useBean statement

C. The file name suffix of the referenced bean file is .java

D. JavaBean files can be referenced in any directory

Reference answer :
A
Answer Explanation :
JavaBean is a public class
15.
In the following description of the characteristics of the MVC design pattern, the error is ()

A. Conducive to the division of labor in development

B. Enhance the coupling of the program structure

C. Facilitate the reuse of components

D. The MVC design pattern is one of the current mainstream design patterns

Reference answer :
B
Answer explanation :
The functional modules in the MVC design pattern are independent of each other, and the software using this pattern has extremely high maintainability, scalability and reusability
16.
Among the following statements about the characteristics of JavaBean, it is wrong is ( ).

A. JavaBean is a private class

B. When setting and getting attributes, use the setXxx() and getXxx() methods

C. There must be a default no-argument constructor

D. Attributes must be privatized

Reference answer :
A
Answer Explanation :
JavaBean cannot be a private class, only a public class.
17.
Assuming that there is an int-type attribute Num in the class that creates JavaBean, which of the following is the correct way to set this attribute ( ).

A、public void setNum(int n) { Num = n; }

B、public setNum(int n) { Num = n; }

C、public voidsetNum(int n) { Num = n; }

D、void setNum(int n) { Num = n; }

Reference answer :
A
answer description :
B option lacks the return value type, C option lacks spaces between void and setNum() methods, and D option lacks public modifiers

multiple choice

18.
The MVC design pattern divides the software program into three core modules, including ( ).

A. Model

B. Presentation layer (View)

C. View (View)

D. Controller

Reference answer :
A, C, D
Answer explanation :
The MVC design pattern divides the software program into three core modules: model (Model), view (View) and controller (Controller).
19.
Among the following options, JavaBean is used in JSP Apply includes ( ).

A. Get JavaBean attribute information

B. Get the member method of JavaBean

C. Applying JavaBean in JSP pages

D. Assign values ​​to JavaBean properties

Reference answer :
A, C, D
Answer explanation :
The application of JavaBean in JSP includes: obtaining JavaBean attribute information, applying JavaBean in JSP pages, and assigning values ​​to JavaBean attributes.

True or False

20.
MVC is also called a three-tier architecture, where C refers to the business logic layer.



Reference answer :
wrong
answer description :
MVC is a design pattern, where C refers to the controller (Controller), known as the control layer
21,
a JavaBean will only be instantiated once.



Reference answer :
Wrong
answer description :
The same JavaBean can be instantiated multiple times
22.
JavaBean needs to have a default no-argument construction method.



Reference answer :
Yes
answer explanation :
No
23.
The controller is responsible for managing the business data of the application, defining access control and modifying the business rules of these data.



Reference answer :
Wrong
answer Explanation :
The controller (Controller) is responsible for the part of the application that handles user interaction. It reads data from the view, controls user input, and sends data to the model.
24.
The JSP Model1 architecture model adopts the technology of JSP+Servlet+JavaBean, in fact it is the MVC design pattern.


Reference
answer :
wrong
answer description :
JSP Model1 uses JSP+JavaBean technology to separate page display from business logic.
25.
jsp:getProperty must appear after its corresponding jsp:useBean tag.



Reference answer : Explanation
to the answer : No 26. JavaBean is roughly divided into two types: visual JavaBean and non-visual JavaBean.




Reference
answer : Explanation
to the answer : The original purpose of JavaBean was to package reusable code. In traditional applications, JavaBean is mainly used to implement some visual interfaces, such as a form, button, text box, etc. Such JavaBean is called a visual JavaBean. With the continuous development of technology and the needs of projects, JavaBean is mainly used to implement some business logic or encapsulate some business objects. Since such JavaBean does not have a visual interface, it is also called non-visual JavaBean. 27. The MVC design pattern divides the software program into three core modules: model (Model), view (View) and controller (Controller)




Reference
answer : Explanation
for the answer : None 28. When the page receives information with Chinese garbled characters, you can use JavaBean to deal with the Chinese garbled characters.





Reference answer : Explanation
to
the answer :
Use JavaBean to solve Chinese garbled characters, define a method for processing character encoding in the JavaBean class, and transcode the received data.
29.
In the JSP Model2 model, the role of the controller is realized by the Servlet.


Reference
answer : Explanation
for
answer :
None

fill in the blank

30.
JSP Model1 adopts the technology of JSP+JavaBean, among which, JSP implements process control and page display, and objects encapsulate data and business logic.

Reference answer :
[JavaBean]
Answer explanation :
JSP Model1 uses JSP+JavaBean technology to separate page display from business logic. Among them, JSP implements process control and page display, and JavaBean object encapsulates data and business logic.
31.
In order to use JSP technology more conveniently, Sun provides two development models for JSP technology: JSP Model1 and JSP.

Reference answer :
[JSP Model2]
Answer description :
No
32.
The view in the MVC model is responsible for interacting with the user, and it obtains data from it to display to the user.

Reference answer :
[Model]
Answer explanation :
The view in the MVC pattern is responsible for interacting with the user, and it obtains data from the model to display to the user.
33.
The JSP Model2 model is the MVC design pattern, in which the role of the model is realized by.

Reference answer :
[JavaBean]
Answer explanation :
No
34.
The JSP Model2 model is the MVC design pattern, in which the role of the view is realized by the page.

Reference answer :
[JSP]
Answer description :
No
35.
JSP Model1 adopts JSP+JavaBean technology, among which, process control and page display are realized, and JavaBean objects encapsulate data and business logic.

Reference answer :
[JSP]
Answer explanation :
No
36.
JSP Model2 model is the design pattern, in which the role of controller is realized by Servlet, the role of view is realized by JSP page, and the role of model is realized by JavaBean.

Reference answer :
[MVC]
Answer description :
No
37.
The JSP Model 2 architecture model effectively realizes the separation of page display, process control and separation.

Reference answer :
【Business logic】
Answer explanation :
The JSP Model2 architecture model adopts the technology of JSP+Servlet+JavaBean. This technology extracts the process control code in the original JSP page and encapsulates it into a Servlet to realize page display, process control and business logical separation.

Guess you like

Origin blog.csdn.net/weixin_48053866/article/details/126257228