Face PA Lu Guodong: Some of the questions of the finishing

Source: Internet
Author: User
Tags concurrentmodificationexception
inherited1, the purpose of inheritance is to extend the function of the class
2, a subclass of Java can only inherit a parent class
3, Java does not allow multiple inheritance, allowing multiple layers of inheritance
4. The private method in the parent class cannot be overridden in a subclass, and if a subclass has a duplicate method, it is not called a overwrite, but a new
Defines a method.
5, the parent class and subclasses define attributes with the same name, and subclasses overwrite the properties in the parent class, and Super.geta () calls the properties in the parent class.
This.geta () calls the properties of a subclass


the difference between overloading and overriding1. Word: Overloading overriding
2, Definition: Method name is the same, parameter type or number of different methods of name parameter type return value type of the same
Methods that do not require a write on permission cannot have more restrictive permissions on the subclass method
3, scope: occurs in the same class in the Inheritance class


Super keywordRepresents a specified operation in a parent class called from a subclass, such as invoking a property, method, construct, and so on. Because the parameterless construction method in the parent class is invoked by default during instantiation of a subclass, if you now want to invoke a parameter construct, you must indicate in the subclass the parameter constructor method to invoke. For example: Super (Name,age)


the difference between this and super1, Property access: This access to properties in this class, if there is no this property in this class, then continue to find super from the parent class is to access the properties in the parent class.
2. Access method: This accesses the method in this class and looks in the parent class if there is no such method in this class. Super is directly accessing the methods in the parent class.
3. Call construct: This calls the constructs in this class and must be placed in the first row of the constructor method. Super calls the parent class construct, which must be placed in the first row of the subclass method.
4, this represents the current object.
5, this and super two keywords cannot appear in the construction at the same time.


usage of the math class1. Math.Abs (int a): Returns the absolute value of the values. Parameters can be of type int, float, double, long
2. Math.acos (Double A): Returns the reverse cosine of the angle.
3 Math.asin (Double A): Returns the sine chord of the horn.
4. Math.atan (Double A): Returns the tangent of the horn.
5. Math.atan2 (Double A): Converts rectangular coordinates (x,y) to polar coordinates (R,THETA).
6 MATH.CBRT (Double A): Returns the cubic root of a double value.
7. Math.ceil (Double A): Returns the smallest (nearest negative infinity) Double value that is greater than or equal to the argument and is equal to an integer.
8. Math.Cos (Double A): Returns the triangular cosine of the angle.
9 Math.cosh (Double x): Returns the hyperbolic cosine of a double value.
Math.exp (Double A): Returns the value of the double power of Euler number E.
Math.floor (Double A): Returns the largest (nearest positive infinity) Double value that is less than or equal to the argument and is equal to an integer.
Math.max (int a,int b): Returns a larger value of two values. parameter contains the type int, float, long, double.
math.min (int a,int b): Returns one of the smaller values of two values. parameter contains the type int, float, long, double.
Math.random (): Returns a double value with a plus sign.
Math.Round (Double A): Returns a Long that is closest to the argument.
Math.Round (float a): Returns the int with the nearest parameter.


the problem of int Division12/10=1
12f/10=1.2
12d/10=1.2
12/10f=1.2
12/10d=1.2
------------Double Type----------
2.3/0.0 = Infinity
2.3/-0.0 =-infinity
0.0/0.0 = NaN
0.0/-0.0 = NaN
0.0/0.1 = 0.0
0.0/-0.1 =-0.0


------------Float Type----------
2.3/0.0 = Infinity
2.3/-0.0 =-infinity
0.0/0.0 = NaN
0.0/-0.0 = NaN
0.0/-0.1 =-0.0

several design patterns1. Factory mode
2. Template Method Mode: Template method: Defines the skeleton of an algorithm in an operation, and delays some steps into subclasses. The T-template method allows subclasses to redefine certain steps of the algorithm without altering the structure of an algorithm.
1 Template method pattern is based on the inheritance of code reuse Basic Technology, template method pattern structure and usage is also one of the core of object-oriented design. In Template method mode, the same code can be placed in the parent class, and different method implementations are placed in different subclasses.
2 in the template method pattern, we need to prepare an abstract class, implement part of the logic in concrete ways and in the form of a concrete constructor, and then declare some abstract methods to enable the subclass to implement the remaining logic. Different subclasses can implement these abstract methods in different ways, thus having different implementations of the remaining logic, which is the intention of the template method pattern.
3. Single case mode
public class Singleton   
{   
    private static final Singleton Singleton = null;   
  
    Private Singleton ()   
    {   
    } public   
    static Singleton getinstance ()   
    {   
        if (singleton== null)   
        {   
            Synchronized (Singleton.class)   
            {   
                if (singleton== null)   
                {   
                    singleton= new Singleton ();   
                }   
            }   
        }   
        Return singleton   
    }   
}


The first condition is that if the instance is created, then there is no need to sync, so just go back.
Otherwise, we'll start synchronizing threads.
The second condition is that if a thread in the synchronized thread creates an object, then the other thread does not have to create the
Static UsageWhen the static property is invoked, the "class name. Property" method is used.
The static method cannot call a non-static property or call a non-static method, because static properties and methods are initialized before the object is instantiated.
Other applications: You can count how many objects have been generated altogether.


type of memory space in JavaStack Memory: The name of the saved object, which is the address of the heap memory access
Heap Memory: Saving basic properties for each object
Global Data area: Saving properties of a static type
Global code area: Saving the definition of all methods


the difference between HashMap and HashtableHashMap and Hashtable both implement the map interface, but before deciding which one to use, we need to figure out the difference between them. The main differences are: thread safety, Synchronization (synchronization), and speed.
HashMap can be almost equivalent to Hashtable, except that HashMap is synchronized, and can accept null (HashMap can accept null key values (keys) and values (value), and Hashtable not).
HashMap is synchronized, and Hashtable is synchronized, which means that Hashtable is thread-safe, multiple threads can share a hashtable, and if there is no correct synchronization, Multiple threads cannot share hashmap. Java 5 provides Concurrenthashmap, which is an alternative to Hashtable, and is better than Hashtable extensibility. Another difference is that the HashMap iterator (iterator) is a fail-fast iterator, while the Hashtable enumerator iterator is not fail-fast. So when there are other threads that change the structure of the hashmap (adding or removing elements), the concurrentmodificationexception will be thrown, but the remove () of the iterator itself Method removes an element, it does not throw a concurrentmodificationexception exception. But this is not a certain behavior, it depends on the JVM. This is also the difference between enumeration and iterator.
Because Hashtable is thread-safe and synchronized, it is slower than hashmap in a single-threaded environment. If you don't need to sync, you just need a single thread, so it's better to use HashMap performance than Hashtable.
HashMap does not guarantee that the order of elements in the map will change over time.

the difference between forward and redirectA: Forward is the server request resources, the server directly access the URL of the destination address, the URL of the response content read over, and then send the content to the browser, the browser does not know where the server sent the content from, so its address bar or the original address.
Redirect is the server based on logic, send a status code, tell the browser to request that address again, generally speaking, the browser will be requested by all the parameters of the request again, so session,request parameters can be obtained

The former is only the control in the container of the steering, in the client browser address bar will not show the direction of the address, the latter is a complete jump, the browser will get the address of the jump, and resend the request link. In this way, you can see the link address after the jump from the address bar of the browser. So, the former is more efficient, when the former can meet the need, try to use the forward () method, and it also helps to hide the actual link. In some cases, for example, you need to jump to a resource on a different server, you must use the Sendredirect () method.


js Intercept stringFunction: Split ()
Function: To store a string partition into an array using a specified delimiter
Example:
Str= "Jpg|bmp|gif|ico|png";
Arr=thestring.split ("|");
Arr is an array that contains the character values "JPG", "BMP", "GIF", "ico", and "PNG"
Function: John ()
Function: Merges an array into a string using the separator of your choice
Example:
var delimitedstring=myarray.join (delimiter);
var mylist=new Array ("JPG", "BMP", "GIF", "ico", "PNG");
var portablelist=mylist.join ("|");
The result is jpg|bmp|gif|ico|png.
Function: substring ()
Function: string interception, for example, to get "Minidx" from "minidxsearchengine" to use SUBSTRING (0,6)
Function: IndexOf ()
Function: Returns the subscript of the first character in a string that matches a substring
var mystring= "JavaScript";
var w=mystring.indexof ("V"); W'll be 2
var x=mystring.indexof ("S"); X would be 4
var y=mystring.indexof ("Script"); y'll also be 4
var z=mystring.indexof ("key"); Z'll be-1


