Interview Questions and Answers - Order By Rating Q181. What are different types of dependency injections ? Design
Ans. Setter injection
Constructor injection
Interface injection
Look-up method/method injection Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  dependency injection   design patterns Asked in 1 Companies Q182. Which objects are eligible for garbage collection ? Core Java
Ans. Objects that have lost their reference i.e. they cannot be accessed/used by the program anymore. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  garbage collection Asked in 1 Companies basic Q183. Explain what happens when insertion is performed in case of ArrayList and LinkedList. Data Structure
Ans. Array List works on Array and when we add an element in middle of the list, Array List need to update the index of all subsequent elements. I the capacity is full, it even may need to move the whole list to a new memory location . Linked List works on Double linked list algorithm and all it has to do is to adjust the address of the previous and next elements. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  arraylist vs linkedlist  collections  list Asked in 2 Companies Q184. How does relational database facilitates read optimization ? 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  database  rdbms  read optimization Q185. Does relational database facilitate read or write optimization while storing information ? database
Ans. Usually Relational Databases are optimized for writing. Some exception being usage of indices where indices needs to be updated after insertion and eventually helps with Log(n) reading time. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  read optimization  rdbms  relational database Q186. What is read and write optimization in relation to databases ? Which database facilitates read optimization and which facilitates write optimization ? 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  read optimization   write optimization Q187. What is abstraction ? Design
Ans. Abstraction is a process of hiding the implementation details and describing only the functionality to the user. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  bstraction  oops concepts  oops principle Asked in 22 Companies Q188. Can you explain software design principles cohesion and coupling with an example? Design
This question was recently asked at 'Fidelity Information Services (FIS)'.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  cohesion  coupling Asked in 1 Companies   frequent Q189. Can you write the code for implementing the one to many (student -> courses) relationship in hibernate? Hibernate
Ans. @OneToMany(cascade = CascadeType.ALL)
@JoinColumn(name = "student_id")
private Set countries; Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Asked in 1 Companies Q190. Suppose we have a string "Java is object oriented language" and we have to reverse every alternate word in string. How would we do that using Java program. Core Java
This question was recently asked at 'datalake 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  string manipulation  code  coding Asked in 1 Companies Q191. How is LinkedList collection class internally implemented ? Is it a Linked List or Doubly Linked List ? Core Java
This question was recently asked at 'Ancestry'.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  linkedlist  internal implementation of linkedlist Asked in 1 Companies Q192. Which of the two - Arrays or LinkedList - is a better data structure for implementing Queue ? and Why ? Data Structure
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  Arraylist  linkedlist  queue  collections Q193. Which immutable classes have you worked with ? Can you name some immutable Collections ? How to make an immutable collection ? Core Java
Ans. string and wrapper class objects Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  immutability  immutable  immutability classes   immutable  immutability collections Asked in 3 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  queue  blockingqueue  collections Q195. Which Data structure can be used for creating Queue ? Data Structure
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  queue  collections  data structure Q196. How can we ensure thread safety in static method ? Core Java
Ans. By using synchronized static method or synchronized block Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  threads  synchronization  static methods Asked in 2 Companies intermediate Q197. Can we use primitive types with Collection classes ? Core Java
Ans. No, As collection classes involve use of Generics, they cannot accept primitive types. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  collection classes  collections Q198. Write a Program to print fibonacci series using recursion. Core Java
Ans. public class FibonacciUsingRecursion {
public static void main(String[] args) throws IOException{
getNextFibanocci(1,1);
}
static int getNextFibanocci(int a,int b){
if(a+b >= 100){
return 0;
} else {
System.out.println(a+b);
getNextFibanocci(b,a+b);
}
return 0;
}
} Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  fibonacci  recursion Q199. What could be the driving force to have dependencies injected through class than through config file while using IOC or Dependency Injection ? Design
Ans. Unit Testing Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  dependency injection  inversion of control Q200. Which of the following databases - Cassandra / Oracle - provides more flexibility about querying the database ? Database
Ans. Oracle as it is not modeled for a particular query or set of queries. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  Cassandra  Nosql database  nosql vs relational database Q201. Which of the two Normalization / Denormalization facilitate better performance ? Which of the two facilitate better space management ? Database
Ans. DeNormalization facilitate better performance. Normalization remove data duplication and hence facilitate better database space management. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  normalization  denormalization  normalization vs denormalization Q202. Difference between Normalization and Denormalization ? Database
Ans. Normalization is the process of splitting one Table into multiple so as to avoid Data duplication whereas Denormalization is the process of reducing Tables that creates data duplication but would remove joins in the queries. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  normalization  denormalization  normaization vs denormalization Asked in 1 Companies Q203. How different is the Search algorithm when we query Cassandra Tables and When we query Oracle Tables ? Cassandra
Ans. Relational Database uses linear search if we don't query using indices. Performance for linear search is O(n). If indices have been used , relational database uses binary search. Performance for binary search is O(Log n).
Casandra uses hash search. Performance for Hash Search is O(1). Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  cassandra vs oracle  nosql vs relational  search algorithm Q204. Which validation frameworks have you worked on ? Frameworks
This question was recently asked at 'Sofi'.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  validation frameworks Asked in 1 Companies Q205. Explain Hibernate Validation ? Hibernate
This question was recently asked at 'Sofi'.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  hibernate  hibernate validation Asked in 1 Companies Q206. Which of the two - iteration or recursion - is slower ? Core Java
Ans. Any function call is slower than the code in the same method as Java has to maintain stack of meta and function call information. So recursion is slower. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  iteration  recursion  iteration vs recursion Q207. As root, if you have to assign the owner for the file and set only read permission for the owner, Write a unix command to do it. Unix
Ans. chmod 477 Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  unix commands  setting file permissions  chown  chmod Q208. Is dependency injection possible if we don't have inheritance / Composition ? Design
Ans. Without composition - No, as it's the core of dependency injection.
With Inheritance - Yes, through interface implementation. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  dependency injection  inversion of control  ioc Q209. Which of the OOP's features facilitate dependency injection ? Design
Ans. Inheritance , Runtime Polymorphism and Composition. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  dependency injection  inversion of control  ioc  oops  oops features Q210. Lets say we have a set "set1" with objects of Class A, Class has a non static string called element1, Write a code ( using lambda expression ) to see if there is any object in the set with element1 = "Hello". Core Java
Ans. set1.stream().filter(p->p.element1.equals("Hello")).findAny().isPreent();
or
set1.stream().map(A::getElement1).anyMatch("Hello"::equals) Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  lambda expressions  java 8  java8  java 8 filter  findAny()