Interview Questions and Answers for 'Ato' | 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 Rating

   next 30
 Q31. What are the cursors available in Java ?Core Java
Ans. Enumeration
Iterator
List iterator

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

   Like         Discuss         Correct / Improve     cursors  iterator


 Q32. Is there a way to know size of an object in Java ?Core Java
Ans. No, Java doesn't have a sizeOf operator. In C / C++ , its required to determine how much memory allocation is required which is not the case with Java. Java handles memory allocation and deallocation intrinsically.

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

   Like         Discuss         Correct / Improve     sizeOf  size of object  sizeOf operator     Asked in 1 Companies        rare


 Q33. Does java supports operator overloading ?Core Java
Ans. No

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

   Like         Discuss         Correct / Improve     operator overloading     Asked in 1 Companies      basic


 Q34. Which operators in Java have highest precedence ?Core Java
Ans. Braces, i.e () and [] have the highest precedence

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

   Like         Discuss         Correct / Improve     java operators


 Q35. Which type of memory is cleaned / recovered by garbage collection - stack or heap ?Core Java
Ans. Heap memory.

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

   Like         Discuss         Correct / Improve     memory management  stack  heap  garbage collection     Asked in 2 Companies


  Q36. Difference between Array and ArrayList ?Core Java
Ans. <a href="http://javahungry.blogspot.com/2015/03/difference-between-array-and-arraylist-in-java-example.html" rel="nofollow">http://javahungry.blogspot.com/2015/03/difference-between-array-and-arraylist-in-java-example.html</a>

  Sample Code for ArrayList

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

   Like         Discuss         Correct / Improve     array  arraylist     Asked in 11 Companies      basic        frequent


Frequently asked Generic Question.
  Q37. Why do you want to work for our company ?General
Ans. [Open Ended Answer]

Usually answered stating your keen interest in the role offered and challenges and opportunities the role offers.

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

   Like         Discuss         Correct / Improve          Asked in 42 Companies        frequent


 Q38. Which is better in terms of performance - Iterator or Spliterator ?Core Java
Ans. Spliterator has better performance potential than iterators but only if the potential is used. Spliterator can iterate streams in parallel as well as in sequence whereas iterator can only iterate in sequence.

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

   Like         Discuss         Correct / Improve     iterator  collections  streams  parallel streams  Spliterator


 Q39. How Spliterator in Java 8 different than iterator ?Core Java
Ans. Though there are many differences the way internally they both iterates the collections and streams respectively, but the main difference in performance that is achieved by spliterator as it can iterate Streams in Parallel whereas iterator only iterates collections sequentially.

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

   Like         Discuss         Correct / Improve     java8  java 8  spliterator  java 8 streams  streams


Basic and Very Frequently asked.
  Q40. 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


 Q41. How is == operator different for objects and primitive types ? Core Java
Ans. For objects or references, == operator check if the reference on left and right points to the same object.

For primitive types or variables, == operator check if the variable on left and right holds the same value.

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

   Like         Discuss         Correct / Improve     ==  object equality  operator      Basic


 Q42. What is the difference between = and == in Java ?Core Java
Ans. = is the assignment operator that assigns the result of the expression on the right to the variable on the left, whereas

== is the operator to check object equality to see if the reference on left and right are pointing to the same object. For primitive types, its used to check if both variables holds the same value.

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

   Like         Discuss         Correct / Improve     =  ==  assignment operator  object equality  difference between      Basic


Rarely asked as it was introduced with Java 8.
 Q43. What is the use of :: operator wef from Java 8 ?Core Java
Ans. We can refer to a function using this operator like System.out.println(intList.stream().reduce(Math::max).get());

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

   Like         Discuss         Correct / Improve     :: operator   lambda expression  java 8


 Q44. What is the difference between the following two code lines ?

1. new OuterClass().new InnerClass();

2. new OuterClass.InnerClass();
Core Java
Ans. In first case we are trying to initialize Inner class object using the instance of Outer Class whereas in second case we are trying to initialize the Inner class object directly using the Outer class name.

In second case , Inner class is "static inner class" as we cannot access "non static inner class" using Classname alone.

In first case, the inner class could be either "static inner class" or "non static inner class".

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

   Like         Discuss         Correct / Improve     inner classes  inner class   static inner class   new operator


 Q45. Is New Keyword a method Name ?Core Java
Ans. No, Its an Operator.

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

   Like         Discuss         Correct / Improve     new keyword  operator


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


Very Frequently asked across all type of companies and across all levels.
  Q47. Difference between Public, Private, Default and Protected ?Core Java
Ans. Private - Not accessible outside object scope.

Public - Accessible from anywhere.

Default - Accessible from anywhere within same package.

Protected - Accessible from object and the sub class objects.

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

   Like         Discuss         Correct / Improve     java   oop   access specifier   public   private   default   protected   public vs private vs default vs protected     Asked in 12 Companies      basic        frequent

Try 1 Question(s) Test


Very frequently asked. Among first few questions in almost all interviews. Among Top 5 frequently asked questions. Frequently asked in Indian service companies (HCL,TCS,Infosys,Capgemini etc based on multiple feedback ) and Epam Systems
  Q48. Difference between == and .equals() ?Core Java
Ans. "equals" is the method of object class which is supposed to be overridden to check object equality, whereas "==" operator evaluate to see if the object handlers on the left and right are pointing to the same object in memory.

x.equals(y) means the references x and y are holding objects that are equal. x==y means that the references x and y have same object.

Sample code:

String x = new String("str");
String y = new String("str");

