Interview Questions On Java,Java EE


Enter your email address:



Add to Technorati Favorites
Google PageRank Checker
Locations of visitors to this page

Friday, April 3, 2015

Core Java Interview Questions

Every year many thousand technocrats choose Java careers across the globe,after formally taking Java training classes,courses and/or Java certifications like OCJP etc.While appearing for technical interviews,these budding Java programmers face variety of technical questions, are asked to write code snippets to prove their mettle in relevant topics of Java.They are not only assessed on language basics but also on their familiarity with Java development tools, coding standards and guidelines,optimization of Java code,load tests,securing code through Java obfuscation and many more. It is their performance in these interviews which decides their career fate and is highly dependent on to-the-point and not too verbose answers.

Apart from technical questions, an interviewee faces a spate of personal questions as well.In post, Personal Interview Questions you will find variety of questions asked on personal front.In wired world, it is very important to know where your resources are lying and how credible are they.

This blog intends to provide a consolidated knowledge base for all netizens,budding Java Engineers or experienced ones, interested in Java technology.This blog will primarily focus on 'Core Java' related questions and later on advanced topics in Java EE space,Open source technologies and frameworks and more.At this point this is a nice idea to put a roadmap right away to put all these questions in an organized fashion. In order to access questions list on a particular topic,please click the links associated with it.It will open the questions list in the same browser window and in order to comeback to this page, while going through various posts, you have to click back button in your bowser window.Each answer for a question on various topics will open in a fresh window,while you are through with reading an answer,close the open window in order to comeback to the questions list.If you want to access Master List of Core Java Interview Questions then click here.


