Several frequently asked questions

Source: Internet
Author: User
Tags switches try catch

is in the cattle on the Internet, a large God on the surface to see, the great God summed up the question, I write the answer for easy access, there is no wrong please leave a message, change at any time.

J2SE Foundation
1. The size of the nine basic data types, as well as their encapsulation class.

Basic Type size/byte Encapsulation Class
Byte 1 Byte
Short 2 Short
Char 2 Character
Int 4 Integer
Float 4 Float
Double 8 Double
Long 8 Long
Boolean - Boolean

2. Can switch use string to make arguments?
Not before Jdk7, Jdk7 can be.
3. The difference between equals and = =.
* = = is an operator.
* Equals is the method of the string object, which can be. (dot) out.
For a string object, the instantiated object can be stored in a different location, but the stored content is the same, at this point, if you want to compare the contents of storage, you should use equals.
4. What are the common methods of object?
Clone (), Equals (), Hashcode (), toString (), notify (), Notifyall (), Wait (), getclass () to be supplemented
5. Java Four kinds of references, weak strength soft virtual, used to the scene.
I don't know
6. The role of Hashcode.
Hashcode is used to identify whether 2 objects are equal and are used in conjunction with equals.
7. The difference between ArrayList, linkedlist and vectors.
One is the array list, and the other is the list of lists.
8. The difference between String, StringBuffer, and StringBuilder.
The array used to hold the character string is declared final, so it can only be assigned once and cannot be changed.
If you need to change multiple times, you need to use Stringbulider or stringbuffer, the difference is that StringBuffer is thread-safe.
9. Features and usage of MAP, Set, List, Queue, stack.
The difference between HashMap and Hashtable.
HashMap and Concurrenthashmap differences, hashmap of the underlying source code.
As can be seen from the Concurrenthashmap code, it introduces a concept of "segmented lock", which can be understood as dividing a large map into n small Hashtable, according to Key.hashcode () to decide which Hashtable to put the key.
The difference between TreeMap, HashMap and Lindedhashmap.
Collection package structure, and the difference between collections.
Do you have return,finally in Try Catch finally,try?
If there is an exception in the try and there is a return in the try, the normal execution order is Try--catch-finally-return
In short, finally always execute!
Excption and error packet structure. Oom What situation you have encountered, SOF what you have encountered.
Three features and meanings of Java-oriented objects.
Encapsulation, inheritance, polymorphism
The meaning of override and overload to distinguish.
When overloaded, the method name is the same, but the parameter type and number are different, and the return value type can be the same or different. The return type cannot be used as a distinguishing criterion for overloaded functions.
When overridden, overwrites the previous method body and executes the newly written method body.
The difference between interface and the abstract class.
Abstract class represents an inheritance relationship in Java, and a class can only use one inheritance relationship at a time. However, a class can implement multiple interface.
You can have your own data members in the abstract class, or you can have non-abstarct methods.
Abstract classes can have non-abstract methods. There is no implementation method in the interface.
Pending additions
The difference between static class and non static class.
The implementation principle of Java polymorphism.
I don't know
21. Two ways to implement Multithreading: Thread and runable.
Thread is inherited from the thread class, runnable is the implementation of the Runnable interface, runnable can reuse code, better.
22. Thread synchronization method: Sychronized, lock, Reentrantlock and so on.
23. Level of Lock: Method Lock, Object lock, Class lock.
24. Write out the producer consumer model.
Threadlocal's design philosophy and role.
ThreadPool usage and advantages.
First: Reduce resource consumption. Reduce the consumption caused by thread creation and destruction by reusing the threads that have been created.
Second: Improve response speed. When a task arrives, the task can be executed immediately without waiting for the thread to be created.
Third: Improve the manageability of threads.
First, define a thread pool threadpoolexecutor, using executor to invoke runnable.
The other things in concurrent bag: Arrayblockingqueue, Countdownlatch and so on.
The difference between wait () and sleep ().
During the call to the sleep () method, the thread does not release the object lock.
When the Wait () method is called, the thread discards the object lock, enters the waiting lock pool waiting for the object, and the thread only enters the object lock pool when the Notify () method is called for this object.
The ratio of foreach to normal for loop efficiency.
The For loop efficiency is higher than foreach when the fixed length or length does not require calculation.
It is convenient to use foreach in the uncertain length, or when the calculation length has a performance loss.
Java io and NiO.
31. The reflection acts on the principle.
32. Generic common features, list can be converted to list.
The upward transformation is safe.
33. Principles and features of several ways to parse xml: DOM, SAX, pull.
Compare Java with C + +.
Java1.7 and 1.8 new features.
36. Design mode: Single case, factory, adapter, responsibility chain, observer, etc.
Use of the Notoginseng. Jni.

JVM
1. Memory models and partitions require detailed information about what to put in each area. The
is divided into stacks, heaps, method areas, method areas where the contents and static members of the. class file and type data are stored, the stack holds references, and the heap holds the instantiated objects.
2. The partition inside the heap: Eden,survival from to, the old age, the respective characteristics.
3. Object creation method, object memory allocation, object access location.
Virtual opportunity to the New keyword, first go to the constant pool to find there is no symbolic reference to this class, and check whether the referenced class has been loaded, parsed, and initialized, if not the class will first execute the loading process, after passing the check, the virtual machine allocates memory for the new object. The
Access location includes handle access and direct pointer access.
4. Two ways to determine GC: reference count and reference chain.
5. GC Three methods of collection: the principle and characteristics of labeling, labeling, and copying algorithms, and where to use them, if you want to optimize the collection method, what are the ideas?
6. What are GC collectors? Features of the CMS collector with the G1 collector. When did the
7. Minor GC and full GC occur?
8. Several commonly used memory debugging tools: Jmap, Jstack, Jconsole. The
9. Class loads five processes: load, validate, prepare, parse, initialize.
10. Parental delegation Model: Bootstrap ClassLoader, Extension ClassLoader, Applicationclassloader.
11. Dispatch: Static allocation and dynamic dispatch.

Operating system
1. The difference between a process and a thread.
A. Address space and other resources: processes are independent of each other and are shared among threads of the same process. Threads within a process are not visible in other processes.
B. Communication: interprocess communication IPC, where threads can directly read and write process data segments (such as global variables) for communication-requiring process synchronization and mutex support to ensure data consistency.
C. Scheduling and switching: Thread context switches are much faster than process context switches.
D. In a multithreaded OS, a process is not an executable entity.
How resources are shared between threads: 1 encapsulate the data to be shared into another object, manipulate the object
2 runnable as an inner class, and define the member variables to be shared in the external class.
2. The necessary condition of the deadlock, how to deal with the deadlock.
If every process in a process collection waits for an event that can only be raised by another process in the collection, including himself, this is a deadlock.
Four prerequisites for deadlock
Mutex condition (Mutual exclusion): A resource cannot be shared and can only be used by one process.
Request and hold condition (holds and wait): a process that has received a resource can request a new resource again.
Non-deprivation condition (no pre-emption): The allocated resources cannot be forcibly stripped from the corresponding process.
Cyclic wait condition (Circular wait): Several processes in the system make up loops in which each process waits for resources that are being consumed by neighboring processes.
1. Ignore the problem. For example, the ostrich algorithm, the algorithm can be applied in the case of very few deadlocks occur. Why is called the ostrich algorithm, because the legend of the ostrich saw the danger of burying his head under the ground, perhaps the ostrich feel that there is no danger to see it. It's kind of like deceiving.
2. Detect deadlocks and restore.
3. Carefully allocate resources dynamically to avoid deadlocks.
4. Prevent deadlocks by breaking one of the four necessary conditions of deadlock.
3. Window Memory Management method: Segment storage, page storage, Segment page storage.
4. Several states of the process.
5. IPC several communication methods.
6. What is virtual memory.
7. The difference between a virtual address, a logical address, a linear address, and a physical address.

TCP/IP
1. The structure and function of the OSI and TCP/IP layers, and what are the protocols.
2. The difference between TCP and UDP.
TCP UDP
is connected to a connection-oriented non-connected
transport reliability unreliable
application transferring large amounts of data small amounts of data
slow fast
3. TCP message structure.
4. TCP Three handshake and four wave waving process, each state name and meaning, the role of timewait.
5. TCP Congestion control.
6. TCP sliding window with fallback N-pin protocol.
7. The message structure of HTTP.
8. The status code meaning of HTTP.
9. Several types of Http request.
The difference between Http1.1 and Http1.0
11. How HTTP handles long connections.
The cookie and the session Act on the principle.
13. The whole process of accessing a webpage on a computer is: DNS, HTTP, TCP, OSPF, IP, ARP. The entire process of the
. Ping. What the ICMP message is. The
C/S mode uses socket communication, several key functions.
. IP address classification.
17. The router differs from the switch.

