JAVA interview questions (a)

A, Java basics
1.Java those basic data types, String is not the basic data types, what is the difference between them.
2. Operation of the string:
write a method for reversing a string, such as: input abc, output cba
write a way to achieve the replacement string, such as: input bbbwlirbbb, bbbhhtccc output
conversion between data types 3.
how numeric character into a digital (Integer, Double)
how numbers to characters
how before the decimal point two, and rounded.
4. the date and time
how to get the date, hour, minute and second
how to get from 1970 to the present number of milliseconds
how to get a date is the last day of the month
how to format date
5 arrays and collections
6 file and directory (I / O) operations
how to list all the files in a directory
how to list all subdirectories in a directory
is determined whether there is a file or directory
how to read and write files
7.Java achieve polymorphism ( Inherited, reload, cover)
8. transcoding, how to achieve the conversion GB2312 string to ISO-8859-1 encoded encoded string.
step 9.Java database access, Statement The difference between the PreparedStatement
10. The following codes for errors that may exist, and why:
Two, JSP & Servlet technology
1. Describe the difference between JSP and Servlet, the common, the scope of their application
2. Web development need to be addressed when HTML tags, what kind of treatment should be done, should be screened for those characters (
3. How the JSP reading the client's request, how to access CGI variables, how to determine the true path to a file Jsp.
4. describe the role of Cookie and Session, and the difference between the respective range of applications, Session works.
the external file contains lists Jsp way, what is the difference between the two.
6. Description Jsp role in errorPage of application.
7. Jsp in how to use the JavaBeans.
tag library 8. introduces the JSP
9.Jsp Servlet and how the request is forwarded respectively achieved.
three, J2EE knowledge
1. introduction difference between J2EE, J2SE, J2SE is.
2.J2EE is a technology that is also a platform, he provided those techniques.
3. What is the Application Server, it has what features and benefits.
4. briefly advantages and principles of connection pooling.
effect 5.Web.xml of
four other
1.Web security considerations (form validation, verification, security applications, SSL, consider the code browser Basic mode)
2. You are the brief introduction The MVC.
3. briefly know XML.
4. documentation and coding standards
The 5.Java paging, efficiency considerations.
6. briefly what you know structs.
Role 1.xml in the project
2.s-EJB and the difference between e-EJB
3 session side effects
4.cmp and bmp the advantages and disadvantages of
several parts necessary 5.j2me program
6.c difference / s and B / s in
7. Construction of a connect pool, and then call it,
the difference 8.j2ee dotnet platform and platform
9.ejb of life Cycle
10.session bean and entity bean difference between
transaction mechanism 11.ejb in
12.synchronized (producers and consumers)
13.String and StringBuffer
14.Serializable
15.MVC (Struts workflow)
16. What is MDA
17. the difference between tcp and udp of
the difference between the list with 18. the hash table and an array of
difference between heap and stack 19. the
classification and distinction 20.ejb of
21. you now views the software industry as well as the domestic software industry
22. talk about java multithreading
23 . talk about file encryption technology
24. software development life cycle
25. The routing protocol types and characteristics of
the key components of the GUI awt and swing 26.java design
27. awareness java stream
28. briefly describe the difference between swing and awt.
29. A Description of java programming event processing mode.
30. ?? how do you write too applet applet security permissions trial enumeration java application or applet, servlet / jsp can be used to communicate with.
31. Description of logical operations (such as &, |) and operating conditions (such as &&, || ) difference.
Contact and 32. Description of the difference between the Servlet and Java Server Page.
Similarities and differences 33. outlined synchronized and java.util.concurrent.locks.Lock of?
operating ban in the EJB specification 34.EJB What?
35 .java addition to the eight basic types, in a virtual machine as well as what kind of, what role?
36. in addition to using the new keyword to create an object accidentally, non-exhaustive list of examples of ways to create more than the other three?
37.classloader in the JDK API, there is the same class loading Classpath in the web-inf of what is the difference?
38. list three or more garbage collection algorithm, and compare their advantages and disadvantages?
39. Develop code that implements a thread pool
40. describe JVM loaded class file the principle mechanism?
41. try to illustrate A typical garbage collection algorithm?
42. Please write java binary tree algorithm, to add data to form a binary tree functions, and to print out a way to order.
43. Please write a java program to achieve threaded connection pool?
44. Given a C-language functions required to achieve the java class were called in.
45. how to get the length of the array?
46. the access modifier to use "public / private / protected / default modifier" is
47. when a class or method with the keyword final modification, what is the point ?
48. grasp the concept of classes and objects, to grasp the essence of object-oriented programming
? 49. the static variables and static methods of significance, how to reference a class static variable or static method
50.JAVA how language exception handling, keyword: thorws , the throw, the try, the catch, a finally
51.Object class (or a subclass) of the finalize () method is called under what circumstances?
52. a ".java" whether the original document may include more than one class (not an internal class )?
53. the concept of internal master classes and interfaces
54.StringTokenizer class with
55. the data structure, how to traverse the elements of the List?
If you want to save or access data in accordance with the key, what data structure?
to master the related Collection Use of oral and classes
What is the difference 56. When using StringBuffer class and the String class string concatenation?
57. calls destroy Thread class () method what are the consequences?
58. The multi-threaded, what keywords synchronization method modified? Stop () and suspend () method is not recommended why?
59. establish communication using the socket client and server process
60.JAVA language of international applications, Locale class, Unicode
61. the description of the role of reflection mechanism
62. how to read and write a file?
63. in the graphical interface, how to deal with a mouse click a button event?
pop-up drop-down box 64. in the graphical interface, a table, how to edit cells ?
65. how to load picture?
66. What is a modal dialog?
67. MVC explained the concept of
using 68.GUI layout manager, FlowLayout, BorderLayout, GridBagLayout
when a node 69. how to construct a tree? tree of choice how to get this node?
70. the input character box to edit, how to control only integer input?
71. describe the process of using JDBC connection to the database
72.EJB divided into several categories? What is BMP, CMP?
73. the What is JNDI ?
What 74.ADO is? ActiveX data objects, is an application-level programming interface.
75. the four kinds of JDBC way? the current version?
76.EJB there? What is the difference?
77.JavaBean and EJB What is the difference?
78. software development life cycle Several stages?
What factors 79. The software development?
80. How do software development for version control?
81.UML, the class view of how to represent the class inheritance and aggregation?
Difference 82. The client and server-side cursors cursors?
Difference between static and dynamic cursor 83. The cursor?
84. dotnet several of which make up the basic framework?
What 85.Oracle in SGA is?
What is 86.web servers?
87.UNIX in QT What does this mean?
88. what stage in the software development life cycle to begin testing?
89.dotnet comparison of J2EE?
90. What is ActiveX?
What 91.Java in IDL is?
What 92.ISO9000 and CMM are? IS09000 and CMM (capability maturity model) certification is a common international software quality assessment method of .CMM five maturity levels.
first, talk about the final, the difference finally, finalize the.
Final? modifier (keyword) if a class is declared final, meaning that it can not send another unexpected new sub-category, not as a parent when the class is inherited, so a class can not both be declared abstract, has been declared as final. the variable or method declared as final, can guarantee that they are not in use change. is declared as final variables must be declared given the initial value, and in later references Can only read, can not be modified. The method is declared as final can also use, not overloaded
finally? Finally block to provide exception handling to perform again when any cleanup operation. If an exception is thrown, then the match catch child sentence will be executed, then control will enter the finally block (if any).
finalize? method name .Java technology allows the use of finalize () method to remove the object to do the necessary clean-up work before going out from memory in the garbage collector. This method is by the garbage collector calls this object in determining this object is not referenced of which is defined in the Object class, so all classes inherit it. subclass covering finalize () method to organize system resources or perform other cleanup work .finalize () method is a garbage collector before deleting objects this object is called.
second, anonymous inner class (anonymous inner classes) if you can extends (inheritance) other classes, can implements (achieve) interface (interface)?
anonymous inner class is not the name of the inner class. not extends ( inheritance) other classes, but a class can be used as an interface, by another internal class.
third, different Static Nested class inner class and, to put it better (face some very general questions).
the Nested class (C ++ is typically say), inner class (usually JAVA statement) the biggest difference .Java C ++ classes and inner nested class is whether there is a reference pointing outwards . Specific visible http: //www.frontfree.net/articles/services/view.asp?id=704&page=1
Note: Creating a static inner class object static inner classes (Inner Class) means that one does not need a external object 2 can not be accessed from a static object inside an external object class
distinction fourth, and & & &.
& is the bitwise operators && is a Boolean operator.
fifth difference, and the HashMap the Hashtable.
Map belong to the class interface, implements only keys mapped to a specific value.
The HashMap no classification or sorting which allows a plurality of keys and null null values.
The Hashtable the HashMap is similar, but not null and a null value it is also slower than the HashMap, because it is synchronous.
sixth, collection and collections of distinction.
collections is a java.util under the category, which includes various sets of static methods operation.
collection is under java.util Interface, it is the father of a set of interface structure.
seventh, when to use assert.
assertion is a Boolean expression that contains the statement, assuming that the expression is true in the implementation of this statement. If the expression evaluates to false, then reports a system for debugging purposes AssertionError that:.
assert (a> 0); // throws AssertionError IF AN a <= 0
assertion can have two forms:
assert Expression1;
assert Expression1: Expression2;
Expression1 should always produce a Boolean value.
Expression2 can arrive at a value of any expression. this value is used to generate the display more String debugging information.
assertion in default The next condition is disabled To enable assertions at compile time, you need to use source 1.4 mark:
javac -source 1.4 Test.java
To enable assertions at runtime, use -enableassertions or -ea mark.
To choose to disable assertions at runtime, use the -da or -disableassertions mark.
To enable assertions system classes, use - or esa -dsa marker may also be enabled or disabled on the basis of assertions of the package.
it can be placed at any position asserted expected under normal circumstances would not arrive on the assertion may be used to validate the parameters passed to the private methods, however, do not assert it should be used to validate the parameters passed to public methods, because regardless of whether the assertion is enabled, the public methods to check its parameters. However, both in the public method can also be in non-public method postcondition assertion test in use. in addition , the assertion should not in any way alter the program state.
eighth, GC What is? Why should there be GC? (basic).
GC is a garbage collector .Java programmer need not worry about memory management, because the garbage collector will automatically be managed to request garbage collection, you can call one of the following methods:
System.gc ()
. Runtime.getRuntime () gc ()
ninth, String s = new String ( " xyz"); created Several String Object?
Two objects, one is "xyx", a reference point is the object s "xyx" the.
Tenth, Math.round (11.5) is equal to how much? Math.round (-11.5) equals how much?
The Math. round (11.5) return (long) 12, Math.round (-11.5 ) return (long) -11;
Eleventh, short s1 = 1; s1 = s1 + 1; there is nothing wrong with short s1 = 1;? S1 + = 1; there anything wrong?
Short s1 = 1; s1 = s1 + 1; there is wrong, s1 is short type, s1 + 1 is an int, not explicitly into short type may be modified to s1 = (short) (s1 + 1) .short s1 = 1;. s1 + = 1 correctly.
XII, SLEEP () and wait () What is the difference? engage threads favorite
sleep () method is the method thread to stop for some time after the expiration of the sleep interval, the thread may not immediately resume execution. this is because at that time, other threads may running and is not scheduled to give up, unless (a) "wake up" the thread with a higher priority
(b) running thread for other reasons obstruction.
when the wait () is thread-interaction, if the thread a synchronization object x sends a wait () call, the thread will be suspended, the object was transferred into a wait state, or wait until it is time to wake up.
XIII, Java has no GOTO?
Goto? the Java reserved word, now no use in java.
XIV, the array has no length () this method? String has no length () this method?
arrays are not length () this method has length Property.
String Yes Yes length () this method.
15, Overload and Override difference method .Overloaded the possibility of changing the type of return value?
Overriding rewrite and overloading Overloading Java methods are different manifestations of polymorphism. Overriding rewrite polymorphism of performance between a parent class and subclass, overloading Overloading is a polymorphism in a class performance. If the definition of a category of methods and his father have the same name and parameters, we say that the method is rewritten (Overriding). Object subclasses using this method, you call the definition in the subclass of it , the parent class is defined as being "blocked" in. If a plurality of the same name defined in a class method, or they have different number of parameters or different parameter types, the so called overlay method (Overloading) method .Overloaded is possible to change the type of the return value.
16, Set elements are not repeated, then the method used to distinguish whether or not repeat it? is == or equals ()? they have what difference?
Set in the elements is not repeated, then use the iterator () method to distinguish whether or not repeat .equals () is the interpretation of two Set whether equal.
equals () and == means to determine whether the value of a reference point to the same object equals () is covered in the class, is that when two separate Content and type of the object of match, then return true value.
XVII, give me one of your most often see runtime exception.
ArithmeticException, ArrayStoreException, a BufferOverflowException is, a BufferUnderflowException is, CannotRedoException, CannotUndoException, ClassCastException, CMMException, a ConcurrentModificationException, DOMException, EmptyStackException, IllegalArgumentException, IllegalMonitorStateException, IllegalPathStateException, IllegalStateException,
ImagingOpException, IndexOutOfBoundsException, MissingResourceException, NegativeArraySizeException, NoSuchElementException, NullPointerException, ProfileDataException, ProviderException, RasterFormatException, SecurityException, SystemException, UndeclaredThrowableException, UnmodifiableSetException, UnsupportedOperationException
eighteenth, error and exception What is the difference?
error represents a serious problem in the case of recovery is not impossible, but very difficult. For example, memory overflow. program can not be expected to handle such a situation .
exception that a design or implementation issues. In other words, it means that if run properly. does not happen from the
nineteenth, List, Set, Map whether inherited from the Collection interface?
List, the Set Map is not the
second ten, abstract class and interface What is the difference?
there is a statement of the method to achieve it without the class is called abstract class (abstract class), which is used to create a manifestation of some basic behavior of the class, and as such a statement , but it can not be achieved in the case of the class class. abstract class instance can not be created, however can create a variable whose type is an abstract class and points it to a specific sub-class. constructor is not abstract or subclass of the abstract class provides static methods .Abstract implement all abstract methods of their parent class, it is an abstract class. Instead, implement this method in the subclass. know the behavior of other classes can implement these in the class method.
Interface (interface) is a variant of an abstract class in the interface, all methods are abstract. multiple inheritance can be obtained by implementing such an interface. All methods interface Is abstract, there is no similarity in a procedure interface can only define static final member variables. Implementation of the interface and subclass can not inherit behavior from the interface definition in addition to the implementation class. When the class implements a special interface, which defines the (coming procedure of giving) all such interface. then, a method that may be implemented on any call interface of the object class interface. as an abstract class, which allows the use of interface name as the reference variable type usually dynamic the series will take effect. reference can be converted to interface type, or conversion from interface type, instanceof operator can be used to determine whether an object class implements the interface.
XXI, abstract whether the method is also static, it simultaneously is native, it also is synchronized?
can not
The twenty-second, the interface is inheritable interfaces? Are abstract class can implement (implements) the interface? Abstract class is inheritable entity class (concrete class)?
Interfaces can be inherited interface abstract class can implement (implements) interface, a class is abstract inheritable entity class, but only if the entity class must have explicit constructor.
Twenty-third, start a thread is run () or start ()?
start a thread that calls start () method, represented by the thread of virtual processor can run the state, which means that it can schedule and execute by the JVM. this does not mean that the thread will run immediately .run () method can produce signs must quit to stop a thread.
twenty-fourth, whether constructor constructor can be override?
constructor constructor can not be inherited and can not rewrite Overriding, but can be overridden overloading.
twenty-fifth, can inherit String class?
String class is final class can not inherit it.
the first XXVI, when a thread enters a synchronized method of an object, other threads can access this object other methods?
No, an object of a synchronized method Can be accessed by a thread.
Twenty-seventh, try {} there is a return statement, then the code will finally followed after the try {} Lane will not be executed, when executed, before or after return ?
will be executed, executed before return.
28 of the programming problem: 2 the most efficient method calculated by multiplying 8 equal to a few?
there are a C programmer background especially like to ask this question.
2 << 3
29, the two objects the same value (x.equals (y) == true) , but may have different hash code, this sentence right?
No, have the same hash code.
Thirtieth, when after an object is passed as a parameter to a method, this method can change the properties of this object, and returns the result of changes in, then in the end is passed by reference or value transfer here?
it is passed by value .Java programming language only passed by value parameters. when a method is passed to the object instance as a parameter, the value of the parameter is the object of the content object may be changed in the method is called, but the object reference is never changed.
the first thirty-one, swtich on whether the role of the byte, whether acting on the long, whether acting on String?
switch (expr1) in, expr1 is an integer expression. So the switch and case statements should be delivered to int, short, char or byte.long, string can not act on the swtich.
thirty-second, the programming problem: to write out a Singleton.
Singleton pattern major role is to ensure that a Java application, a class of only one instance of existence.
general Singl eton mode usually there are several forms:
The first form: define a class, its constructor is private, it has a private static class variable in the case of initialization, then, through a public method of getInstance obtaining a reference to it, which in turn calls a method.
public class the Singleton {
Private the Singleton () {}
// define themselves in their own internal one instance, is not it strange?
// Note that this is private for internal calls
private static Singleton instance = new new Singleton ();
// here provides a static method for external access to the class, direct access to
public static the Singleton the getInstance () {
return instance;
}
}
the second form:
public class the Singleton {
Private static instance the Singleton = null;
public static the synchronized the Singleton the getInstance () {
// this method is an improvement over the above, do not generate each subject, only the first
generation // instance when used, improve the efficiency!
IF (instance == null)
instance the Singleton new new = ();
return instance;}
}
other forms:
define a class, it the constructor is private, all the static method.
first is generally considered to be more safer form

Reproduced in: https: //www.cnblogs.com/521taobao/archive/2012/03/17/2402450.html

Guess you like

Origin blog.csdn.net/weixin_33894992/article/details/93355433