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 | ||||
| ||||
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   | ||||
| ||||
Ans. Not purely object oriented Language. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve   expert | ||||
| ||||
Ans. Yes, through constructor overloading | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  constructor overloading | ||||
| ||||
Ans. Returning from inside a finally block will cause exceptions to be lost. A return statement inside a finally block will cause any exception that might be thrown in the try block to be discarded. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  exception handling  finally block Asked in 1 Companies | ||||
| ||||
This question was recently asked at 'Huawei'.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 | ||||
| ||||
This question was recently asked at 'Boeing'.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 | ||||
| ||||
Ans. Yes new Properties().putAll(System.getenv()); | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  java.util.properties  environment variables | ||||
| ||||
Ans. System.getEnv gets the environment variables where System.getProperties gets Java properties. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  System.getEnv  System.getProperties  environment variables | ||||
| ||||
Ans. HashMap implements the Map interface while the Dictionary does not. HashMap was introduced after HashTable and Dictionary. Dictionary is currently obsolete in java. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  hashmap  dictionary class | ||||
| ||||
Ans. sortedMap is an interface ,while TreeMap is an implementation of sortMap. We can not create an instance of sortedMap but we can create an instance of treeMap | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  treemap  sortedmap | ||||
| ||||
Ans. ArrayList is a list , i.e an implementation of List interface whereas HashSet is a Set and an implementation of Set interface. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  arraylist  hashset | ||||
| ||||
Ans. ArrayList is a variable length collection class whereas arrays are fixed length primitive structure. We can use generics with arraylist but not with arrays. We can store primitive data types within arrays but can't with ArrayList. In ArrayList that needs to be converted to Wrapper objects. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  arraylist  arrays  collection classes  collections basic   frequent | ||||
| ||||
Ans. Vector is Synchronized one where as Arraylist is not Synchronized. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve   | ||||
| ||||
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   | ||||
| ||||
Ans. final keyword is used to restrict the user from modifying the variable, extending the class and overriding a method static keyword is used for memory management which can be used for variable, class, method where in it belongs to the class not to the instance of object | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve   Asked in 2 Companies | ||||
| ||||
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   | ||||
| ||||
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   | ||||
| ||||
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   | ||||
| ||||
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   | ||||
| ||||
Ans. 1. Creating a class helps in specifying operations on the Strings like length , sub string , concatenation etc. 2. It acts as a Wrapper class for "Array of Characters" and hence facilitates it's usage in collections, assignment to null. 3. Immutability of String objects facilitates in reuse , security and caching. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  string class | ||||
| ||||
Ans. "equals" method is the method of object class that needs to be overridden to check object equality. This is not specific to any class like String. equalsignorecase is the method of String class that provides a definition that ignores the case of characters during comparison. The only difference between them in String class is that the equals() methods considers the case while equalsIgnoreCase() methods ignores the case during comparison. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  equals  equalsignorecase  equals vs equalsignorecase | ||||
| ||||
Ans. "equals" is the method of object class which is supposed to be overridden to check object equality. x.equals(y) means the references x and y are holding objects that are equal with the equality defined by the definition of equals method. 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  equals  hascode  equals vs hascode | ||||
| ||||
Ans. "equals" is the method of object class which is supposed to be overridden to check object equality. x.equals(y) means the references x and y are holding objects that are equal. The compareTo() method is used for comparing two objects in Java. It is usually defined for the classes whose objects needs to be ordered through Comparable interface or need to be part of an ordered collection like TreeSet or TreeMap. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  equals  compareTo  equals vs compareTo | ||||
| ||||
Ans. Yes, ConcurrentHashMap is synchronized. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  ConcurrentHashMap | ||||
| ||||
Ans. No HashMap isn't synchronized. ConcurrentHashMap and Hashtable are synchronized. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  hashmap  synchronization | ||||
| ||||
Ans. Yes, an abstract class can have a constructor in Java. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  abstract class  public constructor Asked in 1 Companies | ||||
| ||||
Ans. If we do not mention, Cloneable Interface to the Class which we want to Clone then we get this exception, only if we try to clone an object Like: public class TestClone{ @Override protected Object clone() throws CloneNotSupportedException { return super.clone(); } } In Main, You try to do: TestClone clone = new TestClone(); TestClone clone2 = (TestClone) clone.clone(); You will get CloneNotSupportedException. Just add -> public class TestClone implements Cloneable { and things are fixed. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  exceptions handling  cloning | ||||
| ||||
Ans. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve   Asked in 1 Companies | ||||
| ||||
Ans. All threads share a common heap. Each thread has a private stack, which it can quickly add and remove items from. This makes stack based memory fast, but if you use too much stack memory, as occurs in infinite recursion, you will get a stack overflow. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  memory management  heap memory Asked in 1 Companies | ||||
| ||||
Ans. CustomArrayList myarrayList = new CustomArrayList(); myarrayList.add("Value 1"); myarrayList.add("Value 2"); myarrayList.add("Value 3"); for (String string : myarrayList) { System.out.println(string); } package sample.utils; import java.util.ArrayList; import java.util.Iterator; import java.util.List; public class CustomArrayList implements Iterable { private ArrayList mylist = new ArrayList(); public void add(T t) { this.mylist.add(t); } @Override public Iterator iterator() { return new CustomIterator(mylist); } class CustomIterator implements Iterator { private int indexPosition = 0; private List internalList; public CustomIterator(List internalList) { this.internalList = internalList; } @Override public boolean hasNext() { if (internalList.size() >= indexPosition 1) { return true; } return false; } @Override public E next() { E val = internalList.get(indexPosition); indexPosition ; return val; } } } | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  iterator Asked in 1 Companies | ||||