125 common java interview pen questions Summary 4

Source: Internet
Author: User
Tags xml parser ssl connection

58. Basic concepts of threads, basic states of threads, and relations between States
A thread refers to an execution unit that can execute program code during program execution. Each program has at least one thread, that is, the program itself.
Java threads have four states: running, ready, suspended, and ended.

59. Common JSP commands
<% @ Page language = "java" contenType = "text/html; charset = gb2312 "session =" true "buffer =" 64kb "autoFlush =" true "isThreadSafe =" true "info =" text "errorPage =" error. jsp "isErrorPage =" true "isELIgnored =" true "pageEncoding =" gb2312 "import =" java. SQL. * "%>
IsErrorPage (whether the Exception object can be used), isELIgnored (whether to ignore the expression)
<% @ Include file = "filename" %>
<% @ Taglib prefix = "c" uri = "http: // ......" %>

60. Under what circumstances do I call doGet () and doPost ()?
The method attribute in the form label in the Jsp page is doGet () when get is called, and doPost () is called when post is called ().

61. servlet Lifecycle
The web container loads the servlet and starts its lifecycle. Call the servlet init () method to initialize the servlet. Call the service () method to implement and call different do *** () methods based on different requests. End the service. The web Container calls the servlet's destroy () method.

62. How to Implement servlet single-thread mode
<% @ Page isThreadSafe = "false" %>

63. Methods for transferring objects between pages
Request, session, application, cookie, etc.

64. What are the similarities and differences between JSP and Servlet, and what are their relationships?
JSP is an extension of Servlet technology. It is essentially a simple Servlet method, with more emphasis on the external expression of the application. After JSP compilation, it is "servlet-like ". The main difference between Servlet and JSP is that the application logic of Servlet is in the Java file and is completely separated from the HTML in the presentation layer. In JSP, Java and HTML can be combined into a file with the extension. jsp. JSP focuses on views. Servlet is mainly used for control logic.

