Interview Questions and Answers - Order By Newest Q631. Is there any relationship between Web.xml and Spring.xml ? Spring
Ans. No, there is no relationship between web.xml and spring.xml but you have to configure spring.xml in web.xml in order initialize beans when application starts up Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  spring  web.xml  spring.xml  deployment descriptor Asked in 1 Companies Q632. Scale yourself on Java on the scale of 1 to 10 General
Ans. [Open Ended Answer]
The objective of the question is to check how efficient one is in the language so that appropriate level questions are asked. Don't tell too high number if you are being interviewed for a junior or mid level position as the interviewer may throw advance level questions. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Asked in 17 Companies Q633. Which environment variables do we need to set in order to run Java programs? Core Java
Ans. PATH, CLASSPATH and JAVA_HOME Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  environment variables  path  classpath  java_home Asked in 3 Companies basic   frequent Q634. Is there a way to know size of an object in Java ? Core Java
Ans. No, Java doesn't have a sizeOf operator. In C / C++ , its required to determine how much memory allocation is required which is not the case with Java. Java handles memory allocation and deallocation intrinsically. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  sizeOf  size of object  sizeOf operator Asked in 1 Companies   rare Q635. How does Java handle integer overflows and underflows? Core Java
Ans. It uses those low order bytes of the result that can fit into the size of the type allowed by the operation. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  integer  data types Asked in 1 Companies   rare Ans. Interface that is declared inside the interface or class, is known as nested interface. It is static by default. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  interface  nested interface intermediate Try 1 Question(s) Test Q637. What kind of thread is garbage collection thread ? Core Java
Ans. Daemon thread Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  garbage collection intermediate Try 2 Question(s) Test Q638. What is the difference between the Reader/Writer java.io hierarchy and the Stream class hierarchy? Core Java
Ans. The Reader/Writer hierarchy is character oriented, whereas the Stream class hierarchy is byte oriented. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java io  streams intermediate Ans. It's an object that reads from one stream and writes to another. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java io  io filter intermediate Q640. Can we convert a numeric IP address to a web host name ? Java EE
Ans. Yes, using InetAddress.getByName("<IP Address>").getHostName(); Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  ip address to hostname  INETAddress intermediate Q641. Which interface is responsible for transaction management in JDBC ? Database
Ans. Connection Interface Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  jdbc Q642. how to access the methods of an inner class? Core Java
Ans. It depends on the type of inner class
To access non static inner class method
new OuterClass().new InnerClass().getMethod();
To access static method of static inner class
new OuterClass.InnerClass().getMethod(); Sample Code for inner class Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  inner classes  nested aclasses Asked in 1 Companies Intermediate   frequent Q643. What are the cursors available in Java ? Core Java
Ans. Enumeration
Iterator
List iterator Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  cursors  iterator Q644. Which Web and Application server is being used by your application ? Server
Ans. We are using Apache 2.3 and Tomcat 5.6 Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  web server  application server  server Basic   frequent Q645. How do you monitor your logs while investigating a high severity problem ? Support
Ans. We try to look for errors in the last n minutes when the issue occurred. If the issue is still occurring intermittently, We tail the logs for different application server instances to see the error snippets coming in the live logs. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  production support  unix  application logs Q646. What actions you take if there is an issue related to Database server ? Support
Ans. We involve DBA and try to solve it through them. By the time they are solving it , we keep the stake holders informed regarding the progress. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  database  database server  production support Q647. How are DB transactions handled in Hibernate ? Hibernate
Ans. // Non-managed environment idiom
Session sess = factory.openSession();
Transaction tx = null;
try {
tx = sess.beginTransaction();
// do some work
...
tx.commit();
}
catch (RuntimeException e) {
if (tx != null) tx.rollback();
throw e; // or display error message
}
finally {
sess.close();
} Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Asked in 1 Companies Ans. Its used to access the object properties using the object reference or class properties using the Class Name. Moreover its used to access the classes and Interfaces of a package. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  operators Q649. How should we handle errors while writing or accessing Stored Procedures? Database
Ans. Store Procedure returns the error code. Moreover we can put the call withing try block and catch SQL Exception. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  stored procedure  exception handling Q650. What is memory leak ? How Java helps countering memory leaks compared to C++ ? Core Java
Ans. Memory Leak is a situation wherein we have a reserved memory location but the program has lost its reference and hence has no way to access it.
Java doesn't have concept of Pointers, Moreover Java has concept of Garbage collection that frees up space in heap that has lost its references. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  memory leak  garbage collection intermediate   frequent Q651. What are the points to be considered if we move from Eager initialization to Lazy Initialization in Hibernate ? Hibernate
Ans. Make sure that the properties of dependent Hibernate entities are not accessed and if yes, better wrap the whole code within single transaction. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  lazy loading  lazy initialization Q652. How does Lazy Initialization helps improving performance of an application ? Hibernate
Ans. Lazy Initialization means , Load Dependencies when required. Which means less load on application resources as only required data is loaded upfront. It's not only good for better performance but for better resource utilization too. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  lazy loading  lazy initialization   frequent Q653. What are the benefits of creating immutable objects ? Core Java
Ans. 1. Security and Safety - They can be shared across multiple threads as they are thread safe. Moreover, it protects then from bad state due to interception by the other code segment. One such problem due to mutability and access by alternate code segment could be the change of hash code and then the impact on its search with hash collections.
2. Reuse - In some cases they can be reused as only one copy would exist and hence it can be relied upon. For example - String Pool Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  immutable  immutability objects Asked in 1 Companies Intermediate   frequent Q654. Can you name some of the Java frameworks in different domains ? Frameworks
Ans. Web Framework - Spring , Struts, Play
Dependency Injection frameworks - Google Guice , PicoContainer and Dagger
ORM Framework - Hibernate
Big Data / ETL Frameworks - Apche Hadoop , Apache Crunch, Apache Spark.
View Frameworks - JSF , Apache Wicket,jtwig.
Java Gui Frameworks - SWT , AWT, JavaFX
Testing - Junit, Mockito, PowerMock, EasyMock, JMock, JMockit
Rest Web services - Jersey , Restlet , RestX, RestEasy ,Restfulie
Here is the big list for reference - http://javasearch.buggybread.com/home2.php?keyword= Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  frameworks Asked in 2 Companies intermediate   frequent Q655. What is the difference between
File f = new File("homexyz.txt");
and
File f = File.createTempFile("xyz",".txt","home"); ? Core Java
Ans. First will not create physical file in storage whereas the second will. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  file handling  File.createTempFile  file handling intermediate   rare Q656. What is a certificate authority ? Security
Ans. A trusted organization which issues public key certificates and provides identification to the bearer. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  authentication  auth certificatesAns. https://javasearch.buggybread.com/InterviewQuestions/questionSearch.php?searchOption=label' Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  Algorithm  Sorting Algorithm Asked in 4 Companies basic   frequent Q658. What will be the output of following code ?
Base Interface
public interface BaseInterface {
int i = 4;
}
Derived Interfaces
public interface DerivedInterface1 extends BaseInterface{
int i = 5;
}
public interface DerivedInterface2 extends BaseInterface{
int i=6;
}
Implementing Class
public class Class implements DerivedInterface1,DerivedInterface2 {
public static void main(String[] args){
System.out.println(BaseInterface.i);
}
}
What will be the output upon executing main and Why ? Core Java
Ans. It will print 4 because member elements of an interface are implicitly static and hence the concept of overriding doesn't work.
Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  interfaces  coding  code  extending interfaces  diamond interfaces Asked in 1 Companies intermediate Q659. What will be the output of following code ?
Base Interface
public interface BaseInterface {
int i = 4;
}
Derived Interfaces
public interface DerivedInterface1 extends BaseInterface{
int i = 5;
}
public interface DerivedInterface2 extends BaseInterface{
int i=6;
}
Implementing Class
public class Class implements DerivedInterface1,DerivedInterface2 {
int i=10;
public static void main(String[] args){
System.out.println(new Class().i);
}
}
What will be the output upon executing main and Why ? Core Java
Ans. 10 Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  interfaces  coding  code intermediate Q660. 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