Core java,springs,Hibernate Interview Questions & Answers

4 avg. rating (80% score) - 5879 votes

Core java,springs,Hibernate Interview Questions & Answers

Are you good at Core java, Springs, Hibernate? Looking For a chance to grow your career in Core java, springs, hibernate jobs then we provide complete Core java, Springs, hibernate interview Question and Answers in our site. To be precise Core Java is Java is a general-purpose computer-programming language that is concurrent, class-based, object-oriented, and specifically designed to have as few implementation dependencies as possible, The Spring Framework is an application framework and inversion of control container for the Java platform, Hibernate ORM (Hibernate in short) is an object-relational mapping tool for the Java programming language. If you are good at the Core java, springs, hibernate then there are various companies that offer jobs in various role like Developer Core Java, Java with Spring Restful, JAVA Spring Developer, Cloud Architect - Java/Spring/Hibernate and many other roles too. For more information visit our site wisdomjobs.com.

Core Java,springs,Hibernate Interview Questions

Core java,springs,Hibernate Interview Questions
    1. Question 1. What Is Annotation In Java?

      Answer :

      An annotation, in the java programming language is a special form of syntactic metadata that can be added to Java Source Code. Classes, methods, variables parameters and packages may be annotated. Unlike Java doc tags, Java annotation are reflective, in that they are embedded in class files generated by the compiler and may be retained by the java VM to make retrievable at run-time.

      Annotation is basically to attach metadata to method, class or package. Metadata is used by the compiler to perform some basic compile-time checking

    2. Question 2. What Is The Most Important Feature Of Java?

      Answer :

      Java is a platform independent language.

    3. Question 3. What Are The Differences Between The Methods Sleep() And Wait()?

      Answer :

      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. Question 4. How Many Types Of Memory Areas Are Allocated By Jvm?

      Answer :

      Many types:

      • Class(Method) Area
      • Heap
      • Stack
      • Program Counter Register
      • Native Method Stack

    5. Question 5. What Is The Difference Between Prepared Statement And Statement In Java?

      Answer :

      A statement is parsed and executed each time its call sent to database. A prepared statement may be parsed once and executed repeatedly with different parameters.

    6. Question 6. What Do You Mean By Platform Independence?

      Answer :

      Platform independence means that we can write and compile the java code in one platform (eg Windows) and can execute the class in any other supported platform eg (Linux,Solaris,etc).

    7. Question 7. What Is The Difference Between Constructors And Other Methods In Core Java?

      Answer :

      • Constructor will be automatically invoked when an object is created whereas method has to be called explicitly.
      • Constructor needs to have the same name as that of the class whereas functions need not be the same.
      • There is no return type given in a constructor signature (header). The value is this object itself so there is no need to indicate a return value.
      • There is no return statement in the body of the constructor.
      • The first line of a constructor must either be a call on another constructor in the same class (using this), or a call on the superclass constructor (using super). If the first line is neither of these, the compiler automatically inserts a call to the parameterless super class constructor.

    8. Question 8. What Is Jit Compiler?

      Answer :

      Just-In-Time(JIT) compiler:It is used to improve the performance. JIT compiles parts of the byte code that have similar functionality at the same time, and hence reduces the amount of time needed for compilation.Here the term “compiler” refers to a translator from the instruction set of a Java virtual machine (JVM) to the instruction set of a specific CPU.

    9. Question 9. What Are Four Steps For The Execution Of Query:

      Answer :

      • Query is parsed
      • Query is compiled.
      • Query is optimized.
      • Query is executed.

      In case of statement, the above four steps are performed every time. And in case of prepared statement the above three steps are performed once.

    10. Question 10. What Is A Jvm?

      Answer :

      JVM is Java Virtual Machine which is a run time environment for the compiled java class files.

    11. Question 11. What's The Difference Between J2sdk 1.5 And J2sdk 5.0?

      Answer :

      There's no difference, Sun Microsystems just re-branded this version.

    12. Question 12. What Is Platform?

      Answer :

      A platform is basically the hardware or software environment in which a program runs. There are two types of platforms software-based and hardware-based. Java provides software-based platform.

    13. Question 13. Explain Java Thread Life Cycle.

      Answer :

      The life cycle of threads in Java is very similar to the life cycle of processes running in an operating system. During its life cycle the thread moves from one state to another depending on the operation performed by it or performed on it. A Java thread can be in one of the following states:

      • NEW: A thread that is just instantiated is in new state. When a start () method is invoked, the thread moves to the ready state from which it is automatically moved to runnable state by the thread scheduler.
      • RUNNABLE (ready_running) A thread executing in the JVM is in running state.
      • BLOCKED A thread that is blocked waiting for a monitor lock is in this state. This can also occur when a thread performs an I/O operation and moves to next (runnable) state.
      • WAITING A thread that is waiting indefinitely for another thread to perform a particular action is in this state.
      • TIMED_WAITING (sleeping) A thread that is waiting for another thread to perform an action up to a specified waiting time is in this state.
      • TERMINATED (dead) A thread that has exited is in this state.

    14. Question 14. What Is The Difference Between A Jdk And A Jvm?

      Answer :

      JDK is Java Development Kit which is for development purpose and it includes execution environment also. But JVM is purely a run time environment and hence you will not be able to compile your source files using a JVM.

    15. Question 15. What Would You Use To Compare Two String Variables - The Operator == Or The Method Equals()?

      Answer :

      I would use the method equals() to compare the values of the Strings and the == to check if two variables point at the same instance of a String object.

    16. Question 16. What Is The Main Difference Between Java Platform And Other Platforms?

      Answer :

      The Java platform differs from most other platforms in the sense that it's a software-based platform that runs on top of other hardware-based platforms.It has two components:

      • Runtime Environment
      • API(Application Programming Interface)

    17. Question 17. Which Way A Developer Should Use For Creating Thread, I.e. Sub Classing Thread Or Implementing Runnable.

      Answer :

      There are two ways of creating Thread in java (i.e. sub classing or implementing Runnable). It is very important to understand the implication of using these two approaches. There are two different points about using these two approaches.

      By extending the thread class, the derived class itself is a thread object and it gains full control over the thread life cycle. Implementing the Runnable interface does not give developers any control over the thread itself, as it simply defines the unit of work that will be executed in a thread.

      Another important point is that when extending the Thread class, the derived class cannot extend any other base classes because Java only allows single inheritance. By implementing the Runnable interface, the class can still extend other base classes if necessary.

      To summarize, if developer needs a full control over the Thread life cycle, sub classing Thread class is a good choice, and if programs need more flexibility by extending other class developer, should go with implementing Runnable interface.

    18. Question 18. What Is A Pointer And Does Java Support Pointers?

      Answer :

      Pointer is a reference handle to a memory location. Improper handling of pointers leads to memory leaks and reliability issues hence Java doesn't support the usage of pointers.

    19. Question 19. How Can A Subclass Call A Method Or A Constructor Defined In A Superclass?

      Answer :

      Use the following syntax: super.myMethod(); To call a constructor of the superclass, just write super(); in the first line of the subclass‘s constructor.

    20. Question 20. What Gives Java Its 'write Once And Run Anywhere' Nature?

      Answer :

      The bytecode. Java is compiled to be a byte code which is the intermediate language between source code and machine code. This byte code is not platform specific and hence can be fed to any platform.

    21. Question 21. What Is The Difference Between Synchronized And Synchronized Block?

      Answer :

      In case of a Synchronized method a thread may need to have the lock for a longer time as compared to the synchronized block.

      Another difference between synchronized method and block is that we don’t specify the particular object whose monitor is required to be obtained by thread for entering a synchronized method, whereas we can specify the particular object in case of synchronized block.

    22. Question 22. Does Java Support Multiple Inheritance?

      Answer :

      Java doesn't support multiple inheritance.

    23. Question 23. How Would You Make A Copy Of An Entire Java Object With Its State?

      Answer :

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

    24. Question 24. What Is Classloader?

      Answer :

      The classloader is a subsystem of JVM that is used to load classes and interfaces. There are many types of classloaders e.g. Bootstrap classloader, Extension classloader, System classloader, Plugin classloader etc.

    25. Question 25. Static Synchronization Vs Instance Synchronization?

      Answer :

      When a static synchronized method is called, the program obtains the class lock before calling the method. This mechanism is identical to the case in which method is non-static, it is just a different lock, and this lock is solely for static method. Apart from the functional relationship between the two locks, they are not operationally related at all.

    26. Question 26. Is Java A Pure Object Oriented Language?

      Answer :

      Java uses primitive data types and hence is not a pure object oriented language.

    27. Question 27. What Is The Role Of Ioc Container In Spring?

      Answer :

      IOC container is responsible to:

      • create the instance.
      • configure the instance, and
      • assemble the dependencies.

    28. Question 28. What Are The Types Of Ioc Container In Spring?

      Answer :

      There are two types of IOC containers in spring framework.

      1. BeanFactory
      2. ApplicationContext

    29. Question 29. What Is The Difference Between Beanfactory And Applicationcontext?

      Answer :

      BeanFactory is the basic container whereas ApplicationContext is the advanced container. ApplicationContext extends the BeanFactory interface. ApplicationContext provides more facilities than BeanFactory such as integration with spring AOP, message resource handling for i18n etc.

    30. Question 30. What Are The Transaction Management Supports Provided By Spring?

      Answer :

      Spring framework provides two type of transaction management supports:

      • Programmatic Transaction Management: should be used for few transaction operations.
      • Declarative Transaction Management: should be used for many transaction operations.

    31. Question 31. What Are Classes For Spring Jdbc Api?

      Answer :

      • JdbcTemplate
      • SimpleJdbcTemplate
      • NamedParameterJdbcTemplate
      • SimpleJdbcInsert
      • SimpleJdbcCall

    32. Question 32. How Can You Fetch Records By Spring Jdbctemplate?

      Answer :

      You can fetch records from the database by the query method of JdbcTemplate. There are two interfaces to do this:

      • ResultSetExtractor
      • RowMapper

    33. Question 33. What Is Aop?

      Answer :

      AOP is an acronym for Aspect Oriented Programming. It is a methodology that divides the program logic into pieces or parts or concerns. It increases the modularity and the key unit is Aspect.

    34. Question 34. What Are The Aop Terminology?

      Answer :

      AOP terminologies or concepts are as follows:

      • JoinPoint
      • Advice
      • Pointcut
      • Aspect
      • Introduction
      • Target Object
      • Interceptor
      • AOP Proxy
      • Weaving

    35. Question 35. What Are The Types Of Advice In Aop?

      Answer :

      There are 5 types of advices in spring AOP.

      • Before Advice
      • After Advice
      • After Returning Advice
      • Throws Advice
      • Around Advice

    36. Question 36. What Does @controller Annotation?

      Answer :

      The @Controller annotation marks the class as controller class. It is applied on the class.

    37. Question 37. What Does @requestmapping Annotation?

      Answer :

      The @RequestMapping annotation maps the request with the method. It is applied on the method.

    38. Question 38. What Does The Viewresolver Class?

      Answer :

      The View Resolver class resolves the view component to be invoked for the request. It defines prefix and suffix properties to resolve the view component.

    39. Question 39. Which Viewresolver Class Is Widely Used?

      Answer :

      The org.springframework.web.servlet.view.InternalResourceViewResolver class is widely used.

    40. Question 40. How To Detect The Operating System On The Client Machine?

      Answer :

      In order to detect the operating system on the client machine, the navigator.appVersion string (property) should be used.

    41. Question 41. How Many Types Of Association Mapping Are Possible In Hibernate?

      Answer :

      There can be 4 types of association mapping in hibernate.

      • One to One
      • One to Many
      • Many to One
      • Many to Many

    42. Question 42. Is It Possible To Perform Collection Mapping With One-to-one And Many-to-one?

      Answer :

      No, collection mapping can only be performed with One-to-Many and Many-to-Many.

    43. Question 43. What Is Lazy Loading In Hibernate?

      Answer :

      Lazy loading in hibernate improves the performance. It loads the child objects on demand. Since Hibernate 3, lazy loading is enabled by default, you don't need to do lazy="true". It means not to load the child objects when parent is loaded.

    44. Question 44. What Is Hql (hibernate Query Language)?

      Answer :

      Hibernate Query Language is known as an object oriented query language. It is like structured query language (SQL). The main advantage of HQL over SQL is:

      • You don't need to learn SQL
      • Database independent
      • Simple to write query

    45. Question 45. What Is Sessionfactory?

      Answer :

      SessionFactory provides the instance of Session. It is a factory of Session. It holds the data of second level cache that is not enabled by default.

    46. Question 46. What Is Session?

      Answer :

      • It maintains a connection between hibernate application and database.
      • It provides methods to store, update, delete or fetch data from the database such as persist(), update(), delete(), load(), get() etc.
      • It is a factory of Query, Criteria and Transaction i.e. it provides factory methods to return these instances.

    47. Question 47. Explain Criteria Api?

      Answer :

      Criteria is a simplified API for retrieving entities by composing Criterion objects. This is a very convenient approach for functionality like "search" screens where there is a variable number of conditions to be placed upon the result set.

      Example : List employees = session.createCriteria(Employee.class) .add(Restrictions.like("name", "a%") ) .add(Restrictions.like("address", "Boston")) .addOrder(Order.asc("name") ) .list();

    48. Question 48. What Are The Most Common Methods Of Hibernate Configuration?

      Answer :

      The most common methods of Hibernate configuration are:

      • Programmatic configuration
      • XML configuration (hibernate.cfg.xml)

    49. Question 49. How Would You Reattach Detached Objects To A Session When The Same Object Has Already Been Loaded Into The Session?

      Answer :

      You can use the session.merge() method call.

    50. Question 50. What Are The States Of Object In Hibernate?

      Answer :

      There are 3 states of object (instance) in hibernate.

      • Transient: The object is in transient state if it is just created but has no primary key (identifier) and not associated with session.
      • Persistent: The object is in persistent state if session is open, and you just saved the instance in the database or retrieved the instance from the database.
      • Detached: The object is in detached state if session is closed. After detached state, object comes to persistent state if you call lock() or update() method.

Core Java Tutorial

Core Java,springs,hibernate Interview Questions

Core Java,springs,hibernate Practice Tests

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

Core Java Tutorial