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

   next 30
 Q991. Have you used any framework to capture command line arguments or options ?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     


 Q992. Write code to get count of every 5 letter word in a string using lambda expression

Core Java
Ans. String str = "I had been saying that he had been there";

Map<String,Long> countWords = Arrays.asList(str.split(" ")).stream().filter(p->p.length() = 5).collect(Collectors.groupingBy(p->p,Collectors.counting()));

System.out.println(countWords);

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

   Like         Discuss         Correct / Improve     Collectors  lambda  filter  coding  java 8


 Q993. Can you write code so that we can keep track of Keys that have their values changed along with the number of times they were changed.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     


 Q994. What are the different types of methods in Java ?Core Java
Ans. Static Methods
Instance Methods
Accessor / Mutator or getter setters

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

   Like         Discuss         Correct / Improve     


 Q995. Are getters setter / accessor mutator methods instance methods or static methods ? why ?Core Java
Ans. They are usually instance methods. They are usually applied to DAOs / DTOs / POJO that are used to transport objects and used to access object elements. As they are tied to objects and are not common to all objects of a class, hence they are created as non static.

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

   Like         Discuss         Correct / Improve     


 Q996. 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


 Q997. 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


 Q998. 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     


 Q999. 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


 Q1000. 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


 Q1001. 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


 Q1002. 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


 Q1003. 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


 Q1004. 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


 Q1005. 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     


 Q1006. 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


 Q1007. 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


 Q1008. 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


  Q1009. 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


 Q1010. 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


 Q1011. 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


 Q1012. 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


 Q1013. 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


 Q1014. 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


 Q1015. 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     


 Q1016. 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


 Q1017. 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


 Q1018. 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


 Q1019. Which is the best collections for maintaining elements in an order ?Core Java
 This question was recently asked at 'Dell'.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


 Q1020. What is Dynamic Binding ?Core Java
Ans. Dynamic Binding happens at runtime. Method overriding is an example of Dynamic Binding

 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: