Java OOP 101
1. What is THE B/S architecture? What is the C/S architecture
(1) B/S(Browser/Server), Browser/Server program
(2) C/S(Client/Server), Client/Server, and desktop applications
2. What are the development platforms for Java?
(1) JAVA SE: mainly used in client development
(2) JAVA EE: Mainly used in Web application development
(3) JAVA ME: mainly used in embedded application development
3. What is JDK? What is the JRE?
(1) JDK: Java Development Kit: Java development kit is the environment that developers need to install
(2) JRE: Java Runtime Environment, which is required for Running Java programs
4. What are the features of the Java language
(1) Easy to learn, rich class library
(2) Object-oriented (the most important feature of Java, so that programs are less coupled and more cohesive)
(3) Platform independence (THE JVM is fundamental to Java’s cross-platform use)
(4) Reliable and safe
(5) Support multi-threading
Open baidu APP to see hd pictures
Java collection/generic interview questions 24
Difference between ArrayList and linkedList
An Array is an index-based data structure that uses an index to search and read data in an Array quickly.
The time required to fetch the Array is O(1), but deleting the Array is expensive because it requires rearranging all the data in the Array.
Disadvantages: Array initialization must specify the length of initialization, otherwise an error is reported
Such as:
int[] a = newint[4]; Int c[] = {23,43,56,78}; // length: 4, index range: [0,3]
List – Is an ordered Collection that can contain repeating elements, providing indexed access, and inherits the Collection.
List has two important implementation classes: ArrayList and LinkedList
ArrayList: You can think of an array that grows automatically
The toArray method of ArrayList returns an array
The asList method of ArrayList returns a list
The underlying implementation of ArrayList is Array, an Array expansion implementation
LinkList is a double-linked list that performs better than ArrayList when adding and removing elements. But it is weaker in get and set
ArrayList. Of course, these comparisons are large data or frequent operations.
Java exception interview questions 8
1. What are the two types of exceptions in Java?
2. How many mechanisms are there for handling exceptions?
3. How to customize an exception
4, try catch fifinally, try has a return, finally is executed?
5. Excption and Error package structure
6. Thow is different from THORws
7, The difference between Error and Exception?
What is the difference between error and exception
IO and NIO in Java
IO streams in Java?
2. Java IO vs. NIO
3. What are the common IO classes
4. The difference between byte stream and character stream
Block IO model
6. Non-blocking IO model
7, multiplexing IO model
8. Signal driven IO model
9. Asynchronous IO model
10, JAVA NIO
NIO buffer
12. Non-blocking of NIO
13, the Channel
14 and Buffer
15, the Selector
11 Java reflection interview questions
1. What other methods can you use to create objects besides using new?
2. Is it more efficient to create objects with Java reflection or with new?
The role of Java reflection
4. Where is reflection used?
5, the implementation of reflection:
Java reflection class
7. Pros and cons of reflection mechanism:
Java Reflection API
9, Reflection use steps (get Class object, call object method)
There are several ways to get a Class object
11. Use reflection to dynamically create object instances
10. Java serialization
What is Java serialization and how to implement it?
2. Save (persist) objects and their state to memory or disk
Serialized objects are held as byte arrays – static members are not saved
4. Serialized user remote object transfer
5, Serializable implementation
6. WriteObject and readObject customize serialization policies
7. Serialize ids
Serialization does not save static variables
The Transient keyword prevents the variable from being serialized to a file
10. Serialization (implemented in Deep Clone 1)
Java annotation 2 interview questions
1. What are the four standard meta-annotations?
2. What are annotations?
Multithreading and parallel hair 108 questions
1. There are several ways to implement multithreading in Java
Inheriting Thread class;
Implement Runnable interface;
Implement the Callable interface to create Thread threads through the FutureTask wrapper;
Multithreading with returns is implemented using ExecutorService, Callable, and Future (that is, ExecutorService is used to manage the previous three approaches).
Inherit the Thread class
The Thread class is essentially an instance that implements the Runnable interface and represents an instance of a Thread. The only way to start a Thread is through the start() instance method of the Thread class. The start() method is a native method that starts a new thread and executes the run() method.
publicclassMyThreadextendsThread{publicvoidrun(){System.out.println(“MyThread.run()”); }}MyThread myThread1 = new MyThread(); myThread1.start();
3. Implement the Runnable interface.
If you cannot extend Thread directly if your class already extends another class, you can implement a Runnable interface.
publicclassMyThreadextendsOtherClassimplementsRunnable{publicvoidrun(){System.out.println(“MyThread.run()”); MyThread = new MyThread(); MyThread = new MyThread(); Thread thread = new Thread(myThread); thread.start(); Thread.run () publicVoidRun (){if (target! = null) {target.run(); }}
JVM interview 87
1. Is there a memory leak in Java? Please describe it briefly.
Will be. Memory leaks can occur when implementing heaped data structures yourself, see Effective Java.
2, In 64-bit JVMS, int length is the majority.
In Java, the length of a variable of type int is a fixed value of 32 bits, regardless of the platform. In 32-bit and 64-bit Java virtual machines, the length of an int is the same.
What are the differences between Serial and Parallel GC?
Serial and Parallel both cause stop-the-world during GC execution. The main difference between them is that the Serial collector is the default copy collector and only has one thread for GC, while the Parallel collector uses multiple GC threads for GC.
For 32-bit and 64-bit JVMS, is the length of a variable of type int the majority?
In 32-bit and 64-bit JVMS, variables of type int are the same length, either 32 bits or 4 bytes.
5. The difference between WeakReference and SoftReference in Java?
Although WeakReference and SoftReference are both beneficial to improving the efficiency of GC and memory, WeakReference will be recovered by GC once it loses the last strong reference, while SoftReference cannot prevent collection. But it can be deferred until the JVM runs out of memory.
6. What does the JVM option -xx :+UseCompressedOops do? Why use it
When you migrate your application from a 32-bit JVM to a 64-bit JVM, the heap memory is suddenly increased, almost doubling, as Pointers to objects are increased from 32-bit to 64-bit.
This also adversely affects the amount of data cached by the CPU (which is much smaller than memory). Because the main motivation for moving to a 64-bit JVM is the ability to specify a maximum heap size, some memory can be saved by compressing OOP. With the -xx :+UseCompressedOops option, the JVM uses 32-bit OOP instead of 64-bit OOP.
7. How to determine whether the JVM is 32-bit or 64-bit using a Java program?
You can check some system properties such as sun.arch.data.model or os.arch to get this information.
第 83 题 MySQL interview
1. Database storage engine
Database storage engine is the bottom software organization of database. Database management system (DBMS) uses data engine to create, query, update and delete data. Different storage engines provide different storage mechanisms, indexing techniques, locking levels, and other functions. Different storage engines can be used to obtain specific functions. Many different database management systems now support many different data engines. Storage engines include: 1. MyIsam, 2. InnoDB, 3. Memory, 4. Archive, 5.
InnoDB (B+ tree)
The underlying storage structure of InnoDB is B+ tree. Each node of the B tree corresponds to a page of InnoDB. The page size is fixed and is generally set to 16K. Non-leaf nodes have only key values, while leaf nodes contain completion data
Applicable scenarios:
1) Frequently updated tables, suitable for handling multiple concurrent update requests.
2) Support transactions.
3) Recovery from disasters (through bin-log, etc.).
4) Foreign key constraints. Only he supports foreign keys.
5) Support automatic increment of column attribute AUTO_INCREMENT.
3, TokuDB (Fractal Tree- Nodes with data)
The bottom storage structure of TokuDB is a Fractal Tree, which is similar to B+ Tree. In the Fractal Tree, each child pointer points to a child node. There is also a Message Buffer, which is a FIFO queue for caching update operations.
For example, an insert operation only needs the Message Buffer that landed on a node to return immediately, and does not need to search for the leaf node. These cached updates are asynchronously merged to the corresponding nodes at query time or in the background.
TokuDB adds indexes online without affecting read and write operations. The write performance is very fast. The Fractal Tree has advantages in transaction implementation. It is mainly used for infrequently accessed data or archiving historical data.
50 Redis interview questions
1. What is Redis?
Redis is a high performance key-value database that is completely open source and free and complies with the BSD protocol.
Redis and other key-value caching products have the following three characteristics:
Redis supports data persistence, saving data in memory to disk, which can be reloaded for use upon restart.
Redis not only supports simple key-value type data, but also provides the storage of list, set, zset, hash and other data structures.
Redis supports data backup, namely, data backup in master-slave mode.
Redis advantage
High performance – Redis can read 110,000 times /s and write 81,000 times /s. Rich data types – Redis supports binary case Strings, Lists, Hashes,Sets and Ordered Sets data type operations.
Atomic – All operations in Redis are atomic, meaning that they either succeed or fail at all. Individual operations are atomic. Multiple operations also support transactions, namely atomicity, wrapped in MULTI and EXEC instructions.
Rich features – Redis also supports publish/subscribe, notifications, key expiration, and more.
2. What is the difference between Redis and other key-value stores?
Redis has more complex data structures and provides atomic operations on them, which is a different evolutionary path from other databases. Redis data types are transparent to programmers while being based on basic data structures without additional abstractions. Redis runs in memory but can persist to disk, so memory is a tradeoff for high-speed reads and writes to different data sets, since the amount of data cannot be greater than hardware memory. Another advantage of an in-memory database is that it is much easier to operate in memory than the same complex data structures on disk, allowing Redis to do a lot of things with a lot of internal complexity. At the same time, they are compact in terms of disk formats and are produced in an appending manner because they do not require random access.
3. Redis data type?
Redis supports five data types: string, hash, list, set, and Zsetsorted set.
If you are an advanced user in Redis, you also need to add the following data structures HyperLogLog, Geo, Pub/Sub.
If you mention that you’ve also played with Redis modules like BloomFilter, RedisSearch, or Redis-ML, the interviewer’s eyes will light up.
24 Memcached interview questions
1. What is Memcached and what does it do?
Memcached is an open source, high-performance memory retention software. In its name, Mem means memory and Cache means Cache. Memcached is used to temporarily save all kinds of data in the database in the pre-planned memory space to reduce the direct and high concurrent access of services to the database, thus improving the database access performance and accelerating the dynamic application of web sites.
2. How to implement Memcached distributed cluster?
Note: A Memcached cluster is different from a Web service cluster. The sum of all Memcached data is the database data. Each Memcached is a piece of data. (Memcached data is a portion of mysql database data.)
A. Program side implementation
The program loads the IP list of all MCS and hashes the key.
For example, web1 (key)===> corresponds to A,B,C,D,E,F,G… . Several servers. (Through hash algorithm)
B. Load balancer
The purpose of the consistent hashing algorithm is not only to ensure that each object requests only one corresponding server, but also to minimize the reallocation of cache server updates when nodes go down.
MongoDB interview questions 95
1. What is mongodb?
MongoDB is an open source database system based on distributed file storage written in C++ language. Adding more nodes can ensure server performance under high load conditions. MongoDB aims to provide scalable, high-performance data storage solutions for WEB applications.
MongoDB stores data as a document. The data structure consists of key=>value pairs. MongoDB documents are similar to JSON objects. Field values can contain other documents, arrays, and document arrays.
2. What are the features of mongodb?
(1) MongoDB is a document storage-oriented database, which is relatively simple and easy to operate.
(2) You can index any attribute in the MongoDB record (e.g. FirstName=”Sameer”,Address=”8 Gandhi Road”) for faster sorting.
(3) You can create data images locally or online, which makes MongoDB more scalable.
(4) If the load increases (requiring more storage space and stronger processing capacity), it can be distributed to other nodes in the computer network, which is called sharding.
(5) Mongo supports rich query expressions. Query instructions use JSON-style tags to easily query objects and arrays embedded in documents.
(6) MongoDb can replace completed documents (data) or some specified data fields with update() command.
(7) Map/ Reduce in Mongodb is mainly used for batch processing and aggregation of data.
8. Map and Reduce. The Map function invokes emit(key,value) to traverse all records in the set and send the key and value to the Reduce function for processing.
(9) Map and Reduce functions are written in Javascript, and mapReduce operations can be performed by db.runCommand or mapReduce command.
(10) GridFS is a built-in feature in MongoDB that can be used to store a large number of small files.
(11) MongoDB allows script execution on the server side, you can use Javascript to write a function, directly executed on the server side, also
You can store the definition of a function on the server and call it next time.
Spring interview question 131
1. What are the main features of Spring Framework versions?
2. What is Spring Framework?
Spring is an open source application framework designed to reduce the complexity of application development. It is lightweight and loosely coupled. It has a layered architecture that allows users to select components while also providing a cohesive framework for J2EE application development. It can integrate other frameworks, such as Structs, Hibernate, EJB, etc., so it is also called the framework of frameworks.
3. List the advantages of the Spring Framework.
Due to the layered architecture of Spring Frameworks, users are free to choose which components they want. The Spring Framework supports POJOs (Plain Old Java Object) programming for continuous integration and testability. JDBC is simplified thanks to dependency injection and inversion of control. It’s open source and free.
Spring Boot interview 92
1. What is Spring Boot?
Over the years, Spring has become more and more complex as new features have been added. Just visit the official website page to see the different capabilities of all Spring projects that can be used in our applications. If we have to start a new Spring project, we must add construction paths or Maven dependencies, configure the application sequence server, and add Spring configuration. So starting a new Spring project takes a lot of effort because we now have to do everything from scratch.
Spring Boot is the solution to this problem. Spring Boot has been built on top of the existing Spring framework. Using Spring startup, we avoided all the template coding and configuration we had to do before. Therefore, Spring Boot can help us use existing Spring functionality more robustly with less effort
2、为什么要用SpringBoot
Spring Boot has many advantages, such as:
(1) Independent operation
Spring Boot and embedded with various servlet containers, Tomcat, Jetty, etc., now no longer need to be deployed into a war package container, Spring Boot as long as the executable jar package can run independently, all dependencies are in a JAR package.
(2) Simplify configuration
Spring-boot-starter-web initiators automatically depend on other components, simplifying maven configurations.
(3) Automatic configuration
Spring Boot can automatically configure beans based on classes and JAR packages in the current classpath. For example, a Spring-boot-starter-Web initiator can have web functions without other configuration.
(4) No code generation and XML configuration
Spring Boot configuration is done without code generation and without XML configuration files, all with the help of conditional annotations, one of the core features of Spring4.x.
(5) Application monitoring
Spring Boot provides a series of endpoints to monitor services and applications for health checks
If you need to get more Java interview information can be forwarded attention + private letter xiaobian interview