Search Interview Questions | ![]() ![]() Click here and help us by providing the answer. ![]() Click Correct / Improve and please let us know. |
|
| ||||
Interview Questions and Answers - Order By Newest | ||||
![]() ![]() | ||||
| ||||
![]() | ||||
![]() | ||||
![]() ![]() ![]() ![]() | ||||
| ||||
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); } } | ||||
![]() | ||||
![]() ![]() ![]() ![]() | ||||
| ||||
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); } } | ||||
![]() | ||||
![]() ![]() ![]() | ||||
| ||||
Ans. public class BuggyBread{ public static void main (String args[]) { for(int counter=1;counter<=100;counter++){ if(counter % 5 == 0){ System.out.println(counter); } } } } | ||||
![]() | ||||
![]() ![]() ![]() | ||||
| ||||
Ans. public class BuggyBread1{ public static void main (String args[]) { for(int x=1;x<=100;x++){ for(int y=1;y <= x;y++){ System.out.println(x); } } } } | ||||
![]() | ||||
![]() ![]() ![]() | ||||
| ||||
Ans. public class BuggyBread{ public static void main (String args[]) { for(int x=1;x<=100;x++){ for(int y=1;y <= x;y++){ System.out.print(y); } System.out.println(" "); } } } | ||||
![]() | ||||
![]() ![]() ![]() | ||||
| ||||
![]() | ||||
![]() | ||||
![]() ![]() ![]() ![]() | ||||
| ||||
Ans. Performance of a system doesn't solely rely on size of processor or it's communication size. It should also be compatible with other resources like memory, storage etc. Moreover it makes no sense to have 64 bit systems when there is hardly any software than can run on 64 bit system. | ||||
![]() | ||||
![]() ![]() ![]() | ||||
| ||||
![]() | ||||
![]() | ||||
![]() ![]() ![]() ![]() | ||||
| ||||
Ans. public class BuggyBread { public static void main(String args[]) { for(int x=10;x<100;x++){ int tensDigit = x/10; int unitDigit = x%10; if((tensDigit+unitDigit)*3 == x){ System.out.println(x); } } } } | ||||
![]() | ||||
![]() ![]() ![]() ![]() | ||||
| ||||
Ans. class A { public void test() { System.out.println("Class A Test"); } } class B extends A { public void test() { System.out.println("Class B Test"); } } | ||||
![]() | ||||
![]() ![]() ![]() ![]() | ||||
| ||||
Ans. class A { public void test() { System.out.println("Class A Test"); } } class B extends A { public void test() { System.out.println("Class B Test"); } public static void main(String[] args){ A a = new B(); a.test(); // will print Class B Test } } | ||||
![]() | ||||
![]() ![]() ![]() ![]() | ||||
| ||||
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 longestWord = ""; str = str.replaceAll(",",""); str = str.replaceAll(";",""); str = str.replaceAll("/.",""); for(String word: str.split(" ")){ if(word.length() > longestWord.length()){ longestWord = word; } } System.out.println(longestWord); } } | ||||
![]() | ||||
![]() ![]() ![]() | ||||
| ||||
Ans. public class BuggyBread { public static void main(String args[]) { Map<String,Integer> wordLength = new HashMap(); String str = "We are what we repeatedly do; excellence, then, is not an act but a habit."; String longestWord = ""; str = str.replaceAll(",",""); str = str.replaceAll(";",""); str = str.replaceAll("/.",""); str = str.toLowerCase(); for(String word: str.split(" ")){ if(wordLength.containsKey(word)){ wordLength.put(word, wordLength.get(word).intValue() + 1); } else { wordLength.put(word, 1); } } for(Map.Entry<String, Integer> entry:wordLength.entrySet()){ if(entry.getValue().intValue() > 1){ System.out.println(entry.getKey()); } } } } | ||||
![]() | ||||
![]() ![]() ![]() | ||||
| ||||
Ans. public class BuggyBread1 { public static void main(String args[]) { Map<String,Integer> wordLength = new HashMap(); String str = "We are what we repeatedly do; excellence, then, is not an act but a habit"; String longestWord = ""; str = str.replaceAll(",",""); str = str.replaceAll(";",""); str = str.toLowerCase(); for(String word: str.split(" ")){ wordLength.put(word, word.length()); } for(Map.Entry<String, Integer> entry:wordLength.entrySet()){ if(entry.getValue().intValue() > 5){ System.out.println(entry.getKey()); } } } } | ||||
![]() | ||||
![]() ![]() ![]() | ||||
| ||||
Ans. public class BuggyBread { public static void main(String args[]) { Map<String,Integer> wordLength = new HashMap(); String str = "We are what we repeatedly do; excellence, then, is not an act but a habit"; str = str.replaceAll(",",""); str = str.replaceAll(";",""); str = str.toLowerCase(); for(String word: str.split(" ")){ wordLength.put(word, word.length()); } List<Map.Entry<String, Integer>> list = new LinkedList<Map.Entry<String, Integer>>( wordLength.entrySet() ); Collections.sort( list, new Comparator<Map.Entry<String, Integer>>() { public int compare( Map.Entry<String, Integer> o1, Map.Entry<String, Integer> o2 ) { return (o1.getValue()).compareTo( o2.getValue() ); } } ); int countWords = 1; for(Map.Entry<String, Integer> entry:list){ if(countWords <= 3){ System.out.println(entry.getKey()); } countWords++; } } } | ||||
![]() | ||||
![]() ![]() ![]() | ||||
| ||||
Ans. public class BuggyBread { public static void main(String args[]) { Map<String,Integer> wordLength = new HashMap(); String str = "We are what we repeatedly do; excellence, then, is not an act but a habit"; str = str.replaceAll(",",""); str = str.replaceAll(";",""); str = str.toLowerCase(); for(String word: str.split(" ")){ wordLength.put(word, word.length()); } List<Map.Entry<String, Integer>> list = new LinkedList<Map.Entry<String, Integer>>( wordLength.entrySet() ); Collections.sort( list, new Comparator<Map.Entry<String, Integer>>() { public int compare( Map.Entry<String, Integer> o1, Map.Entry<String, Integer> o2 ) { return (o1.getValue()).compareTo( o2.getValue() ) * -1; } } ); int countWords = 1; for(Map.Entry<String, Integer> entry:list){ if(countWords <= 3){ System.out.println(entry.getKey()); } countWords++; } } } | ||||
![]() | ||||
![]() ![]() ![]() | ||||
| ||||
Ans. public class BuggyBread { public static void main(String args[]) { Map<String,Integer> wordLength = new HashMap(); String str = "We are what we repeatedly do; excellence, then, is not an act but a habit"; for(String word: str.split(" ")){ wordLength.put(word, word.length()); } List<Map.Entry<String, Integer>> list = new LinkedList<Map.Entry<String, Integer>>( wordLength.entrySet() ); Collections.sort( list, new Comparator<Map.Entry<String, Integer>>() { public int compare( Map.Entry<String, Integer> o1, Map.Entry<String, Integer> o2 ) { return (o1.getValue()).compareTo( o2.getValue() ) * -1; } } ); System.out.println(list); } } | ||||
![]() | ||||
![]() ![]() ![]() | ||||
| ||||
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"; System.out.println(str.replaceAll(" ", "")); } } | ||||
![]() | ||||
![]() ![]() ![]() | ||||
| ||||
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[] splittedString = str.split(" "); for(String word: splittedString){ word = word.trim(); if(!word.equals("")){ System.out.print(word.trim()); System.out.print(" "); } } } } | ||||
![]() | ||||
![]() ![]() ![]() | ||||
| ||||
Ans. CREATE TABLE TABLE_NAME ( ID NUMBER PRIMARY KEY, NAME VARCHAR(50) NOT NULL, ); INSERT INTO TABLE_NAME(ID, NAME) VALUES(1, "Abc"); | ||||
![]() | ||||
![]() ![]() ![]() ![]() | ||||
| ||||
Ans. 1. Object Level Reuse - private methods 2. Class Level Reuse - static methods 3. package level Reuse - default methods 4. Application Level Reuse - Classes 5. Multiple Applications Level Reuse - Libraries , Frameworks | ||||
![]() | ||||
![]() ![]() ![]() | ||||
| ||||
Ans. https://qr.ae/TWK2Ok | ||||
![]() | ||||
![]() ![]() ![]() | ||||
| ||||
Ans. boolean byte char double float int long short void | ||||
![]() | ||||
![]() ![]() ![]() ![]() ![]() | ||||
| ||||
Ans. && - AND || - OR ! - LOGICAL NOT | ||||
![]() | ||||
![]() ![]() ![]() ![]() | ||||
| ||||
Ans. public class BuggyBread { public static void main(String args[]) { int number = 7; boolean perfectNumber = true; for(int x=2;x<number;x++){ if(number % x == 0){ perfectNumber = false; } } if(perfectNumber){ System.out.println("Perfect Number"); } else { System.out.println("Not a Perfect Number"); } } } | ||||
![]() | ||||
![]() ![]() ![]() | ||||
| ||||
Ans. public class BuggyBread { public static void main(String args[]) { for(int number=1;number < 100;number++){ boolean perfectNumber = true; for(int x=2;x<number;x++){ if(number % x == 0){ perfectNumber = false; } } if(perfectNumber){ System.out.println(number); } } } } | ||||
![]() | ||||
![]() ![]() ![]() | ||||
| ||||
Ans. Introduced with java 8 , Method References help us to point to methods by their name. A method references is described using :: symbol | ||||
![]() | ||||
![]() ![]() ![]() | ||||
| ||||
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"; int count = 1; for(Character c: str.toCharArray()){ if(Character.isUpperCase(c)){ break; } else { count++; } } System.out.println(count); } } | ||||
![]() | ||||
![]() ![]() ![]() | ||||
| ||||
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"; int count = 0; for(Character c: str.toCharArray()){ if(Character.isUpperCase(c)){ count++; } } System.out.println(count); } } | ||||
![]() | ||||
![]() ![]() ![]() | ||||
![]() ![]() | ||||