Data structure and algorithms
1. Linked lists and arrays.
2. Queue and Stack, out of stack and into the stack.
3. Deleting, inserting, and reversing the linked list.
4. String manipulation.
5. The hash function of the hash table, what are the conflict resolution methods.
6. Various sorts: bubbling, selection, inserting, Hill, merge, Quick row, heap row, bucket row, cardinal principle, average time complexity, worst time complexity, space complexity, stability.
7. The partition function and the merge function of the fast row.
8. Improvements to bubbles and quick rows.
9. Two points to find, with the variant of the binary search.
10. Two fork tree, B + Tree, AVL tree, red black tree, Huffman tree.
11. Follow-up traversal of the two fork tree: recursive and non-recursive notation, sequence traversal algorithm.
12. Diagram of the BFS and DFS algorithm, the minimum spanning tree prim algorithm and the shortest path Dijkstra algorithm.
KMP algorithm.
14. Permutation combination problem.
15. Dynamic programming, greedy algorithm, divide and conquer algorithm. (not usually asked)
16. Big Data Processing: Similar to 1 billion data to find the largest number of 1000 ... Wait a minute

Android
1. Activity and fragment life cycle.
2. Acitivty's four-medium start mode and features.
1. Standard mode (default)
The activity that we create directly is the activity of this mode, the activity of this mode is characterized by: as soon as you create an activity instance, once the activity is activated, a newly created instance is added to the task stack. Exiting the activity destroys the instance in the task stack.

    1. Singletop mode
      This mode takes into account whether the activity instance currently being activated is at the top of the stack in the task stack, and if it is at the top of the stack without recreating the new instance, the existing instance will be reused or a new instance will be created in the task stack.

    2. Singletask mode
      If there is an activity instance of the pattern in the task stack, the activity instance above that instance in the stack is removed, and the activity is reused by invoking the Newinstance () method of the instance, so that the instance is in the top position of the stack. Otherwise, re-create a new activity instance.

    3. SingleInstance mode
      When the mode activity instance is created in the task stack, the activity is reused by invoking the Newinstance () method of the instance as long as the instance is still in the task stack, that is, whenever the activity of that type is activated. The same activity instance is used at this point, and it will be at the top of the stack of the task stack. This mode is typically used to load slower, less expensive activity that does not need to be recreated every time.

    4. Activity caching methods.
    5. Service life cycle, two startup methods, what is the difference.
      1 by StartService

      Service Experience OnCreate-OnStart
      Direct OnDestroy when StopService.
      If the caller exits directly without calling StopService, the service will run in the background. The next caller can get up and stopservice.

2 by Bindservice

The service will only run OnCreate, and this time the caller and the service are bound together

When the caller exits, Srevice calls onunbind->ondestroyed to be bound together. And this approach can also make

Callers (for example) invoke other methods on the service.
5. How to ensure that the service is not killed.
6. What is the difference between the two methods of registration for broadcasting?
1. Register in the Androidmanifest.xml file.
Benefit: Once the application is installed on the phone, broadcast receiver will start to take effect. Regardless of whether the application process is running, the broadcast event can be accepted by the application if it is enabled.
2. Registering the broadcast via code
Benefits: Once the application is stopped, the broadcast stops.
7. How to use intent, which data types can be passed.
8. How to use ContentProvider.
9. Thread, Asyctask, intentservice use scenes and features.
10. Five kinds of layouts: framelayout, LinearLayout, Absolutelayout, Relativelayout, Tablelayout respectively, and comparison of drawing efficiency.
A. Android data storage format.
Basic operation of SQLite.
The MVC pattern in Android.
The role of Merge and Viewstub.
What are the advantages and disadvantages of JSON?
16. What are the two types of animations, and what are the characteristics of each?
Handler, loop Message Queuing model, the role of each part.
18. How to opt out of terminating the app.
The difference between the. Asset directory and the Res directory.
How Android speeds up activity.
Android Memory Optimization method: ListView Optimization, timely shutdown of resources, picture cache and so on.
Application scenarios for weak references and soft references in Android.
The four attributes of bitmap, and the size of each of the attribute formations.
View and view group categories. Custom View procedure: Onmeasure (), OnLayout (), OnDraw ().
Touch event distribution mechanism.
Android long connection, how to deal with the heartbeat mechanism.
The start-up process of zygote.
The Android ipc:binder principle.
29. What frame have you used, whether you have read the source code, whether you know the underlying principle.
Android5.0, 6.0 new features.
31. Five Large components
Activity,broadcast receiver,service,content provider,intent

Reference: http://www.nowcoder.com/discuss/3043

Several frequently asked questions

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.