1. Scope public,private,protected, and not write the difference.
A: The scope is different:
Scope Current class same package descendant class other package
public √ √ √ √
protected √ √ √ x
friendly √ √ x x
Private√xxx
What's the difference between 2.& and &&?
Answer:& is a bitwise operator, which means that bitwise operations,&& are logical operators that identify the logic and
the difference between 3.Collection and collections.
A: Collection is the superior interface of the collection class, and the interfaces that inherit from it are mainly set and list,
Collections is a helper class for collection classes that provides a series of static methods for searching, sorting, and threading security of various collections.
4.String s=new String ("xyz"); several objects were created.
Answer: Two, one is a character object, one is a character object reference object.
5.math.round (11.5) equals how much. Math.Round (-11.5) equals how much.
Answer: The parameter plus 0.5 takes the nearest long integer, so Math.Round (11.5) ==12,math.round (-11.5) =-11;
6.short s1=1;s1=s1+1; what's wrong? Short s1=1;s1+=1; what's wrong?
A: The short s1=1,s1=s1+1;s1+1 result is int, and the S1 need to be forced into the short type;
7. Array has no length () this method. String has no length () this method.
A: The array has no length () This method, there is length this property. String has the length () method.
8. Common Runtime Execption (run-time error)
A : common run-time anomalies are as follows these 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, SystemException, Undeclaredthrowableexception, Unmodifiablesetexception, Unsupportedoperationexception.
What is the difference between 9.error and execption?
A: Error indicates that recovery is not impossible, but it is a serious problem, such as a memory overflow, that is difficult to recover. It is impossible to expect the procedure to handle such a situation.
Execption represents a design or implementation problem. This will not happen if the program is running normally.
10.list,set Whether the map inherits from collection.
A: List and set are, map is not
11. Whether the constructor constructor can be override.
A: constructor constructor cannot be inherited, and therefore cannot be overriding, but can be overloaded overloading.
12. Whether the string class can be inherited.
A: The string class is the final class and therefore cannot be inherited.
13.try{} There is a return statement, so the code immediately following this try in the finally{} will not be executed, when it is executed, before or after it.
A: It will be executed before return.
14. The most effective way to calculate 2 times 8 is equal to a few.
A: 2<<3 the left shift several times 2 of the square.
Whether 15.swtich can function on a byte, whether it can function on a long, whether it can function on a string.
A: jdk1.7 before long,string can not function in swtich,jdk1.7 after Sting could
The difference between 16.ArrayList and Vector, HashMap and Hashtable.
Answer: ArrayList and Vector:
Vectors are thread-safe, synchronized, and ArrayList are not; when growth is needed, the vector defaults to one-fold growth, while ArrayList is half the original.
HashMap and Hashtable:
HashMap is an implementation of the introduction of the map interface that allows null key,null value, thread insecurity, but high efficiency
Hashtale thread synchronization, which is thread safe, does not allow null Key,null value, but does not have hashmap high efficiency
17.char variable can be stored in a Chinese character. Why.
A: Yes, because Java is encoded in Unicode, one char occupies 16 bytes, one Chinese occupies two bytes, so it is OK.
type 18.float float f=3.4 is correct.
Answer: The accuracy is inaccurate, float f=3.4f.
the difference between 19.Sring and StringBuffer.
A: The length of a string is immutable, and the length of the StringBuffer is variable. If you want to manipulate the contents of a string frequently, especially if the content is to be modified, use StringBuffer, or use the StringBuffer ToString () method if you need a string last.
20.String is the most basic type of data.
Answer: Basic data types include Byte,int,char,long,float,double,boolean and short.
Stiring belong to the final class.
What is the difference between 21.int and Interger?
A: int is the original data type of Java, Interger is the encapsulation class of Java for Int.
the difference between the 22.final,finally,finalize.
A: final--modifier (keyword) If a class is declared final, it means that it cannot derive a new subclass and cannot be inherited as a parent class. Declaring a variable or method final can guarantee that they will not be changed in use. A variable declared as final must be given an initial value in the declaration and be read intelligently in a future reference, and cannot be modified. The method that is declared final is also smart to use and cannot be overloaded.
Finally: Again exception handling is to provide a finally block to perform any cleanup operations. If an exception is thrown, the matching catch statement executes, and then the control enters the finally block.
Finzlize: Method name. Java technology allows you to use the Finzlize () method to do the necessary cleanup before the garbage collector clears the object out of memory. This method is invoked by the garbage collector in determining that the object is not referenced by this object. It is defined in the object class. So all of the classes inherit from it. Subclasses override the Finalize () method to adjust system resources or perform other cleanup work. The Finalize () method is invoked on this object before the garbage collector deletes the object.
23. What are the aspects of object-oriented features
For:
1. Abstract:
Abstraction is to ignore those aspects of a topic that are not relevant to the current goal in order to give full attention to the aspects associated with the current goal. Abstraction is not about trying to understand all the problems, but just choosing a part of it and not having some details for the moment. Abstract includes two aspects, one is process abstraction, but data abstraction.
2. Inheritance:
Inheritance is a hierarchical model of join classes, and the reuse of word order and encouragement classes provides a way to articulate common features. A new class of objects can derive from an existing class, which inherits the class. 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 (the parent Class) of the new class. Derived classes can inherit methods and instance variables from its base class, and classes can modify or add new methods to make them more suitable for special requirements
3. Package:
Encapsulation is the process of enclosing data and processes, access to data only through defined interfaces. Object-oriented computing begins with the basic concept that the real world can be depicted as a series of fully autonomous, encapsulated objects that access other objects through a protected interface.
4. Polymorphism:
Polymorphism refers to allowing objects of different classes to respond to the same message. Polymorphism consists of parametric polymorphism and inclusion polymorphism. Polymorphism language has the advantages of flexibility, abstraction, behavior sharing and code sharing, and it is a good solution to the problem of the same name for happy application functions.
24. Whether or not a call to a sattic method can be emitted from within a static method.
A: No, if you have a method () that contains objects, you cannot guarantee that the object is initialized.
25. When writing the Clone () method, there is usually a piece of code.
A: Super (). Clone