Monday, March 14, 2016

Interview Question for Experience

Interview Question for Experience / Fresher
=======================================
1) What is Singleton ? and write a program for Singleton Class.

2) What are the conditions to be followed while we go for Singleton class?

3) How to remove the spaces in the given String ?

Note: Should not use String methods, and StringBuffer.
Eg:
Input : Java is easy and interesting
Output: Javaiseasyandinteresting
Use the Best Approach.

solution : String s = "Java is easy and interesting";
for(int i=0 ;i<s.length();i++){
if(s.charAt(i)==' ')

{
System.out.print("");
}
else{
System.out.print(s.charAt(i));
}
}

 
4)  What is daemon thread?

Ans: Daemon thread is a low priority thread. It runs intermittently in the back ground, and takes care of the garbage collection operation for the java runtime system. By calling setDaemon() method is used to create a daemon thread.

5) Write a program to replace the new character in the String.

 You can use anything.
Example:
Enter the String :
Java is easy and interesting.
Enter the character which is to be modified :
a
Enter the new character :
$
Output:
J$v$ is e$sy $nd interesting.

 6) Write a program to remove the duplicate characters. You can use anything.

Eg :
Input : Java is easy and interesting
Output: Jav iseyndtrg
Give the complete program. We will see how many are trying !!!


No comments:

Post a Comment