This 48 Java technology points to increase your interview success rate by 5 times times!

Source: Internet
Author: User
Tags aop modifiers object object reflection serialization shallow copy

Java Basics (with eggs at the end of the article)

What are some of the basic types in Java, and how many bytes are consumed?

Unit is bit, non-byte 1b=8bit

Can a string be inherited? Why?

No, because the string class has a final modifier, and the final decorated class cannot be inherited, the implementation details are not allowed to change. The string str= "a" that we normally define is still different from string Str=new string ("a").

The former is called by default string.valueof to return the string instance object, as to which depends on your assignment, such as String num=1, which is called

public static String valueOf (int i) {

return integer.tostring (i);

}

The latter is called the following section:

public string (string original) {

This.value = Original.value;

This.hash = Original.hash;

}

Finally, our variables are stored in a char array.

Private final char value[];

Technical tutorials are also recommended for everyone:

JAVA8 0 Basic Primer https://edu.csdn.net/course/detail/3044?utm_source=bokeyuanxk

DROOLS7 rules engine Getting Started tutorial https://edu.csdn.net/course/detail/5523?utm_source=bokeyuanxk

Spring boot develops small and beautiful personal blogs https://edu.csdn.net/course/detail/6359?utm_source=bokeyuanxk

Explore the bus, device, and drive model of Linux HTTPS://EDU.CSDN.NET/COURSE/DETAIL/5329?UTM_SOURCE=BOKEYUANXK

Getting started with software testing to master HTTPS://EDU.CSDN.NET/COURSE/DETAIL/8729?UTM_SOURCE=BOKEYUANXK

Spring Boot Getting Started Https://edu.csdn.net/course/detail/9068?utm_source=boekeyuanxk

Java Multithreading + Online Banking withdrawal case explaining HTTPS://EDU.CSDN.NET/COURSE/DETAIL/8973?UTM_SOURCE=BOKEYUANXK

String, StringBuffer, StringBuilder the difference.

String string constant (final decoration, not inherited), string is a constant and cannot be changed after it is created. (You can create a string object using StringBuffer and StringBuilder (two commonly used string manipulation classes). )

The StringBuffer string variable (thread safe), which is also the final category, is not allowed to be inherited, and most of the methods are synchronized, including the common Append method, which is also synchronized (synchronized decorated). It has appeared since the jdk1.0. Its ToString method caches the object to reduce the cost of copying elements.

Public synchronized String toString () {

if (Tostringcache = = null) {

Tostringcache = Arrays.copyofrange (value, 0, count);

}

return new String (Tostringcache, true);

}

The StringBuilder string variable (non-thread safe) starts to appear since jdk1.5. As with StringBuffer, the same interfaces and classes are inherited and implemented, except for the fact that the method does not use the synch modifier, but the difference is that the last ToString will return a new object directly.

Public String toString () {

Create a copy, don ' t share the array

return new String (value, 0, count);

}

What is the difference between ArrayList and LinkedList.

The ArrayList and LinkedList both implement the list interface, which has the following different points:

1, ArrayList is an index-based data interface, and its underlying is an array. It can randomly access elements with an O (1) time complexity. In contrast, LinkedList stores its data as a list of elements, with each element linked to its previous and subsequent elements, in which case the time complexity of finding an element is O (n).

2, with respect to arraylist,linkedlist Insert, add, delete operation is faster, because when the element is added anywhere in the collection, you do not need to recalculate the size as an array or update the index.

3, LinkedList more memory than ArrayList, because LinkedList stores two references for each node, one to the previous element, and one to the next.

The instantiation sequence of classes, such as parent static data, constructors, fields, subclass static data, constructors, fields, and their execution order when new.

This topic examines the steps that are performed when the ClassLoader is instantiated (load –> connections, initialization).

The parent class static generation variable,

Parent class static code block,

Sub-class static variables,

Subclass Static code block,

Parent class non-static variable (parent class instance member variable),

Parent class constructors,

Sub-class non-static variables (subclass instance member variables),

The subclass constructor.

Test demo:http://blog.csdn.net/u014042066/article/details/77574956

See my blog, "in-depth understanding of class loading": http://blog.csdn.net/u014042066/article/details/77394480

