Search Interview Questions | 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. |
|
| ||||
Interview Questions and Answers - Order By Newest | ||||
| ||||
Ans. http://javasearch.buggybread.com/CodeSnippets/searchCodeSamples.php?&category=code&searchOption&keyword=964 | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  builder design pattern  builder pattern  code  coding intermediate | ||||
| ||||
Ans. http://javasearch.buggybread.com/CodeSnippets/searchCodeSamples.php?&category=code&searchOption&keyword=965 | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  constructor overloading  code  coding Asked in 2 Companies basic | ||||
| ||||
Ans. http://javasearch.buggybread.com/CodeSnippets/searchCodeSamples.php?&category=code&searchOption&keyword=963 | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  ternary operator  code  coding | ||||
| ||||
Ans. http://javasearch.buggybread.com/CodeSnippets/searchCodeSamples.php?&category=code&searchOption&keyword=952 | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  set  collections  sorting  treeset  code  coding | ||||
| ||||
Ans. As Class B has been declared abstract , we can either implement any of these methods and just declare rest of them abstract. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  interfaces  abstract classes  code  coding | ||||
Try 2 Question(s) Test | ||||
| ||||
Ans. false false | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  object equality  code  coding   frequent | ||||
| ||||
Ans. There are many problems with the code 1. The method returns void and hence we cannot return any integer value. 2. We cannot return more than one value from a method. 3. The code after 1st Return statement is unreachable. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  coding  code | ||||
| ||||
Ans. http://www.programmingsimplified.com/java/source-code/java-program-armstrong-number | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  program  code  coding  armstrong number Asked in 1 Companies | ||||
| ||||
Ans. package com.string; import java.util.Scanner; public class String13 { public static void main(String[] args) { System.out.println("Enter Sentence"); Scanner sc=new Scanner(System.in); String sentence=sc.nextLine(); String[] words=sentence.split(" "); int count=0; for (String string : words) { string.trim(); if(!string.equals("")){ count++; System.out.println(string " " count); } } } } | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  code  coding Asked in 1 Companies | ||||
| ||||
Ans. int[] arr = {1,-1,2,-3,3,-4,4,5,6,-5,-6,-7,-8,8,9,-9}; List positiveNumbers = new ArrayList<>(); List negativeNumbers = new ArrayList<>(); for(int i = 0; i < arr.length(); i ){ if(I < 0){ negativeNumbers.add(i); } else { positiveNumbers.add(i); } } System.out.println("Positive Numbers:" + positiveNumbers); System.out.println("Negative Numbers:" + negativeNumbers); | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  code  program  coding Asked in 1 Companies | ||||
| ||||
Ans. https://www.tutorialspoint.com/javaexamples/thread_procon.htm | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  coding  code Asked in 1 Companies | ||||
Frequently asked in high end product companies. | ||||
| ||||
Ans. https://www.geeksforgeeks.org/lru-cache-implementation/ | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  cache  LRU cache  coding  code Asked in 10 Companies intermediate | ||||
| ||||
Ans. It will print 4 because member elements of an interface are implicitly static and hence the concept of overriding doesn't work. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  interfaces  coding  code  extending interfaces  diamond interfaces Asked in 1 Companies intermediate | ||||
| ||||
Ans. 10 | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  interfaces  coding  code intermediate | ||||
| ||||
Ans. public class Class{ public static void main(String[] args){ List<Integer> collector = new ArrayList(); Scanner scanner = new Scanner(System.in); int x = scanner.nextInt(); while(x != 0){ collector.add(x); x = scanner.nextInt(); } System.out.println(collector.stream().collect(Collectors.averagingInt(p->((Integer)p)))); } } | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  coding  code  collector  streams  Collectors.average Asked in 1 Companies | ||||
| ||||
Ans. public class Class{ public static void main(String[] args){ String string1 = "Hello I am Jack. I live in United States. I live in california state."; String string2 = "I live in"; if(string1.indexOf(string2) >= -1){ System.out.println("string2 is sub string of string1"); } else { System.out.println("string2 is not sub string of string1"); } } } | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  string  coding  code | ||||
| ||||
Ans. public class Class{ public static void main(String[] args){ String string1 = "Hello I am Jack. I live in United States. I live in california state."; String string2 = "I live in"; int startIndex = 0; int endIndex = string1.length()-1; int countNoOfOccurences = 0; String remainingString = string1; while(startIndex < endIndex){ if(remainingString.indexOf(string2) != -1){ countNoOfOccurences++; startIndex = remainingString.indexOf(string2) + string2.length(); remainingString = remainingString.substring(startIndex); } else { break; } } System.out.println(countNoOfOccurences); } } | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  string  code  coding Asked in 2 Companies | ||||
| ||||
Ans. public class Class { public static void main(String[] args) { String str = "mallam"; String firstHalf = str.substring(0, str.length() / 2); String secondHalf = str.substring(str.length() / 2); if (firstHalf.equals(new StringBuilder(secondHalf).reverse().toString())) { System.out.println("It's a Colidrome"); } else { System.out.println("It's not a Colidrome"); } } } | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  Colidrome  String  Code  Coding Asked in 1 Companies | ||||
| ||||
Ans. public class Class{ public static void main(String[] args){ for(int i=1;i<= 100;i++){ if(i%3 == 0){ if(i%5 == 0){ System.out.println("FizzBuzz"); } System.out.println("Fizz"); } else if(i%5 == 0){ System.out.println("Buzz"); } else { System.out.println(i); } } } } | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  code  coding Asked in 2 Companies | ||||
| ||||
Ans. public class BuggyBread { public static void main(String args[]) { Map<Character, Integer> countMap = new HashMap(); String str = "hello world"; for (char character : str.toCharArray()) { if (countMap.containsKey(character)) { countMap.put(character, countMap.get(character) + 1); } else { countMap.put(character, 1); } } System.out.println(countMap); } } | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  String  Code  Coding  Character Asked in 1 Companies | ||||
| ||||
Ans. public class BuggyBread{ public static void main (String args[]) { Set<Character> set = new HashSet(); Set<Character> setWithDuplicateChar = new HashSet(); String str = "hello world"; for(char character: str.toCharArray()){ if(set.contains(character)){ setWithDuplicateChar.add(character); } else { set.add(character); } } System.out.println(setWithDuplicateChar); } } | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  String  Code  Coding | ||||
| ||||
This question was recently asked at 'Compro Technologies'.This question is still unanswered. Can you please provide an answer. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  code.coding.0 and cross game Asked in 1 Companies | ||||
| ||||
Ans. int arr[]={1,3,5,6,4,8,9,2,10}; Arrays.sort(); System.out.println(arr[arr.length-1]); | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  code  coding  find in array Asked in 1 Companies | ||||
| ||||
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(" "); Set str1WordsSet = new HashSet(); for(String word:str1Words){ str1WordsSet.add(word); } for(String word:str2Words){ if(str1WordsSet.contains(word)){ System.out.println(word); } } } } | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  String  coding  code | ||||
| ||||
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(" "); Set str1WordsSet = new HashSet(); for(String word:str1Words){ str1WordsSet.add(word); } int commonWordsCount = 0; for(String word:str2Words){ if(str1WordsSet.contains(word)){ commonWordsCount++; } } System.out.println(commonWordsCount); } } | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  String  coding  code | ||||
| ||||
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 for(String word: str.split(" ")){ wordSet.add(word); } for(String word: wordSet){ System.out.print(word); System.out.print(" "); } } } | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  String  coding  code Asked in 1 Companies basic | ||||
| ||||
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 for(String word: str.split(" ")){ wordSet.add(word); } for(String word: wordSet){ System.out.print(word); System.out.print(" "); } } } | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  String  coding  code | ||||
| ||||
Ans. public class BuggyBread { public static void main(String args[]) { displayNumbersBetween(2,10); } private static void displayNumbersBetween(int start,int end){ if(start > end){ return ; } else { System.out.println(start); displayNumbersBetween(start+1,end); } } } | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  recursion  code  coding | ||||
| ||||
Ans. public class BuggyBread { public static void main(String args[]) { displayNumbersBetween(5,7); } private static void displayNumbersBetween(int start,int end){ if(start > end){ return ; } else { for(int x=1;x<=start;x++){ System.out.print("*"); } System.out.println(""); displayNumbersBetween(start+1,end); } } } | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  recursion  code  coding | ||||
| ||||
Ans. public class BuggyBread { public static void main(String args[]) { for(int x=1;x<=10;x++){ for(int y=1;y<=x;y++){ System.out.print("*"); } System.out.println(""); } } } | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  coding  code | ||||