Interview Questions and Answers - Order By Newest Q1861. 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 Q1862. 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 Q1863. How serialization breaks Singleton pattern ? Design
Ans. It's not serialization but de serialization that breaks purpose of singleton as new objects can be brought to life using the serialized object. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  singleton Q1864. 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 Q1865. 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 Q1866. 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 Q1867. 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 Q1868. 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 Q1869. What does @VisibleForTesting annotation denotes ? Testing
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  VisibleForTesting 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 Q1871. What are different in memory data structures that are used in No Sql Database ? NoSql Database
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   Q1872. 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   Q1873. 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 8Ans. 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 Q1875. 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 Q1876. 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 Q1877. 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 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 Q1879. 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 Q1880. 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 Q1881. Have you faced any problem integrating software / services with any of your partners or vendors ? General
This question was recently asked at 'iHart'.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 Q1882. 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 Q1883. 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 Q1884. 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   Q1885. Can you give an example of a Get and Post Request. Web Service
This question was recently asked at 'One Click Retail,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 2 Companies Q1886. Can you design a program that can identify if two shapes on x and y plane would intersect ?
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 Q1887. Explain CAP Theorem.
This question was recently asked at 'One Click Retail'.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 Q1888. Have you heard of Rest method Patch ?
This question was recently asked at 'One Click Retail'.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 Q1889. Do you think we should have security Tokens in Url ? Design
This question was recently asked at 'One click retail'.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 Q1890. What information should be sent in url vs sent within the body in case of Post request ? Design
This question was recently asked at 'one click retail'.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