What kinds of map classes are used, what is the difference, HASHMAP is thread-safe, what is the map used in the concurrency, what are their internal principles, such as storage, hashcode, expansion, default capacity, etc.

HashMap is thread insecure, HashMap is an array + linked list + red black tree (JDK1.8 added red and black tree parts) implemented, using a hash table to store,

Refer to this link: https://zhuanlan.zhihu.com/p/21673805

JAVA8 Concurrenthashmap Why give up the segmented lock, what's the problem, if you come to design, how do you design.

Reference: https://yq.aliyun.com/articles/36781

There are no sequential MAP implementation classes, and if so, how they are guaranteed to be orderly.

TreeMap and Linkedhashmap are ordered (treemap default ascending, Linkedhashmap records the insertion Order).

Reference: http://uule.iteye.com/blog/1522291

Abstract class and interface differences, classes can inherit multiple classes, interfaces can inherit multiple interfaces, the class can implement multiple interfaces.

1. Abstract classes and interfaces cannot be instantiated directly, and if instantiated, the abstract class variable must point to the subclass object that implements all the abstract methods, and the interface variable must point to the class object that implements all the interface methods.

2, abstract class to Quilt class inheritance, interface to be class implementation.

3, interface can only do method declaration, abstract class can do method declaration, can also do method to achieve

4, the variables defined in the interface can only be public static constants, the variables in the abstract class are ordinary variables.

5. Abstract methods in abstract classes must all be implemented by the quilt class, if the subclass can not fully implement the parent class abstract method, then the subclass can only be abstract class. Similarly, when an interface is implemented, if the interface method cannot be fully implemented, then the class can only be an abstract class.

6, the abstract method can only affirm, cannot realize. abstract void ABC (); cannot be written as abstract void abc () {}.

7, abstract class can have no abstract method

8, if there is an abstract method in a class, then this class can only be abstract class

9, abstract methods to be implemented, so can not be static, nor can it be private.

10, the interface can inherit the interface, and can inherit the interface more, but the class can only inherit one root.

The difference between inheritance and aggregation is.

Inheritance refers to the ability of a class (called a subclass, a sub-interface) to inherit another class (called the parent class, the parent interface) and to augment its own new functionality, which is the most common relationship between classes and classes or interfaces and interfaces, and in Java such relationships are explicitly identified by the keyword extends, In the design of the general is not controversial;

Aggregation is a special case of association relationship, he embodies the whole and part, the relationship of ownership, that is, the relationship between the whole and the part is has-a, they can have their own life cycle, some can belong to multiple whole objects, can also be shared for multiple whole objects, such as computer and CPU, The relationship between the company and its employees, and the expression at the code level, and the association is consistent, can only be differentiated from the semantic level;

Reference: http://www.cnblogs.com/jiqing9006/p/5915023.html

Tell me what the difference between NiO and bio you understand is, talk about the reactor model.

IO is stream-oriented, and NIO is a buffer-oriented

Reference: https://zhuanlan.zhihu.com/p/23488863

Http://developer.51cto.com/art/201103/252367.htm

http://www.jianshu.com/p/3f703d3d804c

The principle of reflection, reflection three ways to create an instance of a class

Reference: Http://www.jianshu.com/p/3ea4a6b57f87?amp

http://blog.csdn.net/yongjian1092/article/details/7364451

In reflection, Class.forName and ClassLoader differ.

https://my.oschina.net/gpzhang/blog/486743

Describes several implementations of dynamic agents, respectively, to say the corresponding advantages and disadvantages.

The JDK Cglib JDK is based on the reflection mechanism, which requires an interface approach, because

Proxy.newproxyinstance (Target.getclass (). getClassLoader (),

Target.getclass (). Getinterfaces (), this);

Cglib is based on ASM Framework, realizes non-reflection mechanism to proxy, uses space to exchange time, agent efficiency is higher than JDK

http://lrd.ele.me/2017/01/09/dynamic_proxy/

The difference between dynamic agent and cglib implementation

Ibid. (based on Invocationhandler and Methodinterceptor)

Why the CGlib method can implement the proxy for the interface.

Ditto

Final use

Classes, variables, methods

