Morgan Stanley Round-2 | 4-7 years of Experience.

แชร์
ฝัง
  • เผยแพร่เมื่อ 17 ธ.ค. 2024

ความคิดเห็น • 24

  • @exploreviralvideos
    @exploreviralvideos 5 หลายเดือนก่อน

    Second round was good.
    The design question about corona was good, it wil take some time to think in all perspective.

    • @codeAtoZ
      @codeAtoZ  5 หลายเดือนก่อน

      Yes... That question was very new for me

  • @ManishTiwari-or8zt
    @ManishTiwari-or8zt 5 หลายเดือนก่อน +1

    Spring does not manage the complete lifecycle of a prototype bean. We have to clean up prototype-scoped objects and release expensive resources that the prototype beans hold.
    With the help of BeanPostProcessor and DisposalBean interface we have to implmemt and write the clean up code.
    If someone need I can post the code here to show how to do that?

    • @codeAtoZ
      @codeAtoZ  5 หลายเดือนก่อน +1

      Yes sure... We all learn here from each other

    • @ManishTiwari-or8zt
      @ManishTiwari-or8zt 5 หลายเดือนก่อน

      @@codeAtoZ In the last question I think he was trying highlight below scenerio-
      If we are working on with the collection! We should pay attention to not lose the data
      List data = new ArrayList();
      Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8).parallelStream().map(i -> {
      data.add(i); // // AVOID STATEFUL LAMBDA EXPRESSIONS!
      return i;
      }).forEachOrdered(i -> System.out.print(i + " "));
      // 1 2 3 4 5 6 7 8
      // [1, 3, 4, 5, 2] ->missing !
      System.out.println();
      System.out.println(data);
      For an ArrayList object, the JVM internally manages a primitive array
      of the same type. As the size of the dynamic ArrayList grows, a new, larger primitive array is periodically required. If two threads both trigger the array to be resized at the same time, a result can be lost, producing the unexpected value shown here.
      Solution :
      we can make use concurrent stream like ConcurrentHashMap , CopyOnWriteArrayList
      example-
      Stream stream1 = Stream.of("Debjeet", "Roy", "Code With Roy").parallel();
      ConcurrentMap map = stream1
      .collect(Collectors.toConcurrentMap(String::length, k -> k, (s1, s2) -> s1 + "," + s2));

      System.out.println(map); // {3=Roy, 7=Debjeet, 13=Code With Roy}
      System.out.println(map.getClass()); // java.util.concurrent.ConcurrentHashMap

    • @ManishTiwari-or8zt
      @ManishTiwari-or8zt 5 หลายเดือนก่อน

      @@codeAtoZ In the last question I think he was trying highlight below scenerio-
      If we are working on with the collection! We should pay attention to not lose the data
      List data = new ArrayList();
      Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8).parallelStream().map(i -> {
      data.add(i); // // AVOID STATEFUL LAMBDA EXPRESSIONS!
      return i;
      }).forEachOrdered(i -> System.out.print(i + " "));
      // 1 2 3 4 5 6 7 8
      // [1, 3, 4, 5, 2] ->missing !
      System.out.println();
      System.out.println(data);
      For an ArrayList object, the JVM internally manages a primitive array
      of the same type. As the size of the dynamic ArrayList grows, a new, larger primitive array is periodically required. If two threads both trigger the array to be resized at the same time, a result can be lost, producing the unexpected value shown here.
      Solution :
      we can make use concurrent stream like ConcurrentHashMap , CopyOnWriteArrayList
      example-
      Stream stream1 = Stream.of("Debjeet", "Roy", "Code With Roy").parallel();
      ConcurrentMap map = stream1
      .collect(Collectors.toConcurrentMap(String::length, k -> k, (s1, s2) -> s1 + "," + s2));

      System.out.println(map); // {3=Roy, 7=Debjeet, 13=Code With Roy}
      System.out.println(map.getClass()); // java.util.concurrent.ConcurrentHashMap

    • @ManishTiwari-or8zt
      @ManishTiwari-or8zt 5 หลายเดือนก่อน

      @@codeAtoZ Here is the code
      public class PrototypeBeanPostProcessor implements BeanPostProcessor, DisposableBean, ApplicationContextAware {
      private ApplicationContext context;
      List prototypeBeans = new LinkedList();
      public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
      if (context.isPrototype(beanName)) {
      synchronized (prototypeBeans) {
      prototypeBeans.add(bean);
      }
      }
      return bean;
      }
      public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
      this.context = applicationContext;
      }
      public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
      return bean;
      }
      public void destroy() throws Exception {
      synchronized (prototypeBeans) {
      for (Object bean : prototypeBeans) {
      if (bean instanceof DisposableBean) {
      DisposableBean disposable = (DisposableBean)bean;
      try {
      disposable.destroy();
      } catch (Exception e) {
      e.printStackTrace();
      }
      }
      }
      prototypeBeans.clear();
      }
      }
      }

  • @mansoor_333
    @mansoor_333 5 หลายเดือนก่อน +1

    that corona question blew my mind

    • @codeAtoZ
      @codeAtoZ  5 หลายเดือนก่อน

      Yes.. Me too

  • @mayanksharma1491
    @mayanksharma1491 5 หลายเดือนก่อน

    You don't get nervous before/ during interviews?... have you ever got blank during any interview?

    • @codeAtoZ
      @codeAtoZ  5 หลายเดือนก่อน

      Yes I do at times... But I try to back it up with as much nearby answers as possible. If I don't know it completely then I tell clearly.. Sorry I am not aware of it.

  • @babhijit
    @babhijit 5 หลายเดือนก่อน

    Did you get any offer from Morgan Stanley ? What was the position you were interviewed for ?

    • @babhijit
      @babhijit 5 หลายเดือนก่อน

      @@MithuMuni what do you mean ?

    • @codeAtoZ
      @codeAtoZ  5 หลายเดือนก่อน

      Yes

  • @KalyanKumarDheshoju-h2g
    @KalyanKumarDheshoju-h2g 22 ชั่วโมงที่ผ่านมา

    Bad audio quality

  • @ayush5018
    @ayush5018 5 หลายเดือนก่อน

    Hi, was this the final round and have u got the offer?

    • @codeAtoZ
      @codeAtoZ  5 หลายเดือนก่อน

      Yes

  • @mayanksharma1491
    @mayanksharma1491 5 หลายเดือนก่อน

    Approx how much are they offering?

    • @codeAtoZ
      @codeAtoZ  5 หลายเดือนก่อน

      In the range of 25 - 31

  • @Rudar263
    @Rudar263 5 หลายเดือนก่อน

    Did you get selected

    • @codeAtoZ
      @codeAtoZ  5 หลายเดือนก่อน

      Yes

  • @ManishTiwari-or8zt
    @ManishTiwari-or8zt 5 หลายเดือนก่อน

    Here is the code
    public class PrototypeBeanPostProcessor implements BeanPostProcessor, DisposableBean, ApplicationContextAware {
    private ApplicationContext context;
    List prototypeBeans = new LinkedList();
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
    if (context.isPrototype(beanName)) {
    synchronized (prototypeBeans) {
    prototypeBeans.add(bean);
    }
    }
    return bean;
    }
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
    this.context = applicationContext;
    }
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
    return bean;
    }
    public void destroy() throws Exception {
    synchronized (prototypeBeans) {
    for (Object bean : prototypeBeans) {
    if (bean instanceof DisposableBean) {
    DisposableBean disposable = (DisposableBean)bean;
    try {
    disposable.destroy();
    } catch (Exception e) {
    e.printStackTrace();
    }
    }
    }
    prototypeBeans.clear();
    }
    }
    }

  • @abhishekmaahraz3295
    @abhishekmaahraz3295 5 หลายเดือนก่อน

    What was asked in Round 1 ?

    • @codeAtoZ
      @codeAtoZ  5 หลายเดือนก่อน

      I have already uploaded video... See in playlist