Interview Questions and Answers for 'Google' | 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 for 'Google' - 43 question(s) found - Order By Newest

next 30
Advanced level question. Frequently asked in High end product companies. Frequently asked in Google , Cognizant and Deloitte ( Based on 2 feedback )
  Q1. Why is String immutable in Java ?Core Java
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


Basic and Very Frequently asked.
  Q2. What is Polymorphism in Java ?Core Java
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


Frequently asked in all types of companies especially Indian Services companies. Frequently asked in CTS (Based on 2 feedback)
  Q3. What is the use of hashcode in Java ?Core Java
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 usually asked in High end product companies. Have been asked in Google and Amazon (Based on 1 Feedback)
  Q4. Describe, in general, how java's garbage collector works ?Core Java
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


 Q5. What is cloud computing ?Cloud Computing
Ans. Cloud Computing is a way of using IT infrastructure with following traits -

1. On Demand Infrastructure
2. Broad Network Access
3. Resource Pooling
4. Rapid Elasticity
5. Measured Service

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

   Like         Discuss         Correct / Improve     google cloud platform (GCP)  Amazon Web Services (AWS


 Q6. Why is cloud infrastructure so powerful ?Cloud Computing
Ans. Because it gives the ability to provision infrastructure on Demand with No contracts and strings attached.

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

   Like         Discuss         Correct / Improve     Amazon Web Service (AWS)   Google Cloud Platform (GCP)


 Q7. Given two files with list of words, write a program to show the common words in both filesCore Java
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


 Q8. What are the reasons to choose between reserved and on demand instances ?Server
Ans. In terms of compute options and configurations, Reserved Instances and On Demand instances are the same. The only difference between the two is that a Reserved Instance is one you rent (reserved) for a fixed duration, and in return you receive a discount on the base price of an On Demand instance.

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

   Like         Discuss         Correct / Improve     aws  aws ec2  aws computing  amazon cloud computing  amazon ec2  production support  Google Cloud Platform (GCP)


 Q9. Is Google App Engine , IAAS, PAAS or SAAS ?Google Cloud Platform (GCP)
Ans. It's PAAS ( Platform as a service )

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

   Like         Discuss         Correct / Improve     Google App Engine


 Q10. Why would a cloud customer use resources in multiple regions and zones ?Cloud Computing
Ans. 1. Fault Tolerance
2. Better Access by bringing the application closer to the users.

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

   Like         Discuss         Correct / Improve     Google Cloud Computing (GCP)  Amazon Web Services (AWS)  Availability Zones  Regions and Zones  Infrastructure


 Q11. Have you ever heard about csrf attacks ?Security
Ans. Yes, Cross-Site Request Forgery (CSRF) is an attack that forces an end user to execute unwanted actions on a web application in which they're currently authenticated.

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

   Like         Discuss         Correct / Improve     csrf attack  Cross-Site Request Forgery (CSRF)     Asked in 16 Companies


 Q12. What are system integrators in Cloud Computing?Cloud Computing
 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     Amazon Web Services (AWS)   Google Cloud Platform (GCP)


 Q13. Write a program to print the index of the first non repeated character in a java stringCore Java
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


 Q14. If you have access to a function that returns a random integer from one to five, write another function which returns a random integer from one to seven.Core Java
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


 Q15. Difference between TCP and UDP ?Networking
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


 Q16. What are fail-fast Iterators ?Core Java
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 high end product companies.
 Q17. Write code for LRU CacheCore Java
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


 Q18. Write a Program to check number of occurrences of one string within another ? Core Java
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


 Q19. Given a graph, find if it represents a treeAlgorithm
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


 Q20. What are the different layers of cloud computing ?Infrastructure
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)


 Q21. How cloud computing is different than virtualization ?Server
Ans. A Virtualization is software that virtualizes your hardware into multiple machines while Cloud computing is the combination of multiple hardware devices. In Virtualization, a user gets dedicated hardware while in Cloud computing multiple hardware devices provide one login environment for the user.

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

   Like         Discuss         Correct / Improve     cloud computing  virtualization  production support  Google Cloud Platform (GCP)


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


  Q23. Write code to sort an array.Algorithm
Ans. https://www.geeksforgeeks.org/arrays-sort-in-java-with-examples/

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

   Like         Discuss         Correct / Improve     array  sorting     Asked in 16 Companies      basic        frequent


 Q24. What is elasticity in relation to Cloud infrastructure ?Cloud Computing
Ans. The power to scale computing resources up and down easily with minimal friction

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

   Like         Discuss         Correct / Improve     Amazon Web Service (AWS)  Google Cloud Platform (GCP)


 Q25. What is life cycle of cloud deployment process ?Cloud Computing
 This question was recently asked at 'Barclays'.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     Google Cloud Platform (GCP)  Amazon Web Services (AWS)     Asked in 1 Companies


 Q26. Write a code to detect the longest palindromic substring Core Java
 This question was recently asked at '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          Asked in 1 Companies


 Q27. What are the types of clouds in cloud computing ?Cloud Computing
Ans. Private, Public, Hybrid, Community

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

   Like         Discuss         Correct / Improve     Google Cloud Platform (GCP)     Asked in 1 Companies


 Q28. Have you ever worked on Google Cloud Platform ?Google Cloud Platform
 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     


 Q29. Explain Virtual machines in Google Cloud Platform.Google Cloud Platform (GCP)
Ans. Virtual machines are IAAS in GCP which can called Compute Engine

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

   Like         Discuss         Correct / Improve     Google cloud Platform  GCP


 Q30. Explain Identity management in GCP ?Google Cloud Platform (GCP)
Ans. IAM is used to define the level of access to GCP services

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

   Like         Discuss         Correct / Improve     GCP


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: