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 for 'Code' - 166 question(s) found - Order By Rating | ||||
| ||||
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  SCM  Source Code Management  Configuration Control  Git  Svn | ||||
| ||||
Ans. equals, compareTo and hashcode are of use when the objects are used within collections. Equals helps with collections that helps maintaining only unique objects ( like Set ) compare and compareTo helps with collections that helps maintaining objects in order ( TreeSet, TreeMap etc ) hascode helps with collections that facilitates hash searching ( like hashSet, hashMap etc ) | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  equals   compareTo   hashcode method | ||||
| ||||
Ans. https://www.evoketechnologies.com/blog/code-review-checklist-perform-effective-code-reviews/ | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  clean code Asked in 1 Companies | ||||
| ||||
Ans. If there is a situation to remove duplicates values from an arrayList. Developer implemented using legacy for-loop where I suggested to use Linked hash set to remove duplicates from the list. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  Clean code Asked in 3 Companies | ||||
| ||||
Ans. "equals" is the method of object class which is supposed to be overridden to check object equality. x.equals(y) means the references x and y are holding objects that are equal with the equality defined by the definition of equals method. Hashcode is used for bucketing in Hash implementations like HashMap, HashTable, HashSet etc. The value received from hashcode() is used as bucket number for storing elements. This bucket number is the address of the element inside the set/map. when you do contains() then it will take the hashcode of the element, then look for the bucket where hashcode points to and if more than 1 element is found in the same bucket (multiple objects can have the same hashcode) then it uses the equals() method to evaluate if object are equal, and then decide if contain() is true or false, or decide if element could be added in the set or not. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  equals  hascode  equals vs hascode | ||||
| ||||
Ans. At that bucket, it will form a linked list depending on what equals method evaluates for that object. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  hashcode  collections Asked in 2 Companies | ||||
| ||||
Ans. String | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  Code  Coding  method overloading Asked in 1 Companies | ||||
| ||||
Ans. We have followed this practice in one of the project. The only downside we felt was the need to merge the new snapshot version to master after the release. The Benefit is that it's easy to just ignore the branch if complete rollback happens and hence master remains in sync with production. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  source code management  scm  svn  git  release process | ||||
| ||||
Ans. We keep a Working Branch , Release Branch and Master. Working Branch is what we work on. We release from the release branch. So the flow for merge is Work Branch -> Release Branch -> Master | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  source code management  scm  svn  git  scm branching | ||||
| ||||
Ans. Code Segment | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  Memory Management  Code Memory Segment  Code Segment Memory  Code Segment | ||||
| ||||
Ans. Unreachable code is a code segment that can never be executed in any case. For example - int x = 5; return; System.out.println(x); In this code , 2nd line will return the control out of the method and hence 3rd line will never get executed and hence is unreachable code. This will be caught at compile time only. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  unreachable code | ||||
| ||||
Ans. Yes | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  .class file  java byte code  interfaces | ||||
| ||||
Ans. File folder = new File(path); if(!folder.exists()){ try { folder.mkdir(); } catch (Exception e) {} } | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  code  coding  file handling basic | ||||
| ||||
This question was recently asked at 'Softenger'.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  design  string length Asked in 1 Companies basic | ||||
| ||||
Ans. it takes 1 to 4 bytes | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  utf  unicode  utf-8 Asked in 1 Companies | ||||
| ||||
This question was recently asked at 'Bloomberg'.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  string Asked in 1 Companies | ||||
| ||||
This question was recently asked at 'Bloomberg'.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  cloning  design pattern   cloning design pattern Asked in 1 Companies | ||||
| ||||
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 | ||||
| ||||
Ans. Use hashCode() which returns an integer value, generated by a hashing algorithm | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  hash codes  hashcode Asked in 1 Companies | ||||
| ||||
Ans. import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; public class FileUtility { public static void main(String[] args) { System.out.println(printFile("/home/userme/notes")); } private static int printFile(String filePath) { int wordCount = 0; try (BufferedReader br = new BufferedReader(new FileReader(filePath))) { String line = null; String[] wordsArray = null; while ((line = br.readLine()) != null) { wordsArray = line.split(" "); wordCount = wordsArray.length; } } catch (IOException e) { e.printStackTrace(); } return wordCount; } } | ||||
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. ambiguity error | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  code  method  function  data types Asked in 1 Companies | ||||
| ||||
Ans. private void permutation(String prefix, String sufix) { int ln = sufix.length(); if(ln == 0) { System.out.println(prefix); } else { IntStream.range(0, ln).forEach(i->permutation(prefix sufix.charAt(i), sufix.substring(0,i) sufix.substring(i 1, ln))); } } call:permutation("", "abcdef"); | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  String  code  coding Asked in 1 Companies | ||||
| ||||
This question was recently asked at 'Amazon'.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  coding  code Asked in 1 Companies | ||||
| ||||
This question was recently asked at 'datalake solutions'.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  string manipulation  code  coding Asked in 1 Companies | ||||
| ||||
This question was recently asked at 'Sofi'.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 review Asked in 1 Companies | ||||
| ||||
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  duck number | ||||
| ||||
Ans. false false | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  object equality  ==  coding  code 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. LocalDate today = LocalDate.now(); LocalDate birthday = LocalDate.of(1960, Month.JANUARY, 1); Period p = Period.between(birthday, today); //Now access the values as below System.out.println(period.getDays()); System.out.println(period.getMonths()); System.out.println(period.getYears()); | ||||
Sample Code for LocalDate Sample Code for Period | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  coding  code  date  LocalDate  Period Asked in 1 Companies | ||||
| ||||
This question was recently asked at 'HCL Tech'.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  coding  code Asked in 1 Companies | ||||