{"id":66667,"date":"2018-06-27T10:06:02","date_gmt":"2018-06-27T10:06:02","guid":{"rendered":"https:\/\/www.whizlabs.com\/blog\/?p=66667"},"modified":"2021-01-21T10:43:41","modified_gmt":"2021-01-21T10:43:41","slug":"top-java-interview-questions","status":"publish","type":"post","link":"https:\/\/www.whizlabs.com\/blog\/top-java-interview-questions\/","title":{"rendered":"Top 100 Java Interview Questions with Detailed Answers"},"content":{"rendered":"<p style=\"text-align: justify;\"><strong><em>Are you a Java professional preparing for an interview? If yes, you\u2019ve reached the right page. Yes! We\u2019ve got you covered with Top 100 Java interview questions with detailed answers.<\/em> <\/strong><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">As a Java professional, it is required to be familiar with various Java technologies while going for an interview. In this Java interview questions blog, we have compiled a definitive set of most commonly asked Java interview questions and answers for freshers as well as experienced professionals to help them crack the Java interview. <\/span><\/p>\n<blockquote><p><span style=\"color: #ff6600;\"><em><span style=\"font-weight: 400;\">Millions of developers and a huge number of devices worldwide are using Java. Java is everywhere!!<\/span><\/em><\/span><\/p><\/blockquote>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">We have divided this list of Java interview questions into 9 sections to make it easier for you to easily prepare each section. So, let\u2019s start with the first section Core Java Interview Questions and Answers<\/span><\/p>\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_76 ez-toc-wrap-left counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #ea7e02;color:#ea7e02\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #ea7e02;color:#ea7e02\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/www.whizlabs.com\/blog\/top-java-interview-questions\/#Core_Java_Interview_Questions\" >Core Java Interview Questions<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.whizlabs.com\/blog\/top-java-interview-questions\/#Advanced_Java_Interview_Questions\" >Advanced Java Interview Questions<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/www.whizlabs.com\/blog\/top-java-interview-questions\/#JDBC_Java_Interview_Questions\" >JDBC Java Interview Questions<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/www.whizlabs.com\/blog\/top-java-interview-questions\/#String_Handling_Java_Interview_Questions\" >String Handling Java Interview Questions<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/www.whizlabs.com\/blog\/top-java-interview-questions\/#Exception_Handling_Java_Interview_Questions\" >Exception Handling Java Interview Questions<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/www.whizlabs.com\/blog\/top-java-interview-questions\/#Servlet_Java_Interview_Questions\" >Servlet Java Interview Questions<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/www.whizlabs.com\/blog\/top-java-interview-questions\/#Hibernate_Java_Interview_Questions\" >Hibernate Java Interview Questions<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/www.whizlabs.com\/blog\/top-java-interview-questions\/#Spring_Java_Interview_Questions\" >Spring Java Interview Questions<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/www.whizlabs.com\/blog\/top-java-interview-questions\/#_JSP_Java_Interview_Questions\" >\u00a0JSP Java Interview Questions<\/a><\/li><\/ul><\/nav><\/div>\n<h2 style=\"text-align: justify;\"><span class=\"ez-toc-section\" id=\"Core_Java_Interview_Questions\"><\/span><b>Core Java Interview Questions<\/b><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">In this section, we\u2019ve not only covered the core Java interview questions for freshers but you will also find the core Java interview questions for experienced professionals. If you are an aspirant fresher, determined enough to become a Java professional or want to bring your Java development career one level up, these Core <a href=\"https:\/\/www.whizlabs.com\/blog\/java-interview-questions-for-freshers\/\" target=\"_blank\" rel=\"noopener\">Java interview questions and answer<\/a> will help you reach the goal. If you have come across any other Java interview question, please post it in the comment section.<\/span><\/p>\n<ol style=\"text-align: justify;\">\n<li><b> Can you explain class and object with a Java example?<\/b><\/li>\n<\/ol>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\"><strong>Answer<\/strong> &#8211; Class and Object both are the basis of Object Oriented Programming, and the concept of class and object revolves around the real-world entities.<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">Class &#8211; A class in Java can be defined as a template or program construct that is used to create objects, and also its methods and data types.<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">The declaration of a class may include various components such as class name, body, modifiers, interface (not mandatory), and superclass (not mandatory).<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">Let\u2019s consider an example of class i.e. Student<\/span><\/p>\n<pre style=\"text-align: justify;\">Class Student \r\n\r\n{\r\n\r\n \u00a0\/\/ instance variables declaration\r\n\r\n \/\/ methods definition\r\n\r\n}<\/pre>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">Object &#8211; An object is known as the basic unit of Object Oriented programming. It is a program construct that has state, behavior, and identity.<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">Many objects are created in a Java program that interacts by invoking methods.<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">Let\u2019s consider the object of the Student class, that will be a specific student.<\/span><\/p>\n<pre style=\"text-align: justify;\"><strong>Student amaira = new Student ( );<\/strong><\/pre>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">It means one of the students of Student class is referred by \u2018<strong>amaira<\/strong>\u2019<\/span><\/p>\n<ol style=\"text-align: justify;\" start=\"2\">\n<li><b> What are the basic concepts\/principles of OOPS?<\/b><\/li>\n<\/ol>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\"><strong>Answer<\/strong> &#8211; The Object-Oriented Programming System is based on the four basic principles, these are &#8211;<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">Abstraction &#8211; The abstraction is the concept of representing essential features by hiding internal details or features.<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">Inheritance &#8211; The inheritance is the concept through which the objects of one class are able to acquire the characteristics of the objects of any other class.<\/span><\/p>\n<p style=\"text-align: justify;\"><img decoding=\"async\" class=\"wp-image-66675 size-full aligncenter\" src=\"https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/sites\/2\/2018\/06\/principle-of-oops.png\" alt=\"core java interview questions\" width=\"781\" height=\"391\" srcset=\"https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2018\/06\/principle-of-oops.png 781w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2018\/06\/principle-of-oops-300x150.png 300w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2018\/06\/principle-of-oops-768x384.png 768w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2018\/06\/principle-of-oops-640x320.png 640w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2018\/06\/principle-of-oops-681x341.png 681w\" sizes=\"(max-width: 781px) 100vw, 781px\" \/><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">Polymorphism &#8211; The polymorphism is the object-oriented programming concept that enables the creation of a function, a variable or an object with one name but in multiple forms. <\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">Encapsulation &#8211; An another OOPS concept that is used to hide the behaviour and properties of an object. This concept allows only appropriate outside access. Also, it avoids other objects to access the properties and methods of encapsulated object directly. <\/span><\/p>\n<ol style=\"text-align: justify;\" start=\"3\">\n<li><b> \u00a0Explain the basic features of Java.<\/b><\/li>\n<\/ol>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\"><strong>Answer<\/strong> &#8211; Java was created with the aim of making a simple, portable, and secure programming languages. Apart from these basic features, Java has many other awesome features that make it so popular. These are &#8211; <\/span><\/p>\n<ul style=\"text-align: justify;\">\n<li style=\"font-weight: 400;\"><i><span style=\"font-weight: 400;\">Java is a simple programming language<\/span><\/i><\/li>\n<\/ul>\n<ul style=\"text-align: justify;\">\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Java is distributed<\/span><\/li>\n<\/ul>\n<ul style=\"text-align: justify;\">\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Java is faster i.e. high-performance<\/span><\/li>\n<\/ul>\n<ul style=\"text-align: justify;\">\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Java is dynamic in nature<\/span><\/li>\n<\/ul>\n<ul style=\"text-align: justify;\">\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Java is multithreaded<\/span><\/li>\n<\/ul>\n<ul style=\"text-align: justify;\">\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Java is robust in nature<\/span><\/li>\n<\/ul>\n<ul style=\"text-align: justify;\">\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Java is highly portable language<\/span><\/li>\n<\/ul>\n<ul style=\"text-align: justify;\">\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Java is independent of platform<\/span><\/li>\n<\/ul>\n<ul style=\"text-align: justify;\">\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Java provides high-level security<\/span><\/li>\n<\/ul>\n<ul style=\"text-align: justify;\">\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Java is architecture neutral<\/span><\/li>\n<\/ul>\n<ul style=\"text-align: justify;\">\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Java is an object-oriented programming language<\/span><\/li>\n<\/ul>\n<ol style=\"text-align: justify;\" start=\"4\">\n<li><b> How is Java an object-oriented language?<\/b><\/li>\n<\/ol>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\"><strong>Answer<\/strong> &#8211; Being an object-oriented programming language is an important feature of Java. Let\u2019s understand what makes it object-oriented.<\/span><\/p>\n<ul style=\"text-align: justify;\">\n<li style=\"font-weight: 400;\"><i><span style=\"font-weight: 400;\">Java follows Object Oriented programming model<\/span><\/i><\/li>\n<\/ul>\n<ul style=\"text-align: justify;\">\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Java is focused on the modular approach<\/span><\/li>\n<\/ul>\n<ul style=\"text-align: justify;\">\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Java follows the concept of abstraction<\/span><\/li>\n<\/ul>\n<ul style=\"text-align: justify;\">\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Java strictly follows object-oriented principle encapsulation<\/span><\/li>\n<\/ul>\n<ul style=\"text-align: justify;\">\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Java is based on the inheritance i.e. object-oriented concept<\/span><\/li>\n<\/ul>\n<ul style=\"text-align: justify;\">\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Java follows the object-oriented principle of polymorphism<\/span><\/li>\n<\/ul>\n<ol style=\"text-align: justify;\" start=\"5\">\n<li><b> How will you compile a Java program?<\/b><\/li>\n<\/ol>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\"><strong>Answer<\/strong> &#8211; In order to compile a Java program, follow the steps mentioned below &#8211;<\/span><\/p>\n<ol style=\"text-align: justify;\">\n<li><i><span style=\"font-weight: 400;\">Save the source code file with .java extension. For example &#8211; student.java<\/span><\/i><\/li>\n<li><span style=\"font-weight: 400;\"> Javac compiler will then create a bytecode version of the source file i.e. Student.class<\/span><\/li>\n<li><span style=\"font-weight: 400;\"> The bytecode is the executable code and thus executed by the Java Virtual Machine (JVM), also known as Java runtime systems.<\/span><\/li>\n<\/ol>\n<ol style=\"text-align: justify;\" start=\"6\">\n<li><b> What does \u201cpublic static void main (String args [ ] )\u201c signify? Explain.<\/b><\/li>\n<\/ol>\n<p style=\"text-align: justify;\"><strong>Answer &#8211; <\/strong><\/p>\n<ul style=\"text-align: justify;\">\n<li style=\"font-weight: 400;\"><i><span style=\"font-weight: 400;\">\u201cpublic\u201d is the access specifier <\/span><\/i><\/li>\n<\/ul>\n<ul style=\"text-align: justify;\">\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">\u201cstatic\u201d is the access modifier that allows main ( ) method to be invoked without creating any instance of the class<\/span><\/li>\n<\/ul>\n<ul style=\"text-align: justify;\">\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">\u201cvoid\u201d is the return type that specifies that the main ( ) method won\u2019t return any value<\/span><\/li>\n<\/ul>\n<ul style=\"text-align: justify;\">\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">main ( ) is the pre-defined method that is called in the beginning of a java program<\/span><\/li>\n<\/ul>\n<ul style=\"text-align: justify;\">\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">\u201cString args [ ]\u201d are the arguments of the type String, when a Java program is run, the Java application accepts it.<\/span><\/li>\n<\/ul>\n<ol style=\"text-align: justify;\" start=\"7\">\n<li><b> What does \u201cSystem.out.println ( )\u201d specify?<\/b><\/li>\n<\/ol>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\"><strong>Answer &#8211;<\/strong> <\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">\u201c<strong>System<\/strong>\u201d is the pre-defined class in Java that gives access to the system<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">\u201c<strong>out<\/strong>\u201d is the output stream<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">\u201c<strong>println<\/strong>\u201d is the method that is used to print line on the console i.e. println is the console output statement<\/span><\/p>\n<blockquote><p><a href=\"https:\/\/www.whizlabs.com\/oracle-java-certifications\/\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"alignnone size-full wp-image-66772\" src=\"https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/sites\/2\/2018\/06\/java-banner.jpg\" alt=\"java banner\" width=\"728\" height=\"90\" srcset=\"https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2018\/06\/java-banner.jpg 728w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2018\/06\/java-banner-300x37.jpg 300w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2018\/06\/java-banner-640x79.jpg 640w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2018\/06\/java-banner-681x84.jpg 681w\" sizes=\"(max-width: 728px) 100vw, 728px\" \/><\/a><\/p><\/blockquote>\n<ol style=\"text-align: justify;\" start=\"8\">\n<li><b> What do you know about JVM?<\/b><\/li>\n<\/ol>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\"><strong>Answer<\/strong> &#8211; The full form of JVM is the <strong>Java Virtual Machine<\/strong>. Some important features of Java Virtual Machine are &#8211;<\/span><\/p>\n<ul style=\"text-align: justify;\">\n<li style=\"text-align: justify;\"><span style=\"font-weight: 400;\">JVM is platform dependent<\/span><\/li>\n<li style=\"text-align: justify;\"><span style=\"font-weight: 400;\">JVM is the runtime system of Java<\/span><\/li>\n<li style=\"text-align: justify;\"><span style=\"font-weight: 400;\">JVM acts as an interpreter for the bytecode<\/span><\/li>\n<li>JVM supports a number of programming languages i.e. <a href=\"https:\/\/www.whizlabs.com\/blog\/jvm-languages\/\" target=\"_blank\" rel=\"noopener\">JVM languages<\/a><\/li>\n<li style=\"text-align: justify;\"><span style=\"font-weight: 400;\">JVM is responsible to maintain the security of the system<\/span><\/li>\n<li style=\"text-align: justify;\"><span style=\"font-weight: 400;\">JVM is what actually provides the environment for the program execution<\/span><\/li>\n<\/ul>\n<ol style=\"text-align: justify;\" start=\"9\">\n<li><b> Define garbage collection.<\/b><\/li>\n<\/ol>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\"><strong>Answer<\/strong> &#8211; In Java, garbage collection is used to free up the memory. It is done by clearing\/deleting those objects which are no more required by any program. Two steps are involved in the process of garbage collection &#8211;<\/span><\/p>\n<p style=\"text-align: justify;\"><strong>Step 1: Garbage Object Collection<\/strong><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">This step involves the grouping and collection of all the objects that are not referenced by any program. The garbage collector uses various methods for the collection of garbage objects such as <strong>system.gc( ) or runtime.gc( )<\/strong><\/span><\/p>\n<p style=\"text-align: justify;\"><strong>Step 2: Run Finalize Method<\/strong><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">After the collection of objects, the next step is to free the memory space by deleting the objects that has been gathered by the garbage collector. Then, Finalize method is executed in order to delete all the objects that are dynamically created.<\/span><\/p>\n<ol style=\"text-align: justify;\" start=\"10\">\n<li><b> Define polymorphism.<\/b><\/li>\n<\/ol>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">Answer &#8211; The meaning of word polymorphism is &#8211; one name and many forms. Polymorphism refers to the characteristic of methods to act differently on the basis of the calling object. Followings are the key features of polymorphism &#8211;<\/span><\/p>\n<ul style=\"text-align: justify;\">\n<li><span style=\"font-weight: 400;\">It allows the use of one interface to implement various methods<\/span><\/li>\n<li>\n<p style=\"display: inline !important;\">It supports method overloading i.e. allows the use of multiple methods with same name but different arguments.<\/p>\n<\/li>\n<li>\n<p style=\"display: inline !important;\">It supports method overriding I.e. allows the use of multiple methods with same name, same argument, and return type.<\/p>\n<\/li>\n<\/ul>\n<ol style=\"text-align: justify;\" start=\"11\">\n<li><b> What do you know about constructor?<\/b><\/li>\n<\/ol>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\"><strong>Answer<\/strong> &#8211; A constructor can be defined as a block of code very similar to the method that is called on the creation of an instant of the object. The features of the constructor are as follows &#8211;<\/span><\/p>\n<ul style=\"text-align: justify;\">\n<li><i><span style=\"font-weight: 400;\">The name of the constructor is same as that of the name of the class.<\/span><\/i><\/li>\n<li>\n<p style=\"display: inline !important;\">It doesn\u2019t have any return type.<\/p>\n<\/li>\n<li>\n<p style=\"display: inline !important;\">It is not considered as the class member like other methods.<\/p>\n<\/li>\n<li>\n<p style=\"display: inline !important;\">It is invoked automatically when a new instance of an object is created.<\/p>\n<\/li>\n<li>\n<p style=\"display: inline !important;\">It can not be inherited like other methods of the class.<\/p>\n<\/li>\n<li>\n<p style=\"display: inline !important;\">It is not compulsory to create a constructor for the class.<\/p>\n<\/li>\n<\/ul>\n<blockquote><p>Get More Core Java Interview Questions here &#8211;\u00a0<a href=\"https:\/\/www.whizlabs.com\/blog\/core-java-interview-questions\/\" target=\"_blank\" rel=\"noopener noreferrer\">https:\/\/www.whizlabs.com\/blog\/core-java-interview-questions\/<\/a><\/p><\/blockquote>\n<h2 style=\"text-align: justify;\"><span class=\"ez-toc-section\" id=\"Advanced_Java_Interview_Questions\"><\/span><strong>Advanced Java Interview Questions<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">In the second section, we cover the advanced Java interview questions and answers for freshers as well as experienced professionals. If you are looking for some advanced Java interview questions to crack the Java interview and get a better job, these advanced Java interview questions for experienced are only for you. If you have any other Java interview questions for freshers or experienced professionals, please post in the comment section.<\/span><\/p>\n<ol style=\"text-align: justify;\" start=\"12\">\n<li><b> What are the different Access Specifiers in Java?<\/b><\/li>\n<\/ol>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\"><strong>Answer<\/strong> &#8211; Access Specifiers are used to setting the access level of the classes and the methods, fields, and constructors in the classes. There are four different types of Access Specifiers in Java &#8211;<\/span><\/p>\n<ul style=\"text-align: justify;\">\n<li style=\"text-align: justify;\"><span style=\"font-weight: 400;\"><strong>Public<\/strong> &#8211; The classes, fields, and methods defined by public access specifier, are accessible by every class.<\/span><\/li>\n<li style=\"text-align: justify;\"><span style=\"font-weight: 400;\"><strong>Private<\/strong> &#8211; The fields and methods defined by private access specifier are accessible within the same class to which those fields and methods belong. The private fields and methods can\u2019t even be inherited by any subclasses.<\/span><\/li>\n<li style=\"text-align: justify;\"><span style=\"font-weight: 400;\"><strong>Protected<\/strong> &#8211; The fields and methods defined by protected access specifier are accessible only in the class to which those fields and methods belong. <\/span><\/li>\n<li style=\"text-align: justify;\"><span style=\"font-weight: 400;\"><strong>Default<\/strong> &#8211; Default means no specifier. When the methods, fields, and classes are not defined by any access specifier, then those methods, fields, and classes are accessible in the package to which those methods, fields, and classes belong.<\/span><\/li>\n<\/ul>\n<p style=\"text-align: justify;\"><b>13.. What are the different method signatures in Java?<\/b><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">Answer &#8211; A method inside a class is the sequence of statement to perform a specific task. \u00a0<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\"><strong>Method Signatures:\u00a0<\/strong><\/span><span style=\"font-weight: 400;\">A number of parameters such as method name, return type, access specifiers etc. constitute the method signature. The various elements of the method signature are &#8211;<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\"><strong>Method name<\/strong> &#8211; Method name is the mandatory signature, such as display ( )<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\"><strong>Return type<\/strong> &#8211; Return type of the method is also the mandatory method signature, it can be void, int, float, string etc.<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\"><strong>Access Modifier<\/strong> &#8211; It is the method signature that is not compulsory to be defined. It can be synchronized, static, etc.<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\"><strong>Access Specifier<\/strong> &#8211; Not mandatory method signature; access specifier can be private, public, protected etc.<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\"><strong>Parameters<\/strong> &#8211; A method may either have or not parameters; these are given in parenthesis such as (String name, int number);<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">A few examples of methods with the signatures are &#8211; <\/span><\/p>\n<blockquote>\n<p style=\"text-align: left;\"><span style=\"font-weight: 400;\">public static void getFinalName (String Name) { }<\/span><\/p>\n<p style=\"text-align: left;\"><span style=\"font-weight: 400;\">Void displaySum ( ) { }<\/span><\/p>\n<p style=\"text-align: left;\"><span style=\"font-weight: 400;\">public synchronized int getSalary (double grossSalary) { }<\/span><\/p>\n<\/blockquote>\n<ol style=\"text-align: justify;\" start=\"14\">\n<li><b> What is a thread? What do you know about its lifecycle?<\/b><\/li>\n<\/ol>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">Answer &#8211; A thread is an execution in the program which follows the single flow of control. The life cycle of thread comprises of the five states, that are being mentioned below &#8211;<\/span><\/p>\n<p style=\"text-align: justify;\"><b>Newborn state &#8211;<\/b><span style=\"font-weight: 400;\"> When an instance of the thread is created, the thread is considered to be in this newborn state. In this state, the thread is not considered alive, and the state exists before the start ( ) method is invoked.<\/span><\/p>\n<p style=\"text-align: justify;\"><b>Runnable state &#8211;<\/b><span style=\"font-weight: 400;\"> The life of the thread starts from this state i.e. runnable state. When the start ( ) function is invoked, the thread enters in the runnable state.<\/span><\/p>\n<p style=\"text-align: justify;\"><b>Running state &#8211; <\/b><span style=\"font-weight: 400;\">When the thread enters the runnable state, it is ready to run and start the program execution. When the thread is actually in the execution phase, it is said to be in the running state.<\/span><\/p>\n<p style=\"text-align: justify;\"><b>Blocked state &#8211; <\/b><span style=\"font-weight: 400;\">During the running state, the thread may have to wait for the resources that are being used by any another thread. During the waiting phase, the thread is known to be in the blocked state.<\/span><\/p>\n<p style=\"text-align: justify;\"><b>Dead state &#8211;<\/b><span style=\"font-weight: 400;\"> When the execution of the program is <\/span><\/p>\n<p style=\"text-align: justify;\"><img decoding=\"async\" class=\"wp-image-66676 size-full aligncenter\" src=\"https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/sites\/2\/2018\/06\/Dead-state.png\" alt=\"java interview questions\" width=\"719\" height=\"443\" srcset=\"https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2018\/06\/Dead-state.png 719w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2018\/06\/Dead-state-300x185.png 300w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2018\/06\/Dead-state-682x420.png 682w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2018\/06\/Dead-state-640x394.png 640w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2018\/06\/Dead-state-681x420.png 681w\" sizes=\"(max-width: 719px) 100vw, 719px\" \/><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">done and the run ( ) method is completed, the thread is said to be in the dead state. After this state, a thread cannot be in execute or run again.<\/span><\/p>\n<ol style=\"text-align: justify;\" start=\"15\">\n<li><b> What are the Applets? <\/b><\/li>\n<\/ol>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\"><strong>Answer<\/strong> &#8211; Applets are the small Java programs that can be sent from one computer to the other computer over the network with the use of Applet Viewer that supports Java.<\/span><\/p>\n<p style=\"text-align: justify;\"><strong>Applets have following properties &#8211;<\/strong><\/p>\n<ul style=\"text-align: justify;\">\n<li style=\"font-weight: 400;\"><i><span style=\"font-weight: 400;\">Being a Java program, an applet can be run in a web browser<\/span><\/i><\/li>\n<\/ul>\n<ul style=\"text-align: justify;\">\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">It has the set of whole Java API <\/span><\/li>\n<\/ul>\n<ul style=\"text-align: justify;\">\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Applets are known to be the fully functional Java application<\/span><\/li>\n<\/ul>\n<ul style=\"text-align: justify;\">\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Applets offer a high-level security, called sandbox security<\/span><\/li>\n<\/ul>\n<ul style=\"text-align: justify;\">\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Applets follow the security ruled of the web browser<\/span><\/li>\n<\/ul>\n<ol style=\"text-align: justify;\" start=\"16\">\n<li><b>Mention the situations when you will prefer to use interfaces and when abstract classes.<\/b><\/li>\n<\/ol>\n<p style=\"text-align: justify;\"><b>Answer<\/b><span style=\"font-weight: 400;\"> &#8211; It depends when a Java programmer will use interfaces and when abstract class. Let\u2019s discuss both one by one &#8211;<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\"><strong>Abstract Classes are used &#8211;<\/strong> <\/span><\/p>\n<ul style=\"text-align: justify;\">\n<li style=\"font-weight: 400;\"><i><span style=\"font-weight: 400;\">When you need to make multiple implementations of the same kind with common behaviour<\/span><\/i><\/li>\n<\/ul>\n<ul style=\"text-align: justify;\">\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">In order to create inheritance hierarchies (already planned)<\/span><\/li>\n<\/ul>\n<ul style=\"text-align: justify;\">\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">When you have to leave the implementation task on the inheriting subclass by enabling the generalised form of abstraction<\/span><\/li>\n<\/ul>\n<p style=\"text-align: justify;\"><strong>Interface is used &#8211;<\/strong><\/p>\n<ul style=\"text-align: justify;\">\n<li style=\"font-weight: 400;\"><i><span style=\"font-weight: 400;\">When you need multiple classes to use some methods that are not to be included in the class<\/span><\/i><\/li>\n<\/ul>\n<ul style=\"text-align: justify;\">\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">When multiple implementations share the signatures of method or program design is changed frequently<\/span><\/li>\n<\/ul>\n<ol style=\"text-align: justify;\" start=\"17\">\n<li><b> How are the source code files named in Java?<\/b><\/li>\n<\/ol>\n<p style=\"text-align: justify;\"><b>Answer<\/b><span style=\"font-weight: 400;\"> &#8211; The name of the Java source code file is same as that of the public class or interface, defined by programmer during writing the program code. It is restricted that source code won\u2019t contain more than one public class or interface. While naming a Java source code file, there may be occurrence of two different cases &#8211; <\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\"><strong>Case 1<\/strong>: When there is no public class or interface in the source code file &#8211; <\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">Although it is mandatory that source code file will contain only one public class or interface but it may not contain any public class or interface. In this case, the java source code file will be named something else except its interfaces and classes. <\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\"><strong>Case 2<\/strong>: When there is one public class or interface in the source code file &#8211; <\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">It is the case when one public class or inheritance occur in the source code file. In this case, the name of the java source code file will be same as that of the public class or interface that has been defined in the program code.<\/span><\/p>\n<ol style=\"text-align: justify;\" start=\"18\">\n<li><b> What do you mean by the nested class?<\/b><\/li>\n<\/ol>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\"><strong>Answer<\/strong> &#8211; In general, the meaning of nested means one in another. In Java, a nested class means a class within another class i.e. the class that is declared inside an another class is the nested class. <\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">Some times, the nested class is also known as the inner class. The Syntax is &#8211;<\/span><\/p>\n<pre style=\"text-align: justify;\">class Parent_class\r\n\r\n{\r\n\r\n\/\/code\r\n\r\nclass Nested_class\r\n\r\n{\r\n\r\n\/\/code\r\n\r\n}\r\n\r\n}<\/pre>\n<p style=\"text-align: justify;\"><strong>Advantages of nested class in Java<\/strong><\/p>\n<ul style=\"text-align: justify;\">\n<li style=\"font-weight: 400;\"><i><span style=\"font-weight: 400;\">Permitted to access all the methods and data members (including private) of the outer class <\/span><\/i><\/li>\n<\/ul>\n<ul style=\"text-align: justify;\">\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">As it groups interfaces and classes in one place, thus develops easily maintainable and readable code<\/span><\/li>\n<\/ul>\n<ul style=\"text-align: justify;\">\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Less code is required to be written<\/span><\/li>\n<\/ul>\n<ol style=\"text-align: justify;\" start=\"19\">\n<li><b> Does Java support networking?<\/b><\/li>\n<\/ol>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\"><strong>Answer<\/strong> &#8211; Yes, Java supports networking. There are two types of classes in Java to support networking i.e. low-level and high-level. These classes control the network applications programming. As Java is platform independent in nature, Java networking is also platform independent.<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">The classes to support Java networking are &#8211; <\/span><\/p>\n<ul style=\"text-align: justify;\">\n<li style=\"text-align: justify;\"><b>Low-level classes &#8211;<\/b><span style=\"font-weight: 400;\"> These classes support socket programming like DataramSocket, Socket, and ServerSocket classes.<\/span><\/li>\n<li style=\"text-align: justify;\"><b>High-level classes &#8211; <\/b><span style=\"font-weight: 400;\">These classes provide support for URLEncoder, web programming URL, and URL connection.<\/span><\/li>\n<\/ul>\n<ol style=\"text-align: justify;\" start=\"20\">\n<li><b> Is there any alternative to inheritance? Explain.<\/b><\/li>\n<\/ol>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\"><strong>Answer<\/strong> &#8211; Yes, there is an alternative to inheritance in Java; Delegation. Followings are the important points about delegation &#8211;<\/span><\/p>\n<ul style=\"text-align: justify;\">\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Delegation specifies that there exists an instance of any class that works as the instance variable and used to send messages to that instance of the class.<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Delegation is comparatively safer than that of the inheritance as the programmer doesn\u2019t need to think about the forwarded message. As the instance belongs to the existing known class and doesn\u2019t make you accept all the methods of superclass, only the selected and required methods can be provided.<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Due to delegation, the programmer have to write more code. Also, it is harder to reuse the delegation unlike inheritance as it is not a subclass.<\/span><\/li>\n<\/ul>\n<ol style=\"text-align: justify;\" start=\"21\">\n<li><b> What is the difference between JDK, JVM, and JRE?<\/b><\/li>\n<\/ol>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">Answer &#8211; The difference between JDK, JVM, and JRE is as follows:<\/span><\/p>\n<p style=\"text-align: justify;\"><b>JDK &#8211; <\/b><span style=\"font-weight: 400;\">JDK stands for Java Development Kit. JDK is the most commonly used software development environment for Java programmers. It is meant for the development of Java applications and applets. It consists of Java Runtime Environment, a compiler (javac), an interpreter (Java), an archiver (jar), a generator for documentation (Javadoc), and some other tools that are required in the development of Java applications.<\/span><\/p>\n<p style=\"text-align: justify;\"><b>JVM &#8211; <\/b><span style=\"font-weight: 400;\">JVM is an acronym for JavaVirtual Machine. It acts as an interpreter for the byte code. It is the real runtime system of Java and provides an environment for the execution of Java programs and applications. Most important, Java Virtual Machine is independent of the platform.<\/span><\/p>\n<p style=\"text-align: justify;\"><b>JRE &#8211; <\/b><span style=\"font-weight: 400;\">JRE is the Java Runtime Environment, also known as Java RTE. It is the Java Virtual Machine implementation that is responsible for the execution of Java applications. It provides everything that is required for the execution of a Java application. It comprises of the Java Virtual Machine, supporting files, and core classes. <\/span><\/p>\n<ol style=\"text-align: justify;\" start=\"22\">\n<li><b> What is the difference between WAR and JAR files?<\/b><\/li>\n<\/ol>\n<p style=\"text-align: justify;\"><b>Answer &#8211; The difference between WAR and JAR files is being described in the following table &#8211; <\/b><\/p>\n<table>\n<tbody>\n<tr>\n<td><b>WAR Files <\/b><\/td>\n<td><b>JAR Files<\/b><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">1. The term WAR files stand for the Web Archive Files.<\/span><\/td>\n<td><span style=\"font-weight: 400;\">1. The term JAR files stand for the Java Archive Files.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">2. WAR files are responsible for the storage of Java classes, XML, and JavaServer pages.<\/span><\/td>\n<td><span style=\"font-weight: 400;\">2. Java files allow the aggregation and storage of multiple Java files into a single file.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">3. WAR files are mainly used for the purpose of web applications.<\/span><\/td>\n<td><span style=\"font-weight: 400;\">3. JAR files are mainly used to handle Java classes in a library.<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<ol style=\"text-align: justify;\" start=\"23\">\n<li><b> What exactly happens when an object is created in Java?<\/b><\/li>\n<\/ol>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\"><strong>Answer<\/strong> &#8211; When an object is created in Java, a number of things happen in a specific sequence to ensure whether the object has been created properly, these are &#8211;<\/span><\/p>\n<ol style=\"text-align: justify;\">\n<li style=\"text-align: justify;\"><span style=\"font-weight: 400;\"><strong> Memory Allocation<\/strong> &#8211; The memory is allocated for the storage of all the instance variables and the other data of object and its superclasses that are related to implementation.<\/span><\/li>\n<li style=\"text-align: justify;\"><span style=\"font-weight: 400;\"><strong> Initialization<\/strong> &#8211; After memory allocation, the objects are declared and initialized with their default values.<\/span><\/li>\n<li style=\"text-align: justify;\"><span style=\"font-weight: 400;\"><strong> Constructor<\/strong> &#8211; Next, the constructors call other constructors for its superclasses. java.lang.Object is the base class for all the objects in Java, so this process is repeated continuously until the constructor for java.lang.Object is called. <\/span><\/li>\n<li style=\"text-align: justify;\"><span style=\"font-weight: 400;\"><strong> Execution<\/strong> &#8211; In this step, the initialization of all the instance variable takes place and the initialisation blocks are executed. After that the execution of the body of the constructor takes place.<\/span><\/li>\n<\/ol>\n<h2 style=\"text-align: justify;\"><span class=\"ez-toc-section\" id=\"JDBC_Java_Interview_Questions\"><\/span><b>JDBC Java Interview Questions<\/b><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">In the third section, here we cover the JDBC Java interview questions and answers. Go through these basic and advanced JDBC Java interview questions and broaden your knowledge to crack the interview. If you have any other JDBC Java interview questions, please post in the comment section.<\/span><\/p>\n<ol style=\"text-align: justify;\" start=\"24\">\n<li><b> What do you know about JDBC?<\/b><\/li>\n<\/ol>\n<p style=\"text-align: justify;\">JDBC is a Java API that is responsible for the connection and execution of Java query with the database. JDBC API uses JDBC drivers to create a connection between database and the query. JDBC API can be used to access data from any relational database.<\/p>\n<ol style=\"text-align: justify;\" start=\"25\">\n<li><b> What are the steps to connect a Java application with the database using JDBC?<\/b><\/li>\n<\/ol>\n<p style=\"text-align: justify;\"><b>Answer <\/b>&#8211; Followings are the steps that will connect a Java application with the database using JDBC:<\/p>\n<p style=\"text-align: justify;\"><b>Step 1: <\/b>Registration of the driver class using forName( ) method of the Class class.<\/p>\n<p style=\"text-align: justify;\"><b>Step 2: <\/b>Creation of connection object using getConnection( ) method of the DriverManager class.<\/p>\n<p style=\"text-align: justify;\"><b>Step 3: <\/b>Creation of statement object using createStatement( ) method. Of the connection interface.<\/p>\n<p style=\"text-align: justify;\"><b>Step 4: <\/b>Execution of the query using executeQuery( ) method of the Statement interface.<\/p>\n<p style=\"text-align: justify;\"><b>Step 5: <\/b>Closure of the connection object using close( ) method of the Connection interface.<\/p>\n<ol style=\"text-align: justify;\" start=\"26\">\n<li><b> Name different types of JDBC statements in Java.<\/b><\/li>\n<\/ol>\n<p style=\"text-align: justify;\"><b>Answer &#8211; Following are the 3 different types of JDBC statements in Java:<\/b><\/p>\n<ol style=\"text-align: justify;\">\n<li><i>Statement<\/i><\/li>\n<li>CallableStatement<\/li>\n<li>PreparedStatement<\/li>\n<\/ol>\n<ol style=\"text-align: justify;\" start=\"27\">\n<li><b> How will you store an image in database?<\/b><\/li>\n<\/ol>\n<p style=\"text-align: justify;\"><b>Answer &#8211; <\/b>In Java, the images can be stored in a database with the <strong>setBinaryStream( ) method<\/strong> of the Prepared Statement interface. This method will set the Binary information into the parameterIndex.<\/p>\n<p style=\"text-align: justify;\">The syntax is &#8211;<\/p>\n<p style=\"text-align: justify;\">Public void setBinaryStream(Int paramIndex,InputStream stream)<\/p>\n<p style=\"text-align: justify;\">Throws SQLException<\/p>\n<ol style=\"text-align: justify;\" start=\"28\">\n<li><b> How are the stored functions and procedures executed in Java?<\/b><\/li>\n<\/ol>\n<p style=\"text-align: justify;\"><b>Answer &#8211; <\/b>In Java, the stored functions and procedures are executed with the help of CallableStatement interface.<\/p>\n<ol style=\"text-align: justify;\" start=\"29\">\n<li><b> Name the various components of JDBC API.<\/b><\/li>\n<\/ol>\n<p style=\"text-align: justify;\">There are various components of JDBC API are classes and interfaces that are stored in java.sql package, these are &#8211;<\/p>\n<p style=\"text-align: justify;\"><strong>Classes<\/strong> &#8211; Blob, DriveManager, Types, Clob, SQLException etc.<\/p>\n<p style=\"text-align: justify;\"><strong>Interfaces<\/strong> &#8211; Statement, Connection, ResultSet, PreparedStatement, DatabaseMetaData, ResultSetMetaData, CallableStatement etc.<\/p>\n<ol style=\"text-align: justify;\" start=\"30\">\n<li><b> What is the batch processing technique in JDBC?<\/b><\/li>\n<\/ol>\n<p style=\"text-align: justify;\"><b>Answer &#8211; <\/b>In Java, the batch processing technique is used to perform the execution of multiple queries at the same time. During batch processing, the grouping of related SQL statements is done into a batch and then performs their execution instead of performing the execution of a single query. In this way, the batch processing results in faster execution of queries and improved performance.<\/p>\n<ol style=\"text-align: justify;\" start=\"31\">\n<li><b> What do you know about Connection interface in JDBC API?<\/b><\/li>\n<\/ol>\n<p style=\"text-align: justify;\"><b>Answer &#8211; <\/b>The Connection interface is used for the maintenance of a session with the database. It can also be used for the management of transactions. It contains various factory methods that returns the instance of CallableStatement, Statement, PreparedStatement, and DatabaseMetaData.<\/p>\n<ol style=\"text-align: justify;\" start=\"32\">\n<li><b> Differentiate statements execute, executeQuery, and executeUpdate.<\/b><\/li>\n<\/ol>\n<p style=\"text-align: justify;\"><b>Answer &#8211; <\/b>The difference between execute, executeQuery, and executeUpdate is as follows &#8211;<\/p>\n<p style=\"text-align: justify;\"><strong>execute (String query)<\/strong> &#8211; The execute statement is used to perform the execution of SQL query. When the result is an ResultSet, it returns TRUE, e.g. returns TRUE value for Update or Insert queries.<\/p>\n<p style=\"text-align: justify;\">getResultSet( ) method is used to get the ResultSet and getUpdateCount( ) is method is used to get the value of update count.<\/p>\n<p style=\"text-align: justify;\"><strong>executeQuery(String query)<\/strong> &#8211; The executeQuery statement is used for the execution of Select queries and to return the ResultSet. The value of ResultSet is never set to null even when no matching record is found for the query.<\/p>\n<p style=\"text-align: justify;\">executeQuery method should be used for the execution of Select queries as it cannot be used for insert and update queries. It throws java.sql.SQLException if someone executes update\/insert query with the message that executeQuery method cannot be used for update\/insert.<\/p>\n<p style=\"text-align: justify;\"><strong>executeUpdate (String query)<\/strong> &#8211; The execute update statement is used for the execution of DML (i.e. Insert, Update, and Delete) statements and also for DDL statements those don\u2019t return any value.<\/p>\n<p style=\"text-align: justify;\">For DML statements the return value is int and equals to the DML statements row count. While in case of DDL statements, the return value is 0.<\/p>\n<p style=\"text-align: justify;\">So, the execute( ) method is used only if you don\u2019t know the type of query statement else the use of executeQuery( ) and executeUpdate( ) methods is preferred.<\/p>\n<ol style=\"text-align: justify;\" start=\"33\">\n<li><b> Name the interface that performs transaction management in JDBC.<\/b><\/li>\n<\/ol>\n<p style=\"text-align: justify;\"><b>Answer &#8211; <\/b>The Connection interface performs the transaction management in JDBC. It provides various methods such as rollback( ), commit( ) etc. that helps in transaction management in JDBC<b>.<\/b><\/p>\n<h2 style=\"text-align: justify;\"><span class=\"ez-toc-section\" id=\"String_Handling_Java_Interview_Questions\"><\/span><b>String Handling Java Interview Questions<\/b><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">The fourth section covers the String handling Java interview questions and answers. Preparing through these String Java interview questions will \u00a0be highly helpful to crack the Java interview. If you have any other String-based Java interview questions, please post in the comment section, we\u2019ll cover them up.<\/span><\/p>\n<ol style=\"text-align: justify;\" start=\"34\">\n<li><b> Why are the string objects immutable in Java?<\/b><\/li>\n<\/ol>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\"><strong>Answer &#8211;<\/strong> In general, the meaning of term immutable is unchangeable i.e. that cannot be changed. <\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">String objects are immutable in Java which means once the string objects are created, it is not possible to change its value. <\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">String objects are immutable as Java is based on the concept of string literal. To understand this, consider that 5 references are there, all of which refers to the one object called \u201cnaira\u201d. In this case, if the value of the object is changed by one reference variable, it will also affect the value of the other reference variables. This is the reason why string objects are immutable in Java.<\/span><\/p>\n<ol style=\"text-align: justify;\" start=\"35\">\n<li><b> What are the different ways to create String objects in Java?<\/b><\/li>\n<\/ol>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\"><strong>Answer &#8211;<\/strong> There are two ways to create String objects in Java:<\/span><\/p>\n<ul style=\"text-align: justify;\">\n<li><b>By String Literal <\/b><\/li>\n<\/ul>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">String object using String literal is created by using double quotes. For example &#8211;<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">String s=\u201chello\u201d;<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">Every time, when you create a string literal, JVM checks string constant pool to find if the string already exists. If the string already exists, it will return a reference to the pooled instance. If the string is not already there in the pool, JVM creates the new string and store it in the pool.<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">Now consider,<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">String s1=\u201chey\u201d;<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">String s2=\u201chey\u201d;<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">Here, the second statement will not create the new instance as the first statement has already created that.<\/span><\/p>\n<ul style=\"text-align: justify;\">\n<li><b>By New Keyword<\/b><\/li>\n<\/ul>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">This is an another method to create String objects in Java using new keyword. For example &#8211; <\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">String s=new String(\u201cNiharika\u201d);<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">This statement will create two objects and one reference variable.<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">In this case, JVM creates a new string object in a heap memory and the literal \u201cNiharika\u201d will be stored in the constant pool of the string. The variable s refers to the String object in the heap. <\/span><\/p>\n<ol style=\"text-align: justify;\" start=\"36\">\n<li><b> Differentiate StringBuilder and StringBuffer in Java.<\/b><\/li>\n<\/ol>\n<p style=\"text-align: justify;\"><b>Answer &#8211; <\/b>The basic difference between StringBuilder and StringBuffer is given as &#8211;<\/p>\n<p style=\"text-align: justify;\"><strong>StringBuffer<\/strong> &#8211; It is a user mutable string i.e. its value can be changed any time after it has been created. The objects that are created using StringBuffer, are stored in the heap and StringBuffer is thread safe.<\/p>\n<p style=\"text-align: justify;\"><strong>StringBuilder<\/strong> &#8211; It is also a user mutable string i.e. its value can be changed any time after it has been created. StringBuilder also stores the objects in heap like StringBuffer but the main difference is that StringBuilder is not thread safe.<\/p>\n<table>\n<tbody>\n<tr>\n<td><b>Index<\/b><\/td>\n<td><b>StringBuffer<\/b><\/td>\n<td><b>StringBuilder<\/b><\/td>\n<\/tr>\n<tr>\n<td><b>Modifiable<\/b><\/td>\n<td><span style=\"font-weight: 400;\">Yes, it can be modified or changed i.e. mutable<\/span><\/td>\n<td><span style=\"font-weight: 400;\">No, it can\u2019t be modified or changed i.e. immutable<\/span><\/td>\n<\/tr>\n<tr>\n<td><b>Storage Area<\/b><\/td>\n<td><span style=\"font-weight: 400;\">Objects created through StringBuffer are stored in heap.<\/span><\/td>\n<td><span style=\"font-weight: 400;\">The objects created through StringBuilder are stored in heap.<\/span><\/td>\n<\/tr>\n<tr>\n<td><b>Thread Safe <\/b><\/td>\n<td><span style=\"font-weight: 400;\">Yes, it is thread safe.<\/span><\/td>\n<td><span style=\"font-weight: 400;\">No, it is not thread safe.<\/span><\/td>\n<\/tr>\n<tr>\n<td><b>Synchronization<\/b><\/td>\n<td><span style=\"font-weight: 400;\">All the methods in StringBuffer are synchronized<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Methods are not synchronized in StringBuilder <\/span><\/td>\n<\/tr>\n<tr>\n<td><b>Method Access<\/b><\/td>\n<td><span style=\"font-weight: 400;\">A method can access only one thread at a time<\/span><\/td>\n<td><span style=\"font-weight: 400;\">A method can access multiple threads simultaneously at a time<\/span><\/td>\n<\/tr>\n<tr>\n<td><b>Performance<\/b><\/td>\n<td><span style=\"font-weight: 400;\">StringBuffer is slower than StringBuilder even while calling the same methods of a class<\/span><\/td>\n<td><span style=\"font-weight: 400;\">StringBuilder is faster when it comes to calling the same methods of a class<\/span><\/td>\n<\/tr>\n<tr>\n<td><b>Conversion <\/b><\/td>\n<td><span style=\"font-weight: 400;\">StringBuffer to String conversion can be done by using toString ( ) method, + \u201c\u201d or \u00a0String.valueOf ( ) method<\/span><\/td>\n<td><span style=\"font-weight: 400;\">StringBuilder to String conversion can be done by using toString ( ) method.<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<ol style=\"text-align: justify;\" start=\"37\">\n<li><b> How will you create an immutable class in Java?<\/b><\/li>\n<\/ol>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\"><strong>Answer &#8211;<\/strong> There are a number of immutable classes in Java such as Boolean, Integer, Float, Long, Double, Short, Byte, String etc. To sum up, String class and all the wrapper classes are immutable. An immutable class can also be created by creating a final class containing final data members. <\/span><\/p>\n<p style=\"text-align: justify;\"><strong>A class is said to be final when<\/strong><\/p>\n<ul style=\"text-align: justify;\">\n<li><span style=\"font-weight: 400;\">The class itself is final i.e. it is not possible to create its subclasses.<\/span><\/li>\n<li><span style=\"font-weight: 400;\">It has a final instance variable i.e. it is not possible to change its value after the creation of an object.<\/span><\/li>\n<li><span style=\"font-weight: 400;\">There are no setter methods i.e. there will not be any option to change the value of instance variable.<\/span><\/li>\n<\/ul>\n<p style=\"text-align: justify;\"><b>For example &#8211; <\/b><\/p>\n<pre style=\"text-align: justify;\"><span style=\"font-weight: 400;\">public final class Student <\/span>\r\n\r\n<span style=\"font-weight: 400;\">{<\/span>\r\n\r\n<span style=\"font-weight: 400;\">Final String idNumber;<\/span>\r\n\r\n<span style=\"font-weight: 400;\">public Employee(String idNumber)<\/span>\r\n\r\n<span style=\"font-weight: 400;\">{<\/span>\r\n\r\n<span style=\"font-weight: 400;\">this.idNumber = idNumber;<\/span>\r\n\r\n<span style=\"font-weight: 400;\">}<\/span>\r\n\r\n<span style=\"font-weight: 400;\">public String getidNumber( )<\/span>\r\n\r\n<span style=\"font-weight: 400;\">{<\/span>\r\n\r\n<span style=\"font-weight: 400;\">return idNumber;<\/span>\r\n\r\n<span style=\"font-weight: 400;\">}<\/span>\r\n\r\n<span style=\"font-weight: 400;\">}<\/span><\/pre>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">This is a final class with name Student that contains one parameterised constructor, one final data member, and a getter method.<\/span><\/p>\n<ol style=\"text-align: justify;\" start=\"38\">\n<li><b> Why does the Java use the concept of string literal?<\/b><\/li>\n<\/ol>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\"><strong>Answer &#8211;<\/strong> Java uses the concept of string literal as it makes Java more memory efficient. It is because the concept of string literal doesn\u2019t create a new String object if that is already existing in the String constant pool. It avoids the redundant storage and thus saves memory.<\/span><\/p>\n<ol style=\"text-align: justify;\" start=\"39\">\n<li><b> How many String objects the following code will create? Explain.<\/b><\/li>\n<\/ol>\n<ul style=\"text-align: justify;\">\n<li><b>String s1 = \u201cHello\u201d;<\/b><\/li>\n<li><b>String s2 = \u201cHello\u201d;<\/b><\/li>\n<li><b>String s3 = \u201cHello\u201d;<\/b><\/li>\n<li><b>String s4 = \u201cHello\u201d;<\/b><\/li>\n<li><b>String s5 = \u201cHello\u201d;<\/b><\/li>\n<\/ul>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\"><strong>Answer &#8211;<\/strong> The given code will create only one String object. <\/span><\/p>\n<p style=\"text-align: justify;\"><strong>Explanation<\/strong> &#8211; Only the first statement will create the String object \u201cHello\u201d. For the next statements, as the string is already there in the constant pool, JVM will not create any instance instead will return a reference to the pooled instance.<\/p>\n<ol style=\"text-align: justify;\" start=\"40\">\n<li><b> What is the main difference between string and stringbuffer object?<\/b><\/li>\n<\/ol>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\"><strong>Answer &#8211;<\/strong> The main difference between string and stringbuffer object can be explained in terms of the mutability.<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">String object is immutable while StringBuffer object is mutable.<\/span><\/p>\n<ol style=\"text-align: justify;\" start=\"41\">\n<li><b> What is the use of toString() method in Java?<\/b><\/li>\n<\/ol>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\"><strong>Answer &#8211;<\/strong> The toString() method returns the object representation. Whenever an object is printed, Java complier will invoke the toString() method for that object. This overriding of toString() method will return the desired output on the basis of your implementation.<\/span><\/p>\n<h2 style=\"text-align: justify;\"><span class=\"ez-toc-section\" id=\"Exception_Handling_Java_Interview_Questions\"><\/span><b>Exception Handling Java Interview Questions<\/b><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">The fifth section covers the Exception handling Java interview questions and answers. Preparing through these Exception Handling Java interview questions will \u00a0be highly helpful to crack the Java interview. If you have any other Exception-based Java interview questions, please post in the comment section, we\u2019ll cover them up.<\/span><\/p>\n<ol style=\"text-align: justify;\" start=\"42\">\n<li><b> What is exception handling? <\/b><\/li>\n<\/ol>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\"><strong>Answer<\/strong> &#8211; Exception handling can be defined as the process of handling runtime errors such as IO, Remote, ClassNotFound, Remote etc.<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">The exceptions may effect the normal execution of application, that\u2019s why the exception handling is used.<\/span><\/p>\n<p style=\"text-align: justify;\"><b>Importance of exception handling<\/b><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">Exception handling is very important while creating Java programs and applications. It is important as it helps to maintain the normal flow of the application avoiding any disruption (i.e. runtime error). <\/span><\/p>\n<ol style=\"text-align: justify;\" start=\"43\">\n<li><b> What is an exception? How is it different from error?<\/b><\/li>\n<\/ol>\n<p style=\"text-align: justify;\"><strong>Answer &#8211; <\/strong><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">In general terms, exception is something that creates abnormal condition. <\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">In Java, the runtime errors are known as exceptions. These are the events or conditions, thrown at the runtime and affects the normal flow of a program. <\/span><\/p>\n<p style=\"text-align: justify;\"><b>Difference between Exception and Error &#8211;<\/b><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">The exceptions are the recoverable conditions that thrown at runtime while errors are the irrecoverable conditions that are also thrown at runtime. <\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">The example of exception is FilenotFoundException that will be thrown when the particular file is not found or that does not exist.<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">The example of error is OutofMemory.<\/span><\/p>\n<ol style=\"text-align: justify;\" start=\"44\">\n<li><b> Name the keywords that are used to handle exceptions in Java.<\/b><\/li>\n<\/ol>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\"><strong>Answer &#8211;<\/strong> The Java exceptions are handled by the use of five keywords:<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">throw<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">throws<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">finally<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">try<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">catch<\/span><\/p>\n<ol style=\"text-align: justify;\" start=\"45\">\n<li><b> Differentiate checked exception and unchecked exception.<\/b><\/li>\n<\/ol>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\"><strong>Answer<\/strong> &#8211; The differences between checked exception and unchecked exception are as follows:<\/span><\/p>\n<table>\n<tbody>\n<tr>\n<td><b>Checked Exception<\/b><\/td>\n<td><b>Unchecked Exception<\/b><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">The checked exceptions are those which are checked at the compile time.<\/span><\/td>\n<td><span style=\"font-weight: 400;\">The unchecked exceptions are those which are not checked at the compile time.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">These exceptions are thrown by the classes that extend Throwable class except RuntimeException.<\/span><\/td>\n<td><span style=\"font-weight: 400;\">These exceptions are thrown by the classes that extend RuntimeException.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">The examples are SQLException, IOException etc.<\/span><\/td>\n<td><span style=\"font-weight: 400;\">The examples are NullPointerException, Arithmetic Exception etc.<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<ol style=\"text-align: justify;\" start=\"46\">\n<li><b> Explain the hierarchy of exception in Java.<\/b><\/li>\n<\/ol>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\"><strong>Answer &#8211;<\/strong> The hierarchy of exception in Java can be explained by the following diagram &#8211;<\/span><\/p>\n<p style=\"text-align: justify;\"><img decoding=\"async\" class=\"alignnone wp-image-66678 size-full\" src=\"https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/sites\/2\/2018\/06\/hierarchy-of-exception-in-java.png\" alt=\"java interview questions and answers\" width=\"767\" height=\"319\" srcset=\"https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2018\/06\/hierarchy-of-exception-in-java.png 767w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2018\/06\/hierarchy-of-exception-in-java-300x125.png 300w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2018\/06\/hierarchy-of-exception-in-java-640x266.png 640w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2018\/06\/hierarchy-of-exception-in-java-681x283.png 681w\" sizes=\"(max-width: 767px) 100vw, 767px\" \/><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">The parent class of all the Exception and Error classes is the Throwable class. The exceptions are classified into two types &#8211; Checked Exceptions and Unchecked Exceptions. Also, the errors are of two types &#8211; Assertion Errors and Virtual Machine Errors.<\/span><\/p>\n<ol style=\"text-align: justify;\" start=\"47\">\n<li><b> Explain some of the methods of Exception class in Java.<\/b><\/li>\n<\/ol>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\"><strong>Answer &#8211;<\/strong> The specific methods used to handle exception handling are not present in the Exception class andlasses but all the exception handler methods are defined in the parent class i.e. Throwable. Some of the methods that are used for exception handling are:<\/span><\/p>\n<p style=\"text-align: justify;\"><b>String toString( ) &#8211;<\/b><span style=\"font-weight: 400;\"> The information about Throwable is returned by this method in String format. The output String of this method contains a localized message along with the name of the Throwable class.<\/span><\/p>\n<p style=\"text-align: justify;\"><b>String getMessage( ) &#8211;<\/b><span style=\"font-weight: 400;\"> The result of this method is the message String of Throwable. <\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">Synchronized Throwable getCause( )- The output of this method specifies the cause null id or the exception.<\/span><\/p>\n<p style=\"text-align: justify;\"><b>String getLocalizedMessage( ) &#8211; <\/b><span style=\"font-weight: 400;\">This method is overriden by the subclasses to provide specific localized message to the calling program. In Throwable class, this method is implemented just by using getMessage( ) method which returns the exception message.<\/span><\/p>\n<p style=\"text-align: justify;\"><b>void printStackTrace( ) &#8211; <\/b><span style=\"font-weight: 400;\">This method is used to print the information about stack trace. This is an overloaded method. In order to write stack trace information to the stream or file, we can pass PrintWriter or PrintStream as argument of this method.<\/span><\/p>\n<ol style=\"text-align: justify;\" start=\"48\">\n<li><b> Write some statements the will create custom Exceptions.<\/b><\/li>\n<\/ol>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\"><strong>Answer<\/strong> &#8211; The custom exceptions can be created by extending the Exception class or its subclasses.<\/span><\/p>\n<p style=\"text-align: justify;\"><strong>Example 1:<\/strong><\/p>\n<pre style=\"text-align: justify;\"><span style=\"font-weight: 400;\">class NewException extends ArithmeticException{<\/span>\r\n\r\n<span style=\"font-weight: 400;\">}<\/span>\r\n\r\n<span style=\"font-weight: 400;\">\/\/this will create Unchecked Exception<\/span><\/pre>\n<p style=\"text-align: justify;\"><strong>Example 2:<\/strong><\/p>\n<pre style=\"text-align: justify;\"><span style=\"font-weight: 400;\">class NewException extends Exception <\/span>\r\n\r\n<span style=\"font-weight: 400;\">{<\/span>\r\n\r\n<span style=\"font-weight: 400;\">}<\/span>\r\n\r\n<span style=\"font-weight: 400;\">\/\/this will create Checked Exception<\/span><\/pre>\n<p style=\"text-align: justify;\"><strong>Example 3:<\/strong><\/p>\n<pre style=\"text-align: justify;\"><span style=\"font-weight: 400;\">Class NewException extends IOException<\/span>\r\n\r\n<span style=\"font-weight: 400;\">{<\/span>\r\n\r\n<span style=\"font-weight: 400;\">}<\/span>\r\n\r\n<span style=\"font-weight: 400;\">\/\/this will create Checked Exception<\/span><\/pre>\n<ol style=\"text-align: justify;\" start=\"49\">\n<li><b> Is it possible to use try block without catch block?<\/b><\/li>\n<\/ol>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\"><strong>Answer<\/strong> &#8211; Yes, it is possible to use try block without catch block. It is not always required that the try block should be followed by a catch block. Try block can also be followed by a finally block. And the exceptions that are to be thrown should be declared in the throws clause of the method.<\/span><\/p>\n<ol style=\"text-align: justify;\" start=\"50\">\n<li><b> In which case the finally block will not be executed?<\/b><\/li>\n<\/ol>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\"><strong>Answer<\/strong> &#8211; In case of the program exit, the finally block will not be executed. So, when the program exits either by causing a serious error that may cause the abortion of the process or by calling System.exit() method, it will stop the finally block from execution.<\/span><\/p>\n<ol style=\"text-align: justify;\" start=\"51\">\n<li><b> Differentiate throw and throws.<\/b><\/li>\n<\/ol>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\"><strong>Answer &#8211;<\/strong> The main differences between throw and throws are as follows &#8211; <\/span><\/p>\n<table>\n<tbody>\n<tr>\n<td><b>Throw<\/b><\/td>\n<td><b>Throws<\/b><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">1. Throw is used to trigger the expectation.<\/span><\/td>\n<td><span style=\"font-weight: 400;\">1. Throws is used for the declaration of an expectation.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">2. Throw is used inside the method body<\/span><\/td>\n<td><span style=\"font-weight: 400;\">2. Throws is used in the method signature.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">3. Throw is followed by the instance of exception class, such as <\/span><\/p>\n<p><span style=\"font-weight: 400;\">Throw new ArithmeticException (\u201cArithmetic Exception\u201d);<\/span><\/td>\n<td><span style=\"font-weight: 400;\">3. Throws is followed by the name of exception class, such as <\/span><\/p>\n<p><span style=\"font-weight: 400;\">Throws ArithmeticException; <\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">4. Using throw, one exception can be handled at a time.<\/span><\/td>\n<td><span style=\"font-weight: 400;\">4. Using throws, multiple exceptions can be declared at the same time.<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<ol style=\"text-align: justify;\" start=\"52\">\n<li><b> How will you differentiate final, finalize, and finally?<\/b><\/li>\n<\/ol>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\"><strong>Answer<\/strong> &#8211; The difference between final, finalize, and finally is as follows &#8211;<\/span><\/p>\n<p style=\"text-align: justify;\"><b>Final &#8211;<\/b><span style=\"font-weight: 400;\"> In Java, Final is a keyword that is used to define constants. <\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">Once a class is declared as final, it can not be divided into subclasses.<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">Once a field is marked as final, its value becomes constant that cannot be reset.<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">When a method is declared as final, subclasses cannot override that method.<\/span><\/p>\n<p style=\"text-align: justify;\"><b>Finalize ( ) &#8211;<\/b><span style=\"font-weight: 400;\"> Finalize method in Java is associated with the garbage collection. <\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">The finalize method is automatically invoked before the garbage value collection.<\/span><\/p>\n<p style=\"text-align: justify;\"><b>Finally &#8211;<\/b><span style=\"font-weight: 400;\"> Finally block in Java is used with the try and catch blocks (except when try block uses System.exit(0) call)<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">The finally block is meant for the unexpected error. It executes the last clause mentioned in the try catch block.<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">The finally block contains a set of statements thats execution does not depend on the exception caught by the previous catch block.<\/span><\/p>\n<h2 style=\"text-align: justify;\"><span class=\"ez-toc-section\" id=\"Servlet_Java_Interview_Questions\"><\/span><b>Servlet Java Interview Questions<\/b><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">Here in sixth section, we cover the list of Servlet Java interview questions for the freshers and as well as professionals. If there is any Servlet-based Java interview question, you want to find the answer, post it in the comment section and our expert team will respond with the detailed answer.<\/span><\/p>\n<ol style=\"text-align: justify;\" start=\"53\">\n<li><b> What do you know about Servlet?<\/b><\/li>\n<\/ol>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\"><strong>Answer<\/strong> &#8211; Servlet in Java is server side technology that provides support for the data persistence and dynamic response and thus enhance the web servers capabilities. Some important points about Java Servlets are &#8211; <\/span><\/p>\n<ul style=\"text-align: justify;\">\n<li><span style=\"font-weight: 400;\">There are two types of packages i.e. javax.servlet and java.servlet.http that provides classes and interfaces to write own servlets.<\/span><\/li>\n<li><span style=\"font-weight: 400;\">javax.servlet.Servlet interface is responsible to define the methods for servlet lifecycle, so it is mandatory for all the servlets to implement java.servlet.Servlet interface.<\/span><\/li>\n<li><span style=\"font-weight: 400;\">Java Servlet API provides GenericServlet class that can be extended during the implementation of any generic service.<\/span><\/li>\n<li><span style=\"font-weight: 400;\">The HttpServlet class contains methods to handle HTTP specific services i.e. doPost( ) and doGet( ).<\/span><\/li>\n<li><span style=\"font-weight: 400;\">As the http protocols are mainly used to access the web applications, HttpServlet class is extended. <\/span><\/li>\n<\/ul>\n<ol style=\"text-align: justify;\" start=\"54\">\n<li><b> What are the different stages in a servlet lifecycle?<\/b><\/li>\n<\/ol>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\"><strong>Answer<\/strong> &#8211; The lifecycle of a servlet comprises of the 5 stages:<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">Loading &#8211; The servlet class is loaded<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">Instant Creation &#8211; The servlet instance is created<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">Initialization &#8211; Init method is invoked and the servlet becomes ready<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">Service Request &#8211; Service method is invoked to perform any task<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">Destruction &#8211; invocation of destroy method and the destruction of servlet<\/span><\/p>\n<p style=\"text-align: justify;\"><img decoding=\"async\" class=\"alignnone size-full wp-image-66679\" src=\"https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/sites\/2\/2018\/06\/different-stages-in-servlet-lifecycle.png\" alt=\"java interview Q &amp; A\" width=\"717\" height=\"411\" srcset=\"https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2018\/06\/different-stages-in-servlet-lifecycle.png 717w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2018\/06\/different-stages-in-servlet-lifecycle-300x172.png 300w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2018\/06\/different-stages-in-servlet-lifecycle-640x367.png 640w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2018\/06\/different-stages-in-servlet-lifecycle-681x390.png 681w\" sizes=\"(max-width: 717px) 100vw, 717px\" \/><\/p>\n<ol style=\"text-align: justify;\" start=\"55\">\n<li><b> Explain the working of cookies in Servlets.<\/b><\/li>\n<\/ol>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\"><strong>Answer<\/strong> &#8211; Cookies are the text that are sent to the client by server, and is saved at client side. Servlet APIs contain javax.servlet.http.Cookie class which implements Cloneable and Serializable interfaces an thus provides cookies support.<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">HttpServletRequest getCookies( ) method is used to get the array of cookies from the request.<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">HttpServletResponse addCookie (Cookie c) method is used to attach the cookie in response header.<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">As there is no need to add cookie to the request, no method is there to add or set cookie to the request. Similarly, there is no getter method for the cookies in servlet.<\/span><\/p>\n<ol style=\"text-align: justify;\" start=\"56\">\n<li><b> What are the various methods to manage session in Servlets?<\/b><\/li>\n<\/ol>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\"><strong>Answer<\/strong> &#8211; Session is a state of conversation between the server and the client. It may consist of a number of requests and responses between the server and the client. Session is maintained through session id (that is the unique info about the session). The session id is passed between client and server during every request and response.<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">There are different methods for the management of sessions in servlets &#8211;<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">Cookies<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">URL Rewriting<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">HTML Hidden Field<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">User Authentication<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">Session Management API<\/span><\/p>\n<ol style=\"text-align: justify;\" start=\"57\">\n<li><b> Differentiate between Get and Post methods.<\/b><\/li>\n<\/ol>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\"><strong>Answer<\/strong> &#8211; The difference between Get and Post methods is as follows &#8211; <\/span><\/p>\n<table>\n<tbody>\n<tr>\n<td><b>Get Method<\/b><\/td>\n<td><b>Post Method<\/b><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Get method is used to request data from a particular resource i.e. server<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Post method is used to return the requested data to a particular resource i.e. client<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">The request data is sent in the header, so only the limited data can be sent <\/span><\/td>\n<td><span style=\"font-weight: 400;\">The response data is sent in the body, so large amount of data can be sent<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">doGet method of servlet handles the Get method <\/span><\/td>\n<td><span style=\"font-weight: 400;\">doPost method of servlet handles the Post method<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Get method is no secure as the data is visible in the URL<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Post method is secured as the data is not visible in the URL<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">It is possible to bookmark Get method<\/span><\/td>\n<td><span style=\"font-weight: 400;\">It is not possible to bookmark Get method<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Get method is idempotent i.e. it provides same result on the multiple executions<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Post method is non-idempotent i.e. it provides different results on the multiple executions<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">The Get method is most commonly used and is more efficient as compared to the Post method<\/span><\/td>\n<td><span style=\"font-weight: 400;\">The Post method is less used and is even less efficient as compared to the Get method<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<ol style=\"text-align: justify;\" start=\"58\">\n<li><b> Differentiate ServletConfig and ServletContext.<\/b><\/li>\n<\/ol>\n<p style=\"text-align: justify;\"><b>Answer &#8211; <\/b>In servlet, the difference between ServletConfig and ServletContext is as follows &#8211;<\/p>\n<table>\n<tbody>\n<tr>\n<td><b>ServletConfig<\/b><\/td>\n<td><b>ServletContext<\/b><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">It denotes single servlet<\/span><\/td>\n<td><span style=\"font-weight: 400;\">It denotes the complete set of running web application, and is same for all the servlets<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">The scope of ServletConfig is servlet wide as it is defined within the servlet section of the web.xml file <\/span><\/td>\n<td><span style=\"font-weight: 400;\">The scope of ServletContext is application wide as it is define outside the servlet section of the web.xml file<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">getServletConfig( ) method provides the config object<\/span><\/td>\n<td><span style=\"font-weight: 400;\">getServletContext( ) provides the context object<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">It belongs to a specific servlet so acts as a local parameter<\/span><\/td>\n<td><span style=\"font-weight: 400;\">It belongs to the whole web application so acts as a global parameter<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<ol style=\"text-align: justify;\" start=\"59\">\n<li><b> What do you understand by servlet collaboration?<\/b><\/li>\n<\/ol>\n<p style=\"text-align: justify;\"><b>Answer &#8211; <\/b>The communication between two servlets is known as the servlet collaboration. The different methods through which servlets communicate like sendRedirect( ) method, RequestDispacher interface and others.<\/p>\n<ol style=\"text-align: justify;\" start=\"60\">\n<li><b> How will you differentiate sendRedirect( ) method and forward( ) method?<\/b><\/li>\n<\/ol>\n<p style=\"text-align: justify;\"><b>Answer &#8211; <\/b>The difference between sendRedirect( ) and forward( ) method is as follows &#8211;<\/p>\n<table>\n<tbody>\n<tr>\n<td><b>sendRedirect( ) method<\/b><\/td>\n<td><b>forward( ) method<\/b><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">sendRedirect( ) method \u00a0uses browser URL bar so, always sends a new request<\/span><\/td>\n<td><span style=\"font-weight: 400;\">forward( ) method sends the existing request from a servlet to the resource of another servlet<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">The scope of sendRedirect( ) method is not only within the server but also outside of the server<\/span><\/td>\n<td><span style=\"font-weight: 400;\">The scope of forward( ) method id within the server I.e. it can\u2019t work outside the server<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">sendRedirect( ) method works at the client side <\/span><\/td>\n<td><span style=\"font-weight: 400;\">forward( ) method works at the server side<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<ol style=\"text-align: justify;\" start=\"61\">\n<li><b> What is the meaning of session tracking?<\/b><\/li>\n<\/ol>\n<p style=\"text-align: justify;\"><b>Answer &#8211; <\/b>Session indicates a specific time interval in servlet while session tracking is a method to manage or maintain the user state, also known as session management in servlet.<\/p>\n<p style=\"text-align: justify;\">As the http protocol is stateless due to which every request generated by a user is consider it is required to maintain the state using any of the session tracking techniques. The session tracking is done to recognize a particular user.<\/p>\n<ol style=\"text-align: justify;\" start=\"62\">\n<li><b> Explain cookies in servlet.<\/b><\/li>\n<\/ol>\n<p style=\"text-align: justify;\"><b>Answer &#8211; <\/b>Cookie is defined as a small piece of information that continues to remain between the requests of multiple clients.<\/p>\n<p style=\"text-align: justify;\">Cookie has a name, value, and some other attributes version number, domains and path qualifiers, comment, and a maximum age.<\/p>\n<p style=\"text-align: justify;\">A cookie can be persistent, that remains valid for multiple sessions or non-persistent that remains valid only for one session.<\/p>\n<h2 style=\"text-align: justify;\"><span class=\"ez-toc-section\" id=\"Hibernate_Java_Interview_Questions\"><\/span><b>Hibernate Java Interview Questions<\/b><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\">Here in seventh section, we\u2019ll cover the list of Hibernate Java interview questions. If there are any Hibernate Java interview questions, you want to find the answer, just post it in the comment section and our expert team will respond with the detailed answer.<\/p>\n<ol style=\"text-align: justify;\" start=\"63\">\n<li><b> What do you know about hibernate framework?<\/b><\/li>\n<\/ol>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\"><strong>Answer<\/strong> &#8211; Hibernate is a lightweight, open source, ORM tool. The hibernate framework is meant to simplify the Java application development in order to interact with the database. <\/span><\/p>\n<p style=\"text-align: justify;\"><strong>The hibernate framework has many advantages, these are:<\/strong><\/p>\n<ul style=\"text-align: justify;\">\n<li>Hibernate framework is lightweight and open source under LGPL licence.<\/li>\n<li>Hibernate framework uses Hibernate Query Language (HQL) that is independent of database.<\/li>\n<li>Due to the use of cache, the performance of hibernate framework is very fast.<\/li>\n<li>It make complex joins simpler so it is easy to retrieve data from multiple tables.<\/li>\n<li>Hibernate framework facilitates the automatic creation of tables of the database.<\/li>\n<li>With the Query cache supporting feature, hibernate framework provides status of database and statistics of query.<\/li>\n<\/ul>\n<ol style=\"text-align: justify;\" start=\"64\">\n<li><b> Define ORM.<\/b><\/li>\n<\/ol>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\"><strong>Answer<\/strong> &#8211; Object Relation Mapping (ORM) is a technique of programming used for the mapping of data with the data stored in the database. An ORM tools makes the process of data access, data creation, and data manipulation simpler.<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">The Object Relation Mapping tool uses JDBC APIs to create an interaction with the database.<\/span><\/p>\n<ol style=\"text-align: justify;\" start=\"65\">\n<li><b> What do you know about Hibernate Query Language (HQL)?<\/b><b><br \/>\n<\/b><\/li>\n<\/ol>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\"><strong>Answer<\/strong> &#8211; Hibernate Query Language is an object oriented query language that is much similar to the Structured Query Language.<\/span><\/p>\n<p style=\"text-align: justify;\"><strong>Hibernate Query Language (HQL) has some advantages over Structured Query Language (SQL), these are &#8211; <\/strong><\/p>\n<ul style=\"text-align: justify;\">\n<li><b><span style=\"font-weight: 400;\">HQL is independent of database; no need to change the HQL query if database is changed<\/span><\/b><\/li>\n<li>\n<p style=\"display: inline !important;\"><span style=\"font-weight: 400;\">The previous knowledge or experience with SQL is not required to work with HQL<\/span><\/p>\n<\/li>\n<li>\n<p style=\"display: inline !important;\"><span style=\"font-weight: 400;\">It is easier and simpler to write query with HQL as compared to SQL<\/span><\/p>\n<\/li>\n<\/ul>\n<ol style=\"text-align: justify;\" start=\"66\">\n<li><b> Name the core interfaces of Hibernate.<\/b><\/li>\n<\/ol>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\"><strong>Answer<\/strong> &#8211; There are six core interfaces in the hibernate framework, these are:<\/span><\/p>\n<ul style=\"text-align: justify;\">\n<li><span style=\"font-weight: 400;\">Session<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">SessionFactory<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Configuration<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Criteria<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Query<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Transaction<\/span><\/li>\n<\/ul>\n<ol style=\"text-align: justify;\" start=\"67\">\n<li><b> Differentiate first level cache from second level cache.<\/b><\/li>\n<\/ol>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\"><strong>Answer<\/strong> &#8211; The first level cache is different form second level cache in hibernate. The differences between the two are:<\/span><\/p>\n<table>\n<tbody>\n<tr>\n<td><b>First Level Cache<\/b><\/td>\n<td><b>Second Level Cache<\/b><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">The first level cache is associated with the Session interface of hibernate.<\/span><\/td>\n<td><span style=\"font-weight: 400;\">The second level cache is associated with the SessionFactory interface of hibernate.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">The first level cache is by default enabled.<\/span><\/td>\n<td><span style=\"font-weight: 400;\">The second level cache is not by default enabled. It is required to enable it manually.<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<ol style=\"text-align: justify;\" start=\"68\">\n<li><b><\/b> <b>How many states of object are there in hibernate?<\/b><\/li>\n<\/ol>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\"><strong>Answer<\/strong> &#8211; There are 3 states of object in hibernate:<\/span><\/p>\n<ol style=\"text-align: justify;\">\n<li style=\"font-weight: 400;\"><b>Transient &#8211;<\/b><span style=\"font-weight: 400;\"> When the object is created, it is said to be in the transient state. In the transient state, the object does not have any primary key. Also, the session is not created for the object in this state.<\/span><\/li>\n<li style=\"font-weight: 400;\"><b>Persistent &#8211;<\/b><span style=\"font-weight: 400;\"> When the session is created for the object and is open, the object is said to be in persistent state. This state starts when the instance of the object is saved in the database or retrieved from the database.<\/span><\/li>\n<li style=\"font-weight: 400;\"><b>Detached &#8211; <\/b><span style=\"font-weight: 400;\">When the session of the object is closed, the object is said to be in detached state. The object can also reach to the persistent state again after this state if you invoke update() or lock() method.<\/span><\/li>\n<\/ol>\n<ol style=\"text-align: justify;\" start=\"69\">\n<li><b> Name the different types of association mapping in hibernate.<\/b><\/li>\n<\/ol>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\"><strong>Answer<\/strong> &#8211; There are four different types of association mapping in hibernate. <\/span><\/p>\n<ul style=\"text-align: justify;\">\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">One to One<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Many to One<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">One to Many<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Many to Many<\/span><\/li>\n<\/ul>\n<ol style=\"text-align: justify;\" start=\"70\">\n<li><b> Differentiate persist() and save() method of session of the hibernate.<\/b><\/li>\n<\/ol>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\"><strong>Answer<\/strong> &#8211; Following is the difference between persist() and save() method of session of the hibernate.<\/span><\/p>\n<table>\n<tbody>\n<tr>\n<td><b>persist( )<\/b><\/td>\n<td><b>save( )<\/b><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">The persist( ) method does not return anything.<\/span><\/td>\n<td><span style=\"font-weight: 400;\">The save( ) method returns the instance identifier.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">The syntax of persist( ) method is &#8211; <\/span><\/p>\n<p><span style=\"font-weight: 400;\">public void persist(Object a)<\/span><\/td>\n<td><span style=\"font-weight: 400;\">The syntax of save( ) method is &#8211;<\/span><\/p>\n<p><span style=\"font-weight: 400;\">public Serializable save(Object a)<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">It\u2019s return type if void.<\/span><\/td>\n<td><span style=\"font-weight: 400;\">It\u2019s return type is Serializable.<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<ol style=\"text-align: justify;\" start=\"71\">\n<li><b> Name the different strategies for inheritance mapping in hibernate.<\/b><\/li>\n<\/ol>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\"><strong>Answer<\/strong> &#8211; There are three different types of strategies for inheritance mapping in hibernate:<\/span><\/p>\n<ul style=\"text-align: justify;\">\n<li><span style=\"font-weight: 400;\">Table per subclass; the tables are created according to the class but related to the foreign key<\/span><\/li>\n<li><span style=\"font-weight: 400;\">Table per hierarchy; only one table is created to map the whole hierarchy<\/span><\/li>\n<li><span style=\"font-weight: 400;\">Table per concrete class; tables are created according to the class.<\/span><\/li>\n<\/ul>\n<ol start=\"72\">\n<li><b> How will you make a class immutable in hibernate?<\/b><b><br \/>\n<\/b><span style=\"font-weight: 400;\">Answer &#8211; By default, a class is set to be mutable with the true value of mutable i.e. mutable = \u201ctrue\u201d. In order to make a class immutable, you will require to mark the value of mutable false i.e. mutable = \u201cfalse\u201d.<\/span><\/li>\n<\/ol>\n<ol style=\"text-align: justify;\" start=\"73\">\n<li><b>Differentiate merge() and update() method.<\/b><\/li>\n<\/ol>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\"><strong>Answer<\/strong> &#8211; The difference between merge() and update() method is as follows:<\/span><\/p>\n<table>\n<tbody>\n<tr>\n<td><b>merge() method<\/b><\/td>\n<td><b>update() method<\/b><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">The merge method is used to combine something.<\/span><\/td>\n<td><span style=\"font-weight: 400;\">The update method is used to edit something.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">The merge method is used when the state of the session is not known.<\/span><\/td>\n<td><span style=\"font-weight: 400;\">The update method is used when the session is not in the persistent state.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">It is used to make the modifications at any time.<\/span><\/td>\n<td><span style=\"font-weight: 400;\">It is only used inside the session.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">It doesn\u2019t throw an error when session is in detached state.<\/span><\/td>\n<td><span style=\"font-weight: 400;\">It throws an error when session is in detached state.<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<ol style=\"text-align: justify;\" start=\"74\">\n<li><b> What do you know about lazy loading in hibernate?<\/b><\/li>\n<\/ol>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\"><strong>Answer<\/strong> &#8211; Lazy loading is a technique that is used to improve the performance in hibernate. It results in faster performance by loading the child object on the basis of demand. <\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">Lazy loading is by default enabled in Hibernate 3 and later versions. It means you don\u2019t require to set the value of lazy to true I.e. lazy = \u201ctrue\u201d. It specifies that you won\u2019t require to load child objects if the parent object has already been loaded.<\/span><\/p>\n<h2 style=\"text-align: justify;\"><span class=\"ez-toc-section\" id=\"Spring_Java_Interview_Questions\"><\/span><b>Spring Java Interview Questions<\/b><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">In the eighth section, here we cover the Spring Java interview questions and answers. Go through these basic and advanced Spring framework Java interview questions and broaden your knowledge to crack the interview. If you have any other Spring-based Java interview questions, please post in the comment section.<\/span><\/p>\n<ol style=\"text-align: justify;\" start=\"75\">\n<li><b> Define Spring and explain the advantages of spring framework.<\/b><\/li>\n<\/ol>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\"><strong>Answer<\/strong> &#8211; Spring is a lightweight, integrated, and loosely coupled framework that is used for the development of the enterprise applications with Java programming.<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">Sometimes the Spring framework is considered to be the framework of frameworks as it supports many frameworks such as Hibernate, Struts, EJB, Tapestry, JSF etc. Followings are the advantages of spring framework &#8211; <\/span><\/p>\n<ul style=\"text-align: justify;\">\n<li><span style=\"font-weight: 400;\">Lightweight<\/span><\/li>\n<li><span style=\"font-weight: 400;\">Integrated<\/span><\/li>\n<li><span style=\"font-weight: 400;\">Loose Coupling<\/span><\/li>\n<li><span style=\"font-weight: 400;\">Predefined Templates<\/span><\/li>\n<li><span style=\"font-weight: 400;\">Easy Testing<\/span><\/li>\n<li><span style=\"font-weight: 400;\">Faster Development<\/span><\/li>\n<li><span style=\"font-weight: 400;\">Declarative Support<\/span><\/li>\n<li><span style=\"font-weight: 400;\">Powerful Abstraction<\/span><\/li>\n<\/ul>\n<ol style=\"text-align: justify;\" start=\"76\">\n<li><b> What are the various Spring Modules?<\/b><\/li>\n<\/ol>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\"><strong>Answer<\/strong> &#8211; The spring framework is consisted of various modules which are grouped as Test, Spring Core Container, Instrumentation, Aspects, AOP, Web (MVC\/Remoting), and Data Access\/Integration.<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">Let\u2019s know more about these modules of spring framework &#8211; <\/span><\/p>\n<p style=\"text-align: justify;\"><b>Test &#8211; <\/b><span style=\"font-weight: 400;\">The test layer is responsible to provide the testing support with the testNG and JUnit modules.<\/span><\/p>\n<p style=\"text-align: justify;\"><b>Core Container &#8211;<\/b><span style=\"font-weight: 400;\"> The spring core container is composed of three modules, these are &#8211;<\/span><\/p>\n<p style=\"text-align: justify;\"><b>Context &#8211;<\/b><span style=\"font-weight: 400;\"> It supports EJB, Internationalization, Basic Remoting, and JMS.<\/span><\/p>\n<p style=\"text-align: justify;\"><b>Core and Beans &#8211;<\/b><span style=\"font-weight: 400;\"> \u00a0It provides Dependency Injection and IOC features.<\/span><\/p>\n<p style=\"text-align: justify;\"><b>Expression Language &#8211; <\/b><span style=\"font-weight: 400;\">It provides support to accessing indexers and collections, getting and setting property values, arithmetic and logical operators, method invocation, named variables, object retrieval by name and others.<\/span><\/p>\n<p style=\"text-align: justify;\"><b>Instrumentation, Aspects, and AOP &#8211;<\/b><span style=\"font-weight: 400;\"> The instrumentation module is meant to support to the class loader and class instrumentation implementations.<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">The aspects module is made to support the integration by means of the AspectJ.<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">The AOP module is known to provide support to the implementation of the aspect-oriented programming to make use of pointcuts, advices etc. for the decoupling of the code.<\/span><\/p>\n<p style=\"text-align: justify;\"><b>Web (MVC\/Remoting) &#8211; <\/b><span style=\"font-weight: 400;\">This layer of spring framework is composed of Web, Web-Struts, Web-Servlet, and Web-Portlet modules which are used to provide support for the development of web applications in Java.<\/span><\/p>\n<p style=\"text-align: justify;\"><b>Data Access\/ Integration &#8211; <\/b><span style=\"font-weight: 400;\">This group in spring framework includes OXM, JDBC, JMS, ORM, and Transaction modules which are made to provide support for the database interaction.<\/span><\/p>\n<ol style=\"text-align: justify;\" start=\"77\">\n<li><b> Explain Autowiring in Spring.<\/b><\/li>\n<\/ol>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\"><strong>Answer<\/strong> &#8211; Autowiring is a programming technique that helps programmer to automatically inject the bean without writing any injection logic explicitly.<\/span><\/p>\n<p style=\"text-align: justify;\">The code for the bean injection (with the help of dependency injection) is &#8211;<\/p>\n<p style=\"text-align: justify;\">&lt;bean id= \u201cemp\u201d class= \u201ccom.javapoint.Student\u201d autowire= byFName\u201d \/&gt;<\/p>\n<p style=\"text-align: justify;\">There are different autowiring modes in spring, these are &#8211;<\/p>\n<table>\n<tbody>\n<tr>\n<td><b>Name of Autowiring Module<\/b><\/td>\n<td><b>Details<\/b><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">constructor<\/span><\/td>\n<td><span style=\"font-weight: 400;\">It performs the injection of bean using constructor.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">byName<\/span><\/td>\n<td><span style=\"font-weight: 400;\">It performs the injection of bean on the basis of the name of the property by using setter method.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">byType<\/span><\/td>\n<td><span style=\"font-weight: 400;\">It performs the injection of the bean on the basis of the type of the property by using setter method.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">no<\/span><\/td>\n<td><span style=\"font-weight: 400;\">This mode specifies that the autowiring is disable. It is the default mode of the autowiring.<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<ol style=\"text-align: justify;\" start=\"78\">\n<li><b> Explain various bean scopes in Spring.<\/b><\/li>\n<\/ol>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\"><strong>Answer<\/strong> &#8211; The spring framework contains 5 bean scopes that are explained below:<\/span><\/p>\n<table>\n<tbody>\n<tr>\n<td><b>Name of the Scope<\/b><\/td>\n<td><b>Description<\/b><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">session<\/span><\/td>\n<td><span style=\"font-weight: 400;\">The instance of the bean is created as per the HTTP session.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">request<\/span><\/td>\n<td><span style=\"font-weight: 400;\">The instance of the bean is created as per the HTTP request.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">prototype<\/span><\/td>\n<td><span style=\"font-weight: 400;\">The instance of the bean is created at the time when it is requested.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">globalsession<\/span><\/td>\n<td><span style=\"font-weight: 400;\">The instance of the bean is created as per the global session of HTTP.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">singleton<\/span><\/td>\n<td><span style=\"font-weight: 400;\">The instance of the bean is created only once and is returned by the IOC container. Singleton is the \u00a0default spring scope.<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<ol style=\"text-align: justify;\" start=\"79\">\n<li><b> Mention some Spring annotations you have used.<\/b><\/li>\n<\/ol>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\"><strong>Answer<\/strong> &#8211; Here are the spring annotations that I\u2019ve used in my Java projects:<\/span><\/p>\n<p style=\"text-align: justify;\"><b>@ResponseBody &#8211;<\/b><span style=\"font-weight: 400;\"> to send Object as response. It was mainly used for sending JSON and XML data as response.<\/span><\/p>\n<p style=\"text-align: justify;\"><b>@Controller &#8211; <\/b><span style=\"font-weight: 400;\">used for controller classes<\/span><\/p>\n<p style=\"text-align: justify;\"><b>@PathVariable &#8211; <\/b><span style=\"font-weight: 400;\">to map dynamic values from URI to handler method arguments<\/span><\/p>\n<p style=\"text-align: justify;\"><b>@RequestMapping &#8211;<\/b><span style=\"font-weight: 400;\"> to configure URI mapping in controller handler methods<\/span><\/p>\n<p style=\"text-align: justify;\"><b>@Qualifier &#8211;<\/b><span style=\"font-weight: 400;\"> for avoiding confusion among multiple instances of bean type<\/span><\/p>\n<p style=\"text-align: justify;\"><b>@Autowired &#8211;<\/b><span style=\"font-weight: 400;\"> to autowire dependencies in beans <\/span><\/p>\n<p style=\"text-align: justify;\"><b>@ Scope &#8211; <\/b><span style=\"font-weight: 400;\">for the configuration of the scope of bean in spring<\/span><\/p>\n<p style=\"text-align: justify;\"><b>@Service &#8211;<\/b><span style=\"font-weight: 400;\"> used for service classes<\/span><\/p>\n<p style=\"text-align: justify;\"><b>@ComponentScan, @Configuration, and @Bean &#8211;<\/b><span style=\"font-weight: 400;\"> used for the configurations based on Java<\/span><\/p>\n<p style=\"text-align: justify;\"><b>@Aspect, @After, @Before, PointCut, and @Around &#8211;<\/b><span style=\"font-weight: 400;\"> for the configuration of advices and aspects<\/span><\/p>\n<ol style=\"text-align: justify;\" start=\"80\">\n<li><b> Have you ever integrated Spring framework with Hibernate framework? Explain.<\/b><\/li>\n<\/ol>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\"><strong>Answer<\/strong> &#8211; Yes, I have integrated Spring framework with Hibernate framework by using Spring ORM module. <\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">While using Hibernate 3+ where current session is provided by SessionFactory, HibernateDaoSupport and usingHibernateTemplate classes should be avoided. Instead, DAO pattern was used along with dependency injection for the purpose of integration.<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">Spring ORM was used over Hibernate boiler-plate code in order to implement transaction management <\/span><\/p>\n<ol style=\"text-align: justify;\" start=\"81\">\n<li><b> What do you know about IOC? Explain in detail.<\/b><\/li>\n<\/ol>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\"><strong>Answer<\/strong> &#8211; IOC is an abbreviation for Inversion of Control, it is a design pattern that is used to provide loose coupling. it is a container that is responsible for instantiation, configuration, and assembly of the objects. It retrieves information from XML files and then works. It is used for the removal of the dependencies from the program.<\/span><\/p>\n<p style=\"text-align: justify;\"><b>IOC container is responsible to perform the following functions &#8211;<\/b><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">For the instantiation of the application class<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">For the configuration of the object<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">In order to assemble the object\u2019s dependencies<\/span><\/p>\n<p style=\"text-align: justify;\"><b>Sample IOC Code:<\/b><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">public class Student{<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">Name name;<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">Student(Name name){<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">This.address=address;<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">}<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">}<\/span><\/p>\n<ol style=\"text-align: justify;\" start=\"82\">\n<li><b> Explain how is exception handling performed in Spring framework.<\/b><\/li>\n<\/ol>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\"><strong>Answer<\/strong> &#8211; There are different ways to handle exceptions in spring framework:<\/span><\/p>\n<p style=\"text-align: justify;\"><b>Global Exception Handler &#8211;<\/b><span style=\"font-weight: 400;\"> The exceptions can be handled by defining global exception handler. The global exception handler can be defined by using @ControllerAdvice annotation with the class.<\/span><\/p>\n<p style=\"text-align: justify;\"><b>Controller based &#8211; <\/b><span style=\"font-weight: 400;\">In this, the exception handler method is defined in the controller classes. The annotation @ExceptionHandler is used for controller based exception handling.<\/span><\/p>\n<p style=\"text-align: justify;\"><b>Implementation of HandlerExceptionResolver &#8211;<\/b><span style=\"font-weight: 400;\"> In static pages, it is required to handle the generic exceptions. For this, the HandlerExceptionResolver interface in Spring framework is implemented for creating global exception handler. <\/span><\/p>\n<ol style=\"text-align: justify;\" start=\"83\">\n<li><b> State the advantages of JdbcTemplate in Spring.<\/b><\/li>\n<\/ol>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\"><strong>Answer<\/strong> &#8211; Followings are the advantages of JdbcTemplate in Spring:<\/span><\/p>\n<ul style=\"text-align: justify;\">\n<li><span style=\"font-weight: 400;\">JdbcTemplate provides various methods using those you can directly write the queries. In this way, JdbcTemplate saves the a lot of time as well as work.<\/span><\/li>\n<li><span style=\"font-weight: 400;\">When you use JdbcTemplate class, you don\u2019t require to create statement, connection, close connection, start transaction, and commit transaction for the execution of various queries. So, JdbcTemplate class allows the programmer to perform direct execution of the query.<\/span><\/li>\n<\/ul>\n<ol style=\"text-align: justify;\" start=\"84\">\n<li><b> Name the different types of advice in Spring Aspect Orient Programming (AOP).<\/b><\/li>\n<\/ol>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\"><strong>Answer<\/strong> &#8211; The Spring AOP provides of five types of advices, these are &#8211;<\/span><\/p>\n<ul style=\"text-align: justify;\">\n<li><span style=\"font-weight: 400;\">Around Advice<\/span><\/li>\n<li><span style=\"font-weight: 400;\">Throws Advice<\/span><\/li>\n<li><span style=\"font-weight: 400;\">After Advice <\/span><\/li>\n<li><span style=\"font-weight: 400;\">After Returning Advice <\/span><\/li>\n<li><span style=\"font-weight: 400;\">Before Advice<\/span><\/li>\n<\/ul>\n<ol style=\"text-align: justify;\" start=\"85\">\n<li><b> Differentiate between ApplicationContext and BeanFactory.<\/b><\/li>\n<\/ol>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\"><strong>Answer<\/strong> &#8211; The difference between ApplicationContext and beanFactory is as follows:<\/span><\/p>\n<table>\n<tbody>\n<tr>\n<td><b>ApplicationContext<\/b><\/td>\n<td><b>BeanFactory<\/b><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">The ApplicationContext is an advanced spring container.<\/span><\/td>\n<td><span style=\"font-weight: 400;\">The BeanFactory is a basic spring container.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">The ApplicationContext is the extension of the BeanFactory interface.<\/span><\/td>\n<td><span style=\"font-weight: 400;\">The BeanFactory interface is not an extended interface.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">ApplicationContext interface provides some additional facilities &#8211; message resource handling, integration with spring AOP, and many others.<\/span><\/td>\n<td><span style=\"font-weight: 400;\">BeanFactory interface provides the basic facilities.<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2 style=\"text-align: justify;\"><span class=\"ez-toc-section\" id=\"_JSP_Java_Interview_Questions\"><\/span>\u00a0<b>JSP Java Interview Questions<\/b><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">In this ninth section, we cover the JSP Java interview questions and answers. Go through these JSP Java interview questions and prepare yourself for the Java interview. If you have any other JSP Java interview questions, please post in the comment section.<\/span><\/p>\n<ol style=\"text-align: justify;\" start=\"86\">\n<li><b> What is JSP?<\/b><\/li>\n<\/ol>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\"><strong>Answer<\/strong> &#8211; Java Server Pages (JSP) is a Java technology that is used to develop web applications. It offers some more functionality and features than servlet i.e. JSTL, expression language, custom tags etc. so it is considered as the extension of servlet technology.<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">A Java Server Page is composed of JSP tags along with HTML tags. It is easy to maintain JSP pages as it does not combine development and designing. \u00a0<\/span><\/p>\n<p style=\"text-align: justify;\"><b>Advantages of JSP &#8211;<\/b><\/p>\n<ul style=\"text-align: justify;\">\n<li><span style=\"font-weight: 400;\">Easy to maintain<\/span><\/li>\n<li><span style=\"font-weight: 400;\">Additional functionality<\/span><\/li>\n<li><span style=\"font-weight: 400;\">Faster development<\/span><\/li>\n<li><span style=\"font-weight: 400;\">Less coding<\/span><\/li>\n<\/ul>\n<ol style=\"text-align: justify;\" start=\"87\">\n<li><b> Explain the lifecycle of a JSP page.<\/b><\/li>\n<\/ol>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\"><strong>Answer<\/strong> &#8211; The lifecycle of a JSP page involves following phases &#8211;<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">JSP Page Translation<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">JSP Page Compilation<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">Class file loading by class loader (Classloading)<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">Creation of generated servlet object (Instantiation)<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">Invocation of jspInit( ) method by container (Initialization)<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">Invocation of jspService( ) method by container (Request Processing)<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">Invocation of jspDestroy( ) method by container (Destroy)<\/span><\/p>\n<ol style=\"text-align: justify;\" start=\"88\">\n<li><b> What do you know about JSP Implicit Objects?<\/b><\/li>\n<\/ol>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\"><strong>Answer<\/strong> &#8211; JSP Implicit Objects are those which are created by the web container and can be used by any of the JSP page. In Java, nine JSP Implicit Objects are there.<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">Following table covers all the JSP implicit object with their types.<\/span><\/p>\n<table>\n<tbody>\n<tr>\n<td><b>Object Name<\/b><\/td>\n<td><b>Object Type<\/b><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">request<\/span><\/td>\n<td><span style=\"font-weight: 400;\">HttpServletRequest<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">page<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Object<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">pageContext<\/span><\/td>\n<td><span style=\"font-weight: 400;\">PageContext<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">application<\/span><\/td>\n<td><span style=\"font-weight: 400;\">ServletContext<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">session<\/span><\/td>\n<td><span style=\"font-weight: 400;\">HttpSession<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">out<\/span><\/td>\n<td><span style=\"font-weight: 400;\">JspWriter<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">config<\/span><\/td>\n<td><span style=\"font-weight: 400;\">ServletConfig<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">exception<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Throwable<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">response<\/span><\/td>\n<td><span style=\"font-weight: 400;\">HttpServletResponse<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<ol style=\"text-align: justify;\" start=\"89\">\n<li><b> What do you know about JSTL? <\/b><\/li>\n<\/ol>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\"><strong>Answer<\/strong> &#8211; JSTL stands for JSP Standard Tag Library that contains a set of tags for the development of JSP pages.<\/span><\/p>\n<ul style=\"text-align: justify;\">\n<li><span style=\"font-weight: 400;\">JSTL has the following advantages &#8211;<\/span><\/li>\n<li><span style=\"font-weight: 400;\">Code Reusability<\/span><\/li>\n<li><span style=\"font-weight: 400;\">Fast Development<\/span><\/li>\n<li><span style=\"font-weight: 400;\">Avoids the use of scriptlet tags<\/span><\/li>\n<\/ul>\n<ol style=\"text-align: justify;\" start=\"90\">\n<li><b> What are the different types of JSTL tags?<\/b><\/li>\n<\/ol>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\"><strong>Answer<\/strong> &#8211; There are 5 types of JSTL tags &#8211;<\/span><\/p>\n<p style=\"text-align: justify;\"><b>Core Tags: <\/b><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">The JSTL core tags help in URL management, variable support, flow control etc.<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">The prefix c used for core tags.<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">The URL for core tags is <\/span><a href=\"http:\/\/java.sun.com\/jsp\/jstl\/core\" target=\"_blank\" rel=\"noopener\"><span style=\"font-weight: 400;\">http:\/\/java.sun.com\/jsp\/jstl\/core<\/span><\/a><\/p>\n<p style=\"text-align: justify;\"><b>XML Tags:<\/b><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">The JSTL XML tags help in transformation, flow control etc.<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">The prefix x used for core tags.<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">The URL for XML tags is <\/span><a href=\"http:\/\/java.sun.com\/jsp\/jstl\/core\" target=\"_blank\" rel=\"noopener\"><span style=\"font-weight: 400;\">http:\/\/java.sun.com\/jsp\/jstl\/xml<\/span><\/a><\/p>\n<p style=\"text-align: justify;\"><b>Function Tags:<\/b><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">The JSTL function tags are used to provide support for string length and string manipulation. <\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">The prefix fn used for function tags.<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">The URL for function tags is <\/span><a href=\"http:\/\/java.sun.com\/jsp\/jstl\/core\" target=\"_blank\" rel=\"noopener\"><span style=\"font-weight: 400;\">http:\/\/java.sun.com\/jsp\/jstl\/functions<\/span><\/a><\/p>\n<p style=\"text-align: justify;\"><b>SQL Tags:<\/b><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">The JSTL SQL tags are used to provide SQL support for the development of JSP pages.<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">The prefix sql used for SQL tags.<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">The URL for SQL tags is <\/span><a href=\"http:\/\/java.sun.com\/jsp\/jstl\/core\" target=\"_blank\" rel=\"noopener\"><span style=\"font-weight: 400;\">http:\/\/java.sun.com\/jsp\/jstl\/sql<\/span><\/a><\/p>\n<p style=\"text-align: justify;\"><b>Formatting Tags:<\/b><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">The JSTL formatting tags are used to provide support for message, number, and date formatting etc.<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">The prefix fmt used for formatting tags.<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">The URL for formatting tags is <\/span><a href=\"http:\/\/java.sun.com\/jsp\/jstl\/core\" target=\"_blank\" rel=\"noopener\"><span style=\"font-weight: 400;\">http:\/\/java.sun.com\/jsp\/jstl\/fmt<\/span><\/a><\/p>\n<ol style=\"text-align: justify;\" start=\"91\">\n<li><b> Have you ever heard about EL in JSP?<\/b><\/li>\n<\/ol>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\"><strong>Answer<\/strong> &#8211; In JSP, EL means Expression Language. The EL is used in order to make the objects accessibility simpler in JSP. The expression language provides a number of objects such as session, sessionScope, applicationScope, param, request, requestScope and many others. These objects can be directly used in JSP in a simple manner.<\/span><\/p>\n<ol style=\"text-align: justify;\" start=\"92\">\n<li><b> Differentiate between Java beans and Java custom tags.<\/b><\/li>\n<\/ol>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\"><strong>Answer<\/strong> &#8211; The difference between Java beans and Java custom tags is as follows:<\/span><\/p>\n<table>\n<tbody>\n<tr>\n<td><b>Java Beans<\/b><\/td>\n<td><b>Java Custom Tags<\/b><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Java beans cannot manipulate JSP content.<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Java custom tags can manipulate JSP content.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">It is simple to set up Java beans.<\/span><\/td>\n<td><span style=\"font-weight: 400;\">It is comparatively harder to set up Java custom tags.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Java beans are helpful to reduce the complex operations into simpler form.<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Java custom tags are helpful to reduce the complex operations into simpler form.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Java beans is available in all 1.x versions of JSP.<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Java custom tags can only be used in JSP 1.1<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<ol style=\"text-align: justify;\" start=\"93\">\n<li><b> Name the tags that are used in the development of Java beans.<\/b><\/li>\n<\/ol>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\"><strong>Answer<\/strong> &#8211; Three tags are used for the development of Java beans, these are:<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">jsp:useBean<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">Jsp:getProperty<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">jsp:setProperty<\/span><\/p>\n<ol style=\"text-align: justify;\" start=\"94\">\n<li><b> Write the statement that disables session in JSP.<\/b><\/li>\n<\/ol>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\"><strong>Answer<\/strong> &#8211; The statement that disables session in JSP is:<\/span><\/p>\n<p style=\"text-align: justify;\"><strong>&lt;%@ page session=\u201cfasle\u201d %&gt;<\/strong><\/p>\n<ol style=\"text-align: justify;\" start=\"95\">\n<li><b> How are the context.getRequestDispatcher() and request.getRequestDispatcher() different in terms of use?<\/b><\/li>\n<\/ol>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\"><strong>Answer<\/strong> &#8211; In order to create context.getRequestDispatcher(path), it relative path of the resource is required to be given while in order to create request.getRequestDispatcher(path) absolute path of the resource is required to be given alongwith.<\/span><\/p>\n<ol style=\"text-align: justify;\" start=\"96\">\n<li><strong> Name the directive used in JSP custom tag.\u00a0How will you perform the exception handling in JSP?<\/strong><\/li>\n<\/ol>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\"><strong>Answer<\/strong> &#8211; The directive used in JSP custom tag is JSP tag lib directive.<\/span><\/p>\n<p style=\"text-align: justify;\"><strong>The exceptions in JSP can be handled in two different ways:<\/strong><\/p>\n<ol style=\"text-align: justify;\">\n<li><span style=\"font-weight: 400;\">By the errorPage element \u00a0of web.xml file<\/span><\/li>\n<li><span style=\"font-weight: 400;\">By the errorPage element of page directive<\/span><\/li>\n<\/ol>\n<ol style=\"text-align: justify;\" start=\"97\">\n<li><b> What is the use of JSP in MVC model?<\/b><\/li>\n<\/ol>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\"><strong>Answer<\/strong> &#8211; JSP performs the role of the view in Model View Controller. It is used for the purpose of presentation in MVC model. The MVC is meant to deal with the calling of business classes and model to get the data. After that, this received data is presented to JSP to render to the client.<\/span><\/p>\n<ol style=\"text-align: justify;\" start=\"98\">\n<li><b> Name the various scope values for &lt;jsp:useBean&gt; tag.<\/b><\/li>\n<\/ol>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\"><strong>Answer<\/strong> &#8211; The scope value represents the bean scope i.e. scope of the bean. There are four different scopes of the bean.<\/span><\/p>\n<ul style=\"text-align: justify;\">\n<li><span style=\"font-weight: 400;\">page<\/span><\/li>\n<li><span style=\"font-weight: 400;\">session<\/span><\/li>\n<li><span style=\"font-weight: 400;\">request<\/span><\/li>\n<li><span style=\"font-weight: 400;\">application<\/span><\/li>\n<\/ul>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">The default value of bean scope is page.<\/span><\/p>\n<ol style=\"text-align: justify;\" start=\"99\">\n<li><b> Differentiate between include action and include directive.<\/b><\/li>\n<\/ol>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\"><strong>Answer<\/strong> &#8211; The difference between include action and include directive is as follows:<\/span><\/p>\n<table>\n<tbody>\n<tr>\n<td><b>Include Action<\/b><\/td>\n<td><b>Include Directive<\/b><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">It includes content at the time of request.<\/span><\/td>\n<td><span style=\"font-weight: 400;\">It includes content at the time of page translation.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">It does not include the original content.<\/span><\/td>\n<td><span style=\"font-weight: 400;\">It includes the original content.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Include action invokes the include( ) method of the Vendor provided class.<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Include directive doesn\u2019t invoke any method.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Using include action is better for the dynamic pages.<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Using include directive is better for the static pages.<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<ol style=\"text-align: justify;\" start=\"100\">\n<li><b> Did you find JSP technology extensible?<\/b><\/li>\n<\/ol>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\"><strong>Answer<\/strong> &#8211; Yes, I found JSP technology extensible. The JSP technology is considered extensible as it comes with custom tags or actions that are encapsulated within tag libraries. <\/span><\/p>\n<p style=\"text-align: justify;\"><b>Cover Up<\/b><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">So here we reach the end of the Java interview questions blog. The questions and answers covered in this Java Interview Questions blog are the\u00a0frequently-asked Java interview questions that the recruiters ask to Java Professional in a Java interview.\u00a0These are the Java Interview Questions that will definitely help you ace your job interview.<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">Whizlabs is pioneering the online certification training industry and have helped more than 3 million professionals too advance their career. We are aimed to help you in your journey to build a bright career, so apart from these Java interview questions, we provide Oracle Java certifications online course and practice tests. Our study and practice material is best-in the industry and will help you become an <a href=\"https:\/\/www.whizlabs.com\/oracle-java-certifications\/\" target=\"_blank\" rel=\"noopener noreferrer\">Oracle Java certified<\/a>.<\/span><\/p>\n<p style=\"text-align: justify;\"><b>Wish you the luck for your Java interview!<\/b><\/p>\n<p style=\"text-align: justify;\"><em><span style=\"font-weight: 400;\">Facing any problems with these java interview questions, please comment your problems in the section below and we will get back to you as soon as possible!<\/span><\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Are you a Java professional preparing for an interview? If yes, you\u2019ve reached the right page. Yes! We\u2019ve got you covered with Top 100 Java interview questions with detailed answers. As a Java professional, it is required to be familiar with various Java technologies while going for an interview. In this Java interview questions blog, we have compiled a definitive set of most commonly asked Java interview questions and answers for freshers as well as experienced professionals to help them crack the Java interview. Millions of developers and a huge number of devices worldwide are using Java. Java is everywhere!! [&hellip;]<\/p>\n","protected":false},"author":220,"featured_media":66751,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_uag_custom_page_level_css":"","site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[13],"tags":[66,668,747,875,967,992,999,1004,1455,1483,1497],"class_list":["post-66667","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-java","tag-advanced-java-interview-questions","tag-core-java-interview-questions","tag-exception-handling-java-interview-questions","tag-hibernate-java-interview-questions","tag-java-3","tag-java-interview-questions","tag-jdbc-java-interview-questions","tag-jsp-java-interview-questions","tag-servlet-java-interview-questions","tag-spring-java-interview-questions","tag-string-handling-java-interview-questions"],"uagb_featured_image_src":{"full":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2018\/06\/java_interview_questions.png",600,315,false],"thumbnail":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2018\/06\/java_interview_questions-150x150.png",150,150,true],"medium":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2018\/06\/java_interview_questions-300x158.png",300,158,true],"medium_large":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2018\/06\/java_interview_questions.png",600,315,false],"large":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2018\/06\/java_interview_questions.png",600,315,false],"1536x1536":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2018\/06\/java_interview_questions.png",600,315,false],"2048x2048":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2018\/06\/java_interview_questions.png",600,315,false],"profile_24":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2018\/06\/java_interview_questions.png",24,13,false],"profile_48":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2018\/06\/java_interview_questions.png",48,25,false],"profile_96":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2018\/06\/java_interview_questions.png",96,50,false],"profile_150":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2018\/06\/java_interview_questions.png",150,79,false],"profile_300":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2018\/06\/java_interview_questions.png",300,158,false],"tptn_thumbnail":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2018\/06\/java_interview_questions-250x250.png",250,250,true],"web-stories-poster-portrait":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2018\/06\/java_interview_questions.png",600,315,false],"web-stories-publisher-logo":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2018\/06\/java_interview_questions.png",96,50,false],"web-stories-thumbnail":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2018\/06\/java_interview_questions.png",150,79,false]},"uagb_author_info":{"display_name":"Aditi Malhotra","author_link":"https:\/\/www.whizlabs.com\/blog\/author\/aditi\/"},"uagb_comment_info":45,"uagb_excerpt":"Are you a Java professional preparing for an interview? If yes, you\u2019ve reached the right page. Yes! We\u2019ve got you covered with Top 100 Java interview questions with detailed answers. As a Java professional, it is required to be familiar with various Java technologies while going for an interview. In this Java interview questions blog,&hellip;","_links":{"self":[{"href":"https:\/\/www.whizlabs.com\/blog\/wp-json\/wp\/v2\/posts\/66667","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.whizlabs.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.whizlabs.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.whizlabs.com\/blog\/wp-json\/wp\/v2\/users\/220"}],"replies":[{"embeddable":true,"href":"https:\/\/www.whizlabs.com\/blog\/wp-json\/wp\/v2\/comments?post=66667"}],"version-history":[{"count":6,"href":"https:\/\/www.whizlabs.com\/blog\/wp-json\/wp\/v2\/posts\/66667\/revisions"}],"predecessor-version":[{"id":77129,"href":"https:\/\/www.whizlabs.com\/blog\/wp-json\/wp\/v2\/posts\/66667\/revisions\/77129"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.whizlabs.com\/blog\/wp-json\/wp\/v2\/media\/66751"}],"wp:attachment":[{"href":"https:\/\/www.whizlabs.com\/blog\/wp-json\/wp\/v2\/media?parent=66667"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.whizlabs.com\/blog\/wp-json\/wp\/v2\/categories?post=66667"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.whizlabs.com\/blog\/wp-json\/wp\/v2\/tags?post=66667"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}