Interview Questions and Answers - Order By Rating Q1381. How do threads share information ? Core Java
Ans. Through common memory area. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  threads Asked in 1 Companies Q1382. Can the foreign key column have null values ? Database
This question was recently asked at 'Volkswagen It services'.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 Q1383. 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 Q1384. 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 Q1385. what is the repository structure in svn ? SVN
This question was recently asked at 'Sri Tech'.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 Q1386. What are some of the Java Naming conventions ? Core Java
Ans. 1. Class name should be a noun and should start with capital case character.
2. Interface Name should be an adjective and should start with capital case character.
3. Method and Variable names should follow lower camel case notation.
4. package name should be all lower case.
5. constant variables (static final) should be all capital case. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  naming conventions basic Q1387. 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 Q1388. 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 Q1389. 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 Q1390. What was the worst problem you faced while working with Hibernate ? Hibernate
Ans. Lazy Initialization exceptions Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Q1391. What are the disadvantages of Hibernate over native APIs ? Hibernate
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   Q1392. Do you like Native SQL Apis like JDBC or JPA / Hibernate ? Hibernate
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  JDBC vs JPA  JDBC vs Hibernate Q1393. 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 Q1394. 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.LazyInitializationException Q1395. If we would like to load just the mapping id for the mapped entity in some cases and whole entity in some cases, because we would like to lazily initialize the dependent entity in some case and not load the entity at all in some case, how can we accomplish that.
For example -
Employee entity is mapped to department entity through department id. We want that when we load employee.getDepartment().getDepartmentId(), it shouldn't load the complete department object but just the Id. Hibernate
Ans. a Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Q1396. If we would like to load just the mapping id for the mapped entity, how can we accomplish that.
For example -
Employee entity is mapped to department entity through department id. We want that when we load employee.getDepartment().getDepartmentId(), it shouldn't load the complete department object but just the Id. Hibernate
Ans. We can use
@AccessType("property") for getDepartmentId() method within Department class in that case. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Q1397. Can we have 2 entity fields mapped to the same column in Hibernate ? Hibernate
Ans. No, it's not legal in hibernate. 1 column should be mapped to only one field in entity. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  Ans. 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 Q1399. 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 Q1400. 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 Q1401. 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 Q1402. Which is your favorite Design pattern, each in Creational , Structural and Behavioral and Why ? Design
Ans. [Open Ended Answer] Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  Design Patterns Intermediate Q1403. 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 Q1404. 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 Q1405. 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 Q1406. 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 Q1407. 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 Q1408. 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 Q1409. What is the difference between GIT Commit and Push ? GIT
Ans. Git commit commit the changes to local repository whereas Push commits the changes to Remote repository. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  GIT  Configuration Management  commit vs push Q1410. 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