• done flexton vendor 的screening


    // // Session Details:

    // // Overall Duration of Session: 50 Minutes

    // // problem solving
    // // core java
    // // spring and rest services

    // // You are allowed to use any IDE (NetBeans, Eclipse, IntelliJ, Visual Studio) to develop the code for the question asked.
    // // Then you can copy the code to this page.

    // // Anywhere if you feel that you are not comfortable with the question you can update me and we can skip the question or section.

    // // Candidate Name: Yue
    // // Recruiter Name: Amit

    // // Question:

    // // Given an array of integers, return an array of integers which contains
    // // [1st integer, Sum of next 2 integers (2nd, 3rd), Sum of next 3 integers (4th, 5th, 6th)]

    // // Input size n
    // // [1,6,8,5,9,4,7,2]
    // // Output size m
    // // [1,14,18,9]

    // // Solution:

    // // import java.io.*;
    // // import java.util.*;

    // // //iteration

    // // class MyCode {
    // // public static void main (String[] args) {
    // // int[] n = {1,6,8,5,9,4,7,2,3,4,5,6,7,8};
    // // int[] m = {1,14,18,9};
    // // //initiate a result array
    // // ArrayList<Integer> result = new ArrayList<Integer>();
    // // int startIndex = 0;
    // // int count_of_integers = 1;
    // // int resultElement = 0;

    // // // //1st integer
    // // // result[0] = n[0];
    // // // //Sum of next 2 integers (2nd, 3rd)
    // // // result[1] = n[1] + n[2];
    // // // //Sum of next 3 integers (4th, 5th, 6th)
    // // // result[2] = n[3] + n[4] + n[5];

    // // //for loop
    // // //count_of_integers = 1,2,3,4...
    // // //execute until startIndex reaches to end

    // // while (startIndex <= n.length) {
    // // for (int i = startIndex; i < startIndex + count_of_integers; i++) {
    // // System.out.println("startIndex = " + startIndex);
    // // System.out.println("count_of_integers = " + count_of_integers);
    // // System.out.println("i = " + i);
    // // System.out.println("n[i] = " + n[i]);
    // // resultElement += n[i];
    // // System.out.println("resultElement = " + resultElement);
    // // System.out.println("");
    // // }
    // // result.add(resultElement);
    // // startIndex = startIndex + count_of_integers;
    // // count_of_integers++;
    // // resultElement = 0;
    // // }


    // // //use for loop to print
    // // for (int i = 0; i < result.size(); i++) {
    // // System.out.println(result.get(i));
    // // }
    // // System.out.println();
    // // }
    // // }

    // // Core Java Section:

    // // Question:

    // // Make the changes inside the class to make it thread safe singleton:

    // // class DemoStudent {

    // // private String name;
    // // private List<String> courses;

    // // public DemoStudent() {

    // // }

    // // public String getName() {
    // // return name;
    // // }

    // // public void setName(String name) {
    // // this.name = name;
    // // }

    // // public List<String> getCourses() {
    // // return courses;
    // // }

    // // public void setCourses(List<String> courses) {
    // // this.courses = courses;
    // // }
    // // }

    // // Solution:

    // // public class DemoStudentExample {
    // // //main method
    // // public static void main(String[] args) {
    // // //only have a object
    // // DemoStudent student = new DemoStudent();
    // // //set info name...
    // // }
    // // }

     

    参考答案:https://medium.com/@cancerian0684/singleton-design-pattern-and-how-to-make-it-thread-safe-b207c0e7e368


    // Question:

    // Total number of threads including the main thread for the code mentioned:

    // import java.util.concurrent.ExecutorService;
    // import java.util.concurrent.Executors;

    // public class FixedThreadPool {

    // public static void main(String[] args) {

    // ExecutorService executorService = Executors.newFixedThreadPool(4);

    // for(int i=0;i<7;i++){

    // Thread thread =new Thread(()->{

    // System.out.println("T:1:"+Thread.currentThread().getName());

    // });

    // thread.start();

    // }

    // for(int i=0;i<10;i++){

    // Thread thread=new Thread(()->{

    // System.out.println("T:2:"+Thread.currentThread().getName());

    // });

    // executorService.execute(thread);


    // }


    // }

    // }

    // Solution:

    // 4 Threads

    参考:

    用System.out.println(Thread.activeCount());来打印

    Spring and Rest Services:

    Difference between @Controller and @Restcontroller?


    // Solution:
    return type
    @Controller: can return to a page using some method, can also return json..
    @Restcontroller:can't return to a jsp page

  • 相关阅读:
    猜数字游戏
    发红包程序
    实现微信摇一摇部分功能
    计算1+1/2+1/3+....+1/100的值
    约瑟夫问题
    简易计时器
    简易学生管理系统
    文件加密解密
    分鱼问题
    分橘子问题
  • 原文地址:https://www.cnblogs.com/immiao0319/p/15126496.html
Copyright © 2020-2023  润新知