Interview Questions and Answers for 'Java' | 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 Rating

   next 30
 Q301. what is directive ?Core Java
Ans. A compiler directive is an instruction that tells the JVM how compilation should occur. A directive provides method-context precision in controlling the compilation process.

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

   Like         Discuss         Correct / Improve          Asked in 1 Companies


 Q302. can we use null as keyword ? Core Java
Ans. null is a literal similar to true and false in Java. These are not keywords because these are the values of something. As null is the value of a reference variable, true is the value of a boolean variable.

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

   Like         Discuss         Correct / Improve          Asked in 1 Companies


 Q303. Sort a List of Objects using comparable and comparatorCore Java
 This question was recently asked at 'HCL 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          Asked in 1 Companies


 Q304. What are the drawbacks of Reactive extensions ?ReactiveX
Ans. Reactive extensions have a steep learning curve which makes it confusing for beginner and intermediate developers.

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

   Like         Discuss         Correct / Improve     RxJava  ReactiveX  Reactive Programming


 Q305. Difference between concatMap and flatMap ?RxJava
Ans. Flatmap converts stream(s) into a single streams without maintaining a order where as concatmap does the same along with maintaining the order

flatmap example -[[1,2,3],[4,5,6],[7,8,9]] -> [1,4,7,2,5,8,3,6,9]

concatmap example -[[1,2,3],[4,5,6],[7,8,9]] -> [1,2,3,4,5,6,7,8,9]

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

   Like         Discuss         Correct / Improve     


 Q306. What is the difference between subscribe and blockingSubscribe method ?RxJava
Ans. blockingSubscribe will block the current thread and wait till the chain completes

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

   Like         Discuss         Correct / Improve     


 Q307. What is the difference between subject and observable ?RxJava
Ans. Subject has state, it keeps a list of observers. On the other hand, an Observable is really just a function that sets up observation. While Subjects are Observables, Subjects also implement an Observer interface.

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

   Like         Discuss         Correct / Improve     RxJava  Design  Design Pattern


 Q308. What is the difference between Observer and Observable ?RxJava
Ans. Observable is emiting data and Observer is subscribing to catch the data

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

   Like         Discuss         Correct / Improve     RxJava  Design  Deaign Pattern


 Q309. Which of the Core Java functions / packages / concept do you believe have become irrelevant in today's market ?Core Java
 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     


 Q310. What is the difference between round and scale method of BigDecimal ?Core Java
Ans. Round method would round it to integer places irrespective of if it's decimal places or not whereas scale would only round the decimal places.

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

   Like         Discuss         Correct / Improve     BigDecimal  round  scale


 Q311. Have you ever faced problems with rounding decimal places and what were the reasons ? Core Java
Ans. 1. The problem with double (x*100)/100 doesn't return exact x but few fractions lesser than x and then if you are using floor rounding , it makes a big difference

2. Rounding only after getting a result vs rounding each outcome of 2 operand make difference

3. Usage of inappropriate Rounding mode and Rounding scale.

4. Results with double and BigDecimal

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

   Like         Discuss         Correct / Improve     BigDecimal  double  round  decimal


 Q312. Math.round method rounds the decimal to an integer by stripping off the decimal places. How can we use the same method to keep only 2 decimal places

For example -

Math.round(12.3456) will return 12. What should we do to get 12.34 without using any other class or method.
Core Java
Ans. We can multiply the value by 100 and then use Math.round on that and then divide the result by 100

For example -

(Math.round(12.3456 * 100)) / 100

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

   Like         Discuss         Correct / Improve     Math.round  double


 Q313. Find out the max and min number from given arrayCore Java
 This question was recently asked at 'Expedia'.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


 Q314. Make "I Know Java" as "I Java Know" without using any inbuilt functions.Core Java
 This question was recently asked at 'iOPEX 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          Asked in 1 Companies


 Q315. Find Fibonacci first n numbers using recursion ?Core Java
Ans. public int fibonacci(int n) {
if(n == 0)
return 0;
else
if(n == 1)
return 1;
else
return fibonacci(n - 1) fibonacci(n - 2);
}

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

   Like         Discuss         Correct / Improve          Asked in 1 Companies


 Q316. Find unique values between two arrays using single for loop ?Core Java
 This question was recently asked at 'Net connect'.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     for loop  control statements  loop statement     Asked in 1 Companies


  Q317. Find Intersection/union between two arrays.Core Java
 This question was recently asked at 'Bristlecone,Amazon Lab126,Amazon,Microsoft,Facebook,NCR,Google'.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     arrays  code  coding     Asked in 7 Companies        frequent


 Q318. Can we change return type of Overridden method ?Core Java
