Interview Questions and Answers for 'Code' | 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
 Q71. Will this Code compile ?

abstract public class BuggyBread1{
abstract public void test(){};
}
Core Java
Ans. No. This will give a compilation error saying "Abstract methods do not specify a body".

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

   Like         Discuss         Correct / Improve     java   abstract classes   abstract methods   java compilation error   java coding   java code   coding   yes-no


 Q72. Do you know the way to remove unused imports automatically in eclipse ?Eclipse
Ans. Select the package -> Right Click -> Source -> Organize Imports.

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

   Like         Discuss         Correct / Improve     eclipse   import statement   code cleaning   code review   clean code


 Q73. What is the difference between Fisheye and Crucible ?
Ans. FishEye is used to extract information from source code repository whereas Crucible is used to request, perform and manage code reviews.

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

   Like         Discuss         Correct / Improve     java   fisheye   crucible   code review   tools


 Q74. Can we use Fisheye and Crucible independently ?
Ans. Yes

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

   Like         Discuss         Correct / Improve     java   fisheye   crucible   code review   tools   yes-no


 Q75. What does the red and green line backgrounds denotes in the crucible code Review ?
Ans. Red Background for a line denotes the lines that have been deleted with the change set and Green background denotes the addition.

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

   Like         Discuss         Correct / Improve     java   crucible   fisheye   code review


 Q76. Why Java uses Unicode System ?Core Java
Ans. Before Unicode there were many language / country standards like ASCII , ISO , KOI and BIG 5. In order to accommodate multiple language letters and to overcome problems with using different multiple standards , a new language standard was developed i.e unicode system.

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

   Like         Discuss         Correct / Improve     java   unicode


 Q77. How many elements will be there in TreeSet after the last line and Why ?

TreeSet set = new TreeSet();
set .add(new String("abc"));
set .add(new String("abc"));
Core Java
Ans. One.

As we haven't specified the type of TreeSet, it being evaluated with the first element insertion. Once it's identified that it's of type String and as no comparator has been defined, the comparison is done using the String compareTo method. String compareTo method compares the elements by the content / value.

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

   Like         Discuss         Correct / Improve     java   set   treeset   string   compareto   coding   code


 Q78. What is collision in hash collections ?Core Java
Ans. Collision is the situation when two different elements have the same Hash Code.

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

   Like         Discuss         Correct / Improve     java   collections   collision   hashcode  hash code   hash collections   ebay     Asked in 1 Companies      intermediate        frequent


 Q79. Print natural numbers sequentially with two threads.Core Java
Ans. http://stackoverflow.com/questions/18799591/print-natural-sequence-with-help-of-2-threads1-is-printing-even-and-2nd-is-pri

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

   Like         Discuss         Correct / Improve     print natural numbers with two threads   multithreading   multi threading   threads   code   coding   makemytrip.com


Must know at all levels. Among Top 10 frequently asked questions in Java. Very frequently asked to fresh graduates or less experienced professionals.
  Q80. What is Inheritance ?Core Java
Ans. Its a facility for code reuse and independent extension wherein a derived class inherits the properties of parent class.

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

   Like         Discuss         Correct / Improve     inheritance  object oriented programming (oops)  oops concepts  oops concepts  java concepts  code reuse  code re-use   classes  derived classes     Asked in 14 Companies      basic        frequent


 Q81. Find the repeating number using O(n) time and constant space.Algorithm
Ans. http://www.geeksforgeeks.org/find-duplicates-in-on-time-and-constant-extra-space/

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

   Like         Discuss         Correct / Improve     algorithm   program   code   coding  makemytrip.com


 Q82. Write a method to convert all elements of a set to lower case.Core Java
Ans. http://javasearch.buggybread.com/CodeSnippets/searchCodeSamples.php?keyword=Method+to+convert+all+elements+of+a+collection&category=code

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

   Like         Discuss         Correct / Improve     code  coding  string  String.toLowerCase  set  collections


 Q83. Write code for singleton classDesign
Ans. http://javasearch.buggybread.com/CodeSnippets/searchCodeSamples.php?keyword=singleton+class&category=code

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

   Like         Discuss         Correct / Improve     singleton  code  coding  design pattern     Asked in 1 Companies      Intermediate        frequent


 Q84. Write a program / method to input few numbers and then print the sum.
Ans. http://javasearch.buggybread.com/CodeSnippets/searchCodeSamples.php?&category=code&searchOption&keyword=946

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

   Like         Discuss         Correct / Improve     code  coding  scanner      basic


Very frequently asked to fresh graduates. Frequently asked in NSEiT and Accenture India
 Q85. Write a program to Generate prime numbers till a given numberCore Java
Ans. public class Main {
public static void main(String args[]) {
int number = 2;
int count = 0;
long sum = 0;
int givenNumber = 1000;
while (count < givenNumber) {
if (isPrimeNumber(number)) {
sum = number;
count;
}
number;
}
System.out.println(sum);
}
private static boolean isPrimeNumber(int number) {
for (int i = 2; i <= number / 2; i) {
if (number % i == 0) {
return false;
}
}
return true;
}
}

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

   Like         Discuss         Correct / Improve     generate prime numbers  code  coding     Asked in 5 Companies      basic        frequent


 Q86. Write a program to calculate factorial of a number using recursionCore Java
Ans.

public class Factorial {
   public static void main(String[] args){
      int x = 5;
      
      System.out.println(calculateFactorial(x));
   
   }
   
