Java Face question 02

Source: Internet
Author: User
Tags finally block

The encoding format used internally by 1.JAVA is (utf-8)

2.

public class Threads2 implements Runnable {

@Override
public void Run () {
System.out.println ("Run.");
throw new RuntimeException ("problem");

}

public static void Main (string[] args) {
Thread t = new Thread (new Threads2 ());
T.start ();
System.out.println ("End of Method.");
}

}

Execution Result:

Run.
End of method.
Exception in Thread "Thread-0" Java.lang.RuntimeException:problem

Or:

End of method.
Run.
Exception in Thread "Thread-0" Java.lang.RuntimeException:problem

3.

public class SimpleCalc {
public int value;

public void Calculate () {
Value + = 7;
}
}

public class MultiCalc extends SimpleCalc {
public void Calculate () {
Value-= 3;
}

public void calculate (int multiplier) {
Calculate ();
Super.calculate ();
Value *= multiplier;
}

public static void Main (string[] args) {
MultiCalc calculate = new MultiCalc ();
Calculate.calculate (2);
System.out.println ("value is:" + calculate.value);
}
}

Output Result: Vaue is:8

4. For the common rules of JSP, the correct description is:

If the URL does not start with "/", it is interpreted as relative to the current JSP path.

5. In MVC design mode, the scope of JavaBean is:

Model

6. In a filter, what is the method of handling the filter business?

DoFilter (ServletRequest request,servletresponse response,filterchain chain)

7. A description of the configuration implications of the following spring declarative transaction is (missing the injection of the Sqlsessionfactory attribute).

8, Hibernate API a few of the several types of configuration Hibernate interface is configured

9, the atomicity of the transaction refers to: The atomicity of the transaction refers to all the manipulation of the transaction in the database or all correctly reflected, or all do not reflect

10, the conditions of the outside link can be placed in which of the following statement where;

Part Two brief answer

1. What are the characteristics of the List Map Set three interfaces when accessing elements?

For:

Both list and set are collections of single-column elements that have a common parent interface, collection.

Duplicate elements are not allowed in set.

Save element: The Add method has a Boolean return value that returns True when there is no element in the collection, when the Add method can successfully join the element, and when the collection contains an element equal to the equals of an element, the Add method cannot join the element and return the result to false.

Take the element: can not say that the first few, only the iterator interface to get all the elements, and then iterate through each element.

The list represents a set of sequential

Save elements: When you call the Add (object) method multiple times, each time you join the object in the order of first served, you can also jump in the queue, that is, call the Add (int index,object) method, you can specify the current object in the collection location.

Take element: Method 1:iterator interface Get all, traverse each element individually

Method 2: Call Get (Index i) to specify how to take the first few.

Map is a set of two columns, stored with the Put method: put (obj key,obj value), each time it is stored, to store a pair of key/value, cannot store duplicate key, this repeating rule is equal to equals.

Take element: Use the Get (Object key) method to obtain the corresponding value according to key.

You can also get a collection of all the keys, and you can also get a collection of all the value,

You can also get a collection of Map.entry objects that combine key and value.

Lists hold elements in a particular order, and can have repeating elements. Set cannot have duplicate elements, internal ordering. Map holds the Key-value value, and value can be multivalued.

2. List the sort methods you know. Please write the pseudo code of the shortcut sort.

A: Sorting methods are: Insert sort, choose sort, bubble sort, heap sort, quick sort, merge sort, count sort, cardinal sort, bucket sort
Pseudo-code for quick sorting:

public void QuickSort (Seqlist r,int low,int High) {

         //R[low...high] to quickly sort   
        int pivotpos ;//The position of the datum record after dividing   
        if (Low             //sorting is only required if the interval length is greater than 1 o'clock   
             pivotpos = partition (R,low,high); /to R[low...high]   
             QuickSort (r,low,pivotpos-1);   
             quicksort (R,pivotpos+1,high);   
        }   
    }  

3, talk about final, finally, finalize the difference?

For:

1.final: If a class is final decorated, it means that the class cannot derive a new subclass and cannot be inherited as a parent class. Therefore, a class cannot be declared abstract and is declared final. Declares a variable or method to be final. Can guarantee that they will not be changed when they are in use. It can be initialized in two places: the first is where it is defined, that is, when the final variable is defined, and the second is in the constructor. These two places can only choose one of them, either at the time of definition, or give values in the constructor. A method that is declared final can only be used and cannot be overridden.

2.finally: In exception handling, provide a finally block to perform any cleanup operations. If an exception is thrown, then the matching catch is executed, and then the control enters the finally block, provided there is a finally block.

3.finalize:finalize is the method name, and Java technology allows the use of the Finalize () method to do the necessary cleanup before the garbage collector clears the object from memory. This method is called when the garbage collector confirms that an object is not referenced. It is defined in the object class, so all classes inherit it. The subclass override Finalize () method has collated system resources or performed other cleanup work. The Finalize () method is called on the object before the object is deleted by the garbage collector.

Java face question

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.