Interview Questions 1 - 10  «Prev Next»

Java Reflection and Javabean Questions

  1. How is reflection used in JavaBeans?

    Answer: JavaBeans system will use reflection to infer events and properties. It allows an executing Java program to examine or "introspect" upon itself, and manipulate internal properties of the program. For example, it's possible for a Java class to obtain the names of all its members and display them.

  2. What is an object graph?

    Answer:
    When working with objects, you are using a number of connected objects.Taken from the Server Side: Store an object graph:
    Both Serialization and JDO will automatically store the closure of an object graph once one of the instances is identified as persistent. Both Serialization and JDO store the entire object graph as one file.

  3. How can one identify memory leaks ?

    Answer:
    Memory leaks can happen in many areas. If you have a real problem, you probably need to have a stack trace.
    Analyze the stack trace and discover if the problem is in the permgen, stack or heap area. If the problem is in your stack (StackOverflowError) you probably have a recursion problem (direct or indirect) that causes it. Check your code for exit conditions from recursions and solve it. If the problem is in the heap (OutOfMemoryError) check if you are releasing your objects when they are not needed. Sometimes for a heap problem, you need to rewrite part of your code changing it to a different design.
    For example if you need to extract data from a database to create a file and the quantity of data is very large, you can't handle the data in memory. A possible solution is writing the file row by row while reading the resultset so you will have in memory record only and not the whole table.



  4. What are the differences between a Back End Developer, a Full Stack Developer and a Front End developer?

    Answer:
    First of all, all three terms are related to web-based projects and describe area of required competence.
    'Full stack' means that developer is required to have skills in all levels of application: database, middle tier and user interface, that he is capable to use SQL (backend), webservices and HTML/Javascript when implementing a task.
    'Backend' and 'Frontend' means in practice 'everything on the server side' and 'everything on the client side'.
    Full stack developers are preferred for small or internal-oriented projects, dedicated backend and frontend developers for larger corporations.

  5. Explain the difference between encapsulation and abstraction in Java?

    Answer:
    Encapsulation is:
    1. Binding the data with the code that manipulates it.
    2. It keeps the data and the code safe from external interference.
    Abstraction is the process of hiding the implementation details and showing only functionality to the user. The best way to achieve abstraction is using 1 of the 2 reference types:
    1. abstract class
    2. Interface


  6. Why can't an abstract class be instantiated?

    Answer:
    An abstract class by definition cannot be instantiated. It is a decision of the Java language design (and all similar languages operate in a similar manner). The purpose of an abstract class is to provide the base class for subclasses.

  7. Can you give some scenarios where you have used multi-threading in Java applications?

    Answer:
    Servlets are inherently multi-threaded and each user will be using a thread from the thread pool. The number of threads are configured by means of the web container of the application server. Servlet 3.1 supports non-blocking I/O for better throughput.
    Another example of multi-threading is an application server since every request is a separated thread.

  8. What is wrong with the thread-per-request model?

    Answer:
    The pre-Servlet 3.1 specification uses the thread-per-request model, which limits the number of concurrent connections to the number of concurrently running JVM threads. Every thread introduces a significant increase of memory footprint and CPU utilization by means of context switches. Servlet 3.1 fixes this by means of non-blocking I/O. Fewer threads can be used in a pool to execute the request.
    NIO allows you to manage multiple channels (network connections or files) using only a single (or fewer) threads.

  9. What is the purpose of the strictfp keyword in Java?

    Answer:
    strictfp is a modifier in Java and is meant to be used to get accurate results while working with floating point numbers on different platforms and architectures in Java. strictfp can apply to classes and methods.

  10. What support does Spring framework provide for RESTful webservices?

    Answer:
    Spring MVC web application and RESTful web service framework.

SEMrush Software