Java Language Fundamentals (Click Link To Access Questions' List)
  1. Object Oriented Analysis and Design Basics, UML And Java
  2. Inside JVM
  3. Datatypes,Keywords,Operators and Assignments,Identifies etc.
  4. Declarations and Modifiers,Conversion,Casting and Promotion
  5. Flow control
  6. Assertions
  7. Exception Handling and Garbage Collection
  8. Objects and Classes
Packages and their classes (Click Link To Access Questions' List)
  1. java.lang.*
  2. java.util.*
  3. java.io.*
  4. java.awt.*
  5. java.net.*
Java and Database Access
JFC Swing
Collection APIs

Check more miscellaneous short questions on Core Java with short answers,here.

If you starve for more knowledge on Core Java,you may like to check out online e-books and other resources on Core Java or access all Online Java and Java EE resources. All suggestions,comments are welcome in order to make this space more productive and useful for all its audiences.

Read more on Core Java:
- Short Questions On Core Java
- Interview Questions on Java 5
- Enhancements in Java 7
Continue reading...

Thursday, April 2, 2015

Java EE,Open Source,Advanced Technologies Interview Questions

In continuation of earlier post on Java Interview Questions this post is focussed on interview questions in several Java EE technologies(erstwhile J2EE).Apart from Java EE, interview questions on most widely used open source technologies like Struts,Hibernate,Spring and Velocity and more will also be covered.

On constant requests by readers to put something on personal interview questions, consequently, you may like to read post on personal interview questions , prior talking about Java Enterprise Edition.

Sun Microsystems introduced Java EE 5 specification under JSR 244 and the final release was made public on May ,2006.Java EE has become a cornerstone technology for enterprise level web based solution development.It has more than three million downloads and more than twenty six vendors' application servers support this specification.It is significant to go through an introduction of Java EE 5 before jumping to questions list straightaway.You can capture essence of Java EE 5 here in detail.

If you directly want to access Master List of Java EE Interview Questions then click here.

The list of questions on various topics covered under Java EE hood is as follows(on the basis of different technologies covered under Java EE umbrella) :

Java EE 5(Click To Access Questions' List)
Java Servlets
Java Server Pages and JSP Standard Tag Libraries
Enterprise Java Beans
Java Message Services
Java APIs for XML Parsing
Java Connector Architecture
Java Mail
Java Transaction APIs

Open Source Technologies/Emerging Frameworks:
Struts
Hibernate Framework
Spring Framework
Velocity
Apache AXIS
Annotations or attributes based programming (xdoclet etc).
Aspect Oriented Programming (AOP).
EJB 3.0.
Inversion of Control (IOC) (Also known as Dependency Injection).
JavaServer Faces (JSF) framework.
Test Driven Development (TDD).

Architectures:
Service Oriented Architecture

Others
Java Design Patterns

If anyone of you has come across a very unique experience in terms of technical and personal questions asked, feel free to share your experience.

Keep sharing your resources for ongoing learning...

Learn more about Java EE, here.
Continue reading...

Monday, March 2, 2015

Master List Of Core Java Questions

    OOPS
  1. What is an Object?

  2. What is a Class?

  3. What is OOAD?


  4. What is Data Abstraction ?

  5. What is Data Encapsulation?


  6. What is the difference between Data Abstraction and Information Hiding?

  7. What is Inheritance and what are different types of it?

  8. Why Java uses Singly rooted hierarchy?

  9. Why does Java not support Multiple Inheritance?

  10. Why is Java not 100% pure OOP language?

  11. What is Early Binding?

  12. What is Polymorphism/Late Binding?

  13. What is method overloading?

  14. What is method overriding?

  15. How is Java different from C++?

  16. What is UML and how is it useful in designing large systems?

  17. Is UML useful for procedural programming ?


  18. What are different notations used in UML ?

  19. What is a Use case and an Actor?

  20. How to identify an Actor?

  21. What is Generalization?

  22. What is Association and how it maps into a Java class?

  23. What is Aggregation and how it maps into a Java class?

  24. What is Composition and how it maps into a Java class?

  25. What is Dependency and how it maps into a Java class?

  26. What is the purpose of State machine diagrams?

  27. What are different kinds of Structure diagrams?

  28. What are different kinds of Interaction diagrams?

  29. What are different kinds of Behavior diagrams?

  30. Java Fundamentals

  31. What is a Java Virtual Machine (JVM)?

  32. What is a JVM consisted of?

  33. What is a class loader and what is its responsibilities?

  34. What is heap and stack?

  35. How is your Java program executed inside JVM?

  36. What is Java class file's magic number?

  37. How JVM performs Thread Synchronization?

  38. How JVM performs Garbage Collection?

  39. How to profile heap usage?

  40. What will you do if VM exits while printing "OutOfMemoryError" and increasing max heap size doesn't help?

  41. Should one pool objects to help Garbage Collector?Should one call System.gc() periodically?

  42. An application has a lot of threads and is running out of memory, why?

  43. If your program is I/O bound or running in native methods, do these activities engage JVM?

  44. What is the difference between interpreted code and compiled code?

  45. Why Java based GUI intensive program has performance issues?

  46. What is 64 bit Java ?

  47. What is the difference between JVM and JRE?

  48. What are different primitive datatypes in Java?

  49. What are expressions,statements and blocks in Java?

  50. What is a transient variable?

  51. What is the difference between the '&' operator and the '&&' operator?

  52. Why main method of Java has public static void?

  53. If you have static block, constructor and main method in Java file then what will be the sequence of method calls?

  54. What are the command line arguments?

  55. Does Java support multi dimensional arrays?

  56. What are the restrictions for static method?

  57. Why a abstract method cannot be static?

  58. Is 'sizeof' a keyword?

  59. What is the precedence of operators in Java?

  60. How is an argument passed in Java methods?

  61. What is the difference between class variable, member variable and automatic(local) variable?

  62. When are static and non static variables of a class initialized?

  63. Can shift operators be applied to float types?

  64. What are different Java declarations and their associated rules?

  65. What are Java Modifiers?

  66. Explain final modifier.

  67. Can you change the reference of the final object?

  68. Can abstract class be instantiated?

  69. When does the compiler insist that the class must be abstract?

  70. Where can static modifiers be used?

  71. What is static initializer code?

  72. Can an anonymous class implement an interface and extend a class at the same time?

  73. What are volatile variables?

  74. Can protected or friendly features be accessed from different packages?

  75. How many ways can one write an infinite loop?

  76. When do you use 'continue' and 'break' statements?

  77. What is the difference between 'while' and 'do while' loop?

  78. What is an Assertion and why using assertion in your program is a good idea ?

  79. Explain Assertions with a code exmaple.

  80. How many forms of assertions we have?

  81. When assertions should be avoided?

  82. What situations are best suitable for implementing assertions?

  83. What is Exception ?

  84. What is a user-defined exception?

  85. What do you know about the garbage collector?

  86. Why Java does not support pointers?

  87. Does garbage collection guarantee that a program will not run out of memory?

  88. What is finally in Exception handling?

  89. What can prevent the execution of the code in finally block?

  90. Explain 'try','catch' and 'finally' blocks?

  91. Define Checked and Unchecked exception.

  92. What is the difference between an abstract class and an interface?

  93. What is the use of interface?

  94. What is serializable interface?

  95. Does a class inherit constructors from its superclass?

  96. What's the difference between constructors and other methods?

  97. If the method to be overridden has access type 'protected', can subclass have the access type as 'private'?

  98. If you use super() or this() in a constructor where should it appear in the constructor?

  99. What modifiers may be used with an inner class that is a member of an outer class?

  100. Can an inner class be defined inside a method?

  101. What is an anonymous class?

  102. What is a thread?

  103. What is the difference between process and threads?

  104. What are two types of multitasking?

  105. What are two ways of creating threads in Java and why so?

  106. How does multithreading take place on a computer with a single CPU?

  107. How a Java object be locked for exclusive use by a given thread?

  108. What is Synchronization?

  109. Explain wait(),notify(), and notifyAll() methods?

  110. What is a Daemon thread?

  111. How a dead thread can be started?

  112. What is the difference between String and StringBuffer?

  113. How is '==' different from .equals() method in case of String objects?

  114. Explain StreamTokenizer?

  115. What is Collection?

  116. Explain List,Set and Map.

  117. What is the serialization?

  118. What is the difference between Serializable and Externalizable interface?

  119. What is memory leak?

  120. Difference between ArrayList and Vector class?

  121. What is the difference between Hashtable and HashMap?

  122. What is JFC?

  123. What is the difference between JFC Swing and AWT?

  124. What is the base class for all swing components?

  125. What are lightweight and heavyweight components ?

  126. How can a GUI component handle its own events?

  127. What is a Layout Manager and what are its different types and their advantages?

  128. How are the elements of a GridBagLayout organized?

  129. What are the problems faced by Java programmers in absence of layout managers?

  130. Where the CardLayout is used?

  131. What is the difference between GridLayout and GridBagLayout?

  132. How will you add a panel to a frame?

  133. What is the difference between Application and Applet?

  134. Explain Lifecycle of the Applet and what is the order of method invocation in an applet?

  135. What is the difference between Java class and bean?

  136. What is difference between trusted and untrusted applet?

  137. How do you set Java Library path programmatically?

  138. Explain the usage of java.util.Date and more classes and APIs for date handling in Java?

  139. JDBC

  140. What is JDBC ?

  141. What are four drivers available in JDBC?

  142. How do you establish database connection using JDBC?

  143. How do you connect to a MySql Database using JDBC?

  144. What are the different types of Statements?

  145. What is PreparedStatement and how is different from Statement?

  146. What is the difference between executeQuery () and execute() ?

  147. What is the difference between executeQuery () and executeUpdate()?

  148. How do you call a stored procedure in Java?

  149. What are new features from JDBC2.0 onwards?

  150. How can a cursor move in scrollable result sets?

  151. Differentiate TYPE_SCROLL_INSENSITIVE and TYPE_SCROLL_SENSITIVE?

  152. How will you differentiate the following two ways of loading a database driver?

  153. How can you display a particular web page from an applet?

  154. How can you get the hostname on the basis of IP addres ?

  155. How can you get an IP address of a machine from its hostname?

  156. How do you know who is accessing your server?

  157. What are different socket options?

  158. What should I use a ServerSocket or DatagramSocket in my applications?
Continue reading...

Sunday, March 1, 2015

Master List Of Java EE,Open Source,Advanced Technologies Questions(Release I )

    Servlets

  1. What is a servlet? Explain its lifecycle.

  2. What is the difference between CGI and servlets?

  3. What is a middleware and what is the functionality of Webserver?


  4. Can there be more than one instance of a servlet at one time ?

  5. Why there are no constructors in servlets?

  6. What is a Servlet Context?

  7. What is meant by Session tell me something about HttpSession?

  8. What is the difference between GenericServlet and HTTPServlet?

  9. What is the difference between doGet and doPost methods of HttpServlet class?

  10. Why do GenericServlet and HttpServlet class implement Serializable interface?

  11. How will you pass values from HTML to the servlet?

  12. Can you use System.exit in your servlet end code?

  13. If my browser does not support Cookie and my server sends a Cookie instance what will happen?

  14. Can you use System.exit in your servlet end code?

  15. What is the difference in between encodeRedirectURL and encodeURL?

  16. How do you make servlet thread-safe?

  17. How do you communicate between applet and servlet?

  18. JSP

  19. What is the difference between Java Servlets and Java ServerPages (JSP)?

  20. What is the difference between page directive 'include' and 'jsp include' action command?

  21. What is the difference between 'jsp:forward' and HttpResponse.sendRedirect()?

  22. What is the difference between 'include file=".."' and 'jsp:include page = ... '?

  23. What are implicit objects in JSP?

  24. Explain the life-cycle methods of JSP

  25. Explain different constituents of JSP like comments,expressions,declarations,scriptlets.

  26. Does JSP support XML pages creation?

  27. How can I show various kind of documents to a web client from JSP's and/or servlets?

  28. How will you handle runtime exceptions in your JSPs?

  29. How can you prevent caching in JSP?

  30. EJB

  31. How EJB evolved over the years?

  32. What are Entity Bean and Session Bean?

  33. How is container managed entity bean created?

  34. What is the difference between Container managed persistent and Bean managed persistent

  35. What is the difference between ejbCreate() and ejbPostCreate() in EntityBean?

  36. What are the services provided by the EJB container ?

  37. What are new features of EJB3?

  38. What is Connection Pooling? Is it advantageous?

  39. What's difference between Servlet/JSP session and EJB session?

  40. How is JDO(Java Data Object) different from VO(Value Object) ?

  41. What is session facade?

  42. EJB Transactions

  43. What are Bean-Managed Transactions?

  44. What are some tips for using bean-managed transaction demarcation?

  45. What is JTS ?

  46. What are transaction properties?

  47. What are transaction attributes ? Which transaction attributes should I use in which situations?

  48. How can you handle transaction isolation?

  49. Struts Framework

  50. What is Struts and how it helps in web development?

  51. Explain Struts1.x in a nutshell?

  52. What are the methods in Action class?

  53. How you will handle errors and exceptions in Struts?

  54. How does Validator framework work in Struts?

  55. What is DispatchAction?

  56. How to handle duplicate submits in Struts?(new)

  57. Spring Framework

  58. What is Spring framework

  59. Why is Spring Framework needed anyway?

  60. What do you understand by Inversion of Control/Dependency Injection?

  61. What is BeanFactory?

  62. Explain ApplicationContext in Spring framework.

  63. What is Aspect Oriented Programming and how is it related with Spring?

  64. What are the problems you have with JDBC and how does Spring framework help to resolve them?

  65. Explain typical Bean life cycle in Spring Bean Factory Container

  66. What are ORMs supported by Spring and how it integrates with Hibernate?

  67. Java Message Service APIs

  68. What is messaging and how is it different from RMI?

  69. When is JMS needed?

  70. How Does the JMS API Work with the Java EE Platform?

  71. Explain JMS API Architecture.

  72. Explain Point-to-Point Messaging Domain.

  73. Explain Publish/Subscribe Messaging Domain.

  74. Java Design Patterns

  75. What are Design Patterns and why one needs them?

  76. What are different types of design patterns?

  77. What is Singleton Design Pattern?

  78. What is difference between Abstract Factory and Factory Method design patterns?

  79. Explain Adapter Design Pattern in Java

  80. Explain Decorator Design Pattern in Java

  81. Explain Facade Design Pattern in Java


Continue reading...

Sunday, February 1, 2015

Miscellaneous Core Java Questions With Short Answers


  1. In a Java program, how can you divert program messages to the system console, but error messages, say to a file?

    A. The class 'System has a variable out that represents the standard output, and the variable err that represents the standard error device. By default, they both point at the system console. This how the standard output could be re-directed:

    Stream stream = new Stream(new FileOutputStream("error.txt"));
    System.setErr(stream);
    System.setOut(stream);

  2. How do you know if an explicit object casting is needed?

    A. In order to assign a superclass object to a variable of a subclass,one needs to do explicit casting. For example:

    Person person;
    Man man;
    man = (Man)person;
    While automatic casting happens when you typecast a subclass object as parent class object.


  3. What's the difference between the methods sleep() and wait()

    A. The code sleep(1000); puts thread aside for exactly one second. The code wait(1000), causes a wait of up to one second. A thread could stop waiting earlier if it receives the notify() or notifyAll() call. The method wait() is defined in the class Object and the method sleep() is defined in the class Thread.

  4. Why would you use a synchronized block vs. synchronized method?

    A. A synchronized blocks place locks for shorter periods than synchronized methods.

  5. Can you write a Java class that could be used both as an applet as well as an application?

    A. Yes. Add a main() method to the applet.

  6. Can you call one constructor from another if a class has multiple constructors

    A. Yes. Use this() syntax.

  7. How will you convert a String array to an ArrayList object?

    A.

    String[] stringArray = new String[] {"x", "y", "Z"};
    List list = Arrays.asList(stringArray);



  8. Does it matter in what order catch statements for FileNotFoundException and IOExceptipon are written?

    A. Yes, it does. The FileNoFoundException is inherited from the IOException. Exception's subclasses have to be caught first.

  9. Can an inner class declared inside of a method access local variables of this method?

    A. It's possible if these variables are final.

  10. What can go wrong if you replace && with & in the following code:

    String a=null;
    if (a!=null && a.length()>10) {...}


    A. A single ampersand here would lead to a NullPointerException.

  11. When should the method invokeLater()be used?

    A. To ensure that Swing components are updated through the event-dispatching thread.

  12. What's the difference between a queue and a stack?

    A. Stacks works by last-in-first-out rule (LIFO), while queues use the FIFO rule

  13. You can create an abstract class that contains only abstract methods. On the other hand, you can create an interface that declares the same methods. So can you use abstract classes instead of interfaces?

    A. Sometimes. But your class may be a descendant of another class and in this case the interface is your only option.

  14. If you're overriding the method equals() of an object, which other method you might also consider?

    A.hashCode()

  15. You are planning to do an indexed search in a list of objects. Which of the two Java collections should you use: ArrayList or LinkedList?

    A. ArrayList

  16. How would you make a copy of an entire Java object with its state?

    A. Have this class implement Cloneable interface and call its method clone().

  17. How can you minimize the need of garbage collection and make the memory use more effective?

    A. Use object pooling and weak object references.

  18. There are two classes: A and B. The class B need to inform a class A when some important event has happened. What Java technique would you use to implement it?

    A. If these classes are threads then consider notify() or notifyAll(). For regular classes one can use the Observer interface.

  19. How will you sort a collection object?

    A.
      
    // Sort
    Collections.sort(list);

    // Case-insensitive sort
    Collections.sort(list, String.CASE_INSENSITIVE_ORDER);

    // Reverse-order sort
    Collections.sort(list, Collections.reverseOrder ());

    // Case-insensitive reverse-order sort
    Collections.sort(list, String.CASE_INSENSITIVE_ORDER);
    Collections.reverse(list);



  20. In a Java class, one has 10 variables. One wants to serialize only 3 variables,how can this be achieved?

    A.Make variables as 'transient' which are not to be serialized.


Continue reading...
 

Disclaimer
Interview Questions On Java,Java EE Copyright © 2014