System.out.println(x == y); // prints false
System.out.println(x.equals(y)); // prints true

  Sample Code for equals

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

   Like         Discuss         Correct / Improve     java   string comparison   string   object class   ==    equals   object equality  operator   == vs equals   equals vs ==     Asked in 294 Companies      basic        frequent

Try 6 Question(s) Test


Frequently asked.
  Q49. What is an Iterator?Core Java
Ans. Iterator is an interface that provides methods to iterate over any Collection.

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

   Like         Discuss         Correct / Improve     java   collections   iterator     Asked in 11 Companies      basic        frequent


 Q50. What are the design considerations while making a choice between using interface and abstract class ?Core Java
Ans. Keep it as a Abstract Class if its a "Is a" Relationsship and should do subset/all of the functionality. Keep it as Interface if its a "Should Do" relationship.

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

   Like         Discuss         Correct / Improve     java   oops   abstract classes   interfaces   advanced     Asked in 3 Companies


Frequently asked in CTS ( Based on 2 feedback )
  Q51. What is the difference between comparable and comparator in java.util pkg?Core Java
Ans. Comparable interface is used for single sequence sorting i.e.sorting the objects based on single data member where as comparator interface is used to sort the object based on multiple data members.

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

   Like         Discuss         Correct / Improve     java   java.util   comparable   comparator   collections     Asked in 23 Companies      basic        frequent


 Q52. Difference between Class#getInstance() and new operator ?
Ans. Class.getInstance doesn't call the constructor whereas if we create an object using new operator , we need to have a matching constructor or copiler should provide a default constructor.

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

   Like         Discuss         Correct / Improve     java   constructor   object creation   default constructor   getinstance   new operator


 Q53. What is the difference between >> and >>>?
Ans. Both bitwise right shift operator ( >> ) and bitwise zero fill right shift operator ( >>> ) are used to shift the bits towards right. The difference is that >> will protect the sign bit whereas the >>> operator will not protect the sign bit. It always fills 0 in the sign bit.

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

   Like         Discuss         Correct / Improve     java   operators   bitwise operators   binary shift   right shift


Frequently asked in Infosys and HCL Technologies ( Based on 2 feedback )
 Q54. What are different ways of object creation in Java ?Core Java
Ans. Using new operator - new xyzClass()

Using factory methods - xyzFactory.getInstance( )

Using newInstance( ) method - (Class.forName(xyzClass))emp.newInstance( )

By cloning an already available object - (xyzClass)obj1.clone( )

  Sample Code for object initialization using clone

  Sample Code for object initialization using getInstance

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

   Like         Discuss         Correct / Improve     java   oops   object creation   new operator   class.forname   cloning   ebay     Asked in 9 Companies      expert


 Q55. According to Java Operator precedence, which operator is considered to be with highest precedence?Core Java
Ans. Postfix operators i.e () [] . is at the highest precedence.

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

   Like         Discuss         Correct / Improve     java   operators   operator precedence     Asked in 2 Companies


 Q56. Which Java operator is right associative?Core Java
Ans. The = operator is right associative.

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

   Like         Discuss         Correct / Improve     java   operators   = operator


 Q57. Difference between new operator and Class.forName().newInstance() ?
Ans. new operator is used to statically create an instance of object. newInstance() is used to create an object dynamically ( like if the class name needs to be picked from configuration file ). If you know what class needs to be initialized , new is the optimized way of instantiating Class.

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

   Like         Discuss         Correct / Improve     java   oops   object instantiation   object creation   class.forname   newinstance   new operator   difference between   advanced      intermediate


 Q58. How to find whether a given integer is odd or even without use of modulus operator in java?Core Java
Ans. public static void main(String ar[])
{
int n=5;
if((n/2)*2==n)
{
System.out.println("Even Number ");
}
else
{
System.out.println("Odd Number ");
}
}

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

   Like         Discuss         Correct / Improve     java   code   coding   tricky questions   interesting questions   modulus operator     Asked in 4 Companies        frequent


Frequently asked.
 Q59. If you are given a choice to use either ArrayList and LinkedList, Which one would you use and Why ?Core Java
Ans. ArrayList are implemented in memory as arrays and hence allows fast retrieval through indices but are costly if new elements are to be inserted in between other elements. LinkedList allows for constant-time insertions or removals using iterators, but only sequential access of elements

1. Retrieval - If Elements are to be retrieved sequentially only, Linked List is preferred.

2. Insertion - If new Elements are to be inserted in between other elements , Linked List is preferred.

3. Search - Binary Search and other optimized way of searching is not possible on Linked List.

4. Sorting - Initial sorting could be pain but lateral addition of elements in a sorted list is good with linked list.

5. Adding Elements - If sufficiently large elements needs to be added very frequently ,Linked List is preferable as elements don't need consecutive memory location.

  Sample Code for ArrayList

  Sample Code for LinkedList

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

   Like         Discuss         Correct / Improve     java   collections   list   arraylist   linkedlist   difference between   architecture   data structure   ebay     Asked in 2 Companies      basic        frequent

Try 2 Question(s) Test


 Q60. What is comparator interface used for ?Core Java
Ans. The purpose of comparator interface is to compare objects of the same class to identify the sorting order. Sorted Collection Classes ( TreeSet, TreeMap ) have been designed such to look for this method to identify the sorting order, that is why class need to implement Comparator interface to qualify its objects to be part of Sorted Collections.

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

   Like         Discuss         Correct / Improve     java   collections   treemap   treeset   comparator     Asked in 2 Companies      Intermediate

Try 2 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: