Interview Questions and Answers - Order By Rating Q301. 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 Q302. 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 Q303. 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 Q304. 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 Q305. 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 Q306. 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 Q307. 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 Q308. 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 Q309. 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 Q310. 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 Q311. 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 Q312. 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 Q313. 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 Q314. 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 Q315. 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 Q316. What is an Attribute Dictionary and What are its benefits ? IBM WCS
Ans. Attribute dictionary is a set of common attributes that can be reused by multiple products.
The attribute dictionary provides a central place to manage shared attributes, with the following features:
The ability to standardize attributes.
The ability to easily compare attributes shared by products and SKUs.
The ability to quickly change attributes in one place to affect all catalog entries. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  Attribute dictionary Q317. How to enable Cross Site scripting protection in WCS ? IBM WCS
Ans. By specifying XSiteScriptingProtection within wc-server.xml. Prohibited characters and attributes are specified within XSiteScriptingProtection to protect the application from any XSS attach. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  Cross site scripting  XSS attack  XSS  XSiteScriptingProtection  wc-server.xmlAns. Selenium WebDriver is a tool for automating web application testing.It helps in replicating the manual tester behavior like keyboard entry, mouse events etc and then matching the output against the expected. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  selenium  webdriver Asked in 37 Companies Q319. Upon compiling the following class, What .class files will get created
public class OuterClass{
class InnerClass{
}
}
Core Java
Ans. OuterClass.class AND OuterClass$InnerClass.class Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  class files  compilation  compile  inner classes   nested classes Q320. isnt the use of HashTable and ConcurrentHashMap the same, i.e providing synchronized map collection ? Core Java
Ans. Yes, they both aim at providing synchronized access to the Map collection. The only difference is in their implementation. ConcurrentHashMap came after HashTable and hence technically more efficient as it doesn't lock the complete map while accessing it. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  HashTable  ConcurrentHashMap  map  Collections Q321. Difference between concurrentHashMap and HashTable ? Core Java
Ans. HashTable locks the complete collection to provide synchronization whereas ConcurrentHashMap only locks segments to achieve synchronization and hence better efficient and faster. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  concurrentHashMap  HashTable  Map  Collections Asked in 2 Companies Q322. Write a Program to print asterix like following using Recursion
**
***
****
*****
******
*******
********
*********
**********
Program should set the start and end index and then display this accordingly. For example the above pattern is for displayNumbersBetween(2,10) and following is for displayNumbersBetween(5,7)
*****
******
******* Core Java
Ans. public class BuggyBread {
public static void main(String args[]) {
displayNumbersBetween(5,7);
}
private static void displayNumbersBetween(int start,int end){
if(start > end){
return ;
} else {
for(int x=1;x<=start;x++){
System.out.print("*");
}
System.out.println("");
displayNumbersBetween(start+1,end);
}
}
} Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  recursion  code  coding Q323. Write a Program to display numbers between 2 numbers using recursion Core Java
Ans. public class BuggyBread {
public static void main(String args[]) {
displayNumbersBetween(2,10);
}
private static void displayNumbersBetween(int start,int end){
if(start > end){
return ;
} else {
System.out.println(start);
displayNumbersBetween(start+1,end);
}
}
} Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  recursion  code  coding Q324. Write a program using Recursion to print multiplication of numbers between the start and end number
For example - Passing start number as 2 and end number as 10, it should print 2*3*4*5*6*7*8*9*10 = 3628800 Core Java
Ans.
public class BuggyBread {
public static void main(String args[]) {
System.out.println(multiply(2,5));
}
private static int multiply(int start,int end){
if(start > end){
return 1;
} else {
return start * multiply(start+1,end);
}
}
} Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  recursion Q325. Write a program to print sum of numbers between the start and end number
For example - Passing start number as 2 and end number as 10, it should print 2+3+4+5+6+7+8+9+10 = 54 Core Java
Ans.
public class BuggyBread {
public static void main(String args[]) {
System.out.println(sum(2,10));
}
private static int sum(int start,int end){
if(start > end){
return 0;
} else {
return start + sum(start+1,end);
}
}
} Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  recursion Q326. Write a Program to print factorial of a number using recursion Core Java
Ans. public class BuggyBread {
public static void main(String args[]) {
System.out.println(factorial(5));
}
private static int factorial(int number){
if(number == 1){
return 1;
} else {
return number * factorial(number - 1);
}
}
} Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  recursion Asked in 25 Companies Q327. What is a method reference in Java ? Core Java
Ans. Introduced with java 8 , Method References help us to point to methods by their name.
A method references is described using :: symbol Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  method reference  java 8  lambda expressions Q328. What is the difference between circular queue and priority queue ? Data Structures
Ans. https://qr.ae/TWK2Ok Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  circular queue  priority queue  queue  data structures  collections Q329. Given two files with list of words, write a program to show the common words in both files Core Java
Ans. import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.io.*;
public class Common {
public static void main(String ar[])throws Exception
{
File f=new File("a.txt");
File f1=new File("x.java");
System.out.println(f.exists());
FileInputStream fin = new FileInputStream(f);
FileInputStream fin1 = new FileInputStream(f1);
byte b[]=new byte[10000];
byte b1[]=new byte[10000];
fin.read(b);
fin1.read(b1);
String s1 = new String(b);
String s2 =new String(b1);
String words1[] = s1.trim().split(" ");
String words2[] = s2.trim().split(" ");
Listlist1 = new ArrayList<>(Arrays.asList(words1));
Listlist2 = new ArrayList<>(Arrays.asList(words2));
list1.retainAll(list2);
System.out.println(list1);
}
} Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  file handling  file io  code  coding Asked in 1 Companies Q330. What is the difference between compilation and decompilation ? Core Java
Ans. Compilation is the process of converting Java source files to class files which can be executed by the Java runtime environment whereas Decompilation is the process of converting class files back to the Java Source code. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  compilation vs decompilation  compiler vs decompiler