Http://www.importnew.com/7553.html

Write out three singleton pattern implementations.

Lazy type single case, a hungry man type single case, double check, etc.

Reference: https://my.oschina.net/dyyweb/blog/609021

How do I automate all hashcode and equals implementations for subclasses in the parent class? What's the pros and cons of doing this?

Simultaneous replication hashcode and the Equals method, the advantage can add custom logic, and do not have to call the implementation of the superclass.

Reference: http://java-min.iteye.com/blog/1416727

Please combine with OO design concept, talk about the function of access modifier public, private, protected, default in application design.

Access modifiers, mainly indicating the scope of the modifier block, for easy isolation and protection

A subclass that is identical to a packet of different packages. Non-subclasses of different packages

    • 1
    • 2

Private√

Default√√

Protected√√√

Public√√√√

The most restrictive modifier in the Public:java language, commonly referred to as "public". Classes, properties, and methods that are modified by it are not

Can be accessed only across classes, and across packages (package).

The narrowest modifier for access restrictions in the Private:java language is generally referred to as "private." The classes, attributes, and properties that are modified to

and methods can only be accessed by objects of that class, their subclasses are inaccessible, and cross-package access is not allowed.

Protect: An access modifier between public and private, commonly referred to as a "protected form." The class that is modified by it,

Properties and methods can only be accessed by methods and subclasses of the class itself, even if the subclasses are accessible in different packages.

Default: That is, without any access modifiers, often referred to as the "Default access mode." In this mode, only the same package is allowed to be visited

Ask.

Deep copy and shallow copy differences.

Http://www.oschina.net/translate/java-copy-shallow-vs-deep-in-which-you-will-swim

Array and linked list data structure description, individual time complexity

http://blog.csdn.net/snow_wu/article/details/53172721

The difference between error and exception, the difference between checkedexception,runtimeexception

http://blog.csdn.net/woshixuye/article/details/8230407

Please list 5 run-time exceptions.

Ditto

In your own code, if you create a Java.lang.String object, can the object be loaded by the ClassLoader? Why

Class loading does not have to wait for the first use of the class to load, and the JVM allows some classes to be preloaded ....

Http://www.cnblogs.com/jasonstorm/p/5663864.html

Tell me about your understanding of the hashcode and Equals methods in the Java.lang.Object object. In what scenario you need to re-implement both methods.

Reference Top question

In jdk1.5, generics are introduced and the existence of generics is used to solve problems.

The essence of generics is a parameterized type, which means that the data type being manipulated is specified as a parameter, the benefit of generics is that it checks for type safety at compile time, and all casts are automatic and implicit, to increase the reuse rate of code.

Http://baike.baidu.com/item/java%E6%B3%9B%E5%9E%8B

What is the use of such a a.hashcode (), and what is the relationship with A.equals (b)?

Hashcode

The Hashcode () method provides the Hashcode value of the object, which is a native method, and the default value returned is the same as System.identityhashcode (obj).

Usually this value is a part of the object's head bits a number that has a certain identity object meaning exists, but is never set at the address.

The function is to identify the object with a number. For example, in HashMap, HashSet and other similar collection classes, if you use an object itself as a key, that is, based on this object to implement the hash of the write and find, then the object itself how to implement this? is based on hashcode such a number to complete, only the number to complete the calculation and comparison operation.

Hashcode is the only

Hashcode can only be said to be identified objects, in the hash algorithm may be relatively discrete open, so that the data can be found at the time based on this key to quickly narrow the range of data, but the hashcode is not necessarily unique, so the hash algorithm in the specific linked list, need to loop linked list, The Equals method is then used to compare whether the key is the same.

The relationship between Equals and hashcode

equals equal to two objects, the hashcode must be equal. However, two objects equal to hashcode are not necessarily equal to equals.

1190000004520827

Is it possible that 2 unequal objects have the same hashcode.

Yes

How the HashSet inside Java works.

The bottom layer is based on the HASHMAP implementation

Http://wiki.jikexueyuan.com/project/java-collection/hashset.html

What is serialization, how serialization, why serialization, what problems deserialization will encounter, and how to resolve it.

Http://www.importnew.com/17964.html

JVM knowledge

