More than 3000 questions in repository. There are more than 900 unanswered questions. Click here and help us by providing the answer. Have a video suggestion. Click Correct / Improve and please let us know.
Ans. public class BuggyBread {
public static void main(String args[]) {
String str = "we are what we repeatedly Do excellence, then, is not an act but a haBit";
String wordWithFirstCaptalChar = "";
Ans. public class BuggyBread1 {
public static void main(String args[]) {
String str = "we are what we repeatedly Do excellence, then, is not an act but a haBit";
System.out.println(str.split(" ").length);
}
}
Help us improve. Please let us know the company, where you were asked this question :
Ans. public class BuggyBread {
public static void main(String args[]) {
String str = "we are what we repeatedly Do excellence, then, is not an act but a haBit";
Set<String> words = new HashSet();
for(String word:str.split(" ")){
if(words.contains(word)){
System.out.println(word);
} else {
words.add(word);
}
}
}
}
Help us improve. Please let us know the company, where you were asked this question :
Ans. public class BuggyBread {
public static void main(String args[]) {
String str = "we are what we repeatedly Do excellence, then, is not an act but a haBit";
for(String word:str.split(" ")){
if(word.startsWith("w")){
System.out.println(word);
}
}
}
}
Help us improve. Please let us know the company, where you were asked this question :
Ans. public class BuggyBread {
public static void main(String args[]) {
String str = "we are what we repeatedly Do excellence, then, is not an act but a haBit";
for(String word:str.split(" ")){
if(word.contains("ha")){
System.out.println(word);
}
}
}
}
Help us improve. Please let us know the company, where you were asked this question :
Ans. public class BuggyBread {
public static void main(String args[]) {
String str = "we are what we repeatedly Do excellence, then, is not an act but a haBit";
for(String word:str.split(" ")){
if(word.length() > 2 && word.charAt(2) == 'p'){
System.out.println(word);
}
}
}
}
Help us improve. Please let us know the company, where you were asked this question :
Ans. public class BuggyBread {
public static void main(String args[]) {
String str = "we are what we repeatedly Do excellence, then, is not an act but a haBit";
for(String word:str.split(" ")){
if(word.length() > 2 && word.endsWith("it")){
System.out.println(word);
}
}
}
}
Help us improve. Please let us know the company, where you were asked this question :
Ans. public class BuggyBread {
public static void main(String args[]) {
String str1 = "we are what we repeatedly Do excellence, then, is not an act but a haBit";
String str2 = "we are what we repeatedly Do is";
String[] str1Words = str1.split(" ");
String[] str2Words = str2.split(" ");
Ans. public class BuggyBread {
public static void main(String args[]) {
String str1 = "we are what we repeatedly Do excellence, then, is not an act but a haBit";
String str2 = "we are what we repeatedly Do is";
String[] str1Words = str1.split(" ");
String[] str2Words = str2.split(" ");
Ans.
public class BuggyBread {
public static void main(String args[]) {
String str = "we are what we repeatedly Do excellence, then, is not an act but a haBit";
Set<String> wordSet = new LinkedHashSet(); // Using Linked Hash Set as we would like to retrieve words in the insertion order
Ans. public class BuggyBread {
public static void main(String args[]) {
String str = "we are what we repeatedly do excellence then is not an act but a haBit";
Set<String> wordSet = new TreeSet(); // Using Linked Hash Set as we would like to retrieve words in the insertion order
Program should set the start and end index and then display this accordingly. For example the above pattern is for displayNumbersBetween(2,10) and following is for displayNumbersBetween(5,7)
Ans. HashTable locks the complete collection to provide synchronization whereas ConcurrentHashMap only locks segments to achieve synchronization and hence better efficient and faster.
Help us improve. Please let us know the company, where you were asked this question :
Ans. Yes, they both aim at providing synchronized access to the Map collection. The only difference is in their implementation. ConcurrentHashMap came after HashTable and hence technically more efficient as it doesn't lock the complete map while accessing it.
Help us improve. Please let us know the company, where you were asked this question :
Ans. Both are creational design patterns but singleton facilitates in creation and reuse of single object whereas Factory deals with creation of multiple objects.
Help us improve. Please let us know the company, where you were asked this question :