1.GC What's that? Why is there a GC?
GC is the meaning of garbage collection (Gabage Collection), memory processing is where programmers are prone to problems, forgetting or wrong memory recycling can cause program or system instability or even crashes, The GC functionality provided by Java can automatically monitor whether an object exceeds the scope to achieve the purpose of automatically reclaiming memory, and the Java language does not provide a way to release the displayed operation of the allocated memory.
2.int a=5;int b=7; how to implement without defining a third variable a , b the value of the interchange?
int A=5;int b=7;
A=a+b;
B=a-b;
A=a-b;
3.MVC What are some of the technologies that can be implemented? How is it implemented?
Answer: MVC is shorthand for Model-view-controller. The model represents the business logic of the application (implemented through the JAVABEAN,EJB component), the View is the presentation surface of the application (generated by the JSP page), and the controller is the process control that provides the application (typically a servlet), which uses this design model to apply logic, The process and display logic are divided into different component implementations. These components can be interacted with and reused.
M (DAO) layer, equivalent to the background, V (JSP), equivalent to the foreground, C (control) layer, equivalent to control page jump;
The purpose of the MVC pattern is to realize the functional division of the web system. The model layer implements the business logic in the system, which can often be implemented with JavaBean or EJBS. The view layer is used for interaction with the user and is usually implemented with JSP. The controller layer is a bridge between model and view that can dispatch a user's request and select the appropriate view for display, and it also interprets the user's input and maps them to the actions that the model layer can perform.
M:hibernate/mybatis/ibatis
C:severlet/struts/spring Action
V:jsp/freemarker/tails/taglib/el/velocity
4. What are the aspects of object-oriented features?
Abstract:
Abstraction is about ignoring aspects of a topic that are not related to the current goal, so that you can more fully focus on the aspects that are relevant to the current goal. Abstractions do not intend to understand all of the problems, but simply select one part of them, temporarily without some detail. Abstract includes two aspects, one is the process abstraction, the other is the data abstraction.
Packaging:
Encapsulation is the process and data is surrounded, access to data only through the defined interface. Object-oriented computing begins with this basic concept that the real world can be portrayed as a series of fully autonomous, encapsulated objects that access other objects through a protected interface.
Inherited:
Inheritance is a hierarchical model of a junction class and allows and encourages the reuse of classes, which provides a way to articulate commonalities. A new class of objects can be derived from existing classes, a process known as class inheritance. The new class inherits the attributes of the original class, which is called the derived class (subclass) of the original class, and the original class is called the base class of the new class (The parent Class). Derived classes can inherit methods and instance variables from their base classes, and classes can modify or add new methods to make them more suitable for special needs.
Polymorphism:
Polymorphism refers to allowing objects of different classes to respond to the same message. Polymorphism consists of parameterized polymorphism and inclusion polymorphism. Polymorphism language has the advantage of flexibility, abstraction, behavior sharing and code sharing, which solves the problem of application function with the same name.
5. Describe the basic concepts of threading, the basic state of threads, and the relationship between States.
Threading Concepts
A thread is a sequence of processes that executes a stream. Multiple threads of the same class share a piece of memory space and a set of system resources, and the thread itself has a stack for the execution of the program. Threads are less loaded when switching, so a thread is also known as a light-load process. A process can contain multiple threads.
Thread state
(1) New
The thread object created with the new statement is in the new state, which, like other Java objects, is allocated only memory.
(2) Wait
When the thread is behind new, and before the Start method is called, the thread is in a wait state.
(3) Ready
When a thread object is created, the other thread calls its start () method, and the thread enters the ready state. The thread in this state is in the running pool of the Java Virtual machine and waits for the CPU to use it.
(4) Operating status
The thread in this state consumes the CPU and executes the program code. In a concurrent runtime environment, if the computer has only one CPU, only one thread will be in this state at any time.
Only threads in a ready state have the opportunity to go to the running state.
(5) Blocking status
A blocking state is when a thread abandons the CPU for some reason and temporarily stops running. When a thread is in a blocking state, the Java Virtual Machine does not allocate the CPU to the thread until the thread is back in the ready state before it has a chance to get a running state.
The blocking states are divided into three types:
A. Wait for blocking: The running thread executes the wait () method, and the JVM puts the thread into the waiting pool.
B. Synchronous blocking: When a running thread acquires an object synchronization lock, the JVM puts the thread into the lock pool if the synchronization lock is occupied by another thread.
C. Other blocking: When the running thread executes the sleep () method, or when an I/O request is made, the JVM Cheng the line into a blocked state. When the sleep () state times out, or the I/O process is complete, the thread is re-entered in a ready state.
(6) Death status
When the thread finishes executing the code in the Run () method, or encounters an uncaught exception, it exits the run () method and then enters the dead state, which ends the life cycle.
Additional knowledge:
The difference between a process and a thread
A process has at least one thread. The thread's dividing scale is smaller than the process, which makes the multi-thread procedure high concurrency. In addition, the process has a separate memory unit during execution, and multiple threads share memory, which greatly improves the efficiency of the program operation.
The difference between a thread and a process during execution is that each individual thread has a program run entry, sequence of sequence execution, and exit of the program. However, threads cannot be executed independently, and must be dependent on the application, which provides multiple threads of execution control.
From a logical point of view, the meaning of multithreading is that in an application, multiple execution parts can be executed concurrently. However, the operating system does not consider multiple threads as separate applications for scheduling and managing processes and allocating resources.
Concurrency principle
Multiple threads or processes running "at the same time" are just a manifestation of our senses. In fact, processes and threads are run concurrently, and the thread scheduling mechanism of the OS divides the time into many time fragments (time slices) that are distributed as evenly as possible to the running program, the thread or process that gets the CPU time slice is executed, and the others wait. The CPU then switches back and forth on these processes or threads. All processes and threads on the micro are walking and stopping, macro-running, which is called concurrency, but not in the absolute sense of "simultaneous occurrence."
6.float f=3.4; is it correct?
Not correct
3.4 is a double, assigning a double type (double) to a float (float) belonging to the lower transformation (down-casting, also known as narrowing) will result in a loss of precision, so you need to force the type conversion of float F = (float) 3.4; or write a float F =3.4f.
7. use js to write an Ajax request (get method) write the Code
var xmlhttp;
if (window. XMLHttpRequest ()) {
Xmlhttp=new XMLHttpRequest ();
}else{
Xmlhttp=new ActiveXObject ("microsoftxmlhttp");
}
Xmlhttp.onreadystatechange=function () {
if (xmlhttp.readystate==4&& xmlhttp.readystate==200) {
Local Refresh Code
}
xmlHTTP. Open ("Get", "statutreadycheck.aspx?dates=" +encodeurlcomponene (dates), true);
Xmlhttp.send ();
}
8. to intercept the ABCDEFG of the string (write code)
String str= "ABCDEFG";
String newstr = str.substring (4);
9. briefly answer how to solve the compatibility problem of page front-end browser
Browser compatibility Issue one: different browser tags default external patches and internal patches are different
Problem symptom: Write a few labels casually, without style control, the difference between the margin and padding is big.
Solution: CSS in *{margin:0;padding:0;}
Note: This is the most common and the most easy to solve a browser compatibility problem, almost all of the CSS file starts with a wildcard * to set the internal and external patches of each tag is 0.
Browser compatibility Issue two: block attribute tag float, and there is the margin of the case, in the IE6 show margin than set the large
Problem symptom: A common symptom is that the next piece in IE6 is top to bottom row
Solution: Add Display:inline to the label style control of float and convert it into inline properties
Note: Our most commonly used is div+css layout, and Div is a typical block attribute tag, horizontal layout when we are usually implemented with div float, horizontal spacing setting if using margin to achieve, this is a must encounter compatibility problem.
Browser compatibility Issue three: set a smaller height label (generally less than 10px), in the Ie6,ie7, the height of the tour beyond its own set height
Symptoms: IE6, 7, and the height of this label are uncontrolled, exceeding the height of your own settings
Solution: Set Overflow:hidden for labels that are out of height, or set line height line-height less than you set.
Note: This usually occurs in the label where we set the small rounded background. This problem occurs because the browser before IE8 will give the label a minimum height of the row height. Even if your label is empty, the height of the label will still reach the default row height.
Browser compatibility issues four: in-line attribute tags, set display:block after the float layout, there are horizontal margin, IE6 spacing bug
Problem symptom: The spacing in IE6 is more than the spacing set
Solution: Add display:inline;display:table after Display:block;
Note: In-line property labels, in order to set the width, we need to set display:block; (except that the input tag is special). With float layout and horizontal margin, under IE6, he has a bug of horizontal margin after the Block property float. However, because it is the inline attribute tag itself, so if we add display:inline, its aspect will not be set. We also need to add display:talbe behind Display:inline.
Browser compatibility Issue five: image default Spacing
Problem symptom: When several IMG tags are put together, some browsers will have default spacing, and adding the wildcard character mentioned in the question does not work.
Chance to hit: 20%
Solution: Use the Float property for the IMG layout
NOTE: Because the IMG tag is an inline attribute tag, the img tag is lined up on a single line as long as the container width is not exceeded, but there is a gap between the IMG tags in some browsers. Removing this spacing using float is the right path. (One of my students uses negative margin, although it can be solved, but the negative margin itself is prone to browser compatibility problems, so I forbid them to use)
browser compatibility question six: label minimum height setting min-height incompatible
Problem symptom: Because Min-height itself is an incompatible CSS property, setting Min-height is not very well compatible with each browser.
Solution: If we want to set a minimum height of 200px for a label, the setting required is: {min-height:200px; height:auto!important; height:200px; overflow:visible;}
Note: In the front of the B/s system, there are many situations where we have this demand. When the content is less than a single value (such as 300px). The height of the container is 300px, and when the content height is greater than this value, the container height is high, not the scroll bar. This is when we face this compatibility issue.
Browser compatibility Issue VII: compatible CSS settings for transparency
The way to do a compatible page is to write a small piece of code (a line or a piece of the layout) we have to see in different browsers is compatible, of course, proficiency to a certain degree is not so troublesome. It is recommended that you often encounter compatibility issues with novice users. Many compatibility issues are caused by the browser's default attribute resolution for the label, as long as we can easily fix these compatibility issues with a little bit of setup. If we are familiar with the default properties of tags, we can understand why compatibility issues arise and how to resolve them.
/* CSS hack*/
I seldom use hacker, may be personal habits bar, I do not like to write code ie incompatible, and then use Hack to solve. But the hacker is still very useful. Using hacker I can divide the browser into 3 categories: IE6, IE7 and Roaming, others (IE8 Chrome FF Safari Opera, etc.)
IE6 know Hacker is the underscore _ and the asterisk *
IE7 Hacker is an asterisk *
For example, a CSS setting like this:
height:300px;*height:200px;_height:100px;
IE6 Browser when reading to height:300px will think high 300px; Continue reading, he also know *heihgt, so when IE6 read *height:200px will overwrite the previous one of the conflicting settings, think height is 200px. Continue to read, IE6 also know _height, so he will cover off 200px high setting, set the height of 100px;
IE7 and roaming are the same. read from the setting of height 300px. When they read the *height200px, they stopped because they didn't know _height. So they will parse the height into 200px, the rest of the browsers only know the first height:300px, so they will parse the height into 300px. The order of the writing is important because the same priority and the conflicting properties are set to overwrite the previous one.
Ten. write a MySQL paging statement
SELECT * FROM table limit (pageIndex-1) *pagesize, pageSize;
PageSize Display Quantity per page
PageIndex Show Page No.
Write a SQL statement that asks for a random query of 5 data in the tf_f_user table.
SQL Server:
SELECT TOP 5 * from T_user ORDER by NEWID ()
ORACLE:
SELECT * FROM (SELECT * from T_user ORDER by Dbms_random. RANDOM ()) WHERE Ronum <= 5
Mysql:
SELECT * from T_user ORDER by RAND () LIMIT 5
Access:
SELECT TOP 5* from T_user ORDER by Rnd ([one AutoNumber field])
This statement is available in query in Access and can be run with random results, but in ASP. NET and other background program code can not get the expected random effect.
The correct wording is as follows:
Take the example of asp:
Random random = new Random (System.Guid.NewGuid (). GetHashCode ());
int r = Random. Next ();
String sql = "Select TOP 5 * from T_user ORDER by RND (" + (-r) + * AutoNumber field) "
can i inherit the String class ?
No
Because string is a final decorated class, it cannot be inherited by another class.
Date Time: (write out the code)
-How do I get the date, hour and minute seconds?
Calendar now = Calendar.getinstance ();
System.out.println ("Year:" + Now.get (calendar.year));
System.out.println ("Month:" + (Now.get (calendar.month) + 1));
System.out.println ("Day:" + now.get (calendar.day_of_month));
System.out.println ("Time:" + now.get (calendar.hour_of_day));
System.out.println ("min:" + now.get (Calendar.minute));
System.out.println ("seconds:" + now.get (Calendar.second));
-How to get the number of milliseconds from January 1, 1970 0:0 0 seconds to now?
Gets the GetTime method from 1970 1 1 to the current number of milliseconds in Java the default is from//1970 1 1
public class test1{
public static void Main (string[] args) {
Calendar.getinstance (). Gettimeinmillis ();
System.currenttimemillis ();
Clock.systemdefaultzone (). Millis (); Java 8
}
}
-How to get the last day of a month?
public static String Getlastdayofmonth (int year, int month) {
Calendar cal = Calendar.getinstance ();
Cal.set (Calendar.year, year);
Cal.set (Calendar.month, MONTH);
Cal.set (Calendar.day_of_month,cal.getactualmaximum (calendar.date));
return new SimpleDateFormat ("Yyyy-mm-dd"). Format (Cal.gettime ());
}
public static String Getfirstdayofmonth (int year, int month) {
Calendar cal = Calendar.getinstance ();
Cal.set (Calendar.year, year);
Cal.set (Calendar.month, MONTH);
Cal.set (Calendar.day_of_month,cal.getminimum (calendar.date));
return new SimpleDateFormat ("Yyyy-mm-dd"). Format (Cal.gettime ());
}
-How do I format a date?
Date d = new Date ();
SimpleDateFormat SDF = new SimpleDateFormat ("Yyyy-mm-dd HH:mm:ss");
System.out.println ("Current time:" + Sdf.format (d));
- , seek from Ten to the - Medium can be 3 and the 5 The and of the number of integers (write the code)
public void Getsum () {
int sum = 0;//10 to 100 of the sum of the numbers that can be divisible by 3 and 5
for (int i=10;i<=100;i++) {
if (i%3==0&&i%5==0) {
Sum+=i;
}
}
System.out.println ("10 to 100 of the number that can be divisible by 3 and 5 is:" +sum);
}
15. What is the most efficient way to figure out 3 times 8 equals? (Write code)
2<<3
Java Face question 07