Ans. Yes, we can change return type of overridden method in child class but child's return type should be sub-type of parent's return type.

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

   Like         Discuss         Correct / Improve          Asked in 1 Companies


 Q319. What is garbage collection ?Core Java
Ans. The garbage collection is a facility wherein a program runs on the Java Virtual Machine which gets rid of objects, which are not being used by a Java application anymore. It is a form of automatic memory management and recollection.

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

   Like         Discuss         Correct / Improve          Asked in 4 Companies


 Q320. When to use List, Set and Map in JavaCore Java
Ans. I. If we want a Collection that does not store duplicate values, then we use a Set based collection.

II. If we want to frequently access elements operations based on an index value then we use a List based collection. E.g. ArrayList

III. If we want to maintain the insertion order of elements in a collection then we use a List based collection.

IV. For fast search operation based on a key, value pair, we use a HashMap based collection.

V. If we want to maintain the elements in a sorted order, then we use a TreeSet based collection.

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

   Like         Discuss         Correct / Improve          Asked in 1 Companies


 Q321. Get all numbers from a collection that are both perfect square and palindomeCore Java
Ans. public static void main(String[] args){
      List<Integer> listOfIntegers = Arrays.asList(1,2,3,4,5,6,7,8,9,10,11);
      List<Integer> perfectAndPalindromeIntegers = new ArrayList<Integer>();
      
      for(Integer i: listOfIntegers){
         if(isPalindrome(i) && isPerfect(i)){
            perfectAndPalindromeIntegers.add(i);
         }
      }
      
      System.out.println(perfectAndPalindromeIntegers);
   }
   
   private static Boolean isPalindrome(Integer i){
      String str = String.valueOf(i);
      
      char[] charArray = str.toCharArray();
      
      int x = 0;
      int y = str.length()-1;
      
      while(x < y){
         if(charArray[x] != charArray[y]){
            return false;
         }
      }
      
      return true;
   }
   
   private static Boolean isPerfect(Integer i){
      for(int x=2;x<3;x++){
         if(x*x == i){
            return true;
         }
      }
      
      return false;
   }

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

   Like         Discuss         Correct / Improve     


 Q322. Explain Java collectionsCore Java
Ans. Collection is a container which is used to store and manipulate the group of objects

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

   Like         Discuss         Correct / Improve          Asked in 1 Companies


 Q323. Write a program to sort the Array of StringsCore Java
Ans. String[] s = { "sort", "string", "array" };
Collections.sort(Arrays.asList(s));
System.out.println(Arrays.toString(s));      // [array, sort, string]

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

   Like         Discuss         Correct / Improve          Asked in 1 Companies


 Q324. Write a program that identifies numbers in a list that are palindrome and perfect square ?Core Java
 This question was recently asked at 'Spillman 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          Asked in 1 Companies


 Q325. Can you explain filter and collectors in java 8 ?Core Java
Ans. Filters are used to filter object in stream on certain criteria.
Collector is used to collect outcome of the stream. Collector is a terminal operation.
List numbers = List.of(1,2,3,4,5,6,7);
List evenNumbers = numbers.stream().filter(n -> n%2==0).collect(Collectors.toList());
The above code will filter out odd numbers and return the list of even number.

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

   Like         Discuss         Correct / Improve     collectors  filters  java 8


 Q326. Can you explain filter and collectors in java 8 ?Core Java
Ans. Filters are used to filter object in stream on certail criteria. And collector is used to collect outcome of the stream. Collector is a terminal operation.
List numbers = List.of(1,2,3,4,5,6,7);
List evenNumbers = numbers.stream().filter(n -> n%2==0).collect(Collectors.toList());
The above code will filter out odd numbers and return the list of even number.

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

   Like         Discuss         Correct / Improve     collector  filter


 Q327. Why do we need to close the Scanner ?Core Java
Ans. For releasing input stream reference (System.in), you should close scanner.

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

   Like         Discuss         Correct / Improve     scanner  input output  io


 Q328. What is the difference between instantiation and initialization ?Core Java
Ans. Instantiation is the process of reserving memory for the object

For ex -

List list = new ArrayList();

Initialization is the process of setting the default value for the object or default object construction.

List list = new ArrayList(set);

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

   Like         Discuss         Correct / Improve     


 Q329. Describe inheritance and polymorphism and their importance for OOP. Core Java
 This question was recently asked at 'The Home Depot'.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


 Q330. Design a class that find all files with SSN.Core Java
 This question was recently asked at 'The Home Depot'.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


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: