Saturday, 26 November 2016

interview experiance

NC
26 Nov 2016

Which company you are working
why do yolu want to change the comapny, why not ibm or amdocs why this one ?
Then there is technical paper which has many question, he

wants a discussion on them
1. Integer i1=123
Integer i2=123
i1==i2

2. public int caculate(){
return true ? null:0;
}
3. String s1="abc";
String s2="abc";
s1==s2

4. String s = "One"+1+2+"Two"

5.     public static int me(){
         return true ? null:0;
    }

6.
Then implement the code to reverse the string, very large string

Design patterns, builder, when to use,
Which design pattern sping is implemented, base-face ???

how will you avoid SQL injection  ? in details full length

In one line difference between REST and SOAP

which datatypes are supported in REST

Two applications, which will you preffered to send Data  ?>
JSON or XML

What is Enterprise Java  Edition ?

Why String class is immutable ?

Wednesday, 23 November 2016

weakhashmap

MyKey key=new MyKey(3);
MyValue value=new MyValue(3);
HashMap hashMap=new HashMap<>(); 
hashMap.put(key, value); 
key=null; 
System.gc(); 
System.out.println(hashMap.get(new MyKey(3))); 


 key=new MyKey(3); 
WeakHashMap hashMap2=new WeakHashMap<>(); 
hashMap2.put(key, value); 
key=null; 
TimeUnit.SECONDS.sleep(5); 
System.gc(); 
System.out.println(hashMap2.get(new MyKey(3)));

MyValue [v=3]
null

use of xor

Saturday, 19 November 2016

test

Note from Cracking the coding Interview
How to improving Coding skills
These are the questions you actually want to know. Here are a few ideas of questions that are valuable to many candidates:
1. “How much of your day do you spend coding?”
2. “How many meetings do you have every week?”
3. “What is the ratio of testers to developers to product managers? What is the interaction like? How does project planning happen on the team?”


These questions are designed to demonstrate your deep knowledge of programming or technologies.

  1.  “I noticed that you use technology X. How do you handle problem Y?” 
  2. “Why did the product choose to use the X protocol over the Y protocol? I know it has bene!ts like A, B, C, but many companies choose not to use it because of issue D.

               
Fail fastfail safeAge
immediately throw ConcurrentModificationException if a collection is modified while iterating over it Fail-Safe iterators don’t throw any exceptions if a collection is modified while iterating over it 50
operate on the clone of the collection, not on the actual collection 94
When collection is structuraly modified (add, remove, update) by its instance, Accepted by iterator's remove method Doe 80
use modCount ConcurrentHashMap 80


List list = new ArrayList(Arrays.asList("a","b","c","d","e"));
Iterator i = list.iterator();
while (i.hasNext()) {
//i.remove(); //IllegalStateException
System.out.println(i.next());
i.remove(); // OK

//list.remove("d"); // Always throw concurrent modification exception
//list.add("f"); // Always throw concurrent modification exception
}

h1b good article from nytimes


Use of Logical shift
 right-shift ( >> 1 ) is equivalent to  a /= 2
left shift ( << 1) is equivalent  a=a*2


ii >> 1i >> 2i >> 3
1000
2100
3100
4210
5210
6310
7310
8421
9421
ii << 1i << 2i << 3
1248
24816
361224
481632
5102040
6122448
7142856
8163264
9183672


Spring Controller is singleton and class level parameters are shared among all the request

for each new request a new thread is created