Interview Questions and Answers - Order By Newest Q1361. 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 Q1362. What are the methods to connect to database in Java ? Database
Ans. JDBC ( Java Database Connectivity ),ODBC (Open Database Connectivity), Hibernate, JPA ( Java Persistence API ), JOOQ,MyBatis Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  database connection  jdbc  ORM  Hibernate Asked in 1 Companies Frequently asked Spring interview question. Q1363. 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 Q1364. 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 Q1365. 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 Q1366. 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 Q1367. 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 Q1368. 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 Q1369. 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 Q1370. 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 Q1371. 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 Q1372. 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 Q1373. 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 Q1374. 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 Q1375. 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 Q1376. 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   Q1377. 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   Q1378. 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   Q1379. 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 Q1380. 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 Q1381. 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   Q1382. 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 Q1383. 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 Q1384. 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 Q1385. 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 Q1386. 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 Q1387. 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 Q1388. 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 Q1389. 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 Q1390. What is the precedence of operators in Java ? Core Java
Ans. http://introcs.cs.princeton.edu/java/11precedence/ Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  operators  operator precedence basic