Interview Questions and Answers for 'A' | Search Interview Question - javasearch.buggybread.com
Javasearch.buggybread.com

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.
Label / Company      Label / Company / Text

   



Interview Questions and Answers - Order By Newest

   next 30
 Q1411. Describe a project that didn't go well and what did you learn from it? General
 This question was recently asked at 'ZE PowerGroup'.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          Asked in 1 Companies


 Q1412. Write a Program to print count of each character in a String.Core Java
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


 Q1413. Write a Program to only print characters that have occured more than once in a StringCore Java
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


 Q1414. Write a Program to print all numbers till 100 that are divisible by 5Core Java
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);
      }
   }
}
}

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     


 Q1415. Write a Program to print 1 (1 time) , 2 ( 2 times ) and so on till 100.Core Java
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);
      }
   }
}
}

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     


 Q1416. Write a Program to print series like

1
12
123
1234
12345

till 100
Core Java
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("
");
   }
}
}

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     


 Q1417. Write a program for 0 and cross games? Core Java
 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


 Q1418. why should one we use 32 bit system instead of 64 bit?Operating System
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.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     


 Q1419. Given a sorted array, write a program to check if two elements sum up to third. Core Java
 This question was recently asked at 'Facebook'.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          Asked in 1 Companies


 Q1420. Write a program to print two digit numbers that fulfil following criteria

Summing their digits and then multiplying with 3 should result in the number

For ex - 27 , (2+7) * 3 = 27


Core Java
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);
         }
      }
   }
}

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve          Asked in 1 Companies


 Q1421. Write Code showing InheritanceCore Java
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");
}
}

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve          Asked in 1 Companies


 Q1422. Write a Program / Code showing Inheritance and overriddingCore Java
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
}
}

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve          Asked in 1 Companies


 Q1423. Write a Program to find the longest word in a stringCore Java
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);
   }
}

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     


 Q1424. Write a Program that prints the repeated words in a String

For example -

We are what we repeatedly do; excellence, then, is not an act but a habit.

should print we, should count for case insensitive words too
Core Java
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());
         }
      }
   }
}

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     


 Q1425. Write a Program that prints words longer than 5 characters in a String

For example

We are what we repeatedly do; excellence, then, is not an act but a habit

should print

repeatedly
excellence
Core Java
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());
         }
      }
   }
}

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     


 Q1426. Write a Program to print 3 smallest words in a StringCore Java
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++;
         
      }
   }
}

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     


 Q1427. Write a Program to print 3 largest words in a StringCore Java
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++;

}
}
}

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     


 Q1428. Write a Program to Sort entries of a map by its valueCore Java
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);
      
   }
}

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     


 Q1429. Write a Program to remove all spaces in a String Core Java
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(" ", ""));      
   }
}

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     


 Q1430. Write a Program to remove multiple spaces

For example

We are what we repeatedly do; excellence, then, is not an act but a habit

should result in

We are what we repeatedly do; excellence, then, is not an act but a habit
Core Java
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(" ");
         }
      }
      
      
   }
}

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     


 Q1431. Create a Table with 2 Columns and Insert a row into itDatabase
Ans. CREATE TABLE TABLE_NAME (
ID NUMBER PRIMARY KEY,
NAME VARCHAR(50) NOT NULL,
);

INSERT INTO TABLE_NAME(ID, NAME) VALUES(1, "Abc");

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     ddl  dml  create table  insert records into table     Asked in 1 Companies


 Q1432. What are the ways to Reuse Code in Java ?Core Java
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

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     Code Reuse


 Q1433. What is the difference between circular queue and priority queue ?Data Structures
Ans. https://qr.ae/TWK2Ok

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     circular queue  priority queue  queue  data structures  collections


 Q1434. What are the different primitive data types in Java ?Core Java
Ans. boolean
byte
char
double
float
int
long
short
void

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     data types  primitive data types     Asked in 1 Companies      Basic


 Q1435. What are the different operators in Java ?Core Java
Ans. && - AND
|| - OR
! - LOGICAL NOT

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     operators      Basic


 Q1436. Write a Program to check if a number is perfect or notCore Java
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");
       }
   }
}

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     


 Q1437. Write a Program to print all perfect numbers from 1 to 100Core Java
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);
          }
       }
   }
}

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     


 Q1438. What is a method reference in Java ?Core Java
Ans. Introduced with java 8 , Method References help us to point to methods by their name.

A method references is described using :: symbol

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     method reference  java 8  lambda expressions


 Q1439. Write a Program to print index of first capital character in a string.Core Java
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);
   }
}

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     


 Q1440. Write a Program to count number of capital characters in a StringCore Java
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);
   }
}

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     


previous 30   next 30

Help us and Others Improve. Please let us know the questions asked in any of your previous interview.

Any input from you will be highly appreciated and It will unlock the application for 10 more requests.

Company Name:
Questions Asked: