Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

An interview topic: What can go wrong with this code?

Tags:

java

spring

A simple Calculator class that's wired up as a Spring bean in a web application:

public class Calculator { 
    int result; 

    public int addTwoNumbers(int first, int second) { 
        result = first + second; 
        return result; 
    } 
} 

What can potentially go wrong with this?

like image 936
user1933827 Avatar asked Aug 13 '13 08:08

user1933827


People also ask

What are the important topics for coding interview?

This is probably the most important topic for coding interviews and you should prepare it well. At a bare minimum, you should know about the array, linked list, binary trees, binary search tree, self-balanced trees like AVL tree, hash table(or map or dictionaries as known in Java and Python) stack, queue, and graph.


1 Answers

Multi threading problems. By default Spring beans are singletons.

like image 180
WeMakeSoftware Avatar answered Nov 01 '22 20:11

WeMakeSoftware