What happens when a stack memory overflow occurs.

A Stackoverflowerror exception is thrown if the thread requests a stack depth that is greater than the depth allowed by the virtual machine. Throws a OutOfMemoryError exception if the virtual machine cannot request enough memory space in the dynamic expansion stack.

Reference: http://wiki.jikexueyuan.com/project/java-vm/storage.html

The memory structure of the JVM, Eden and Survivor proportions.

Eden and Survior are assigned by 8:1.

http://blog.csdn.net/lojze_ly/article/details/49456255

What is a complete GC process in the JVM, how the object is promoted to the old age, and what are some of the main JVM parameters that you know.

The birth of the object is the Cenozoic->eden, in the process of minor GC, if still survive, moved to from, into the survivor, to mark Algebra, so check a certain number of times, promoted to the old age,

Http://www.cnblogs.com/redcreen/archive/2011/05/04/2037056.html

http://ifeve.com/useful-jvm-flags/

Https://wangkang007.gitbooks.io/jvm/content/jvmcan_shu_xiang_jie.html

You know what kinds of garbage collectors, their pros and cons, focus on CMS, including principles, processes, advantages and disadvantages

Serial, Parnew, Parallelscavenge, Serialold, Parallelold, CMS, G1

Https://wangkang007.gitbooks.io/jvm/content/chapter1.html

The implementation principle of garbage collection algorithm.

Http://www.importnew.com/13493.html

When there is a memory overflow, you are wrong.

First analyze what type of memory overflow, corresponding tuning parameters or optimization code.

Https://wangkang007.gitbooks.io/jvm/content/4jvmdiao_you.html

Knowledge of the JVM memory model, such as reordering, memory barriers, Happen-before, main memory, working memory, and more.

Memory Barrier: A CPU instruction to guarantee execution order and visibility

Reorder: In order to improve performance, the compiler and the processor will re-pat the execution

Happen-before: The order of execution between operations. Some operations occur first.

Main memory: The area where the shared variable is stored is the main memory

Working memory: Local memory for each thread copy, which stores the thread to read/write a copy of the shared variable

http://ifeve.com/java-memory-model-1/

Http://www.jianshu.com/p/d3fda02d4cae

http://blog.csdn.net/kenzyq/article/details/50918457

Simply tell me about the classloader you know.

Class loader classification (Bootstrap,ext,app,curstom), class loading process (Load-link-init)

http://blog.csdn.net/gjanyanlig/article/details/6818655/

Talk about the reflection mechanism of JAVA.

A Java program can dynamically get all the properties and methods of a class in its running state, and instantiate the class, invoking the function of the method

Http://baike.baidu.com/link?url=c7p1pela3ploagkfaok-4xhe8hzquoab7k5gpck_zpbaa_aw-no3997k1oir8n–1_ Wxxzfothfreca0ljvp6wnowidvtklbzklqvk6jvxyvvnhdwv9yf-nioebtg1hwsnagsjuhoe2wxmiup20rra#7

What are the JVM parameters for your online application?

-server

xms6000m

-xmx6000m

-xmn500m

-xx:permsize=500m

-xx:maxpermsize=500m

-xx:survivorratio=65536

-xx:maxtenuringthreshold=0

-xnoclassgc

-xx:+disableexplicitgc

-xx:+useparnewgc

-xx:+useconcmarksweepgc

-xx:+usecmscompactatfullcollection

-xx:cmsfullgcsbeforecompaction=0

-xx:+cmsclassunloadingenabled

-xx:-cmsparallelremarkenabled

-xx:cmsinitiatingoccupancyfraction=90

-xx:softreflrupolicymspermb=0

-xx:+printclasshistogram

-xx:+printgcdetails

-xx:+printgctimestamps

-xx:+printheapatgc

-xloggc:log/gc.log

G1 and CMS differences, throughput priority and response-first garbage collector selection.

A CMS is a collector that targets the shortest payback time. Implementation based on the tag-purge algorithm. The CPU resource is compared, and the cutting is easy to cause fragmentation.

G1 is a service-oriented garbage collector and is the JDK9 default collector, implemented based on the tag-collation algorithm. Multi-core, multi-CPU can be used to preserve generational, predictable pauses and controllable.

http://blog.csdn.net/linhu007/article/details/48897597

Please explain the meaning of the JVM parameters as follows:

-server-xms512m-xmx512m-xss1024k

-xx:permsize=256m-xx:maxpermsize=512m-xx:maxtenuringthreshold=20

Xx:cmsinitiatingoccupancyfraction=80-xx:+usecmsinitiatingoccupancyonly.

Server Mode startup

Minimum heap Memory 512m

512m Max

Stacks space per line 1m

Permanent Generation 256

Maximum permanent generation 256

Maximum transition to the old age check Count 20

CMS recovery time: Memory consumption 80%

Command JVM does not start the CMS garbage collection cycle based on data collected at run time

Open Source Framework Knowledge

Simply talk about the tomcat structure and its classloader process.

server-– Multiple Service

Container level: –>engine– "Host–>context

Listenter

Connector

Logging, naming, Session, JMX, etc.

Load class with WebappClassLoader

http://www.ibm.com/developerworks/cn/java/j-lo-tomcat1/

http://blog.csdn.net/dc_726/article/details/11873343

Http://www.cnblogs.com/xing901022/p/4574961.html

Http://www.jianshu.com/p/62ec977996df

How Tomcat is tuned and what parameters are involved.

Hardware selection, operating system selection, version selection, JDK selection, configuring JVM parameters, configuring connector number of threads, opening gzip compression, trimspaces, clustering, etc.

http://blog.csdn.net/lifetragedy/article/details/7708724

Talk about the Spring loading process.

Through the listener portal, the core is the Refresh method in Abstractapplicationcontext, where you load the bean factory, bean, create bean instance, interceptor, post processor, etc.

https://www.ibm.com/developerworks/cn/java/j-lo-spring-principle/

Talk about the propagation properties of Spring transactions.

Seven propagation properties.

Transactional propagation behavior

The so-called transaction propagation behavior is that if a transaction context already exists before the current transaction is started, there are several options to specify the execution behavior of a transactional method. The transactiondefinition definition includes the following constants that represent propagation behavior:

Transactiondefinition.propagation_required: If a transaction is currently present, the transaction is joined and a new transaction is created if there is no current transaction.

Transactiondefinition.propagation_requires_new: Creates a new transaction and suspends the current transaction if a transaction is currently present.

Transactiondefinition.propagation_supports: If a transaction is currently present, the transaction is joined, and if no transaction is currently present, it will continue in a non-transactional manner.

Transactiondefinition.propagation_not_supported: Runs in a non-transactional manner, suspending the current transaction if a transaction is currently present.

Transactiondefinition.propagation_never: Runs in a non-transactional manner and throws an exception if a transaction is currently present.

Transactiondefinition.propagation_mandatory: If a transaction is currently present, the transaction is joined and an exception is thrown if there is no current transaction.

Transactiondefinition.propagation_nested: If a transaction is currently present, create a transaction to run as a nested transaction for the current transaction, or if there is no current transaction, The value is equivalent to transactiondefinition.propagation_required.

https://www.ibm.com/developerworks/cn/education/opensource/os-cn-spring-trans/

How Spring manages transactions.

Programmatic and declarative

Ditto

How Spring Configures the transaction (specifically speaking some key XML elements).

Tell me about your understanding of Spring, the principle of non-singleton injection? It's life cycle? The principle of cyclic injection, the implementation principle of AOP, and the several terms in AOP, how they work with each other.

Core components: Bean,context,core, single injection is created by a singleton beanfactory, the life cycle is created by the interface to enable the implementation of the loop injection is through the post-processor, AOP is actually through reflection dynamic proxy, Pointcut, Advice and so on.

AOP Related: http://blog.csdn.net/csh624366188/article/details/7651702/

Dispatcherservlet initialization process in SPRINGMVC.

The portal is a configured ds,ds in Web. Xml that inherits the Httpservletbean,frameworkservlet, which initializes the load bean and instance through the Init method, Initservletbean is the method that actually completes the context work and the bean initialization.

Http://www.mamicode.com/info-detail-512105.html

This 48 Java technology points to increase your interview success rate by 5 times times!

Related Article

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.