Classic problem big collection
1, scope public, private, protected, as well as if you do not write
A: The difference is as follows:
Scope current class with the same package children, other packages
PUBLIC √ √ √ √
Protected √ √ × ×
Friendly √ √ × ×
PRIVATE × × × ×
Do not write, default is Friendly
2, the difference between ArrayList and Vector, the difference between Hashmap and HashTable
A: ARRAYLIST and VECTOR are mainly from two aspects.
I. Synchronization: Vector is a thread safe, that is to say is synchronized, and ArrayList is unsafe line programs, not synchronous.
II. Data growth: When you need to grow, Vector default growth is the original one, but ArrayList is half.
It is mainly from three aspects on Hashmap and HashTable.
I. Historical reasons: HashTable is an implementation of the MAP interface introduced by the Java 1.2 based on the old Dictionary class.
II. Synchronization: Hashtable is a thread safe, that is, HashMap is unsafe, not synchronous
Three. Values: Only HashMap allows you to take null values as a key or value of a table
3, can the CHAR type variable can be stored a Chinese Chinese character? Why?
A: It is possible to define a Chinese, because Java is encoded in Unicode, a char accounts for 16 bytes, so a Chinese is no problem.
4, many threads have several implementation methods, what is it? Synchronize several implementation methods, what is it?
A: Multi-thread has two implementation methods, which are inheriting the Thread class and implementing Runnable interface.
There are two implementations in synchronization, Synchronized, Wait and Notify, respectively.
5. Inheriting the order of execution of the class is generally a choice question, ask you what will print out?
A: Parent class:
Package test;
Public Class FatherClass
{
Public FatherClass ()
{
System.out.println ("FatherClass Create");
}
}
Subclass:
Package test;
Import Test.fatherClass;
Public Class ChildClass Extends FatherClass
{
Public ChildClass ()
{
System.out.println ("ChildClass Create");
}
Public static void main (string [] args)
{
Fatherclass fc = new fatherclass ();
Childclass cc = new childclass ();
}
}
Output results:
C: /> java test.childclass
FatherClass Create
FatherClass Create
Childclass Create
Author Blog:
http://blog.9cbs.net/zorro09/