Interview Questions and Answers for 'A' | 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
 Q2011. Explain Binary SearchAlgorithm
 This question was recently asked at 'Nagarvision'.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     search  binary search     Asked in 1 Companies      basic        frequent


 Q2012. What is the use of second level cache in Hibernate ?Hibernate
Ans. Second level cache is shared between sessions. Hibernate by default uses first level cache. Second level cache need to be configurd to use.
There are several second level cache e.g eh cache,jboss cache etc.

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

   Like         Discuss         Correct / Improve          Asked in 1 Companies


 Q2013. What is the use of Log4j ?Logging
 This question was recently asked at 'IBM'.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      basic


 Q2014. What is the use of @import annotation ?
Ans. @Import annotation in Spring allows you to load bean definitions from one or more another @Configuration files or Components. You might not want to configure all the beans in one configuration file.

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

   Like         Discuss         Correct / Improve          Asked in 1 Companies


 Q2015. Why String is a class in Java ?Core Java
 This question was recently asked at 'NIIT 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


 Q2016. Describe SQL JoinsDatabase
Ans. Oracle having following types of joins these are also called 8i joins. There are:

1. Equi (or) Inner join
2. Non Equi join
3.Self join
4.Outer join

Oracle also support the 9i (or) ANSI standard joins.There are:

1.Inner join
2.Left outer join
3.Right outer join
4.Full outer join
5.Natural join

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

   Like         Discuss         Correct / Improve     sql joins  sql     Asked in 2 Companies


 Q2017. Write a Program to find number of lines , words and characters in a File.Core Java
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


 Q2018. Given a String with some Code, Write a Parser to have proper indentation.Core Java
 This question was recently asked at 'Facebook'.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


 Q2019. How do you make instance of an abstract class ?Core Java
Ans. By extending it to the derived class and thereby creating instance of derived class.

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

   Like         Discuss         Correct / Improve          Asked in 1 Companies


 Q2020. Explain how Mark & Sweep is implemented in garbage collection.Core Java
 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          Asked in 1 Companies


 Q2021. What Parameter we need to specify while creating sockets ?
 This question was recently asked at 'Symantec'.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


 Q2022. How would you stop a Thread in java ?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     


 Q2023. Write code for serialization.Core Java
Ans. // Java code for serialization and deserialization
// of a Java object
import java.io.*;

class Demo implements java.io.Serializable
{
   public int a;
   public String b;

   // Default constructor
   public Demo(int a, String b)
   {
      this.a = a;
      this.b = b;
   }

}

class Test
{
   public static void main(String[] args)
   {
      Demo object = new Demo(1, "geeksforgeeks");
      String filename = "file.ser";
      
      // Serialization
      try
      {
         //Saving of object in a file
         FileOutputStream file = new FileOutputStream(filename);
         ObjectOutputStream out = new ObjectOutputStream(file);
         
         // Method for serialization of object
         out.writeObject(object);
         
         out.close();
         file.close();
         
         System.out.println("Object has been serialized");

      }
      
      catch(IOException ex)
      {
         System.out.println("IOException is caught");
      }


      Demo object1 = null;

      // Deserialization
      try
      {
         // Reading the object from a file
         FileInputStream file = new FileInputStream(filename);
         ObjectInputStream in = new ObjectInputStream(file);
         
         // Method for deserialization of object
         object1 = (Demo)in.readObject();
         
         in.close();
         file.close();
         
         System.out.println("Object has been deserialized ");
         System.out.println("a = " object1.a);
         System.out.println("b = " object1.b);
      }
      
      catch(IOException ex)
      {
         System.out.println("IOException is caught");
      }
      
      catch(ClassNotFoundException ex)
      {
         System.out.println("ClassNotFoundException is caught");
      }

   }
}

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

   Like         Discuss         Correct / Improve     serialization     Asked in 1 Companies


 Q2024. If compareTo() method returns zero, does it mean that the objects are always equal?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     


 Q2025. Find all paths of length L in an acyclic graphAlgorithm
 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     


 Q2026. Write a method receiving a stream of integers, caching the last 10 min of data and returning a number if it's less than the current inputCore 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     


 Q2027. How would you write a socket in JavaCore 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     


 Q2028. How would you implement low latency data structures ?Data Structure
 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     


 Q2029. Why do you think lambda expressions are considered such a big thing for Java 8?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     


 Q2030. What are the drawbacks of creating immutable objects ? Why don't we create all object immutable if mutability possesses so much threat ? Core Java
