Javaoo Summary Two

Source: Internet
Author: User
Tags create directory thread class file transfer protocol

51. What is the difference between AWT and swing?
AWT is a style that uses the style of the operating system to define components, so the component display may not be consistent across platforms. Swing has its own stand-alone display, with a consistent display style across platforms. Swing is expanded on the basis of AWT

52. How do I add an event? ;
1, determine the source of the event, 2, write the listener, realize the monitoring interface, 3, register, establish the event source and listener contact.
53, the flow according to the input and output direction divided into several? What is the relative?
Input stream and output stream
With memory as a reference, if the data is read from the data source into memory, then it is the input stream, also called the read stream. If the data is written to the data source from memory, it is the output stream, also called the write stream.
54, the flow according to the content of the transmission of several? What are the respective parent classes?
Three kinds: byte stream, Word stream, object flow. However, no matter what kind of flow, the underlying part is transmitted in bytes, so the essence is a byte stream. However, in order to facilitate the manipulation of character data and object data, a layer is encapsulated on the basis of the byte stream to form a character stream and an object flow.
The parent class of the byte stream: InputStream, OutputStream
The parent of a character stream: Reader, Writer

55. What happens if the file does not exist when the flow is being manipulated? What happens if the stream doesn't close?
When the stream is written, but the file does not exist, a new file is created, but only if the directory in which it resides must exist, otherwise it will throw filenotfoundexception.
If the stream does not shut down, it wastes resources, and the write stream may not write the data.
56. How can I tell if a file exists? How do I create a directory? How do I know how many files are in a directory?
Determine if the file exists: The files object. exists ();
Create directory: File object. mkdir ();
Get a list of files: File object. listfiles ();

57. When does the static block execute?
Static blocks are executed when the class is loaded and executed only once.
58. What is a relational database?
The relational database is the database structure with the table as the entity, the primary key and the foreign key as the relation between the tables.
59, what is a pair of one or one-to-many, many-to-many?
1, one-to-two: a master table record corresponding to a record from the table, while a record from the table also corresponds to a master table record.
2, one-to-many: a master table records corresponding to a number of records from the table, and one from the table records corresponding to a master table record.
3, many-to-many: a master table records corresponding to a number of records from the table, while a record from the table corresponding to a number of main table records. Many-to-many generally have an intermediate table that describes such relationships
60. What are the integrity of the database?
1, Entity integrity. Ensure that a row of data is valid. A row of data in a table has entity integrity if it is exactly the same as the entity it represents.
Ensure that the entities represented by each line can be distinguished from each other and that there cannot be two records of the same.
Implementation method:--PRIMARY KEY constraint. The primary key cannot be empty, nor can it be duplicated, only one primary key in a table
--Unique constraint. All values assigned to a column must be unique, and the column must have a unique value for each row in the table. The only difference between it and a primary key constraint is that the column can be empty, and you can set a unique constraint on more than one column in a single table
2, Domain integrity. Ensure that a column of data is valid
Domain integrity is the input validity of the specified column
Implementation method:--Non-null constraint: NOT NULL
--Default constraint: Defaults
--Check constraint: check (MySQL not supported)
3, referential integrity. Guarantees that the referenced primary key is valid and is implemented by a FOREIGN KEY constraint
4, user-defined integrity. Guaranteed Custom Rules
61, what is the primary key, what are the characteristics of the primary key?
A primary key is a unique identification of a record in the entire table. The primary key can be used to distinguish different records
Features of the primary key: non-null and cannot be duplicated
62, what is the foreign key, it and foreign key constraints have what difference
A foreign key is a dependency that exists between a column of a table and the primary key of the primary table
A FOREIGN KEY constraint is a constraint that is enforced on the primary key associated with the outer key, and the modification of the data is not allowed if the constraint is violated.
Note: No FOREIGN KEY constraint does not indicate no foreign key
63, how to add foreign key constraints.
ALTER TABLE from table name add constraint fk_1 foreign key (foreign key column name) references primary table name (primary key name)
64. How do I delete a master table record?
Because a primary table record may have a reference from a table record, if you delete the primary table record directly, you may not be able to delete it because of the presence of a foreign key constraint.
There are two ways to delete a primary table record: 1, delete the main table record corresponding to the table record, then delete the main table record, 2, set the foreign key from the table record to null for the main table record, and then delete the main table record
65, add, delete, change, check the basic SQL statement
Add: INSERT into Table name (field list) VALUES (Value list)
Delete: Delete from table name where condition
Change: Update table name set column name = new value WHERE condition
Check: SELECT * FROM table name
66. The difference between delete and truncate
Delete Logs the log, which means that the deleted data can also be recovered, but is inefficient and can delete only part of the data.
Truncate does not log, deleted data cannot be recovered but is efficient and can only delete all data.
67. What are the key words for excluding duplicate records? How can I limit the number of rows that are returned for query data?
Eliminate duplicate records with distinct
Limit the number of rows returned by query data using limit 0,3
68. How to query for null values
cannot be used directly =, to be null or is not NULL
69. What are the aggregate functions of SQL statements?
Count: Count the number of rows
Sum: Gets the aggregate value of a single column
Avg: Calculates the average of a column
Max: Calculate the maximum value of a column
Min: Calculates the minimum value of a column
70. In a grouping statement, what columns can I query?
Can only be grouped columns and aggregate functions
71. The difference between where and having
Where is performed before grouping, so it cannot be followed by an aggregate function
Having performed after grouping is a filter for grouping results, only with aggregate functions
72. Describe the execution order of SQL query statements
First step: Execute from
Step two: where conditional filtering
Step three: Group by group
Fourth step: Execute the Select projection column
Fifth step: Having conditional filtering
Sixth step: Perform ORDER by ordering
73, internal connection and outer connection difference
Inner joins can only query the main table and the data that has corresponding records from the table
Outer joins can query all records in a table, regardless of whether the data has a corresponding record
74. What is JDBC
JDBC is a set of standards for the Java Connection database, the standard provides a large number of interfaces, these interfaces by the manufacturer according to the characteristics of their own database implementation, by the user to make method calls, the user based on the interface call method, you can block different database differences, so no matter what database is connected to a set of APIs.
75. JDBC Development process
1, load the driver, establish the connection
2. Execute SQL statements
3, increase, delete, change the need to update the database, query needs to get the result set, and by iterating through the result set, to get query data.
4. Close the connection

76. What is SQL injection
SQL injection: When you use a word-stitching string, a SQL statement, if the value has a keyword or special character for an SQL statement, may result in an incorrect run result, or a syntax error for the SQL statement.
77. The difference between statement and PreparedStatement
Statement is the parent interface of PreparedStatement. When executing SQL statements with statement, the value of the SQL statement is usually provided by the user, so it can only be set by stitching the string. As a result, the system compiles multiple SQL statements, so it is inefficient and prone to SQL injection
PreparedStatement provides a placeholder mechanism that places the values that need to be set in placeholders, so that whatever value is an SQL statement. does not perform multiple compilation operations, high efficiency. And no matter what the value, will do string processing, will not cause SQL injection.
78. What is a three-tier architecture
1, Presentation layer: As the data display and the provision of data
Adopt the MVC pattern.
M: Represents the model. That is, the implementation class. Media for data storage and transmission
V: Represents the view, which is the GUI form. As a platform for data presentation and collection
C: Indicates control. That is, event handling. Responsible for invoking business components to complete business processing
2, Business layer: business logic processing.
Takes a transactional scripting pattern. Encapsulates all business operations in a single request into a single method. Ensure that the database update operation succeeds at the same time and fails in these business operations. Partially successful partial failures are not allowed, which causes data to clutter the operation.
3, Persistent layer: the main purpose is to complete the conversion of memory data and disk data.
Use DAO mode. Create an entity class and a database table to map, which table corresponds to which class, which column corresponds to which property, and the purpose of persistence is to complete the transformation of the object data and the relational data.

79, the project development process:
Feasibility ANALYSIS--demand analysis--design--coding--testing--maintenance
80. What is reflection?
Reflection: At compile time it is not known which class should be loaded, and the load of the class is performed during run time. The class can be loaded, examined, and self-examined through reflection.

81. How to get the class object? How can I use class objects to produce objects of this class?
1. Class name;
2. Object. GetClass ();
3, Class.forName ("Class full path");
Class object. newinstance (); Call the class no-argument construction method to produce the object
82. What are the differences between threads and processes?
Process refers to a "self-containment" of the running program, directly managed by the operating system, directly run, with its own address space, each process will consume memory once opened.
A thread is a single sequential control flow within a process. A process has multiple threads. Multiple threads share the memory space of a process.
A process-based feature that allows a computer to run two or more programs at the same time
Threads are the smallest processing unit in a thread-based multitasking environment
83. How many ways are there to create threads? How do I start a thread? What is the difference between calling start () and calling run ()?
Creating and starting Threads
You create a thread object in two ways:
--Declares a subclass of the thread class and overrides the Run () method
Class MyThread extends thread{
public void run ();//Override this method
}
--Declare a class that implements the Runnable interface and implement the run () method
Class MyThread Implement runnable{
public void run ();//Implement the method
}
Start thread, call Start ();

The start () method is the method that initiates the thread, which starts a child thread on the main thread, and two threads execute concurrently. Run () is called when the thread starts.
Calling run () directly does not create a new child thread outside the main thread, which is a normal method call


84, the thread has several states?
New-ready-run-dead
Hibernate, suspend, wait, block
85. What is thread priority? What are the levels?
When two or more two threads are in the ready state, the higher-priority thread will take precedence
Divided into 10 levels, the greater the number, the higher the priority
86. What is thread synchronization? What is the result of synchronization?

Thread synchronization (thread safety): When two or more two threads are accessing an object at the same time, in order to avoid data confusion, only one thread is allowed to access at the same moment. The other thread waits.

The consequences of synchronization:
1, data security, 2, low efficiency.
87. What is XML? What is the XML declaration? What is the XML comment?
XML Extensible Markup Language that describes object data in markup and sub-markup mode
Note:<!--comments--annotations cannot be nested
Disclaimer: <?xml version= "1.0" encoding= "UTF-8"?>

88. What are the provisions of a well-formed XML?
--Must have an XML declaration statement <?xml version= "1.0" encoding= "Utf-8"?>
-Must have and have only one root element
--tag-case sensitive
--quotation marks for attribute values
--labeled pairs
--Empty tag close <a/> <a> </a>
--element is properly nested
89. What is the difference between well-formed XML and valid XML?
In addition to XML specification, valid XML satisfies the rules of the corresponding DTD and schema-defined elements.
Valid XML must be well-formed, but well-formed XML is not necessarily valid
90. What is the difference between DOM and sax?
Dom and sax are two ways to parse XML
Dom parsing: 1, tree-based API. 2, can read, can write. 3, random access elements. 4, large documents will cause memory tension.
Sax parsing: 1, an API based on the event model. 2. Low memory consumption. 3, can only read cannot write. 4. The document can only be traversed once, and the element cannot be accessed randomly

91, the TCP/IP protocol is divided into several layers?
4 layers. Application layer, Transport layer, network interconnect layer, network interface layer
92. What is a port? What are the common ports?
Port: Is the channel that the application uses for data interaction, which is used to implement communication between programs. Each application has a fixed port. A port conflict can occur if the two application ports are the same.
Common ports:
1. Protocol: Telnet Protocol Tel Port: 23
2. Protocol: Simple Mail Transfer Protocol SMTP port: 25
3. Protocol: File Transfer Protocol FTP port: 21
4. Protocol: Hypertext Transfer Protocol HTTP port: 80
93. What is the difference between TCP and UDP?
TCP protocol:
1. More reliable bidirectional Flow protocol
2, three-time handshake mechanism
3, provide message confirmation, error detection and error recovery services. If the data is lost during transmission, it will require the sender to resend it. This ensures the integrity of the data.
UDP protocol: less reliable. If the data is lost in transmission, it will not require a re-send, the advantage is fast.

Javaoo Summary Two

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.