65. Four session tracking technologies
Description of the session scope ServletsJSP page
Page No indicates the objects and attributes related to a page. A page is represented by a compiled Java servlet class (which can contain any include command but has no include action. This includes both servlet and JSP pages compiled into servlet.
A request is an object and attribute related to a request sent by a Web Client. A request may span multiple pages and involves multiple Web Components (due to the relationship between the forward instruction and the include action)
A session is an object and attribute associated with a user experience for a Web Client. A Web session can also frequently span requests from multiple clients.
Application represents the objects and attributes related to the entire Web application. This is essentially a global scope that spans the entire Web application, including multiple pages, requests, and sessions

66. Main Methods of the Request object:
SetAttribute (String name, Object): Set the parameter value of the request whose name is name.
GetAttribute (String name): returns the property value specified by name.
GetAttributeNames (): returns the name set of all attributes of the request object. The result is an enumerated instance.
GetCookies (): return all Cookie objects on the client. The result is a Cookie array.
GetCharacterEncoding (): returns the character encoding method in the request.
GetContentLength (): returns the length of the Request Body.
GetHeader (String name): Get the file header defined by HTTP
GetHeaders (String name): returns all the values of the request Header with the specified name. The result is an enumerated instance.
GetHeaderNames (): returns the name of the request Header. The result is an enumerated instance.
GetInputStream (): returns the input stream of the request to obtain data in the request.
GetMethod (): method for obtaining data transmitted from the client to the server
GetParameter (String name): Get the parameter value specified by name sent from the client to the server.
GetParameterNames (): obtains the names of all parameters sent from the client to the server. The result is an enumerated instance.
GetParameterValues (String name): obtains all values of the parameter specified by name.
GetProtocol (): gets the protocol name on which the client transmits data to the server.
GetQueryString (): Get the query string
GetRequestURI (): obtains the client address of the request string.
GetRemoteAddr (): obtains the IP address of the client.
GetRemoteHost (): Get the client name
GetSession ([Boolean create]): returns the Session associated with the request.
GetServerName (): Get the server name
GetServletPath (): Get the path of the script file requested by the client
GetServerPort (): Get the server port number
RemoveAttribute (String name): deletes an attribute in a request.

67. Is J2EE a technology, a platform, or a framework?
J2EE is a standard, a standard platform for enterprise distributed application development.
J2EE is also a framework, including JDBC, JNDI, RMI, JMS, EJB, JTA and other technologies.

68, we often encounter the output of some encoding characters in the web application development process, such as iso8859-1, how to output a certain encoding string?

Public String translate (String str ){
String tempStr = "";
Try {
TempStr = new String (str. getBytes ("ISO-8859-1"), "GBK ");
TempStr = tempStr. trim ();
}
Catch (Exception e ){
System. err. println (e. getMessage ());
}
Return tempStr;
}

69. Briefly describe the differences between logical operations (&, |, ^) and conditional operations (&, |.
There are two main differences:
A. Conditional operations can only operate on the boolean type, while logical operations can operate not only the boolean type, but also the numeric type.
B. logical operations will not generate short circuits

70. How many forms are defined in XML documents? What are the essential differences between them? How can I Parse XML documents?
A: Two forms of dtd schema. B: essential difference: the schema itself is xml and can be parsed by the XML Parser (this is also the fundamental purpose of developing the schema from the DTD). c: DOM, SAX, STAX, etc.
DOM: when processing large files, its performance drops sharply. This problem is caused by the DOM tree structure. This structure occupies a large amount of memory and the DOM must load the entire file into the memory before parsing the file, which is suitable for Random Access to XML.
SAX: it does not exist in DOM. SAX is an event-driven XML parsing method. It reads XML files sequentially without loading the entire file at a time. When a file starts with a file, the document ends, or the tag starts with a tag, it triggers an event. You can write the processing code in the callback event to process the XML file, suitable for sequential access to XML
STAX: Streaming API for XML (StAX)

71. What are the similarities and differences between synchronized and java. util. concurrent. locks. Lock?
The main point is that Lock can complete all functions implemented by synchronized.

Major difference: Lock has more precise thread semantics and better performance than synchronized. Synchronized Automatically releases the Lock, which must be manually released by the programmer and must be released in the finally clause.

 

72. EJB roles and three objects
A complete EJB-based Distributed Computing structure consists of six roles, which can be provided by different developers. Each role must follow the EJB specifications provided by Sun, to ensure compatibility between them. These six roles are EJB component developer (Enterprise Bean Provider), Application aggreger (Application aggreger), Deployer (Deployer), and EJB Server Provider (EJB Server Provider), EJB Container Provider, System Administrator)
The three objects are Remote (Local) interface, Home (LocalHome) interface, and Bean class.

73. Services provided by the EJB container
It mainly provides declarative cycle management, code generation, continuity management, security, transaction management, lock and release management services.

74. What operations are prohibited in ejbs In the EJB specification?
1. threads and thread APIs cannot be operated (thread APIs refer to methods of non-thread objects, such as notify and wait ),
2. awt cannot be operated,
3. server functions cannot be implemented,
4. cannot survive the static genus,
5. You cannot use IO operations to directly access the file system,
6. The local database cannot be loaded .,
7. You cannot use this as a variable or return,
8. It cannot be called cyclically.

75. Main Functions of the remote interface and home interface
The remote interface defines the business method used by the EJB client to call the business method.
The home interface is used by the EJB factory to create and remove EJB instances.

76. bean instance Lifecycle
Stateless Session Bean, Entity Bean, and Message Driven Bean are generally managed by the buffer pool, while Entity Bean and Statefull Session Bean are managed by Cache, which usually includes instance creation, set the context, create an EJB Object (create), call a business method, and remove. For beans with buffer pool management, the instance is not cleared from the memory after create, the buffer pool scheduling mechanism is used to repeatedly reuse instances. For beans with Cache Management, the activation and deactivation mechanisms are used to maintain the Bean status and limit the number of instances in the memory.

77. EJB activation mechanism
Taking Stateful Session Bean as an example: the Cache size determines the number of Bean instances that can coexist in the memory. According to the MRU or NRU algorithm, instances are migrated between the activation and deactivation statuses, when the client calls a service method of an EJB instance, if the corresponding EJB Object finds that it has not bound the corresponding Bean instance, it will activate the Bean store (store the instance through serialization mechanism) from it and then reply (activate) this instance. The corresponding ejbActive and ejbPassivate methods are called before the status changes.

78. EJB types
Session Bean, Entity Bean Message-Driven Bean
Session beans can be divided into Stateful and Stateless.
Entity beans can be divided into two types: Bean management continuity (BMP) and container management continuity (CMP ).

79. Basic Steps for client to call an EJB object
Set the properties of the JNDI service factory and the JNDI service address system, find the Home interface, call the Create method from the Home interface to Create a Remote interface, and call its business method through the Remote interface.

80. How do I specify the memory size for weblogic?
In the Weblogic STARTUP script (startServerName located in the directory of the corresponding Domian server), add set MEM_ARGS =-Xms32m-Xmx200m. You can adjust the minimum memory to 32 MB and the maximum memory to 200 MB.
81. How to set the weblogic hot start mode (Development Mode) and product release mode?
You can change the Startup Mode of the corresponding server to one of the development or product modes on the console. Or modify the Service Startup File or commenv file and add set PRODUCTION_MODE = true.

82. How do I not need to enter the user name and password at startup?
Modify the Service Startup File and add the WLS_USER and WLS_PW items. You can also add encrypted user names and passwords to the boot. properties file.

83. In the weblogic Management Console, After configuring jms, ejb, connection pool, and other related information for an application Domain (or a website or Domain), what files are actually stored in?
The config. xml file stored in this Domain is the core configuration file of the server.

84. What is the default directory structure of a Domain in weblogic? For example, a simple helloWorld. under the directory where jsp is put, you can enter http: // host: Port Number // helloword in the browser. can jsp view the running result? Another example is how to use a self-written javaBean?
Domain Directory Server Directory applications, where the application directory can be accessed as an application. If it is a Web application, the application directory must meet the Web application directory requirements, jsp files can be directly placed in the application directory, Javabean needs to be placed in the application directory of the WEB-INF directory of the classes directory, set the Server default application will be able to achieve in the browser without entering the application name.

85. configuration files required for deploying ejb in weblogic
Different types of EJB involve different configuration files, all involve configuration files including ejb-jar.xml, weblogic-ejb-jar.xmlCMP entity beans generally also need weblogic-cmp-rdbms-jar.xml

86. How to perform ssl configuration and client authentication configuration in weblogic or discuss how to configure ssl in j2ee (standard )?
DemoIdentity is used in the default installation. jks and DemoTrust. to implement SSL in jks KeyStore, You need to configure the server to use Enable SSL and configure its port. In product mode, you need to obtain the private key and digital certificate from the CA, and create the identity and trust keystore, load the obtained key and digital certificate. You can configure whether the SSL connection is unidirectional or bidirectional.

87. How do I view the published ejbs in weblogic?
You can use the console to view all published ejbs in its Deployment.

88. What is CORBA? What is the purpose?
The Common Object Request Broker Architecture is a Common Object Request Broker Architecture, which is standardized by Object Management Group (OMG. It is composed of an Interface Definition Language (IDL), a language binding (binding: also translated as associated encoding), and a protocol that allows interoperation between applications. The objective is to use different programming languages to run in different processes and develop different operating systems.

89. How many common j2ee modes do you know or have heard? And some opinions on the Design Model
Session Facade Pattern: Use SessionBean to access EntityBean
Message Facade Pattern: asynchronous call
EJB Command Pattern: replace SessionBean with Command JavaBeans for Lightweight Access
Data Transfer Object Factory: Using DTO Factory to simplify EntityBean Data provision features
Generic Attribute Access: the AttibuteAccess interface simplifies EntityBean data provision features
Business Interface: Use Remote (local) interfaces and Bean classes to implement the same Interface and standardize Business logic consistency
The design of the EJB architecture directly affects the system performance, scalability, maintainability, component reusability, and development efficiency. The more complex the project, the larger the project team, the more important the design is.

90. Differences between persistent and non-persisten when sending a message Bean in weblogic
The persistent MDB ensures the reliability of message transmission, that is, if an error occurs in the EJB container and the JMS server still sends the message when the MDB is available, non-persistent messages are discarded.

91. Which of the following methods are generally implemented during Servlet execution?
Public void init (ServletConfig config)
Public ServletConfig getServletConfig ()
Public String getServletInfo ()
Public void service (ServletRequest request, ServletResponse response)
Public void destroy ()

92. Common j2ee design patterns? Describe the factory model.
23 Design Patterns in Java:
Factory (Factory mode), Builder (construction mode), Factory Method (Factory Method mode ),
Prototype (original model mode), Singleton (Singleton mode), Facade (Facade mode ),
Adapter (Adapter mode), Bridge (Bridge Mode), Composite (merging mode ),
Decorator, Flyweight, Proxy ),
Command (Command mode), Interpreter (Interpreter mode), Visitor (Visitor mode ),
Iterator, Mediator, Memento ),
Observer (Observer mode), State (State mode), Strategy (Policy mode ),
Template Method (Template Method mode), Chain Of Responsibleity (responsibility Chain mode)
Factory mode: The factory mode is a frequently used mode. Classes implemented based on the factory mode can generate instances of a class in a group based on the provided data, generally, this group of classes has a common abstract parent class that implements the same method, but these methods perform different operations on different data. First, you need to define a base class. The subclass of this class implements the methods in the base class through different methods. Define a factory class. The factory class can generate different subclass instances according to the conditions. After obtaining the subclass instance, developers can call the methods in the base class without having to consider which subclass instance is returned.

93. Does EJB need to directly implement its business interface or Home interface? Please briefly describe the reasons.
The remote interface and Home interface do not need to be implemented directly. Their implementation code is generated by the server. The corresponding implementation class in the program running will be used as an instance of the corresponding interface type.
 

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.