close nav

close nav

Thread: TOP MNC interview questions for 2+

Forum : Job discussions   28 Apr, 2016
User Image
PraveenKumar2936

Newbie

Joined: 20 Apr, 2017

Points: 100

Threads: 1

Posts: 1

TOP MNC interview questions for 2+

| Quote Date : 28 Apr, 2016    Views:2447    

cognizant : wait() notify() notifyAll() are belongs to Thread then why they are placed on Object Class ................. POLARIS: Diff b/w HashMap and ConcurentHashMap ....................... Birlasoft: 1.write Prime number program with minimum iterations. 2.Tell me count of each alphabet in given String using collections. 3. Scenario where to use 11EndPoint and 12EndPoint in SOAP.

tags: java

Comments

User Image
GKnag123

Newbie

Joined : 26 Nov, 2019

Points : 100

Threads: 2

Posts: 2

Re: TOP MNC interview questions for 2+

Reply Date : 22 May, 2021

char count in String 

public class StringCharCount {
public static void main(String[] args) {
String a="sreimanjavasremanjava";
Map m=new LinkedHashMap<>();
char[] ca=a.toCharArray();
for(int i=0;ca.length>i;i++) {
char x=ca[i];
m.put(x, a.chars().filter(c -> c == x).count());
}
System.out.println(m.toString());
}

}?

User Image
coderninja

Newbie

Joined : 30 Jul, 2018

Points : 100

Threads: 0

Posts: 1

Re: TOP MNC interview questions for 2+

Reply Date : 30 Jul, 2018

I was also preparing for my tech interview. Here is what I found while preparing:
If you are preparing for Facebook programming interview - Facebook

User Image
suraj2940

Newbie

Joined : 20 Apr, 2017

Points : 100

Threads: 0

Posts: 1

Re: TOP MNC interview questions for 2+

Reply Date : 28 Apr, 2016

here wait(),notify(),notifyAll() methods are not belong to Thread class directly ,these methods are provided by Object class only. bcz Object class is a super class for all java class

User Image
PraveenKumar2936

Newbie

Joined : 20 Apr, 2017

Points : 100

Threads: 1

Posts: 1

Re: TOP MNC interview questions for 2+

Reply Date : 28 Apr, 2016

wait() notify() notifyAll() methods works on the locks and locks are associated with Object and not Threads.Here one thread should call the another thread to woke up. In Java, the object itself is the entity that is shared between threads which allows them to communicate with each other. The threads have no specific knowledge of each other and they can run asynchronously. They run and they lock, wait, and notify on the object that they want to get access to. They have no knowledge of other threads and don't need to know their status. They don't need to know that it is thread2 which is waiting for the resource -- they just notify on the resource and whomever it is that is waiting (if anyone) will be notified.

Load More

No More Comments