# Backend Interview Exam ## 1、How does stack and heap work in java ?                                                                             ## 2、What is Garbage Collection , How it work , Explain one implementation at leaste.                                                                       ## 3、Please Explain Pessimistic Lock and Optimistic Lock.                                                                     ## 4、By previous question, this code is present Pessimistic Lock. make it complete. tip's relpace #1 #2 ```java= /* * table: bank_account * pk: bank_id (int64) * bank_id : bank serial number * * table: product_stock * pk: product_id * product_id: bank serial number * number: it's a product price * * */ public boolean consume(Long bankId, Integer cost){ //locked bank account BankAccount product = query("SELECT * FROM bank_account WHERE bank_id=#{bankId} #1", bankId); int productId = product.productId; if(product.getNumber() > 0) { int updateCnt = update("#2 product_stock " + "SET number=#{cost} WHERE product_id=#{productId}", cost, productId); if(updateCnt > 0){ //update stock num successful return true; } } return false; } ```                                                                                                         ## 5、Given an integer x, return true if x is palindrome integer. An integer is a palindrome when it reads the same backward as forward. For example, 121 is a palindrome while 123 is not. ```java= ```