Home Java JavaInterview questions 2019 Java interview questions (Tencent)

2019 Java interview questions (Tencent)

Dec 03, 2020 pm 04:33 PM
java Tencent Interview questions

2019 Java interview questions (Tencent)

The following is an interview question from Tencent in 2019. I share it with you. I hope it will be helpful to everyone.

(Recommended video tutorial: java teaching video)

  1. Choose a project from your resume and tell us what major challenges you encountered in it? And your ideas for solving the problem?
  2. A piece of code needs to execute multiple redis commands. How to ensure atomicity without locking?
    Use lua script: https://segmentfault.com/a/1190000009811453
  3. Let’s talk about data structures, such as binary trees and red black trees?
    Understand this article: https://juejin.im/post/5a27c6946fb9a04509096248
  4. Talk about the differences and usage scenarios between B-tree and B tree?
  5. B-tree:
    B-tree is a tree constructed by taking advantage of the characteristics of disk blocks. Each disk block has one node, and each node contains many keys. After increasing the node keywords of the tree, the
    levels of the tree are fewer than the original binary tree, which reduces the number and complexity of data searches.
    B-tree cleverly uses the principle of disk read-ahead to set the size of a node to equal one page (each page is 4K), so that each node only needs one I/O to complete
    Full load.
    B-tree data can be stored in any node.
  6. B tree:
    B tree is a variant of B-tree. B tree data is only stored in leaf nodes. In this way, based on the B-tree, each node stores more keywords, and the tree has fewer levels
    , so querying data is faster. All keyword pointers exist in leaf nodes, so the number of searches per time is The same, so the query speed is more stable;
  7. Which version of mysql and which storage engine use B tree for indexing? Why not use red tree?
    You need to first understand the implementation principles of B tree and red tree. B tree has sequential access pointers, which red trees do not have.
  8. Talk about the differences between several common message middlewares?
  9. RabbitMQ is the first choice for small and medium-sized companies: simple management interface and high concurrency.
  10. More related interview question recommendations: java interview questions and answers
  11. Large companies can choose RocketMQ: higher concurrency, and customized development of rocketmq.
  12. For the log collection function, kafka is preferred and is specially prepared for big data.
  13. How does rabbitmq ensure the reliability of messages?
    For details, see "Exam question bank/rabbitmq"
  14. Springcloud service discovery principle?
    a. Send a heartbeat check every 30s to renew the lease. If the client cannot renew the lease multiple times, it will be removed from the server registration center within 90s.
    a. Registration information and updates will be copied to other Eureka nodes. Clients from any region can find the registration center information. Replication occurs every 30s to locate their services and make remote calls. .
    b. The client can also cache some service instance information, so even if Eureka fails, the client can still locate the service address.
  15. Introduce the various components of springcloud? In addition to eureka, what else can be used for springcloud's registration center?
    The working principle of springcloud
    Features ActiveMQ RabbitMQ RocketMQ kafka
    Development language java erlang java scala
    Single machine throughput 10,000 level 10,000 level 100,000 level
    Timeliness ms level us Level ms level Within ms level
    High availability (master-slave architecture) High (master-slave architecture) Very high (distributed architecture) Very high (distributed architecture)
    Functional features
    Mature The product is used in many companies; it has more documents; it has better support for various protocols
    It is developed based on Erlang, so it has strong concurrency capabilities, extremely good performance, and low latency; the management interface is relatively Rich
    MQ has relatively complete functions and good scalability
    It only supports the main MQ functions. Some functions such as message query and message backtracking are not provided. After all, it is prepared for big data and should be used in the field of big data. Use wide.
    springcloud consists of the following core components:
    Eureka: When each service starts, Eureka Client will register the service to Eureka Server, and Eureka Client can also pull the registry from Eureka Server in turn, thus Know where other services are
    Ribbon: When a request is initiated between services, load balancing is done based on Ribbon, and one machine is selected from multiple machines of a service
    Feign: Feign-based dynamic proxy mechanism, according to annotations and the selected machine, splice the request URL address, and initiate the request
    Hystrix: The request is initiated through the thread pool of Hystrix. Different services use different thread pools, which realizes the isolation of different service calls and avoids service Avalanche
    Problem
    Zuul: If the front-end and mobile terminals need to call the back-end system, they must enter through the Zuul gateway, and the Zuul gateway forwards the request to the corresponding service
    The registration center is okay Use zookeeper.
  16. How many current limiting methods are there for microservices?
    spring cloud gateway: https://windmt.com/2018/05/09/spring-cloud-15-spring-cloud-gateway-ratelimiter/
  17. In the case of current limiting, service isolation can still Is it necessary?
    https://www.javazhiyin.com/25964.html
  18. Dubbo has several types of load balancing? Is load balancing on the server side or the client side?
    Dubbo load balancing is on the client side. Dubbo has 4 built-in load balancing strategies:
    a. RandomLoadBalance: Random load balancing. Choose one at random. It is Dubbo's default load balancing strategy.
    b. RoundRobinLoadBalance: Polling load balancing. Poll to select one.
    c. LeastActiveLoadBalance: The minimum number of active calls, random with the same number of active calls. The active count refers to the difference in counts before and after the call. Make the slow Provider receive fewer requests,
    because the slower the Provider, the greater the difference in counts before and after the call will be made.
    d. ConsistentHashLoadBalance: Consistent hash load balancing. Requests with the same parameters always land on the same machine.
  19. How to implement redis distributed lock? What problem should we pay attention to?
    Learn about this article: https://juejin.im/post/5bbb0d8df265da0abd3533a5
  20. Tell me about the source code you have read? What design patterns or design highlights are used?
    For specific analysis, you need to read some source code, such as spring source code, before the interview.
  21. How to implement aop? Where is aop used in the project?
    Master: https://juejin.im/post/5bf4fc84f265da611b57f906
  22. What is the role of the post-processor?
    BeanPostProcessor in Spring: https://www.jianshu.com/p/f80b77d65d39
  23. Spring bean scope, when to use request scope.
    Detailed reading: https://blog.csdn.net/icarus_wang/article/details/51586776
  24. Tell me about the result of the following question?
  25.   1 package com.giveu.web;
     2
     3 public class VolatileTest {
     4 public static volatile int race = 0;
     5
     6 public static void increase() {
     7 race++;
     8 }
     9
     10 private static final int THREADS_COUNT = 10;
     11
     12 public static void main(String[] args) {
     13 Thread[] threads = new Thread[THREADS_COUNT];
     14 for (int i = 0; i < THREADS_COUNT; i++) {
     15 threads[i] = new Thread(new Runnable() {
     16 @Override
     17 public void run() {
     18 for (int i = 0; i < 10000; i++) {
     19 increase();
     20 }
     21 }
     22 });
     23 threads[i].start();
     24 }
     25 while (Thread.activeCount() > 1) {
     26 Thread.yield();
     27 }
     28 System.out.println(race);
     29 }
     30

The program does not end and no printing occurs.

Related recommendations: java introductory tutorial

The above is the detailed content of 2019 Java interview questions (Tencent). For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

What is a deadlock in Java and how can you prevent it? What is a deadlock in Java and how can you prevent it? Aug 23, 2025 pm 12:55 PM

AdeadlockinJavaoccurswhentwoormorethreadsareblockedforever,eachwaitingforaresourceheldbytheother,typicallyduetocircularwaitcausedbyinconsistentlockordering;thiscanbepreventedbybreakingoneofthefournecessaryconditions—mutualexclusion,holdandwait,nopree

How to use Optional in Java? How to use Optional in Java? Aug 22, 2025 am 10:27 AM

UseOptional.empty(),Optional.of(),andOptional.ofNullable()tocreateOptionalinstancesdependingonwhetherthevalueisabsent,non-null,orpossiblynull.2.CheckforvaluessafelyusingisPresent()orpreferablyifPresent()toavoiddirectnullchecks.3.Providedefaultswithor

Java Persistence with Spring Data JPA and Hibernate Java Persistence with Spring Data JPA and Hibernate Aug 22, 2025 am 07:52 AM

The core of SpringDataJPA and Hibernate working together is: 1. JPA is the specification and Hibernate is the implementation, SpringDataJPA encapsulation simplifies DAO development; 2. Entity classes map database structures through @Entity, @Id, @Column, etc.; 3. Repository interface inherits JpaRepository to automatically implement CRUD and named query methods; 4. Complex queries use @Query annotation to support JPQL or native SQL; 5. In SpringBoot, integration is completed by adding starter dependencies and configuring data sources and JPA attributes; 6. Transactions are made by @Transactiona

Java Cryptography Architecture (JCA) for Secure Coding Java Cryptography Architecture (JCA) for Secure Coding Aug 23, 2025 pm 01:20 PM

Understand JCA core components such as MessageDigest, Cipher, KeyGenerator, SecureRandom, Signature, KeyStore, etc., which implement algorithms through the provider mechanism; 2. Use strong algorithms and parameters such as SHA-256/SHA-512, AES (256-bit key, GCM mode), RSA (2048-bit or above) and SecureRandom; 3. Avoid hard-coded keys, use KeyStore to manage keys, and generate keys through securely derived passwords such as PBKDF2; 4. Disable ECB mode, adopt authentication encryption modes such as GCM, use unique random IVs for each encryption, and clear sensitive ones in time

LOL Game Settings Not Saving After Closing [FIXED] LOL Game Settings Not Saving After Closing [FIXED] Aug 24, 2025 am 03:17 AM

IfLeagueofLegendssettingsaren’tsaving,trythesesteps:1.Runthegameasadministrator.2.GrantfullfolderpermissionstotheLeagueofLegendsdirectory.3.Editandensuregame.cfgisn’tread-only.4.Disablecloudsyncforthegamefolder.5.RepairthegameviatheRiotClient.

How to use the Pattern and Matcher classes in Java? How to use the Pattern and Matcher classes in Java? Aug 22, 2025 am 09:57 AM

The Pattern class is used to compile regular expressions, and the Matcher class is used to perform matching operations on strings. The combination of the two can realize text search, matching and replacement; first create a pattern object through Pattern.compile(), and then call its matcher() method to generate a Matcher instance. Then use matches() to judge the full string matching, find() to find subsequences, replaceAll() or replaceFirst() for replacement. If the regular contains a capture group, the nth group content can be obtained through group(n). In actual applications, you should avoid repeated compilation patterns, pay attention to special character escapes, and use the matching pattern flag as needed, and ultimately achieve efficient

Edit bookmarks in chrome Edit bookmarks in chrome Aug 27, 2025 am 12:03 AM

Chrome bookmark editing is simple and practical. Users can enter the bookmark manager through the shortcut keys Ctrl Shift O (Windows) or Cmd Shift O (Mac), or enter through the browser menu; 1. When editing a single bookmark, right-click to select "Edit", modify the title or URL and click "Finish" to save; 2. When organizing bookmarks in batches, you can hold Ctrl (or Cmd) to multiple-choice bookmarks in the bookmark manager, right-click to select "Move to" or "Copy to" the target folder; 3. When exporting and importing bookmarks, click the "Solve" button to select "Export Bookmark" to save as HTML file, and then restore it through the "Import Bookmark" function if necessary.

'Java is not recognized' Error in CMD [3 Simple Steps] 'Java is not recognized' Error in CMD [3 Simple Steps] Aug 23, 2025 am 01:50 AM

IfJavaisnotrecognizedinCMD,ensureJavaisinstalled,settheJAVA_HOMEvariabletotheJDKpath,andaddtheJDK'sbinfoldertothesystemPATH.RestartCMDandrunjava-versiontoconfirm.

See all articles