   private static int calculateFactorial(int x){
      if(x==1){
         return 1;
      }
      return x * calculateFactorial(x-1);
   }
}

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

   Like         Discuss         Correct / Improve     factorial  calculate factorial  code  coding  recursion     Asked in 1 Companies      basic


 Q87. Write code for the usage of Builder Design Pattern
Ans. http://javasearch.buggybread.com/CodeSnippets/searchCodeSamples.php?&category=code&searchOption&keyword=964

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

   Like         Discuss         Correct / Improve     builder design pattern  builder pattern  code  coding      intermediate


 Q88. Write code for constructor overloadingCore Java
Ans. http://javasearch.buggybread.com/CodeSnippets/searchCodeSamples.php?&category=code&searchOption&keyword=965

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

   Like         Discuss         Correct / Improve     constructor overloading  code  coding     Asked in 2 Companies      basic


 Q89. Write code to check if an integer is odd or even using ternary operator
Ans. http://javasearch.buggybread.com/CodeSnippets/searchCodeSamples.php?&category=code&searchOption&keyword=963

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

   Like         Discuss         Correct / Improve     ternary operator  code  coding


 Q90. Write code to sort elements of a set
Ans. http://javasearch.buggybread.com/CodeSnippets/searchCodeSamples.php?&category=code&searchOption&keyword=952

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

   Like         Discuss         Correct / Improve     set  collections  sorting  treeset  code  coding


 Q91. In the following code , how many methods needs to be implemented in Class B ?

public interface A{
   public void method1();
   public void method2();
   public void method3();
}

abstract class B implements A{
}
Core Java
Ans. As Class B has been declared abstract , we can either implement any of these methods and just declare rest of them abstract.

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

   Like         Discuss         Correct / Improve     interfaces  abstract classes  code  coding

Try 2 Question(s) Test


 Q92. What will the following code print ?

Integer a = 100, b =100;
Integer c = 1000, d = 1000;
System.out.println(a == b);
System.out.println(c ==d);
Core Java
Ans. false
false

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

   Like         Discuss         Correct / Improve     object equality  code  coding        frequent


 Q93. How do you manage source code in repository if you have multiple releases lined up and different teams are working on it? Tools
Ans. We creates separate branches for each project if development work is going on parallel and they are to be released at different times. Once the first release is done, we merge the branch changes into trunk. If they all have to go at one time, we usually would merge everything in the trunk itself.

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

   Like         Discuss         Correct / Improve     scm  source code management  svn  version control  code repository  svn branch     Asked in 1 Companies


 Q94. Is it advisable to just hold checking in your changes to trunk if there is another release planned in between ?
Ans. If it's just smaller change, and single person is working, then this approach is fine. Otherwise there are risk on loosing it on your machine. Moreover , If there are multiple people working , it makes it hard to share code. It's better to create a separate branch and then merge it later to trunk.

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

   Like         Discuss         Correct / Improve     scm  source code management  svn  version control  code repository  svn trunk


 Q95. What are the steps to create a branch in SVN ?
Ans. If the branch is to be created from Trunk and we are using Eclipse.

Go to the Trunk Copy of the Project

Right Click the project and then Click Branch/Tag

In the Create Branch / Tag Dialog, Add the Destination Branch Url

Check whether we want to make copy from the Head Revision or some specific revision Number

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

   Like         Discuss         Correct / Improve     scm  source code management  svn  version control  code repository  svn branch


 Q96. What is the problem with following code ?

public static void main(String[] args) {
int x = 5;
return x*2;

int y = 10;
return y*2;

}
Ans. There are many problems with the code

1. The method returns void and hence we cannot return any integer value.

2. We cannot return more than one value from a method.

3. The code after 1st Return statement is unreachable.

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

   Like         Discuss         Correct / Improve     coding  code


 Q97. Is this code legal in Java ?

public class BuggyBread {
{
System.out.println("HelloWorld.");
}
}
Ans. Yes, It's an instance initialization block.

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

   Like         Discuss         Correct / Improve     code  instance initialization block

Try 1 Question(s) Test


 Q98. What is wrong with the following if statement ?

if(x==y && x.equals(y) {
}
Core Java
Ans. x==y means that both references have same type and are pointing to same memory location and hence would always mean that they have same value.

x.equals(y) is not required in this case.

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

   Like         Discuss         Correct / Improve     if statement  control statements  == and equals  ==  .equals   code optimization

Try 2 Question(s) Test


 Q99. What is wrong with the following if statement ?

if(x==y || x.equals(y) {
}
Core Java
Ans. if x==y turns out to be true x.equals(y) will be true too. If x.equals(y) could be true even if x==y is true or not.

So the only possible outcomes are

1 || 1 = 1
0 || 1 = 1
0 || 0 = 0

i.e the outcome of x.equals(y)

check for x==y is not required in this if statement.

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

   Like         Discuss         Correct / Improve     if statement  control statements  == and equals  ==  .equals   code optimization

Try 1 Question(s) Test


 Q100. What does the web status code 404,500 and 200 mean ?Java EE
Ans. 404 means the resource is not found on the server.The resource might not be deployed correctly.

500 means internal server error which means that resource was located but then it resulted in some exception or error.

200 means Ok.

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

   Like         Discuss         Correct / Improve     web status code     Asked in 1 Companies

Try 1 Question(s) Test


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: