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 - Order By Rating | ||||
| ||||
Ans. Paas - Platform as a service Iaas - Infrastructure as a service Saas - Software as a service | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  cloud computing  Amazon Web Service (AWS)  Google Cloud Platform (GCP) | ||||
| ||||
Ans. We can simply find it by checking the criteria of a tree. A tree will not contain a cycle, so if there is any cycle in the graph, it is not a tree. We can check it using another approach, if the graph is connected and it has V-1 edges, it could be a tree. Here V is the number of vertices in the graph | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve   Asked in 1 Companies | ||||
| ||||
Ans. import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.io.*; public class Common { public static void main(String ar[])throws Exception { File f=new File("a.txt"); File f1=new File("x.java"); System.out.println(f.exists()); FileInputStream fin = new FileInputStream(f); FileInputStream fin1 = new FileInputStream(f1); byte b[]=new byte[10000]; byte b1[]=new byte[10000]; fin.read(b); fin1.read(b1); String s1 = new String(b); String s2 =new String(b1); String words1[] = s1.trim().split(" "); String words2[] = s2.trim().split(" "); Listlist1 = new ArrayList<>(Arrays.asList(words1)); Listlist2 = new ArrayList<>(Arrays.asList(words2)); list1.retainAll(list2); System.out.println(list1); } } | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  file handling  file io  code  coding Asked in 1 Companies | ||||
| ||||
Ans. public class BuggyBread1{ public static void main (String args[]) { String str = "hheello world"; char[] charArray = str.toCharArray(); char selectedChar = 'a'; for(char char1: charArray){ if(!str.contains(Character.toString(char1).concat(Character.toString(char1)))){ selectedChar = char1; break; } } System.out.println(str.indexOf(Character.toString(selectedChar))); } } | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  string  code  coding Asked in 9 Companies | ||||
| ||||
Ans. public class Class{ public static void main(String[] args){ String string1 = "Hello I am Jack. I live in United States. I live in california state."; String string2 = "I live in"; int startIndex = 0; int endIndex = string1.length()-1; int countNoOfOccurences = 0; String remainingString = string1; while(startIndex < endIndex){ if(remainingString.indexOf(string2) != -1){ countNoOfOccurences++; startIndex = remainingString.indexOf(string2) + string2.length(); remainingString = remainingString.substring(startIndex); } else { break; } } System.out.println(countNoOfOccurences); } } | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  string  code  coding Asked in 2 Companies | ||||
Frequently asked in high end product companies. | ||||
| ||||
Ans. https://www.geeksforgeeks.org/lru-cache-implementation/ | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  cache  LRU cache  coding  code Asked in 10 Companies intermediate | ||||
Basic and Very Frequently asked. | ||||
| ||||
Ans. Polymorphism means the condition of occurring in several different forms. Polymorphism in Java is achieved in two manners 1. Static polymorphism is the polymorphic resolution identified at compile time and is achieved through function overloading whereas 2. Dynamic polymorphism is the polymorphic resolution identified at runtime and is achieved through method overriding. | ||||
Sample Code for overloading Sample Code for overriding | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  polymorphism  object oriented programming (oops)  oops concepts  oops concepts Asked in 108 Companies Basic   frequent | ||||
Try 2 Question(s) Test | ||||
| ||||
Ans. Fail-fast iterators detect illegal concurrent modification during iteration and fail quickly and cleanly rather than risking arbitrary, non deterministic behavior at an undetermined time in future. Example could be of an Iterator failing if it smells ConcurrentModificationException. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  fail-fast Iterators  Iterators Asked in 5 Companies intermediate | ||||
Frequently asked in all types of companies especially Indian Services companies. Frequently asked in CTS (Based on 2 feedback) | ||||
| ||||
Ans. 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  java   collections   hashcode   advanced  hashtable Asked in 33 Companies intermediate   frequent | ||||
Try 1 Question(s) Test | ||||
Advanced level question. Frequently asked in High end product companies. Frequently asked in Google , Cognizant and Deloitte ( Based on 2 feedback ) | ||||
| ||||
Ans. 1. String Pool - When a string is created and if it exists in the pool, the reference of the existing string will be returned instead of creating a new object. If string is not immutable, changing the string with one reference will lead to the wrong value for the other references. Example - String str1 = "String1"; String str2 = "String1"; // It doesn't create a new String and rather reuses the string literal from pool // Now both str1 and str2 pointing to same string object in pool, changing str1 will change it for str2 too 2. To Cache its Hashcode - If string is not immutable, One can change its hashcode and hence it's not fit to be cached. 3. Security - String is widely used as parameter for many java classes, e.g. network connection, opening files, etc. Making it mutable might possess threats due to interception by the other code segment. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  java   oops   string   string class   immutable  immutability   advanced Asked in 39 Companies expert   frequent | ||||
Try 4 Question(s) Test | ||||
Advanced level question usually asked in High end product companies. Have been asked in Google and Amazon (Based on 1 Feedback) | ||||
| ||||
Ans. The Java runtime environment deletes objects when it determines that they are no longer being used. This process is known as garbage collection. The Java runtime environment supports a garbage collector that periodically frees the memory used by objects that are no longer needed. The Java garbage collector is a mark-sweep garbage collector that scans Java dynamic memory areas for objects, marking those that are referenced. After all possible paths to objects are investigated, those objects that are not marked (i.e. are not referenced) are known to be garbage and are collected. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  java   garbage collection   java memory management   advanced Asked in 21 Companies intermediate   frequent | ||||
Try 4 Question(s) Test | ||||
| ||||
Ans. We can do that by pulling binary representation using 3 bits ( random(2) ). getRandom7() { String binaryStr = String.valuesOf(random(2))+String.valuesOf(random(2))+String.valuesOf(random(2)); binaryInt = Integer.valueOf(binaryStr); int sumValue=0; int multiple = 1; while(binaryInt > 0){ binaryDigit = binaryInt%10; binaryInt = binaryInt /10; sumValue = sumValue + (binaryDigit * multiple); multiple = multiple * 2; } } | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  java   tricky question   interesting questions   google interview questions   random | ||||
| ||||
Ans. http://www.cyberciti.biz/faq/key-differences-between-tcp-and-udp-protocols/ | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  java   network programming   architecture   Cloud Computing  Google Cloud Computing (GCP)  Amazon Web Services (AWS) Asked in 3 Companies | ||||