Interview Questions and Answers - Order By Rating Q1111. Write program to create a linked list and perform different operations on it. Algorithm
Ans. import java.util.*;
class LinkedListSolution{
protected LinkedList list;
public LinkedListSolution(){
list = new LinkedList();
}
public Object pop() throws NoSuchElementException{
if(list.isEmpty())
throw new NoSuchElementException();
else
return list.removeFirst();
}
public void push(Object obj){
list.addFirst(obj);
}
public Object peek() throws NoSuchElementException{
if(list.isEmpty())
throw new NoSuchElementException();
else
return list.getFirst();
}
public boolean isEmpty(){
return list.isEmpty();
}
public String toString(){
return list.toString();
}
}
class TestStack{
public static void main(String args[]){
LinkedListSolution s = new LinkedListSolution();
s.push("First");
s.push("Second");
s.push("Third");
System.out.println("Top: " s.peek());
s.push("Fourth");
while(!(s.isEmpty()))
System.out.println(s.pop());
}
} Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  Linkedlist  data structures  algorithm Asked in 2 Companies basic Q1112. How Marker interfaces works internally ? Core Java
This question was recently asked at 'GGK 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  marker interfaces  interfaces Asked in 1 Companies expert   rare Q1113. What is an execution engine within JVM ? Core Java
Ans. Execution engine contains interpreter and JIT compiler, which covert byte code into machine code.
Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  jvm  execution engine  compiler Asked in 1 Companies Q1114. How to create list that will sort it's elements dynamically? Algorithm
Ans. Override the behavior of collection class to sort the list upon each element addition. Though it's not recommended as list are sorting heavy data structures.
List<MyType> list = new ArrayList<MyType>() {
public boolean add(MyType mt) {
super.add(mt);
Collections.sort(list, comparator);
return true;
}
}; Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Asked in 1 Companies intermediate Q1115. Is it advisable to keep session or transaction open for long time just to avoid LazyInitializationException ? Hibernate
Ans. No. It's a resource and performance overhead. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  LazyInitializationException  Lazy Loading Q1116. If you are given choice to avoid LazyInitializationException using any of the following measures, which are the ones you will choose and why ?
1. Set lazy=false in the hibernate config file.
2. Set @Basic(fetch=FetchType.EAGER) at the mapping.
3. Make sure that we are accessing the dependent objects before closing the session.
4. Force initialization using Hibernate.initialize Hibernate
Ans. First resolution is a big No as it conveys no lazy loading in complete app. even second is advocating the same but for a particular mapping.
third one is most appropriate if loading and dependent entity property access is closer to each other in code and can be accomplished.
I don't mind using 4th too. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  lazy loading  lazy initialization  LazyInitializationException Q1117. What does the following exception means
org.hibernate.LazyInitializationException: could not initialize proxy - no Session Hibernate
Ans. The error states that Hibernate is not able to initialize proxy / dependent entity objects as there is no session or transaction present. Very likely we are trying to load the dependent entities lazily but the call to dependent object property is not wrapped within the session or transaction. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  Lazy Loading  Lazy Initialization  org.hibernate.LazyInitializationExceptionAns. Amazon Simple Storage Service or S3 is object storage with a simple web service interface to store and retrieve any amount of data from anywhere on the web. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  aws  amazon s3  aws s3  aws storage  amazon cloud storage  amazon s3 Asked in 12 Companies Q1119. What are the daily activities of build and release engineer ?
This question was recently asked at 'greeteck infosolutions'.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  build and release Asked in 1 Companies Q1120. Where do you see yourself in next 5 years? General
Ans. Sample Answers -
Getting better with upcoming technologies and be a Lead developer.
In accordance with the company, working as a permenant employee.
Be an associate architect.
Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Asked in 2 Companies Q1121. What is Exception Wrapping ?
Ans. Exception wrapping is wrapping an exception object within another exception object and then throwing the outer exception. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  exception handling  exception wrapping  exceptions intermediate   rare Q1122. Name few Behavioral Design Patterns ? Design
Ans. Interpreter,Chain of Responsibility,Command,Iterator,Observer,Mediator,Memento Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  Behavioral Design Patterns Intermediate Q1123. Name few structural Design Patterns ? Design
Ans. Adapter,Bridge,Composite,Decorator,Facade,Flyweight,Proxy Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  Design Patterns  Structural Design Patterns Intermediate Q1124. Name few creational design patterns ? Design
Ans. Factory,Abstract Factory,Singleton,Prototype and Builder Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  Design Pattrns  Creational Design Patterns Intermediate Q1125. What access the variable gets if we don't provide any access specifier ? Core Java
Ans. It gets the default access i.e package protected. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  access specifiers  default Access specifier Basic Q1126. Design a Passport Office system Design
This question was recently asked at 'Netcracker Technology'.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  Design Asked in 1 Companies Q1127. What is cloning in GIT ? GIT
Ans. Cloning is the process of making a copy. It could be creating local copy of another local repository or local copy of remote repository. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  GIT  Configuration Management  GIT Cloning Q1128. How are the concept of Association related to Composition and Inheritance ? Core Java
Ans. Composition and Inheritance are the different types of Associations for Classes.
Composition is a has-a association between classes.
Inheritance is a is-a association between classes. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  composition  object oriented programming (oops)  oops concepts  inheritance  object oriented programming (oops)  oops concepts  association  relationship between objects Q1129. What are the core OOPs concepts ? Core Java
Ans. Abstraction, Encapsulation, Polymorphism , Composition and Inheritance Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  core oops concepts Asked in 65 Companies basic   frequent Frequently asked Spring interview question. Q1130. What are the components of Spring framework ? Spring
Ans. Core: [Core, Bean, Context, Expression Language]
Web: [Web, Portlet, Servlet, etc]
Data Access [JMS, JDBC, etc]
AOP, Aspect Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  spring  spring framework components Asked in 12 Companies Q1131. How would you do an object oriented design on animals in a zoo ? Design
This question was recently asked at 'Booking.com,InterContinental Hotels,Caissa,Workday'.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 4 Companies Q1132. Write a method / program that will determine if the parenthesis are balanced in a given string. Core Java
Ans. https://www.geeksforgeeks.org/check-for-balanced-parentheses-in-an-expression/ Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  string  code  coding Asked in 14 Companies Q1133. Why is it important to close files and streams ? Core Java
Ans. Optimizing Resource utilization. When you open a file using any programming language , that is actually a request to operating system to access the file. When such a request is made , resources are allocated by the OS. When you gracefully close those files, those resources are set free.
In Java if you don’t close the streams and files, Garbage collection identifies the open files which have lost the reference and hence will close them. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  file handling Q1134. What is the difference between && and & in Java ? Core Java
Ans. && is a Logical whereas & is a bitwise operator Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  operators  logical vs bitwise operator Q1135. Why don't Java objects have destructors ? Core Java
Ans. Java manages memory using built-in garbage collector Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  destructor  garbage collection Q1136. Write a Java program to print 10 random numbers between 1 to 100? Core Java
This question was recently asked at 'karya technology'.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  coding  code Asked in 1 Companies Q1137. How to find the median number in an array of integers ? Core Java
Ans.
Arrays.sort(numArray);
double median;
if (numArray.length % 2 == 0)
median = ((double)numArray[numArray.length/2] (double)numArray[numArray.length/2 - 1])/2;
else
median = (double) numArray[numArray.length-1/2]; Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  coding Asked in 2 Companies Q1138. Write a Program to find the missing integer in an array of consecutive numbers? Core Java
This question was recently asked at 'Knight Capital'.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. acugload is the utility to load the user access group in the appropriate database. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  acugload Q1140. What are the tag libraries used in WCS ? IBM WCS
Ans. Core tags, sql , xml and fmt tags. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  wcs tag libraries