Substr method
Returns a substring of the specified length starting at the specified position.
Stringvar.substr (start [, length])
Parameters
Stringvar
Required option. The string literal or string object to extract the substring.
Start
Required option. The starting position of the desired substring. The index of the first character in the string is 0.
Length
Options available. The number of characters that should be included in the returned substring.
Description
If length is 0 or negative, an empty string is returned. If this argument is not specified, the substring continues to the


Stringvar's Last
function Substrdemo () {
var s, SS; Declare a variable.
var s = "The rain in Spain falls mainly in the plain.";
SS = S.substr (12, 5); Gets the substring.
return (SS); Returns "Spain".
}


Java features

Inherit wrapper polymorphic Abstraction

the difference between Java extraction and moduloTake more
REM (3,2) =1
REM ( -3,-2) =-1
REM (3,-2) =1
REM ( -3,2) =-1
2. Mold taking
MoD (3,2) =1
MoD ( -3,-2) =-1
MoD (3,-2) =-1
MoD ( -3,2) =1
It can be seen from this that REM and mod are symbolic differences.
When the divisor is the same as the divisor, the result of REM and mod is identical; when the divisor is not the same as the symbol being divisor, the knot


Fruit is different.
Specifically, the REM result has the same symbol as the divisor, and the MoD result has the same symbol as the divisor.
SQL Paging
--Writing 1,not In/top
Select Top * from Pagetest
where ID not in (select top 9900 ID from Pagetest ORDER by ID)
ORDER BY ID


--Writing 2,not exists
Select Top * from Pagetest
Where NOT EXISTS
(select 1 from (select top 9900 ID from Pagetest ORDER by id) a where a.id=pagetest.id)
ORDER BY ID


--Writing 3,max/top
Select Top * from Pagetest
Where id> (select Max (ID) from (select top 9900 ID to pagetest ORDER by ID)
ORDER BY ID


--Writing 4,row_number ()
Select top
(select Row_number () over (order by ID) rownumber,* from pagetest) a
where rownumber>9900


SELECT * FROM
(select Row_number () over (order by ID) rownumber,* from pagetest) a
where rownumber>9900 and rownumber<9951


SELECT * FROM
(select Row_number () over (order by ID) rownumber,* from pagetest) a
where RowNumber between 9901 and 9950


JS cross-domain1, the Document.domain+iframe setting
For examples where the primary domain is the same and the subdomain is different, you can solve the problem by setting the Document.domain method
2. Create script dynamically
Although the browser prohibits Cross-domain access by default, it does not prevent JS files that refer to other domains in the page, and are free to perform the introduced JS


The function in the piece (including the action Cookie, DOM, and so on). Based on this, you can easily create a script node by creating a method to


To achieve full cross-domain communication. The specific procedure may refer to Yui's get Utility
It is interesting to judge whether the script node is loaded or not: IE only through the script's ReadyStateChange properties, other browsers


Is the script's Load event. The following are some of the methods used to determine the completion of script loading.
3. Use HTML5 postMessage
Otherwindow.postmessage (message, targetorigin);
Otherwindow: A reference to the window that receives the information page. Can be the Contentwindow attribute of the IFRAME in the page;


The return value of the window.open, the value taken from the Window.frames by name or subscript.
Message: The data to be sent, string type.
Targetorigin: Used to limit Otherwindow, "*" means no restrictions


4, the use of flash


5, Window.name implementation of cross-domain data transfer

The src attribute of the IFRAME is shifted from Outland to the local domain, and cross-domain data is passed from Outland to the local domain by the window.name of the IFRAME. This cleverly bypasses the browser's Cross-domain access restrictions, but it is also a safe operation.


The above summed up so much, after the collection and then update, but also as a study.

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.