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
    Copy after login

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

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.

Undress AI Tool

Undress AI Tool

Undress images for free

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)

Hot Topics

Java Tutorial
1664
14
PHP Tutorial
1268
29
C# Tutorial
1246
24
Break or return from Java 8 stream forEach? Break or return from Java 8 stream forEach? Feb 07, 2025 pm 12:09 PM

Java 8 introduces the Stream API, providing a powerful and expressive way to process data collections. However, a common question when using Stream is: How to break or return from a forEach operation? Traditional loops allow for early interruption or return, but Stream's forEach method does not directly support this method. This article will explain the reasons and explore alternative methods for implementing premature termination in Stream processing systems. Further reading: Java Stream API improvements Understand Stream forEach The forEach method is a terminal operation that performs one operation on each element in the Stream. Its design intention is

PHP: A Key Language for Web Development PHP: A Key Language for Web Development Apr 13, 2025 am 12:08 AM

PHP is a scripting language widely used on the server side, especially suitable for web development. 1.PHP can embed HTML, process HTTP requests and responses, and supports a variety of databases. 2.PHP is used to generate dynamic web content, process form data, access databases, etc., with strong community support and open source resources. 3. PHP is an interpreted language, and the execution process includes lexical analysis, grammatical analysis, compilation and execution. 4.PHP can be combined with MySQL for advanced applications such as user registration systems. 5. When debugging PHP, you can use functions such as error_reporting() and var_dump(). 6. Optimize PHP code to use caching mechanisms, optimize database queries and use built-in functions. 7

PHP vs. Python: Understanding the Differences PHP vs. Python: Understanding the Differences Apr 11, 2025 am 12:15 AM

PHP and Python each have their own advantages, and the choice should be based on project requirements. 1.PHP is suitable for web development, with simple syntax and high execution efficiency. 2. Python is suitable for data science and machine learning, with concise syntax and rich libraries.

PHP vs. Other Languages: A Comparison PHP vs. Other Languages: A Comparison Apr 13, 2025 am 12:19 AM

PHP is suitable for web development, especially in rapid development and processing dynamic content, but is not good at data science and enterprise-level applications. Compared with Python, PHP has more advantages in web development, but is not as good as Python in the field of data science; compared with Java, PHP performs worse in enterprise-level applications, but is more flexible in web development; compared with JavaScript, PHP is more concise in back-end development, but is not as good as JavaScript in front-end development.

PHP vs. Python: Core Features and Functionality PHP vs. Python: Core Features and Functionality Apr 13, 2025 am 12:16 AM

PHP and Python each have their own advantages and are suitable for different scenarios. 1.PHP is suitable for web development and provides built-in web servers and rich function libraries. 2. Python is suitable for data science and machine learning, with concise syntax and a powerful standard library. When choosing, it should be decided based on project requirements.

Java Program to Find the Volume of Capsule Java Program to Find the Volume of Capsule Feb 07, 2025 am 11:37 AM

Capsules are three-dimensional geometric figures, composed of a cylinder and a hemisphere at both ends. The volume of the capsule can be calculated by adding the volume of the cylinder and the volume of the hemisphere at both ends. This tutorial will discuss how to calculate the volume of a given capsule in Java using different methods. Capsule volume formula The formula for capsule volume is as follows: Capsule volume = Cylindrical volume Volume Two hemisphere volume in, r: The radius of the hemisphere. h: The height of the cylinder (excluding the hemisphere). Example 1 enter Radius = 5 units Height = 10 units Output Volume = 1570.8 cubic units explain Calculate volume using formula: Volume = π × r2 × h (4

PHP's Impact: Web Development and Beyond PHP's Impact: Web Development and Beyond Apr 18, 2025 am 12:10 AM

PHPhassignificantlyimpactedwebdevelopmentandextendsbeyondit.1)ItpowersmajorplatformslikeWordPressandexcelsindatabaseinteractions.2)PHP'sadaptabilityallowsittoscaleforlargeapplicationsusingframeworkslikeLaravel.3)Beyondweb,PHPisusedincommand-linescrip

PHP: The Foundation of Many Websites PHP: The Foundation of Many Websites Apr 13, 2025 am 12:07 AM

The reasons why PHP is the preferred technology stack for many websites include its ease of use, strong community support, and widespread use. 1) Easy to learn and use, suitable for beginners. 2) Have a huge developer community and rich resources. 3) Widely used in WordPress, Drupal and other platforms. 4) Integrate tightly with web servers to simplify development deployment.

See all articles