http://blog.9cbs.net/doodoofish/archive/2004/07/12/39841.aspx
-------------------------------------------------- -------------------------------------------
Looking for a job to interview, there is an interview with a way to deal with the interview. Some of the following topics come from me and my friend's painful interview experience, including these issues include IBM, E * Trade, Siebel, Motorola, Sun, and other size companies. There is no reason for the interview, and it is unreasonable, and it is out of practice. Have written on paper, there is a face test you, and there is also a question in the phone, giving you the estimate of the IDE, so you can buy a lottery ticket, maybe it is specified. So if you have finished reading this article, please don't complain that these problems can be solved with IDE. You have to answer these questions in any case, if you have one or two questions in the interview, you will be able to be rejected. Of course, these are the basic questions of Java. Most people who have interviews will not ask you how Hibernate has more advanced, Eclipse's three components, or Command Design Pattern, they are all aged, and the favorite is basics. . Don't underestimate these foundations, my friend is first-class, and the results are planted under the basis of basics, and the high salary is not worthy. It's better to say less nonsense and start the topic. First, talk about the difference between Final, Finally, Finalize. It is most often asked. Second, anonymous inner class (anonymous internal class) can be extends other classes, can IMPLEMENTS INTERFACE (interface)? Third, Static Nested Class and Inner Class are different, the more better, The interview question is very general). The difference between fourth, & and &&. This is very small. Fifth, the difference between HashMap and HashTable. I often ask. Sixth, the difference between Collection and Collectes. Don't say one is a single one is a plural. Seventh, when do you use Assert. API-level technicians may ask this. Eighth, what is GC? Why have a GC? Foundation. Ninth, string s = new string ("xyz"); created a few String Object? Tenth, Math.Round (11.5) is equal to how much? Math.Round (-11.5) is equal? Eleventh, Short S1 = 1; S1 = S1 1; What is wrong? SHORT S1 = 1; S1 = 1; What is wrong? The interview question is very variable, and it is necessary to prepare for abuse. 12. What is the difference between SLEEP () and WAIT ()? Making the favorite of threads. Thirteenth, there is no goto? It's a very thirteen problem. If you ask this question, I advise you still in this company. Fourteenth, there is a length () method in the array? String has a length () method? The difference between the fifteenth, overload and override. Can OVERLOADED methods change the type of return value? Often asked. Tenth, the elements in the set cannot be repeated, then what method is used to distinguish whether it is repeated? Is it == or equals ()? What is the difference? Seventest, give me one of you most often Runtime Exception. If you can't answer this, the interview will think that you don't have practical programming experience. Eighteenth, what is the difference between ERROR and EXCEPTION? Are the nineteenth, List, SET, MAP inherit from a Collection interface? Ten, what is the difference between Abstract Class and Interface?
Second Eleventh, whether the method of Abstract can be Static, whether it can be Native at the same time, is it possible to be SYNCHRONIZED? 22, whether the interface can inherit the interface? Does the abstract class can implement (IMPLEMENTS) interface? Whether the abstract class is Can I inherit the physical class (Concrete Class)? On the second thirteenth, start a thread is Run () or start ()? 24. Is the constructor can be override? Second fifteenth, can you inherit the String class? 26. After a thread enters an SYNCHRONIZED method of an object, does other threads can enter this object? Second 17, there is a return statement in TRY {}, then follow this TRY The code in finally {} will not be executed, when is executed, before returbium or after? Twon 11, program: 2 multiplied 8 equal to a few? There is a C background Programmers especially like to ask this question. The second nine, the two object values are the same (x.equals (y) == true), but there is a different Hash code, this sentence is not right? Thirty, when an object is passed as a parameter to After a method, this method can change the properties of this object and return the resulting result, then here is the value delivery or reference delivery? 31. If SWTICH can function on Byte, whether it can act on Long Is it possible to play on String? 32, programming questions: write a Singleton. Below is the answer
First, talk about the difference between Final, Finally, Finalize. Final-modifier (keyword) If a class is declared as Final, it means that it is no longer a new subclass and cannot be inherited as a parent class. Therefore, a class cannot be declared as Abstract, and it is declared as final. Declaring variables or methods to Final, ensuring that they are not changed in use. Variables that are declared for final must give initial values at the time of declaration, and only read in future references, cannot be modified. The method that is declared for Final is also only available, and the Finally block is provided when it is not overloaded for Finally-re-abnormal processing, and any clear operation is performed. If you throw an exception, then the matching catch clause will execute, and then the control will enter the Finally block (if any). Finalize-method name. Java technology allows the use of the Finalize () method to make the object to clear the object from the memory before making the necessary cleanup work. This method is called by the garbage collector when it is determined that this object is not referenced. It is defined in the Object class, so all classes have inherited it. Subclasses override the Finalize () method to organize system resources or perform other cleanup work. The Finalize () method is called by this object before the garbage collector deletes the object. Second, anonymous inner class (anonymous internal class) can be extends other classes, can IMplements INTERFACE (interface)? Anonymous internal class is an internal class without name. You cannot extends other classes, but an internal class can be implemented as an interface, and is implemented by another internal class. Third, Static Nested Class and Inner Class are different, the more you say, the better (the interview question is very general). NESTED CLASS (generally C statement), Inner Class (typically Java said). The maximum difference between Java internal classes and C nested classes is whether there is a reference to the outside. Specific visible http://www.frontfree.net/Articles/services/view.asp?id=704&page=1 Note: Static Inner Class means 1 Create a Static internal class, no need for an external class Objects, 2 cannot access an external class object fourth, & &&&&, from an object of a Static internal class. & Is a bit operator. && is the Boolean logic operator. Fifth, the difference between HashMap and HashTable. Both of the MAP interface, implement the unique key to a specific value. The HashMap class is not classified or sorted. It allows a NULL key and multiple NULL values. Hashtable is similar to HashMap, but NULL keys and NULL values are not allowed. It is also slower than HashMap because it is synchronized. Sixth, the difference between Collection and Collectes. Collections is a class under java.util that contains a variety of static methods related to the collection. Collection is an interface under java.util, which is a parent interface of a variety of collections. Seventh, when do you use Assert. As an assertion, a statement containing Boolean expression, assuming that the expression is TRUE when this statement is executed. If the expression is calculated as false, then the system will report an AssertionError.
It is used to debug purposes: assert (a> 0); // throws an assertionError if a <= 0 assertion can have two forms: assert expression1; assert expression1: expness2; Expression1 should always generate a Boolean value. Expression2 can be any expression that draws a value. This value is used to generate a String message displaying more debugging information. As default, it is disabled by default. To enable assertions while compiling, you need to use Source 1.4 tag: Javac -Source 1.4 Test.java To enable assertion at runtime, you can use the -enableassertions or -ea tag. To disable assertion at runtime, you can use the -DA or the -disableAssertions tag. To enable assertion in the system class, you can use the -esa or -dsa tag. You can also enable or disable assertions on the basis of the package. An assertion can be placed at any position that is not reached in normal conditions. As an assertation can be used to verify the parameters passing to the private method. However, assertions should not be used to verify parameters passing to the public method, as there is no matter whether it is enabled, the public method must check its parameters. However, it can be used in public methods or in a non-public method to use asserts to test the post condition. In addition, the assertion should not change the status of the program in any way. Eighth, what is GC? Why have a GC? (Foundation). GC is a garbage collector. Java programmers don't have to worry about memory management because the garbage collector will automatically manage. To request garbage collection, one of the following methods can be called: system.gc () runtime.Gcuntime (). Gc () ninth, string s = new string ("xyz"); create a few String Object? Two Object, one is "XYX", one is a reference object S with "XYX". Tenth, Math.Round (11.5) is equal to how much? Math.Round (-11.5) is equal to? Math.Round (11.5) Return (long) 12, Math.Round (-11.5) Return (long) -11; tenth First, Short S1 = 1; S1 = S1 1; What is wrong? SHORT S1 = 1; S1 = 1; What is wrong? SHORT S1 = 1; S1 = S1 1; It is wrong, S1 is Short type, S1 1 is an INT type and cannot explicitly convert to a Short type. Can be modified to S1 = (Short) (S1 1). Short S1 = 1; S1 = 1 is correct. Chapter 12, SLEEP () and WAIT () What is the difference? The favorite SLEEP () method of the thread is to stop the thread to stop a period of time. After the SLEEP time interval is full, the thread does not necessarily resume it immediately. This is because at that moment, other threads may be running and are not scheduled to give up execution, unless (a) "wake up" thread has higher priority (b) that is running because of other reasons. Wait () is a thread interaction if the thread issues a wait () call, the thread is suspended, the object is adjusted to the waiting state until it is awake or waiting time. Thirteenth, there is a reserved word in Goto? Goto-Java, and now there is not used in Java.
Fourteenth, there is a length () method for arrays? String has a length () method? The array does not have Length () method, with the properties of the length. String has a length () method. Fifteenth, the difference between overload and override. OverLoaded method can change the type of return value? Override Overriding and overload overloading is a different manifestation of Java polymorphism. Overriding Overriding is a manifestation of polymorphism between parent class and subclasses, and overloading overloading is a manifestation in a class. If a method is defined in the subclass with the same name and parameters as its parent class, we say that this method is overriddled. When the subject of subclass uses this method, the definition of the subclass will be called. For it, the definition in the parent class is like "shielded". If a plurality of the same names are defined in a class, they or have different parameters or different parameter types, called overloading. The way OVERLOADED is to change the type of return value. The elements in the SET are not repeated, then what method is used to distinguish whether it is repeated? Is it == or equals ()? What is the difference between them? The elements in Set cannot be repeated, then use Iterator () Method to distinguish whether it is repeated. Equals () is the judgment of whether two SETs are equal. Equals () and == Method Decide whether the reference value points to the same object Equals () override in the class, which is the true value of the content and type of two separate objects. Seventest, give me a Runtime Exception you most often. ArithmeticException, ArrayStoreException, BufferOverflowException, BufferUnderflowException, CannotRedoException, CannotUndoException, ClassCastException, CMMException, ConcurrentModificationException, DOMException, EmptyStackException, IllegalArgumentException, IllegalMonitorStateException, IllegalPathStateException, IllegalStateException, ImagingOpException, IndexOutOfBoundsException, MissingResourceException, NegativeArraySizeException, NoSuchElementException, NullPointerException, ProfileDataException, ProviderException, RasterFORMatException, SecurityException, What is the difference between systemException, undeclaredthrowableException, unmodifiablesetexception, unsupportedopertyXception, error, and exception? Error indicates a serious problem that recovery is not impossible but very difficult. For example, memory is overflow. It is impossible to expect the program to handle this situation. Exception represents a design or implementation problem. That is, it means that if the program runs normally, it will never occur.
Ninth, List, SET, MAP inherits from the Collection interface? List, SET is Map is not the twentieth, what is the difference between Abstract Class and Interface? Declaration method does not implement its class called abstract class (Abstract Class, it is used to create a class that reflects certain basic behavior and declares the class for this class, but cannot implement the class in this class. An instance of the Abstract class cannot be created. However, you can create a variable, which is an abstract class and let it point to an instance of the specific subclass. There is no abstract constructor or abstract static method. Subclasses of the Abstract class provide implementation for all abstraction methods in their parent class, otherwise they are also abstract classes. Instead, this method is implemented in the subclass. Other classes that know their behavior can be implemented in the class. Interface is a variant of an abstract class. In the interface, all methods are abstract. Multiple inheritance can be obtained by achieving such an interface. All methods in the interface are abstract, no probabilities. The interface can only define the Static Final member variable. The implementation of the interface is similar to the subclass, except that the implementation class cannot inherit behavior from the interface definition. When the class implements a special interface, it defines the method of all such an interface (that is, the program body is given). Then, it can call the interface to call the interface on any object of the class of the interface. Because there is an abstract class, it allows the interface name as the type of reference variable. The usual dynamic cable will take effect. The reference can be converted to an interface type or a slave interface type, and the InstanceOf operator can be used to determine whether an object is implemented. Second Eleventh, whether the method of abstract can be static at the same time, whether it is native at the same time, whether it can be SYNCHRONIZED? Can't the twenty-two, whether the interface can inherit the interface? Does the abstract class can implement (imports) interface? Abstraction Whether the class can inherit the physical class (Concrete Class)? The interface can inherit the interface. Abstract classes can be implemented, whether abstract classes can inherit physical classes, but provided that the entity class must have a clear constructor. Second, the thirteenth, starting a thread is Run () or start ()? Starting a thread is calling the start () method so that the virtual processor represented by the thread is running, which means it can be scheduled by JVM and carried out. This doesn't mean that the thread will run immediately. The Run () method can generate a flag that must be exited to stop a thread. Chapter 24. Whether the constructor can be can't be inherited by the Override® constructor constructor, so Overriding cannot be overridden, but Overloading can be overloaded. The second fifteenth, can you inherit the String class? The String class is not inherited by Final. Twentydays, when a thread enters an SYNCHRONIZED method of an object, other methods of other threads can enter this object? No, one Synchronized method of an object can only be accessed by one thread. 27. There is a Return statement in Try {}, so the code in finally {} after this try is not executed, when is executed, before returnome or after it will be executed, in Return Pre-execution. Chapter 28. Program: Two multiplier with the most efficient method is equal to a few? There are C backgrounds, special programs like to ask this question. 2 << 3 Twentins, two object values (x.equals (y) == true), but there are different Hash Code, this sentence is wrong? No, there is the same Hash Code.
Thirty, when an object is passed as a parameter to a method, this method can change the properties of this object, and can return the resulting result, then here is the value delivery or reference delivery? Is a value transfer. The Java programming language is only passed by the value. When an object instance is transmitted to the method as a parameter, the value of the parameter is a reference to the object. The content of the object can be changed in the called method, but the reference to the object will never change. Thirty-first, whether SWTICH can act on Byte, whether it can act on long, can it work on String? Switch (expr1), expr1 is an integer expression. Therefore, the parameters passing to the Switch and the CASE statement should be int, short, char or byte. Long, String can not work on SWTICH. Article 32. Program: Write a Singleton. The main role of the Singleton mode is to ensure that only one example exists in a Java application. General Singleton mode usually has several forms: the first form: Define a class, its constructor is private, it has a state of static private, instantoneation, and GetInstance through a public Method Get a reference to it, then calls it. Public class singleton {private singleton ()} // define one instance in itself, is it very strange? / Note This is private only for internal calling private static singleton instance = new singleton (); // here provides a static method for external access to this Class, you can directly access public static singleton getInstance () {return instance;}} The second form: public class singleleton {private static singleleton instance = null; public static synchronized singleton getInstance () {// This method is improved above, do not have to generate an object each time, only the first time // Generate an instance and improve efficiency! IF (instance == null) instance = new start;}} Other forms: Define a class, its constructor is private, all methods are static. It is generally considered that the first form should be more secure Some HashTable and HashMap HashTable inherited from the Dictionary class, and HashMap is a real-time Map Interface of the Java 1.2 introduced HashMap allows NULL as a key or value of the entry, and HashTable is not allowed. That is, Hashmap removes the Hashtable's Contains method, changed to ContainSvalue and Containskey. Because the Contains method is easy to cause misunderstandings. The biggest difference is that the HashTable method is Synchronize, and HashMap is not, when accessed HashTable, does not need to be synchronized for its method, and HashMap must provide external synchronization.