Ans. Immutable objects relieves us from the problems of inconsistencies and security and helps with better read performance but at the same time are write performance and storage overheads. In case any modification is required , a new object is created and thus creating multiple copies of it.

This is the reason we use StringBuffer / StringBuilder when we have to append some text multiple times and then create a String out of it.

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

   Like         Discuss         Correct / Improve     immutable  immutability objects  immutability


 Q2031. Does immutability facilitates better performance ?Core Java
Ans. Yes , but only the read performance in case we don't need to modify it much. In case we need to modify it a lot , it creates write performance overheads as we would need to create many news objects instead of just changing one.

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

   Like         Discuss         Correct / Improve     immutable  immutability objects  immutability


 Q2032. Do you think that Recursion is expensive on computation ?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     


 Q2033. How do you fetch the records form database ?Database
Ans. To fetch records from a database, you would use SELECT statements

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

   Like         Discuss         Correct / Improve          Asked in 1 Companies


 Q2034. Write a program to rotate array elements clockwise.Core Java
Ans. class Rotate{

void leftRotate(int arr[], int d, int n)
{
for (int i = 0; i < d; i )
leftRotatebyOne(arr, n);
}

void leftRotatebyOne(int arr[], int n)
{
int i, temp;
temp = arr[0];
for (i = 0; i < n - 1; i )
arr[i] = arr[i 1];
arr[i] = temp;
}


void printArray(int arr[], int n)
{
for (int i = 0; i < n; i )
System.out.print(arr[i] " ");
}


public static void main(String[] args)
{
Rotate rotate = new Rotate();
int arr[] = { 1, 2, 3, 4, 5, 6, 7 };
rotate.leftRotate(arr, 2, 7);
rotate.printArray(arr, 7);
}
}

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

   Like         Discuss         Correct / Improve          Asked in 1 Companies


 Q2035. Given an array with number 1 to n, find the missing numbers. Core Java
Ans. int main ()
{
int a []={1..n};
int miss=getMiss (a,n);
Printf ("%d",miss);
}
getMiss (int a [],int n){
int I,total;
total=(n 1)*(n 2);
for (i = 0; i < n; i++)
total -= a[i];
return total;
}

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

   Like         Discuss         Correct / Improve          Asked in 1 Companies


 Q2036. Write a program to find the 10th prime number.Core Java
Ans. import java.util.Scanner;
public class Prime
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
System.out.print("Enter n to compute the nth prime number: ");
int nth = sc.nextInt();
int num, count, i;
num=1;
count=0;

while (count < nth){
num=num 1;
for (i = 2; i <= num; i )
{
if (num % i == 0)
{
break;
}
}
if ( i == num)
{
count = count 1;
}
}
System.out.println("Value of nth prime: " num);
}
}

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

   Like         Discuss         Correct / Improve          Asked in 1 Companies


 Q2037. Write a program to find length of String without using library function.Core Java
Ans. Class lengofstring {
Public static void main(String[] arr) {
int i = 0;
String s = "hello world!";
for (char C: s.toCharArray()) i;
System.out.println("Length: "
i);
}
}

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

   Like         Discuss         Correct / Improve          Asked in 1 Companies


 Q2038. Write a custom exception.Core Java
Ans. if you are creating your own exception is known as custom exception.

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

   Like         Discuss         Correct / Improve          Asked in 1 Companies


 Q2039. What is an exception ? What are the different types of exceptions ?Core Java
Ans. An exception is an unwanted or unexpected event, which occurs during the execution of a program that is at run time, that disrupts the normal flow of the program?s instructions. these are different types arithmetic exceptions, class not found exception, interrupted exception, run time exception etc.

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

   Like         Discuss         Correct / Improve          Asked in 1 Companies


 Q2040. Why use Java ?Core Java
 This question was recently asked at 'Improwea'.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: