Ali Java back end online pen test questions and answers

Clamhub's blog 2020-11-06 01:18:12
ali java end online pen


  1. Except for constructors , What other ways to create objects ?

    • adopt new Statement instantiates an object
    • Create objects dynamically through reflection mechanism
    • adopt clone() Create objects
    • Create objects by deserializing
  2. ArrayList list = new ArrayList(20); Medium list Expand it a few times
    answer : Directly specified capacity , No expansion

  3. Which are symmetric encryption algorithms ()
    A DES B AES C DSA D RSA
    answer :A B

  1. What is the result of the following program
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    class HelloA {
    {
    System.out.println("I'm A class");
    }

    static {
    System.out.println("static A");
    }

    public HelloA() {
    System.out.println("HelloA");
    }
    }

    public class HelloB extends HelloA {
    public HelloB() {
    System.out.println("HelloB");
    }

    {
    System.out.println("I'm B class");
    }

    static {
    System.out.println("static B");
    }

    public static void main(String[] args) {
    new HelloB();
    }
    }

answer :

1
2
3
4
5
6
static A
static B
I'm A class
HelloA
I'm B class
HelloB
  1. What is the result of the following program
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    public class Example {
    String str = new String("good");
    char[] ch = {'a', 'b', 'c'};

    public static void main(String args[]) {
    Example ex = new Example();
    ex.change(ex.str, ex.ch);
    System.out.print(ex.str + " and ");
    System.out.print(ex.ch);
    }

    public void change(String str, char ch[]) {
    str = "test ok";
    ch[0] = 'g';
    }
    }

answer :

1
good and gbc
  1. java Of 8 What are the basic data types and the corresponding packaging types in ?
    answer :
    1
    2
    3
    4
    5
    6
    7
    8
    int Integer
    long Long
    boolean Boolean
    char Character
    float Float
    double Double
    byte Byte
    short Short
  1. General explanation of the thread under the several available states
  • newly build (new)
    A new thread object is created
  • Can run (runnable)
    After the thread object is created , Other threads ( such as main Threads ) Called the object's start() Method , The thread in this state is in the runnable thread pool , Waiting to be selected by thread scheduling , obtain cpu Right to use
  • function (running)
    Operational state (runnable) The thread of the cpu Time slice , Execute program code
  • Blocking (block)
    Blocking state refers to the thread giving up for some reason cpu Right to use , That is to say, to give up cpu Time slice of , Stop running temporarily , Until the thread becomes runnable (runnable) state , To have a chance to get cpu Time slice turns to run (running) state .
  • Death (dead)
    Threads run(),main() Method execution ends , Or quit because of an exception run() Method , The thread ends its life cycle .
  1. The running result of the following program ()
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    public class Example {
    public static void main(String[] args) {
    Thread t = new Thread() {
    public void run() {
    pong();
    }
    };
    t.run();
    System.out.println("ping");
    }

    static void pong() {
    System.out.println("pong");
    }
    }

A. pingpong
B. pongping
C. pingpong and pongping It's possible
D. No output

B

1
2
pong
ping
  1. What is a guardian thread ?GC Whether it's a guardian thread ?
    answer : The guardian thread is used to serve user-defined threads , If the user-defined threads are all executed , even main The thread is also executed , that JVM You're going to quit , The guardian thread stops executing .GC It's the guardian thread .
  1. Write down which sort algorithms you know and which ones ? And write one of the book code implementation
    answer : Bubbling , Quick line up , Insert , Stack row
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
public class SearchDemo{
public static void main(String[] args){
int[] arr = new int[]{9,8,7,6,5,4,3,2,1,0};
quickSort(arr,0,arr.length-1);
}
private static void quickSort(int[] arr, int start, int end){
// Boundary check
if(arr==null||arr.length<=0||start>=end){
return;
}
// Get the correct index of the benchmark data
int index = getIndex(arr,start,end);
// Recursively process the data interval around the benchmark data
quickSort(arr,0,index-1);
quickSort(arr,index+1,end);
}
private static int getIndex(int[] arr,int start,int end){
// Define baseline data
int temp = arr[start];
while(start<end){
// Iterate the data from the tail , When the tail data is greater than or equal to the base data , The tail pointer moves forward
while(start<end&&arr[end]>=temp){
end--;
}
// When the tail data is smaller than the base data , Put the tail data at the head pointer position
arr[start] = arr[end];
// Iterate the data from the first node , When the head data is less than or equal to the base data , The head pointer moves back
while(start<end&&arr[start]<=temp){
start++;
}
// When the head data is larger than the base data , Put the header data at the tail pointer position
arr[end] = arr[start];
}
// When the head and tail hands are equal , The correct position of the benchmark data is found
arr[start] = temp;
return start;
}
}

tencent.jpg

版权声明
本文为[Clamhub's blog]所创,转载请带上原文链接,感谢

  1. Linux 所有命令无法使用的解决方法
  2. Java工程师【2020升级版】
  3. Spring Cloud分布式微服务实战,养成应对复杂业务的综合技术能力
  4. Java全栈工程师
  5. Spring Cloud分布式微服务实战,养成应对复杂业务的综合技术能力
  6. 基于Docker搭建Hadoop集群
  7. Java架构师-十项全能:打造高度深度广度兼备的全面技术人才
  8. 前端学习(2734):重读vue电商网站44之使用 echarts
  9. Java Architect decathlon: building comprehensive technical talents with high depth and breadth
  10. Front end learning (2734): Reread the use of echards in Vue e e-commerce website 44
  11. 函数式编程
  12. Functional programming
  13. Common commands of docker
  14. Knowledge of Tomcat and HTTP protocol
  15. Linux调优相关命令汇总
  16. Summary of Linux tuning related commands
  17. 为什么说HashMap是无序的
  18. Why is HashMap unordered
  19. Using Prometheus and grafana to build a monitoring system for hivemq
  20. kafka和zookeeper在k8s集群踩的一些坑
  21. MySQL中整各种int类型的范围和存储大小
  22. Spring Boot常用starter
  23. Range and storage size of various int types in MySQL
  24. Spring boot commonly used starter
  25. Dubbo source code analysis - loadbalance of cluster fault tolerance
  26. Dubbo source code analysis - service call process
  27. Dubbo source code analysis
  28. Dubbo source code analysis - router of cluster fault tolerance
  29. Mybatis source code analysis - built in data source
  30. Mybatis source code analysis - plug in mechanism
  31. [open source] creating docker image does not depend on Linux and docker environment
  32. Specifying default values when objects are deconstructed in JavaScript
  33. The inconsistent results of regular matching in JavaScript
  34. Spring boot 2. X basic tutorial: using redis's publish subscribe function
  35. Spring boot 2. X Basics: how to extend requests and responses in XML format
  36. Several ways to realize general auth authentication in spring boot
  37. Basic tutorial of spring boot 2. X: changes of data script initialization after version 2.5
  38. You must know the high-level Java enumeration features!
  39. Spring boot 2. X basic tutorial: using mongodb
  40. Basic course of spring cloud Alibaba: perfect integration with Dubbo
  41. What about complex mathematical operations such as sin, log and tan in Java?
  42. Initial experience of serverless: rapid development and deployment of a Hello World (Java version)
  43. Spring boot core technology guide for building multi tenant SaaS platform
  44. Self built API gateway architecture design
  45. Let me ask you a question: will this transaction be rolled back?
  46. Interview questions of design pattern
  47. Spring boot 2. X basic tutorial: using @ scheduled to achieve timing tasks
  48. Oracle common background table query