Interview Questions and Answers - Order By Rating Q961. Can we access elements at a particular index using LinkedList collection class ? Data Structure
Ans. Yes we can. But as the underlying structure of the collection class is double linked list, it will eventually have to traverse to the element linearlly and hence would result in bad performance. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Q962. Which of the following - arrays or LinkedList allow elements to be accessed using index and how ? Data Structure
Ans. Arrays allows elements to be accessed directly using the index.
As Array elements are stored in continuous memory locations it's very easy to find the memory address of any element using the formula as following
Memory Address of Array start or index 0 + ( Size of array element * Index ) Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  arrays  linkedlist Q963. Can we capture the Request body within the interceptor or Filter and perform operations on it ? Spring
Ans. Yes, But with interceptor it will remove the body from the request and then we will have to explicitly add the attributes to the session to forward it to the handler. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  interceptor  filter Q964. Explain your experience working on UI ? Have you worked with JSF ?
General
This question was recently asked at 'Spillman 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 Q965. How can we make sure that only one object of a class get's created ? Design
This question was recently asked at 'Spillman 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 This question was recently asked at 'Spillman Technologies,Motorola Solutions'.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 2 Companies Q967. Why do we need to close the Scanner ? Core Java
Ans. For releasing input stream reference (System.in), you should close scanner. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  scanner  input output  io Q968. What is the difference between instantiation and initialization ? Core Java
Ans. Instantiation is the process of reserving memory for the object
For ex -
List list = new ArrayList();
Initialization is the process of setting the default value for the object or default object construction.
List list = new ArrayList(set); Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Q969. Describe inheritance and polymorphism and their importance for OOP. Core Java
This question was recently asked at 'The Home Depot'.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 Q970. Design a class that find all files with SSN. Core Java
This question was recently asked at 'The Home Depot'.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 Q971. Are getters setter / accessor mutator methods instance methods or static methods ? why ? Core Java
Ans. They are usually instance methods. They are usually applied to DAOs / DTOs / POJO that are used to transport objects and used to access object elements. As they are tied to objects and are not common to all objects of a class, hence they are created as non static. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Q972. What are the different types of methods in Java ? Core Java
Ans. Static Methods
Instance Methods
Accessor / Mutator or getter setters Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  Ans. Use hashCode() which returns an integer value, generated by a hashing algorithm Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  hash codes  hashcode Asked in 1 Companies Q974. Can you write code so that we can keep track of Keys that have their values changed along with the number of times they were changed. 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   Q975. Write code to get count of every 5 letter word in a string using lambda expression
Core Java
Ans. String str = "I had been saying that he had been there";
Map<String,Long> countWords = Arrays.asList(str.split(" ")).stream().filter(p->p.length() = 5).collect(Collectors.groupingBy(p->p,Collectors.counting()));
System.out.println(countWords); Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  Collectors  lambda  filter  coding  java 8 Q976. How would you choose your favorite company name for e.g. three companies are given in radio buttons Infosys, TCS and Aricent. Do You need to loop trough all radio buttons and select your favorite company or can just get the selected value. Javascript
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   Q977. Have you used any framework to capture command line arguments or options ? 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   Q978. Have you worked on creating any cron job ? 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   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  AWS  AWS Lambda 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  aws lambda  aws serverless computing  amazon cloud serverless computing  amazon lambda 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  AWS Lambda Q982. What is the difference between following rounding modes
RoundingMode.CEILING
RoundingMode.DOWN
RoundingMode.FLOOR
RoundingMode.HALF_DOWN
RoundingMode.HALF_UP
RoundingMode.HALF_EVEN
Which is the one you use often and Why ? 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  RoundingMode Q983. What is the advantage of BidDecimal over Double ? Core Java
Ans. BigDecimal provides more precision as compared to double. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  BigDecimal  Double  data types Q984. What will the following code return
list.stream().collect(Collectors.groupingBy(ClassA::getElement1,
Collectors.averagingDouble(ClassA::getElement2))); Core Java
Ans. Map<DataType1,DataType2> where DataType1 is the data type of element1 ( returned by getelement1 method ) and DataType2 is the data type of element2 ( returned by getElement2 method ) Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java 8  collections  java 8 streams Q985. What are we doing here
list.stream().collect(Collectors.groupingBy(ClassA::getElement1,
Collectors.averagingDouble(ClassA::getelement2))); Core Java
Ans. We are averaging elements of a collection by element1 grouped by element1
* list is the reference of collection
* element1 is the member element returned by getElement1 method of ClassA
* element2 is the member element returned by getElement2 method of ClassA Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java 8  collections  java 8 streams  collectors Q986. Can you explain following exception
java.lang.ArithmeticException: Non-terminating decimal expansion; no exact representable decimal result. 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  ArithmeticException Q987. How Reflection can break any design pattern ? Design
Ans. Using java reflection api, we can tweak into a class and modify it's runtime behavior and hence modify the pattern it might be using. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  reflection Q988. Why the singleton class should never implement Cloneable interface ? Design
Ans. Because Singleton implementation doesn't restrict it from cloning and hence we can have multiple objects when we actually don't intend it to have multiple objects. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  singleton  cloning Q989. What are the ways to break singleton pattern ? Design
Ans. If we don't have double checked locking, it can be broken easily through multi threaded access.
Through Reflection.
If multiple class loaders are loading the class.
If the class is serializable or cloneable.
Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  singleton Asked in 2 Companies expert Ans. public class StackUsingArrayList {
public static void main(String[] args) {
List list = new ArrayList();
list.add("A");
list.add("B");
list.add("C");
Stack stack = new Stack();
list.forEach(a -> stack.add(a));
System.out.println(stack);
}
} Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Asked in 1 Companies