Wednesday, 14 September 2016

Write a program in JAVA which accept a String address from user and return true if the address contains pincode at any position and return false if the address does not contain any pincode.

This is another tricky question for the job seekers. Concept is pretty simple here. You have to write a boolean method which will validate the address and return true if it finds PINCODE and return false it does not find.

I am using regular expression to solve this approach.

Sample input:
61 B, Palm Avenue, Joy Bijoy Apartment, 1st Floor, Flat No 1D, West Bengal

Output:
Pincode does not exist.

Sample Input:
61 B, Palm Avenue, Joy Bijoy Apartment, 1st Floor, Flat No 1D, West Bengal 700112

Output:
Pincode exist.

Sample Input:
61 B, Palm Avenue, Joy Bijoy Apartment, West Bengal 700112, 1st Floor, Flat No 1D

Output:
Pincode Exist.

Implemented code:




Sample Output 1:


Sample Output 2:


Sample Output 3:


Tuesday, 13 September 2016

Write a method in Java which accepts a String argument and returns a number of words in it

One of my friends asked me to solve this. User will give the input through console and our program will show the total no of words present in the string.
Input: 
hello, Sourin whats up,what are you doing
Output:
No of words: 8

Implemented code:



Sample Output:



Producer Consumer Problem using Multithreading in JAVA

One of my  friends had faced this problem during his interview in Subex. Concept is pretty simple here. We have two threads here. Consumer thread can not consume anything unless and until Producer Thread has produced.

There are couple of ways to solve this problem. Here I am using volatile Stack to solve this.

Implemented Code:







Sample Output:





Sunday, 4 September 2016

Write a program in JAVA to print EVEN and ODD numbers within a range using multithreading.

I was asked this question in Nokia Networks. You have to write a Java multithreaded program which will take the input range from user and print those numbers as Even or Odd. 


Sample example:
Enter input range: 5
Odd: 1
Even: 2
Odd: 3
Even: 4
Odd: 5

Here is the implemented code:



























Sample Output:



Saturday, 3 September 2016

Java Interview Coding Challanges

 Java Coding is an integral part of JAVA INTERVIEW. If you want to shape your career as a JAVA developer, you will be facing most of java coding challenges which I am going to discuss here. I have faced all of these questions during my java interview with different companies like British Telecom, Edge Verbe, JCPenney, GE, Accenture etc..

I will discuss all of these question one after another in my upcoming blog. I hope that will help you out. To solve these, you should have a basic knowledge on JAVA.

Thanks for following my blog. Happy learning.!!!