{"id":1214,"date":"2021-10-23T17:24:35","date_gmt":"2021-10-23T17:24:35","guid":{"rendered":"https:\/\/rahulshettyacademy.com\/blog\/index.php\/2021\/10\/23\/sdet-interview-questions-part-1\/"},"modified":"2021-10-23T17:24:35","modified_gmt":"2021-10-23T17:24:35","slug":"sdet-interview-questions-part-1","status":"publish","type":"post","link":"https:\/\/rahulshettyacademy.com\/blog\/index.php\/2021\/10\/23\/sdet-interview-questions-part-1\/","title":{"rendered":"Top SDET Interview Questions in Java &#8211; Part 1"},"content":{"rendered":"<p><html><body><\/p>\n<section class=\"tcb-post-content tcb-shortcode thrv_wrapper\" data-css=\"tve-u-16ec5d248bb\">\n<div class=\"tve_flt tcb-style-wrap\" id=\"tve_flt\">\n<div class=\"tve_shortcode_editor tar-main-content\" data-post-id=\"1214\" id=\"tve_editor\">\n<div class=\"thrv_wrapper thrv_text_element\">\n<h3 class=\"\" id=\"t-1635009289844\"><a class=\"tve-froala fr-basic\" name=\"_Toc82204558\" style=\"outline: none;\">This<\/a> is Part 1 in the series of SDET Interview questions and answers in Java<\/h3>\n<\/div>\n<div class=\"thrv_wrapper tve-toc tve-elem-scroll tve-toc-expandable tcb-local-vars-root\" data-animation=\"fade\" data-animation-speed=\"fast\" data-bullet-style='{\"0\":\"tve-u-1739a1b9ec9\",\"1\":\"tve-u-1739a1ba9d6\",\"2\":\"tve-u-1739a1bb53c\"}' data-columns=\"1\" data-columns-d=\"1\" data-css=\"tve-u-17cae279e16\" data-ct=\"toc-60672\" data-ct-name=\"Table of Contents 04\" data-element-name=\"Table of Contents\" data-headers=\"h1,h3,h5\" data-heading-style='{\"0\":\"tve-u-17cae279e1e\",\"1\":\"tve-u-17cae279e20\",\"2\":\"tve-u-17cae279e21\"}' data-highlight=\"section\" data-number-style='{\"0\":\"tve-u-17cae279e1f\",\"1\":\"tve-u-173dc88e09d\",\"2\":\"tve-u-173dc88e7b7\"}' data-numbering=\"basic\" data-state-default=\"expanded\" data-state-default-m=\"collapsed\" data-transition=\"slide\" style=\"\">\n<div class=\"thrive-colors-palette-config\" style=\"display: none !important\"><\/div>\n<div class=\"tve-toc-divider\" style=\"position: absolute; width: 0; height: 0; overflow: hidden;\">\n<div class=\"thrv_wrapper thrv-divider tve-vert-divider\" data-color-d=\"rgba(0, 0, 0, 0.24)\" data-css=\"tve-u-17cae279e17\" data-style=\"tve_sep-1\" data-style-d=\"tve_sep-3\" data-thickness-d=\"6\">\n<hr class=\"tve_sep tve_sep-3\" style=\"\"\/><\/div>\n<\/div>\n<p><svg class=\"toc-icons\" style=\"position: absolute; width: 0; height: 0; overflow: hidden;\" version=\"1.1\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\"><symbol data-id=\"icon-clone-outlined\" id=\"toc-bullet-0\" viewbox=\"0 0 512 512\"><path d=\"M464 0H144c-26.51 0-48 21.49-48 48v48H48c-26.51 0-48 21.49-48 48v320c0 26.51 21.49 48 48 48h320c26.51 0 48-21.49 48-48v-48h48c26.51 0 48-21.49 48-48V48c0-26.51-21.49-48-48-48zM362 464H54a6 6 0 0 1-6-6V150a6 6 0 0 1 6-6h42v224c0 26.51 21.49 48 48 48h224v42a6 6 0 0 1-6 6zm96-96H150a6 6 0 0 1-6-6V54a6 6 0 0 1 6-6h308a6 6 0 0 1 6 6v308a6 6 0 0 1-6 6z\"><\/path><\/symbol><symbol data-id=\"icon-caret-right-solid\" id=\"toc-bullet-1\" viewbox=\"0 0 192 512\">\n<path d=\"M0 384.662V127.338c0-17.818 21.543-26.741 34.142-14.142l128.662 128.662c7.81 7.81 7.81 20.474 0 28.284L34.142 398.804C21.543 411.404 0 402.48 0 384.662z\"><\/path>\n<\/symbol><symbol data-id=\"icon-caret-right-solid\" id=\"toc-bullet-2\" viewbox=\"0 0 192 512\">\n<path d=\"M0 384.662V127.338c0-17.818 21.543-26.741 34.142-14.142l128.662 128.662c7.81 7.81 7.81 20.474 0 28.284L34.142 398.804C21.543 411.404 0 402.48 0 384.662z\"><\/path>\n<\/symbol><\/svg><\/p>\n<div class=\"tve-content-box-background\" data-css=\"tve-u-17cae279e18\" style=\"\"><\/div>\n<div class=\"thrv_wrapper tve-toc-title show-icon reverse tcb-icon-display tve-no-dropzone tve-prevent-content-edit\" data-css=\"tve-u-17cae279e1a\" style=\"\">\n<div class=\"tve-content-box-background\"><\/div>\n<div class=\"tve-cb\" style=\"\">\n<div class=\"tve-toc-title-icon\" data-icon-code=\"icon-close-solid\" style=\"\"><svg class=\"tcb-icon\" data-id=\"icon-close-solid\" data-name=\"\" viewbox=\"0 0 24 24\"><path d=\"M19,6.41L17.59,5L12,10.59L6.41,5L5,6.41L10.59,12L5,17.59L6.41,19L12,13.41L17.59,19L19,17.59L13.41,12L19,6.41Z\"><\/path><\/svg><\/div>\n<div class=\"thrv_wrapper thrv_text_element tve_no_icons\">\n<div class=\"tcb-plain-text\" data-css=\"tve-u-17cae279e1b\" style=\"\">table of contents<\/div>\n<\/p><\/div>\n<\/div>\n<\/div>\n<div class=\"tve-cb tve-toc-content tve-prevent-content-edit\">\n<div class=\"thrv_wrapper tve-toc-list tcb-no-delete tcb-no-save tcb-no-clone tve-no-dropzone\" data-css=\"tve-u-17cae279e1c\" style=\"\">\n<div class=\"tve-content-box-background\" data-css=\"tve-u-17cae279e1d\"><\/div>\n<div class=\"tve-cb\" style=\"\">\n<div class=\"tve_ct_content tve_clearfix\" style=\"\">\n<div class=\"ct_column\">\n<div class=\"thrv_wrapper tve-toc-heading tve-toc-heading-level1 tve_no_icons\" data-css=\"tve-u-17cae279e20\" data-element-name=\"Heading Level 2\" data-tag=\"H3\"><a class=\"tve-toc-anchor tve-jump-scroll\" href=\"#t-1635009289844\" jump-animation=\"smooth\">This is Part 1 in the series of SDET Interview questions and answers in Java<\/a><\/div>\n<div class=\"thrv_wrapper tve-toc-heading tve-toc-heading-level1 tve_no_icons\" data-css=\"tve-u-17cae279e20\" data-element-name=\"Heading Level 2\" data-tag=\"H3\"><a class=\"tve-toc-anchor tve-jump-scroll\" href=\"#t-1638297369020\" jump-animation=\"smooth\">1. What is the difference between JDK, JRE, and JVM?<\/a><\/div>\n<div class=\"thrv_wrapper tve-toc-heading tve-toc-heading-level1 tve_no_icons\" data-css=\"tve-u-17cae279e20\" data-element-name=\"Heading Level 2\" data-tag=\"H3\"><a class=\"tve-toc-anchor tve-jump-scroll\" href=\"#t-1638297369021\" jump-animation=\"smooth\">2. What are the different types of constructors in Java? And How to overload Constructor?<\/a><\/div>\n<div class=\"thrv_wrapper tve-toc-heading tve-toc-heading-level1 tve_no_icons\" data-css=\"tve-u-17cae279e20\" data-element-name=\"Heading Level 2\" data-tag=\"H3\"><a class=\"tve-toc-anchor tve-jump-scroll\" href=\"#t-1635009289846\" jump-animation=\"smooth\">3. What is the static keyword? How it can be used?<\/a><\/div>\n<div class=\"thrv_wrapper tve-toc-heading tve-toc-heading-level1 tve_no_icons\" data-css=\"tve-u-17cae279e20\" data-element-name=\"Heading Level 2\" data-tag=\"H3\"><a class=\"tve-toc-anchor tve-jump-scroll\" href=\"#t-1635009289847\" jump-animation=\"smooth\">4. What is this final keyword? how I can be used?<\/a><\/div>\n<div class=\"thrv_wrapper tve-toc-heading tve-toc-heading-level1 tve_no_icons\" data-css=\"tve-u-17cae279e20\" data-element-name=\"Heading Level 2\" data-tag=\"H3\"><a class=\"tve-toc-anchor tve-jump-scroll\" href=\"#t-1638297369022\" jump-animation=\"smooth\">5. What is the difference between method overloading and method overriding?<\/a><\/div>\n<div class=\"thrv_wrapper tve-toc-heading tve-toc-heading-level1 tve_no_icons\" data-css=\"tve-u-17cae279e20\" data-element-name=\"Heading Level 2\" data-tag=\"H3\"><a class=\"tve-toc-anchor tve-jump-scroll\" href=\"#t-1638297369023\" jump-animation=\"smooth\">6. Could you explain IS-A and HAS-A relationship?<\/a><\/div>\n<div class=\"thrv_wrapper tve-toc-heading tve-toc-heading-level1 tve_no_icons\" data-css=\"tve-u-17cae279e20\" data-element-name=\"Heading Level 2\" data-tag=\"H3\"><a class=\"tve-toc-anchor tve-jump-scroll\" href=\"#t-1638297369024\" jump-animation=\"smooth\">7. Explain this and super keyword<\/a><\/div>\n<div class=\"thrv_wrapper tve-toc-heading tve-toc-heading-level1 tve_no_icons\" data-css=\"tve-u-17cae279e20\" data-element-name=\"Heading Level 2\" data-tag=\"H3\"><a class=\"tve-toc-anchor tve-jump-scroll\" href=\"#t-1638297369025\" jump-animation=\"smooth\">8. How to check instance of Specified type? Explain with example<\/a><\/div>\n<div class=\"thrv_wrapper tve-toc-heading tve-toc-heading-level1 tve_no_icons\" data-css=\"tve-u-17cae279e20\" data-element-name=\"Heading Level 2\" data-tag=\"H3\"><a class=\"tve-toc-anchor tve-jump-scroll\" href=\"#t-1638297369026\" jump-animation=\"smooth\">9. What is a package in Java? What are different types of packages? Can we create a custom package?<\/a><\/div>\n<div class=\"thrv_wrapper tve-toc-heading tve-toc-heading-level1 tve_no_icons\" data-css=\"tve-u-17cae279e20\" data-element-name=\"Heading Level 2\" data-tag=\"H3\"><a class=\"tve-toc-anchor tve-jump-scroll\" href=\"#t-1638297369027\" jump-animation=\"smooth\">10. What is run time polymorphism in Java?<\/a><\/div>\n<div class=\"thrv_wrapper tve-toc-heading tve-toc-heading-level1 tve_no_icons\" data-css=\"tve-u-17cae279e20\" data-element-name=\"Heading Level 2\" data-tag=\"H3\"><a class=\"tve-toc-anchor tve-jump-scroll\" href=\"#t-1638297369028\" jump-animation=\"smooth\">11. What is the difference between static and dynamic binding in java?<\/a><\/div>\n<\/div>\n<div class=\"thrv_wrapper thrv-divider tve-vert-divider\" data-color-d=\"rgba(0, 0, 0, 0.24)\" data-css=\"tve-u-17cae279e17\" data-style=\"tve_sep-1\" data-style-d=\"tve_sep-3\" data-thickness-d=\"6\">\n<hr class=\"tve_sep tve_sep-3\" style=\"\"\/><\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"thrv_wrapper thrv_text_element\">\n<h3 class=\"\" id=\"t-1638297369020\"><a class=\"tve-froala fr-basic\" name=\"_Toc82204558\" style=\"outline: none;\">1. What is the difference between JDK, JRE, and JVM?<\/a><\/h3>\n<p><strong>JDK<\/strong> is Java Development Kit it is used for Developing Java Application<\/p>\n<div class=\"code-block code-block-2\" style=\"margin: 8px auto; text-align: center; display: block; clear: both;\">\n<p><!-- horizontal responsive 2 --><br \/>\n<ins class=\"adsbygoogle\" data-ad-client=\"ca-pub-3231318496783163\" data-ad-format=\"auto\" data-ad-slot=\"2788468763\" data-full-width-responsive=\"true\" style=\"display:block\"><\/ins>\n<\/div>\n<p><strong>JRE<\/strong> is Java Runtime Environment that is used for running java programs\/application<\/p>\n<p><strong>JVM<\/strong> is Java Virtual Machine that provides a Platform Independent execution environment for running your code.<\/p>\n<h3 class=\"\" id=\"t-1638297369021\"><a class=\"tve-froala fr-basic\" name=\"_Toc82204559\" style=\"outline: none;\">2. What are the different types of constructors in Java? And How to overload Constructor?<\/a><\/h3>\n<p><strong>Constructor<\/strong> is a block of code, which will have a name as the Class name. The constructor will be executed when a new instance of the class is created.<\/p>\n<p><strong>There are two types of Constructor<\/strong><\/p>\n<p><em><strong>Default Constructor<\/strong><\/em><\/p>\n<p>Default constructor will not have any parameter, If you don\u2019t define it then compiles creates one automatically. Default constructor will be called by compiler if there is no other constructor.<\/p>\n<p><span style=\"text-decoration: underline;\">Example Code Snippet<\/span><span style=\"text-decoration: underline;\"><\/span><\/p>\n<\/div>\n<div class=\"thrv_wrapper thrv_contentbox_shortcode thrv-content-box tve-elem-default-pad\">\n<div class=\"tve-content-box-background\" style=\"background-image: linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)) !important; background-size: auto !important; background-position: 50% 50% !important; background-attachment: scroll !important; background-repeat: no-repeat !important; --background-image:linear-gradient(rgba(0,0,0,0.5), rgba(0,0,0,0.5))  !important; --background-size:auto auto  !important; --background-position:50% 50%  !important; --background-attachment:scroll  !important; --background-repeat:no-repeat  !important;\"><\/div>\n<div class=\"tve-cb\">\n<div class=\"thrv_wrapper thrv_text_element\" data-css=\"tve-u-17cacb64e60\" style=\"\">\n<p><span data-css=\"tve-u-17cacb67dbb\" style=\"color: rgb(255, 255, 255);\">class Academy {<\/span><\/p>\n<p><span data-css=\"tve-u-17cacb67dbd\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0 \/\/ Constructor<\/span><\/p>\n<p><span data-css=\"tve-u-17cacb67dbf\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0 Academy() {<\/span><\/p>\n<p><span data-css=\"tve-u-17cacb67dc0\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 System.out.println(&#8220;Constructor called&#8221;);<\/span><\/p>\n<p><span data-css=\"tve-u-17cacb67dc2\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0 }<\/span><\/p>\n<p><span data-css=\"tve-u-17cacb67dc3\" style=\"color: rgb(255, 255, 255);\">}<\/span><\/p>\n<p><span data-css=\"tve-u-17cacb67dc4\" style=\"color: rgb(255, 255, 255);\">public class SampleClass {<\/span><\/p>\n<p><span data-css=\"tve-u-17cacb67dc6\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0 public static void main(String args[]) {<\/span><\/p>\n<p><span data-css=\"tve-u-17cacb67dc7\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0 \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u00a0\u00a0\/\/ this invokes default constructor.<\/span><\/p>\n<p><span data-css=\"tve-u-17cacb67dc8\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Academy academy = new Academy();<\/span><\/p>\n<p><span data-css=\"tve-u-17cacb67dca\" style=\"color: rgb(255, 255, 255);\">}\u00a0\u00a0<\/span><\/p>\n<p><span data-css=\"tve-u-17cacb67dcb\" style=\"color: rgb(255, 255, 255);\">}<\/span><\/p>\n<p><span data-css=\"tve-u-17cacb67dcc\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><\/p>\n<p><strong><span style=\"text-decoration: underline;\"><span data-css=\"tve-u-17cacb67dce\" style=\"color: rgb(255, 255, 255);\">Output:<\/span><\/span><\/strong><\/p>\n<p><span data-css=\"tve-u-17cacb67dcf\" style=\"color: rgb(255, 255, 255);\">Constructor called<\/span><\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"thrv_wrapper thrv_text_element\">\n<p><strong>Parameterized Constructor<\/strong><\/p>\n<p>The parameterized constructor will have parameters, this is mainly used for initialization purposes. You can pass different values to a parameterized constructor at the time of object creation, but values should match the constructor signature<\/p>\n<p><span style=\"text-decoration: underline;\">Example Code Snippet<\/span><\/p>\n<\/div>\n<div class=\"thrv_wrapper thrv_contentbox_shortcode thrv-content-box tve-elem-default-pad\">\n<div class=\"tve-content-box-background\" style=\"background-image: linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)) !important; background-size: auto !important; background-position: 50% 50% !important; background-attachment: scroll !important; background-repeat: no-repeat !important; --background-image:linear-gradient(rgba(0,0,0,0.5), rgba(0,0,0,0.5))  !important; --background-size:auto auto  !important; --background-position:50% 50%  !important; --background-attachment:scroll  !important; --background-repeat:no-repeat  !important;\"><\/div>\n<div class=\"tve-cb\">\n<div class=\"thrv_wrapper thrv_text_element\" data-css=\"tve-u-17cacb731fe\" style=\"\">\n<p><span data-css=\"tve-u-17cacb77f46\" style=\"color: rgb(255, 255, 255);\">\u00a0 \u00a0 class Academy {<\/span><\/p>\n<p><span data-css=\"tve-u-17cacb77f48\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0 int a=0;<\/span><\/p>\n<p><span data-css=\"tve-u-17cacb77f49\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0 int b=0;<\/span><\/p>\n<p><span data-css=\"tve-u-17cacb77f4b\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0 \/\/ Parameterized Constructor<\/span><\/p>\n<p><span data-css=\"tve-u-17cacb77f4c\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0 Academy(int a, int b) {<\/span><\/p>\n<p><span data-css=\"tve-u-17cacb77f4d\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 System.out.println(&#8220;Constructor called&#8221;);<\/span><\/p>\n<p><span data-css=\"tve-u-17cacb77f4e\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 System.out.println(&#8220;Addition of &#8220;+a+&#8221; and &#8220;+b+&#8221; = &#8220;+(a+b));<\/span><\/p>\n<p><span data-css=\"tve-u-17cacb77f50\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0 }<\/span><\/p>\n<p><span data-css=\"tve-u-17cacb77f51\" style=\"color: rgb(255, 255, 255);\">}<\/span><\/p>\n<p><span data-css=\"tve-u-17cacb77f52\" style=\"color: rgb(255, 255, 255);\">public class SampleClass {<\/span><\/p>\n<p><span data-css=\"tve-u-17cacb77f54\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 public static void main(String args[]) {<\/span><\/p>\n<p><span data-css=\"tve-u-17cacb77f55\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \/\/ this invokes default constructor.<\/span><\/p>\n<p><span data-css=\"tve-u-17cacb77f56\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Academy academy = new Academy(10,20);<\/span><\/p>\n<p><span data-css=\"tve-u-17cacb77f58\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 }<\/span><\/p>\n<p><span data-css=\"tve-u-17cacb77f59\" style=\"color: rgb(255, 255, 255);\">}<\/span><\/p>\n<p><span data-css=\"tve-u-17cacb77f5a\" style=\"color: rgb(255, 255, 255);\"><strong><span data-css=\"tve-u-17cacb77f5b\" style=\"text-decoration: underline;\">Output:<\/span><\/strong><\/span><\/p>\n<p><span data-css=\"tve-u-17cacb77f5d\" style=\"color: rgb(255, 255, 255);\">Constructor called<\/span><\/p>\n<p><span data-css=\"tve-u-17cacb77f5e\" style=\"color: rgb(255, 255, 255);\">Addition of 10 and 20 = 30<\/span><\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"thrv_wrapper thrv_text_element\">\n<h3 class=\"\" id=\"t-1635009289846\"><a class=\"tve-froala fr-basic\" name=\"_Toc82204560\" style=\"outline: none;\">3. What is the static keyword? How it can be used?<\/a><\/h3>\n<p>The static indicates that the particular member belongs to a type itself, rather than to an instance of that type. That means a static member of the class can be accessed before creating any object for that class.<\/p>\n<p>Static keywords can be used for<\/p>\n<ul class=\"\">\n<li>Variable, also called static fields or Class Variables<\/li>\n<li>Method<\/li>\n<li>Block<\/li>\n<li>Nested Class<\/li>\n<\/ul>\n<p><strong>Static Variable or Static Fields:<\/strong><\/p>\n<p>When you prefix fields or variables with static which is called a static variable. When you create the static variable single copy of that variable is created and shared among all instances of an object.<\/p>\n<ul class=\"\">\n<li>The static variable associated with the class can be accessed directly using the class name. The object reference is not needed.<\/li>\n<li>Static variables are created at the class level.<\/li>\n<\/ul>\n<p><strong>Example Code Snippet<\/strong><\/p>\n<\/div>\n<div class=\"thrv_wrapper thrv_contentbox_shortcode thrv-content-box tve-elem-default-pad\">\n<div class=\"tve-content-box-background\" style=\"background-image: linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)) !important; background-size: auto !important; background-position: 50% 50% !important; background-attachment: scroll !important; background-repeat: no-repeat !important; --background-image:linear-gradient(rgba(0,0,0,0.5), rgba(0,0,0,0.5))  !important; --background-size:auto auto  !important; --background-position:50% 50%  !important; --background-attachment:scroll  !important; --background-repeat:no-repeat  !important;\"><\/div>\n<div class=\"tve-cb\">\n<div class=\"thrv_wrapper thrv_text_element\" data-css=\"tve-u-17cacb8bb0b\" style=\"\">\n<p><span data-css=\"tve-u-17cacb93fe8\" style=\"color: rgb(255, 255, 255);\">public class SampleClass{<\/span><\/p>\n<p><span data-css=\"tve-u-17cacb93fea\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0 \/\/Example of static variable<\/span><\/p>\n<p><span data-css=\"tve-u-17cacb93feb\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0 public static int exampleVariable =10;<\/span><\/p>\n<p><span data-css=\"tve-u-17cacb93fed\" style=\"color: rgb(255, 255, 255);\">}<\/span><\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"thrv_wrapper thrv_text_element\">\n<p><strong>Static method<\/strong><\/p>\n<p>When you create a method and prefix with a static keyword it becomes static methods, static methods belong to the class, not to any object.<\/p>\n<ul class=\"\">\n<li>The static method can be accessed using class name no need for any object reference. The main method is the example of a static method which is commonly used<\/li>\n<li>A static method cannot be overridden<\/li>\n<li>You cannot create abstract method using static keyword<\/li>\n<li>this or super keyword cannot be used for static methods<\/li>\n<\/ul>\n<p><strong>Example Code Snippet<\/strong><\/p>\n<\/div>\n<div class=\"thrv_wrapper thrv_contentbox_shortcode thrv-content-box tve-elem-default-pad\">\n<div class=\"tve-content-box-background\" style=\"background-image: linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)) !important; background-size: auto !important; background-position: 50% 50% !important; background-attachment: scroll !important; background-repeat: no-repeat !important; --background-image:linear-gradient(rgba(0,0,0,0.5), rgba(0,0,0,0.5))  !important; --background-size:auto auto  !important; --background-position:50% 50%  !important; --background-attachment:scroll  !important; --background-repeat:no-repeat  !important;\"><\/div>\n<div class=\"tve-cb\">\n<div class=\"thrv_wrapper thrv_text_element\" data-css=\"tve-u-17cacbf98d5\" style=\"\">\n<p><span data-css=\"tve-u-17cacbffcfa\" style=\"color: rgb(255, 255, 255);\">public class SampleClass{<\/span><\/p>\n<p><span data-css=\"tve-u-17cacbffcfc\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0 public static void sampleMethod(String name) {<\/span><\/p>\n<p><span data-css=\"tve-u-17cacbffcfd\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 System.out.println(name);<\/span><\/p>\n<p><span data-css=\"tve-u-17cacbffcfe\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0 }<\/span><\/p>\n<p><span data-css=\"tve-u-17cacbffd00\" style=\"color: rgb(255, 255, 255);\">}<\/span><\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"thrv_wrapper thrv_text_element\">\n<p><strong>Static Block<\/strong><\/p>\n<p>A block of code which is used with static keyword is known as static block. Static block is mainly used for initializing static variables. You can have multiple static block inside single class. Static block will be executed before main method<\/p>\n<p><strong>Example Code Snippet<\/strong><\/p>\n<\/div>\n<div class=\"thrv_wrapper thrv_contentbox_shortcode thrv-content-box tve-elem-default-pad\">\n<div class=\"tve-content-box-background\" style=\"background-image: linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)) !important; background-size: auto !important; background-position: 50% 50% !important; background-attachment: scroll !important; background-repeat: no-repeat !important; --background-image:linear-gradient(rgba(0,0,0,0.5), rgba(0,0,0,0.5))  !important; --background-size:auto auto  !important; --background-position:50% 50%  !important; --background-attachment:scroll  !important; --background-repeat:no-repeat  !important;\"><\/div>\n<div class=\"tve-cb\">\n<div class=\"thrv_wrapper thrv_text_element\" data-css=\"tve-u-17cacc04a69\" style=\"\">\n<p><span data-css=\"tve-u-17cacc0a2ff\" style=\"color: rgb(255, 255, 255);\">public class SampleClass{<\/span><\/p>\n<p><span data-css=\"tve-u-17cacc0a301\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0 public static List&lt;String&gt; fruits = new LinkedList&lt;&gt;();<\/span><\/p>\n<p><span data-css=\"tve-u-17cacc0a302\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0 static {<\/span><\/p>\n<p><span data-css=\"tve-u-17cacc0a304\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0\u00a0\u00a0 fruits.add(&#8220;Apple&#8221;);<\/span><\/p>\n<p><span data-css=\"tve-u-17cacc0a305\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0\u00a0\u00a0 fruits.add(&#8220;Banana&#8221;);<\/span><\/p>\n<p><span data-css=\"tve-u-17cacc0a306\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0\u00a0\u00a0 fruits.add(&#8220;Kiwi&#8221;);<\/span><\/p>\n<p><span data-css=\"tve-u-17cacc0a308\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0 }<\/span><\/p>\n<p><span data-css=\"tve-u-17cacc0a309\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0<\/span><\/p>\n<p><span data-css=\"tve-u-17cacc0a30a\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0 public static void main(String args[]) {<\/span><\/p>\n<p><span data-css=\"tve-u-17cacc0a30c\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0\u00a0\u00a0 System.out.println(SampleClass.fruits.get(0));<\/span><\/p>\n<p><span data-css=\"tve-u-17cacc0a30d\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0 }<\/span><\/p>\n<p><span data-css=\"tve-u-17cacc0a30e\" style=\"color: rgb(255, 255, 255);\">}<\/span><\/p>\n<p><strong><span data-css=\"tve-u-17cacc0a30f\" style=\"color: rgb(255, 255, 255);\">Output: Apple<\/span><\/strong><\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"thrv_wrapper thrv_text_element\">\n<p><strong>Static Class<\/strong><\/p>\n<p>When you create a class inside another class it is called a nested class, static class only be created as a nested class. Members of the static class can be directly accessed using the outer class.<\/p>\n<ul class=\"\">\n<li>A static class cannot access non-static members of the Outer class<\/li>\n<li>Static class members can be called with outer class reference<\/li>\n<li>Static classes are always nested or inner class<\/li>\n<li>You can use access modifier for static class<\/li>\n<\/ul>\n<p><strong>Example Code Snippet<\/strong><\/p>\n<\/div>\n<div class=\"thrv_wrapper thrv_contentbox_shortcode thrv-content-box tve-elem-default-pad\">\n<div class=\"tve-content-box-background\" style=\"background-image: linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)) !important; background-size: auto !important; background-position: 50% 50% !important; background-attachment: scroll !important; background-repeat: no-repeat !important; --background-image:linear-gradient(rgba(0,0,0,0.5), rgba(0,0,0,0.5))  !important; --background-size:auto auto  !important; --background-position:50% 50%  !important; --background-attachment:scroll  !important; --background-repeat:no-repeat  !important;\"><\/div>\n<div class=\"tve-cb\">\n<div class=\"thrv_wrapper thrv_text_element\" data-css=\"tve-u-17cacc10075\" style=\"\">\n<p><span data-css=\"tve-u-17cacc13704\" style=\"color: rgb(255, 255, 255);\">public class SampleClass{<\/span><\/p>\n<p><span data-css=\"tve-u-17cacc13706\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0 \/\/static class declared here<\/span><\/p>\n<p><span data-css=\"tve-u-17cacc13708\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0 static class SampleStaticClass{<\/span><\/p>\n<p><span data-css=\"tve-u-17cacc13709\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0\u00a0\u00a0 int a = 10;<\/span><\/p>\n<p><span data-css=\"tve-u-17cacc1370a\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0 }<\/span><\/p>\n<p><span data-css=\"tve-u-17cacc1370c\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0<\/span><\/p>\n<p><span data-css=\"tve-u-17cacc1370d\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0 public static void main(String args[]) {<\/span><\/p>\n<p><span data-css=\"tve-u-17cacc1370e\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0\u00a0\u00a0 SampleClass.SampleStaticClass staticClass = new SampleClass.SampleStaticClass();<\/span><\/p>\n<p><span data-css=\"tve-u-17cacc1370f\" style=\"color: rgb(255, 255, 255);\">\u00a0 \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 System.out.println(staticClass.a);<\/span><\/p>\n<p><span data-css=\"tve-u-17cacc13711\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0 }<\/span><\/p>\n<p><span data-css=\"tve-u-17cacc13712\" style=\"color: rgb(255, 255, 255);\">}<\/span><\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"thrv_wrapper thrv_text_element\">\n<h3 class=\"\" id=\"t-1635009289847\"><a class=\"tve-froala fr-basic\" name=\"_Toc82204561\" style=\"outline: none;\">4. What is this final keyword? how I can be used?<\/a><\/h3>\n<p>The final keyword is used for restricting the behavior variable, method, class, etc.<\/p>\n<p>The final keyword can be used with<\/p>\n<ul class=\"\">\n<li>Variable<\/li>\n<li>Methods<\/li>\n<li>Class<\/li>\n<\/ul>\n<p><strong>Final Variable:<\/strong><\/p>\n<ul class=\"\">\n<li>If you prefix any variable with a final keyword then it is called the final variable.<\/li>\n<li>Once the value is assigned to the final variable you cannot change it.<\/li>\n<li>If you don\u2019t initialize the final variable during declaration it is called blank final variable, it can be initialized through constructor.<\/li>\n<li>A\u00a0 final variable can be declared as a static<\/li>\n<li>You can assign the final static variable during the declaration<\/li>\n<li>If you have created a blank static final variable, it can be initialized inside the static block.<\/li>\n<\/ul>\n<p><span style=\"text-decoration: underline;\">Example Code Snippet<\/span><\/p>\n<\/div>\n<div class=\"thrv_wrapper thrv_contentbox_shortcode thrv-content-box tve-elem-default-pad\">\n<div class=\"tve-content-box-background\" style=\"background-image: linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)) !important; background-size: auto !important; background-position: 50% 50% !important; background-attachment: scroll !important; background-repeat: no-repeat !important; --background-image:linear-gradient(rgba(0,0,0,0.5), rgba(0,0,0,0.5))  !important; --background-size:auto auto  !important; --background-position:50% 50%  !important; --background-attachment:scroll  !important; --background-repeat:no-repeat  !important;\"><\/div>\n<div class=\"tve-cb\">\n<div class=\"thrv_wrapper thrv_text_element\" data-css=\"tve-u-17cacc1cbd9\" style=\"\">\n<p><span data-css=\"tve-u-17cacc20678\" style=\"color: rgb(255, 255, 255);\">public class FinalTest{<\/span><\/p>\n<p><span data-css=\"tve-u-17cacc2067a\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0 public static void main(String args[]) {<\/span><\/p>\n<p><span data-css=\"tve-u-17cacc2067d\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 final int i = 10;<\/span><\/p>\n<p><span data-css=\"tve-u-17cacc2067e\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0 }<\/span><\/p>\n<p><span data-css=\"tve-u-17cacc2067f\" style=\"color: rgb(255, 255, 255);\">}<\/span><\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"thrv_wrapper thrv_text_element\">\n<p><strong>Final Methods<\/strong><\/p>\n<p>If you prefix the final keyword to methods it becomes the final method<\/p>\n<p>Final methods cannot be overridden<\/p>\n<p>Static final method is completely valid in java, and it can be declared<\/p>\n<p><strong>Example Code Snippet<\/strong><\/p>\n<\/div>\n<div class=\"thrv_wrapper thrv_contentbox_shortcode thrv-content-box tve-elem-default-pad\">\n<div class=\"tve-content-box-background\" style=\"background-image: linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)) !important; background-size: auto !important; background-position: 50% 50% !important; background-attachment: scroll !important; background-repeat: no-repeat !important; --background-image:linear-gradient(rgba(0,0,0,0.5), rgba(0,0,0,0.5))  !important; --background-size:auto auto  !important; --background-position:50% 50%  !important; --background-attachment:scroll  !important; --background-repeat:no-repeat  !important;\"><\/div>\n<div class=\"tve-cb\">\n<div class=\"thrv_wrapper thrv_text_element\" data-css=\"tve-u-17cacc32490\" style=\"\">\n<p><span data-css=\"tve-u-17cacc33fa3\" style=\"color: rgb(255, 255, 255);\">final void print() {<\/span><\/p>\n<p><span data-css=\"tve-u-17cacc33fa5\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0 int a = 10;<\/span><\/p>\n<p><span data-css=\"tve-u-17cacc33fa6\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0 System.out.println(a);<\/span><\/p>\n<p><span data-css=\"tve-u-17cacc33fa8\" style=\"color: rgb(255, 255, 255);\">}<\/span><\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"thrv_wrapper thrv_text_element\">\n<p><strong>Final Class<\/strong><\/p>\n<p>If you prefix final to class, then it becomes the final class<\/p>\n<p>Final classes cannot be extended or inherited<\/p>\n<p>You can create the inner class as a static final<\/p>\n<p><strong>Example Code Snippet<\/strong><\/p>\n<\/div>\n<div class=\"thrv_wrapper thrv_contentbox_shortcode thrv-content-box tve-elem-default-pad\">\n<div class=\"tve-content-box-background\" style=\"background-image: linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)) !important; background-size: auto !important; background-position: 50% 50% !important; background-attachment: scroll !important; background-repeat: no-repeat !important; --background-image:linear-gradient(rgba(0,0,0,0.5), rgba(0,0,0,0.5))  !important; --background-size:auto auto  !important; --background-position:50% 50%  !important; --background-attachment:scroll  !important; --background-repeat:no-repeat  !important;\"><\/div>\n<div class=\"tve-cb\">\n<div class=\"thrv_wrapper thrv_text_element\" data-css=\"tve-u-17cae284d59\" style=\"\">\n<p><span data-css=\"tve-u-17cae28aa24\" style=\"color: rgb(255, 255, 255);\">public final class<\/span><\/p>\n<p><span data-css=\"tve-u-17cae28aa26\" style=\"color: rgb(255, 255, 255);\">{<\/span><\/p>\n<p><span data-css=\"tve-u-17cae28aa27\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0 \/\/Some Code<\/span><\/p>\n<p><span data-css=\"tve-u-17cae28aa29\" style=\"color: rgb(255, 255, 255);\">}<\/span><\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"thrv_wrapper thrv_text_element\">\n<h3 class=\"\" id=\"t-1638297369022\"><a class=\"tve-froala fr-basic\" name=\"_Toc82204562\" style=\"outline: none;\">5. What is the difference between method overloading and method overriding?<\/a><\/h3>\n<p>Method overloading is class has more than one method of the same name but having different parameter. Method overriding Subclass provides the implementation of the method that has been declared by the Parent class is called method overriding.<\/p>\n<p>Method overloading is an example of compile-time polymorphism. Method overriding is an example of run time polymorphism.<\/p>\n<p>You cannot achieve overloading only by changing the return type. Method overriding will have usually the same return type.<\/p>\n<p>Method overloading can be achieved without inheritance. Method overriding requires inheritance<\/p>\n<p><strong>Example Code Snippet for method overloading<\/strong><\/p>\n<\/div>\n<div class=\"thrv_wrapper thrv_contentbox_shortcode thrv-content-box tve-elem-default-pad\">\n<div class=\"tve-content-box-background\" style=\"background-image: linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)) !important; background-size: auto !important; background-position: 50% 50% !important; background-attachment: scroll !important; background-repeat: no-repeat !important; --background-image:linear-gradient(rgba(0,0,0,0.5), rgba(0,0,0,0.5))  !important; --background-size:auto auto  !important; --background-position:50% 50%  !important; --background-attachment:scroll  !important; --background-repeat:no-repeat  !important;\"><\/div>\n<div class=\"tve-cb\">\n<div class=\"thrv_wrapper thrv_text_element\" data-css=\"tve-u-17cae292817\" style=\"\">\n<p><span data-css=\"tve-u-17cae295cde\" style=\"color: rgb(255, 255, 255);\">\/\/Method overloading<\/span><\/p>\n<p><span data-css=\"tve-u-17cae295ce0\" style=\"color: rgb(255, 255, 255);\">public class SampleClass{<\/span><\/p>\n<p><span data-css=\"tve-u-17cae295ce2\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0 public void add(int a, int b, int c) {<\/span><\/p>\n<p><span data-css=\"tve-u-17cae295ce3\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \/\/some code<\/span><\/p>\n<p><span data-css=\"tve-u-17cae295ce5\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0 }<\/span><\/p>\n<p><span data-css=\"tve-u-17cae295ce6\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0 public void add(int a, int b) {<\/span><\/p>\n<p><span data-css=\"tve-u-17cae295ce7\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \/\/some code<\/span><\/p>\n<p><span data-css=\"tve-u-17cae295ce9\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0 }<\/span><\/p>\n<p><span data-css=\"tve-u-17cae295cea\" style=\"color: rgb(255, 255, 255);\">}<\/span><\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"thrv_wrapper thrv_text_element\">\n<p><strong>Example Code Snippet for Method overriding<\/strong><\/p>\n<\/div>\n<div class=\"thrv_wrapper thrv_contentbox_shortcode thrv-content-box tve-elem-default-pad\">\n<div class=\"tve-content-box-background\" style=\"background-image: linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)) !important; background-size: auto !important; background-position: 50% 50% !important; background-attachment: scroll !important; background-repeat: no-repeat !important; --background-image:linear-gradient(rgba(0,0,0,0.5), rgba(0,0,0,0.5))  !important; --background-size:auto auto  !important; --background-position:50% 50%  !important; --background-attachment:scroll  !important; --background-repeat:no-repeat  !important;\"><\/div>\n<div class=\"tve-cb\">\n<div class=\"thrv_wrapper thrv_text_element\" data-css=\"tve-u-17cae299cef\" style=\"\">\n<p><span data-css=\"tve-u-17cae29d4c8\" style=\"color: rgb(255, 255, 255);\">\/\/Method overriding<\/span><\/p>\n<p><span data-css=\"tve-u-17cae29d4ca\" style=\"color: rgb(255, 255, 255);\">public class SampleClass{<\/span><\/p>\n<p><span data-css=\"tve-u-17cae29d4cb\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0 public void someMethod() {<\/span><\/p>\n<p><span data-css=\"tve-u-17cae29d4cd\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0\u00a0\u00a0 System.out.println(&#8220;Super Class&#8221;);<\/span><\/p>\n<p><span data-css=\"tve-u-17cae29d4ce\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0 }<\/span><\/p>\n<p><span data-css=\"tve-u-17cae29d4cf\" style=\"color: rgb(255, 255, 255);\">}<\/span><\/p>\n<p><span data-css=\"tve-u-17cae29d4d1\" style=\"color: rgb(255, 255, 255);\">class MyClass extends SampleClass{<\/span><\/p>\n<p><span data-css=\"tve-u-17cae29d4d2\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0 public void someMethod() {<\/span><\/p>\n<p><span data-css=\"tve-u-17cae29d4d3\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 System.out.println(&#8220;Sub Class&#8221;);<\/span><\/p>\n<p><span data-css=\"tve-u-17cae29d4d5\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0 }<\/span><\/p>\n<p><span data-css=\"tve-u-17cae29d4d6\" style=\"color: rgb(255, 255, 255);\">}<\/span><\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"thrv_wrapper thrv_text_element\">\n<h3 class=\"\" id=\"t-1638297369023\">6. Could you explain IS-A and HAS-A relationship?<\/h3>\n<p><strong>IS -A relationship<\/strong><\/p>\n<p><strong>IS-A relationship<\/strong> is formed in inheritance, The class which inherit is known as subclass or child class. That means that child class is the type of parent class.<\/p>\n<p>For example, Orange is a Fruit, you need to extend fruit class to make IS-A relationship<strong>\u00a0 <\/strong><\/p>\n<p><strong>Example Code Snippet\u00a0 : IS-A Relationship<\/strong><\/p>\n<\/div>\n<div class=\"thrv_wrapper thrv_contentbox_shortcode thrv-content-box tve-elem-default-pad\">\n<div class=\"tve-content-box-background\" style=\"background-image: linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)) !important; background-size: auto !important; background-position: 50% 50% !important; background-attachment: scroll !important; background-repeat: no-repeat !important; --background-image:linear-gradient(rgba(0,0,0,0.5), rgba(0,0,0,0.5))  !important; --background-size:auto auto  !important; --background-position:50% 50%  !important; --background-attachment:scroll  !important; --background-repeat:no-repeat  !important;\"><\/div>\n<div class=\"tve-cb\">\n<div class=\"thrv_wrapper thrv_text_element\" data-css=\"tve-u-17cae2a93ea\" style=\"\">\n<p><span data-css=\"tve-u-17cae2ab948\" style=\"color: rgb(255, 255, 255);\">class Fruit{<\/span><\/p>\n<p><span data-css=\"tve-u-17cae2ab94a\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0 \/\/some code<\/span><\/p>\n<p><span data-css=\"tve-u-17cae2ab94c\" style=\"color: rgb(255, 255, 255);\">}<\/span><\/p>\n<p><span data-css=\"tve-u-17cae2ab94d\" style=\"color: rgb(255, 255, 255);\">\/\/IS-A relationship<\/span><\/p>\n<p><span data-css=\"tve-u-17cae2ab94f\" style=\"color: rgb(255, 255, 255);\">class Orange extends Fruit {<\/span><\/p>\n<p><span data-css=\"tve-u-17cae2ab950\" style=\"color: rgb(255, 255, 255);\">\/\/some code<\/span><\/p>\n<p><span data-css=\"tve-u-17cae2ab952\" style=\"color: rgb(255, 255, 255);\">}<\/span><\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"thrv_wrapper thrv_text_element\">\n<p><strong>HAS -A relationship<\/strong><\/p>\n<p><strong>HAS-A relationship<\/strong> is composition, which means you are creating the object of a class inside another class. Let\u2019s take the example of Room. The room has a chair. The room should contain chair class reference, i.e you need to create an instance of Chair particular class inside the Room class.<\/p>\n<p><strong>Example Code Snippet : HAS-A Relationship<\/strong><\/p>\n<\/div>\n<div class=\"thrv_wrapper thrv_contentbox_shortcode thrv-content-box tve-elem-default-pad\">\n<div class=\"tve-content-box-background\" style=\"background-image: linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)) !important; background-size: auto !important; background-position: 50% 50% !important; background-attachment: scroll !important; background-repeat: no-repeat !important; --background-image:linear-gradient(rgba(0,0,0,0.5), rgba(0,0,0,0.5))  !important; --background-size:auto auto  !important; --background-position:50% 50%  !important; --background-attachment:scroll  !important; --background-repeat:no-repeat  !important;\"><\/div>\n<div class=\"tve-cb\">\n<div class=\"thrv_wrapper thrv_text_element\" data-css=\"tve-u-17cae2b3161\" style=\"\">\n<p><span data-css=\"tve-u-17cae2b4f09\" style=\"color: rgb(255, 255, 255);\">class Room {<\/span><\/p>\n<p><span data-css=\"tve-u-17cae2b4f0b\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0 Chair chair = new Chair();<\/span><\/p>\n<p><span data-css=\"tve-u-17cae2b4f0d\" style=\"color: rgb(255, 255, 255);\">}<\/span><\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"thrv_wrapper thrv_text_element\">\n<h3 class=\"\" id=\"t-1638297369024\"><a class=\"tve-froala fr-basic\" name=\"_Toc82204564\" style=\"outline: none;\">7. Explain this and super keyword<\/a><\/h3>\n<p><strong>this<\/strong> keyword is used to refer current class instance\/object<\/p>\n<p><strong>this keyword<\/strong> can be used to<\/p>\n<ul class=\"\">\n<li>Current class instance variable<\/li>\n<li>Invoke current class methods<\/li>\n<li>Invoke current class constructor<\/li>\n<li>Can be used to pass the argument to a method<\/li>\n<li>Can be used to pass the argument to a constructor<\/li>\n<li>Return the current class instance<\/li>\n<\/ul>\n<p><strong>Super Keyword<\/strong><\/p>\n<ul class=\"\">\n<li>The super keyword is a reference variable that is used to refer to parent class objects<\/li>\n<li>super can be used to refer to immediate parent class instance variable<\/li>\n<li>super can be used to invoke the parent class method<\/li>\n<li>super can be used to invoke parent class Constructor<\/li>\n<\/ul>\n<p><strong>Example Code Snippet : this and super keywords<\/strong><\/p>\n<\/div>\n<div class=\"thrv_wrapper thrv_contentbox_shortcode thrv-content-box tve-elem-default-pad\">\n<div class=\"tve-content-box-background\" style=\"background-image: linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)) !important; background-size: auto !important; background-position: 50% 50% !important; background-attachment: scroll !important; background-repeat: no-repeat !important; --background-image:linear-gradient(rgba(0,0,0,0.5), rgba(0,0,0,0.5))  !important; --background-size:auto auto  !important; --background-position:50% 50%  !important; --background-attachment:scroll  !important; --background-repeat:no-repeat  !important;\"><\/div>\n<div class=\"tve-cb\">\n<div class=\"thrv_wrapper thrv_text_element\" data-css=\"tve-u-17cae2bbd08\" style=\"\">\n<p><span data-css=\"tve-u-17cae2bf2f6\" style=\"color: rgb(255, 255, 255);\">class First {<\/span><\/p>\n<p><span data-css=\"tve-u-17cae2bf2f8\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0 void print() {<\/span><\/p>\n<p><span data-css=\"tve-u-17cae2bf2fa\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 System.out.println(&#8220;Printing First&#8230;&#8221;);<\/span><\/p>\n<p><span data-css=\"tve-u-17cae2bf2fb\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0 }<\/span><\/p>\n<p><span data-css=\"tve-u-17cae2bf2fd\" style=\"color: rgb(255, 255, 255);\">}<\/span><\/p>\n<p><span data-css=\"tve-u-17cae2bf2fe\" style=\"color: rgb(255, 255, 255);\">class Second extends First {<\/span><\/p>\n<p><span data-css=\"tve-u-17cae2bf2ff\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0 void printOneMore() {<\/span><\/p>\n<p><span data-css=\"tve-u-17cae2bf301\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 System.out.println(&#8220;Printing Second&#8230;&#8221;);<\/span><\/p>\n<p><span data-css=\"tve-u-17cae2bf302\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0 }<\/span><\/p>\n<p><span data-css=\"tve-u-17cae2bf303\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0 void myMethod() {<\/span><\/p>\n<p><span data-css=\"tve-u-17cae2bf305\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 super.print();<\/span><\/p>\n<p><span data-css=\"tve-u-17cae2bf306\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 this.printOneMore();<\/span><\/p>\n<p><span data-css=\"tve-u-17cae2bf307\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0 }<\/span><\/p>\n<p><span data-css=\"tve-u-17cae2bf309\" style=\"color: rgb(255, 255, 255);\">}<\/span><\/p>\n<p><span data-css=\"tve-u-17cae2bf30a\" style=\"color: rgb(255, 255, 255);\">public class KeywordTest {<\/span><\/p>\n<p><span data-css=\"tve-u-17cae2bf30b\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0 public static void main(String args[]) {<\/span><\/p>\n<p><span data-css=\"tve-u-17cae2bf30d\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Second d = new Second();<\/span><\/p>\n<p><span data-css=\"tve-u-17cae2bf30e\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 d.myMethod();<\/span><\/p>\n<p><span data-css=\"tve-u-17cae2bf30f\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0 }<\/span><\/p>\n<p><span data-css=\"tve-u-17cae2bf311\" style=\"color: rgb(255, 255, 255);\">}<\/span><\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"thrv_wrapper thrv_text_element\">\n<h3 class=\"\" id=\"t-1638297369025\"><a class=\"tve-froala fr-basic\" name=\"_Toc82204565\" style=\"outline: none;\">8. How to check instance of Specified type? Explain with example<\/a><\/h3>\n<p>The Java provides <strong>instanceof<\/strong> operater which can be used to check instance of Specified type.<\/p>\n<ul class=\"\">\n<li>The <strong>instanceof<\/strong> operator returns either true or false<\/li>\n<li>The <strong>instanceof<\/strong> operators are used for down casting<\/li>\n<li>The <strong>instanceof<\/strong> operator works on the principle of the is-a relationship<\/li>\n<li>If you <strong>instanceof<\/strong> Operator for null object it will return false.<\/li>\n<\/ul>\n<p><strong>Example Code Snippet<\/strong><\/p>\n<\/div>\n<div class=\"thrv_wrapper thrv_contentbox_shortcode thrv-content-box tve-elem-default-pad\">\n<div class=\"tve-content-box-background\" style=\"background-image: linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)) !important; background-size: auto !important; background-position: 50% 50% !important; background-attachment: scroll !important; background-repeat: no-repeat !important; --background-image:linear-gradient(rgba(0,0,0,0.5), rgba(0,0,0,0.5))  !important; --background-size:auto auto  !important; --background-position:50% 50%  !important; --background-attachment:scroll  !important; --background-repeat:no-repeat  !important;\"><\/div>\n<div class=\"tve-cb\">\n<div class=\"thrv_wrapper thrv_text_element\" data-css=\"tve-u-17cae2c50e2\" style=\"\">\n<p><span data-css=\"tve-u-17cae2c7dfa\" style=\"color: rgb(255, 255, 255);\">public class Apple {<\/span><\/p>\n<p><span data-css=\"tve-u-17cae2c7dfd\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0 public static void main(String args[]) {<\/span><\/p>\n<p><span data-css=\"tve-u-17cae2c7dfe\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Apple apl = new Apple();<\/span><\/p>\n<p><span data-css=\"tve-u-17cae2c7e00\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 if (apl instanceof Apple) {<\/span><\/p>\n<p><span data-css=\"tve-u-17cae2c7e01\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u00a0 System.out.println(&#8220;apl is instance of Apple&#8221;);<\/span><\/p>\n<p><span data-css=\"tve-u-17cae2c7e02\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 } else {<\/span><\/p>\n<p><span data-css=\"tve-u-17cae2c7e04\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 System.out.println(&#8220;apl is not an instance of Apple&#8221;);<\/span><\/p>\n<p><span data-css=\"tve-u-17cae2c7e05\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 }<\/span><\/p>\n<p><span data-css=\"tve-u-17cae2c7e06\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0 }<\/span><\/p>\n<p><span data-css=\"tve-u-17cae2c7e08\" style=\"color: rgb(255, 255, 255);\">}<\/span><\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"thrv_wrapper thrv_text_element\">\n<h3 class=\"\" id=\"t-1638297369026\"><a class=\"tve-froala fr-basic\" name=\"_Toc82204566\" style=\"outline: none;\">9. What is a package in Java? What are different types of packages? Can we create a custom package?<\/a><\/h3>\n<ul class=\"\">\n<li>A package is a group of similar interfaces, classes, and subclasses<\/li>\n<li>Custom package can be created with the package keyword<\/li>\n<li>Access modified can be used for packages<\/li>\n<li>Import keyword is used for importing already created packages.<\/li>\n<li>The package is a good example of java encapsulation<\/li>\n<li>Packages that are inside another package are the sub-packages<\/li>\n<li>Java provides many built-in packages and it allows you to create custom ones as well<\/li>\n<\/ul>\n<\/div>\n<div class=\"thrv_wrapper thrv_text_element\">\n<p><strong>Some of the built-in packages are<\/strong><\/p>\n<p><strong>java.lang : <\/strong>This package contains the classes and interfaces that are fundamental to the core Java<\/p>\n<p><strong>java.util<\/strong> : This library provides users with generic java utilities like collections framework, formatted printing and scanning, array manipulation utilities, event model, date and time facilities, internationalization, and miscellaneous utility classes<\/p>\n<p><strong>java.io<\/strong> This library is very useful and contains the classes that handle fundamental input and output operations in Java<\/p>\n<p><strong>java.net<\/strong> : This package contains classes and interfaces that provide a powerful infrastructure for networking in Java.<\/p>\n<p><strong>java.sql :<\/strong> This package contains all the SQL-related classes and interfaces. This package provides the API for accessing and processing data stored in a data source.<\/p>\n<p><strong>We can create custom packages in Java<\/strong><\/p>\n<p><strong>Example Code Snippet<\/strong><\/p>\n<\/div>\n<div class=\"thrv_wrapper thrv_contentbox_shortcode thrv-content-box tve-elem-default-pad\">\n<div class=\"tve-content-box-background\" style=\"background-image: linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)) !important; background-size: auto !important; background-position: 50% 50% !important; background-attachment: scroll !important; background-repeat: no-repeat !important; --background-image:linear-gradient(rgba(0,0,0,0.5), rgba(0,0,0,0.5))  !important; --background-size:auto auto  !important; --background-position:50% 50%  !important; --background-attachment:scroll  !important; --background-repeat:no-repeat  !important;\"><\/div>\n<div class=\"tve-cb\">\n<div class=\"thrv_wrapper thrv_text_element\" data-css=\"tve-u-17cae2ce7c0\" style=\"\">\n<p><span data-css=\"tve-u-17cae2d1c17\" style=\"color: rgb(255, 255, 255);\">package packageName; \/\/ Use package keyword for creation<\/span><\/p>\n<p><span data-css=\"tve-u-17cae2d1c19\" style=\"color: rgb(255, 255, 255);\">public class ExampleClass{\u00a0<\/span><\/p>\n<p><span data-css=\"tve-u-17cae2d1c1b\" style=\"color: rgb(255, 255, 255);\">\u00a0\/\/ Some Code Here<\/span><\/p>\n<p><span data-css=\"tve-u-17cae2d1c1c\" style=\"color: rgb(255, 255, 255);\">} <\/span><\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"thrv_wrapper thrv_text_element\">\n<h3 class=\"\" id=\"t-1638297369027\"><a class=\"tve-froala fr-basic\" name=\"_Toc82204567\" style=\"outline: none;\">10. What is run time polymorphism in Java?<\/a><\/h3>\n<p>Runtime polymorphism or Dynamic Method Dispatch is a process in which a call to an overridden method is resolved at runtime rather than compile-time.<\/p>\n<ul class=\"\">\n<li>The overridden method is called through the reference variable of a superclass<\/li>\n<li>The object is determined by the object being referred to by the reference variable<\/li>\n<li>The reference variable of Parent class refers to the object of Child class is called upcasting<\/li>\n<\/ul>\n<\/div>\n<div class=\"thrv_wrapper thrv_contentbox_shortcode thrv-content-box tve-elem-default-pad\">\n<div class=\"tve-content-box-background\" style=\"background-image: linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)) !important; background-size: auto !important; background-position: 50% 50% !important; background-attachment: scroll !important; background-repeat: no-repeat !important; --background-image:linear-gradient(rgba(0,0,0,0.5), rgba(0,0,0,0.5))  !important; --background-size:auto auto  !important; --background-position:50% 50%  !important; --background-attachment:scroll  !important; --background-repeat:no-repeat  !important;\"><\/div>\n<div class=\"tve-cb\">\n<div class=\"thrv_wrapper thrv_text_element\" data-css=\"tve-u-17cae2d7566\" style=\"\">\n<p><span data-css=\"tve-u-17cae2da445\" style=\"color: rgb(255, 255, 255);\">class Car {<\/span><\/p>\n<p><span data-css=\"tve-u-17cae2da447\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0 void print() {<\/span><\/p>\n<p><span data-css=\"tve-u-17cae2da449\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 System.out.println(&#8220;Inside Car Class&#8221;);<\/span><\/p>\n<p><span data-css=\"tve-u-17cae2da44a\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0 }<\/span><\/p>\n<p><span data-css=\"tve-u-17cae2da44c\" style=\"color: rgb(255, 255, 255);\">}<\/span><\/p>\n<p><span data-css=\"tve-u-17cae2da44d\" style=\"color: rgb(255, 255, 255);\">class Honda extends Car {<\/span><\/p>\n<p><span data-css=\"tve-u-17cae2da44e\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0 void print() {<\/span><\/p>\n<p><span data-css=\"tve-u-17cae2da450\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 System.out.println(&#8220;Inside Honda Class&#8221;);<\/span><\/p>\n<p><span data-css=\"tve-u-17cae2da451\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0 }<\/span><\/p>\n<p><span data-css=\"tve-u-17cae2da454\" style=\"color: rgb(255, 255, 255);\">}<\/span><\/p>\n<p><span data-css=\"tve-u-17cae2da455\" style=\"color: rgb(255, 255, 255);\">public class MainClass {<\/span><\/p>\n<p><span data-css=\"tve-u-17cae2da456\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0 public static void main(String args[]) {<\/span><\/p>\n<p><span data-css=\"tve-u-17cae2da458\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Car car = new Honda();\/\/ This is Upcasting<\/span><\/p>\n<p><span data-css=\"tve-u-17cae2da459\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 car.print();<\/span><\/p>\n<p><span data-css=\"tve-u-17cae2da45b\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0 }<\/span><\/p>\n<p><span data-css=\"tve-u-17cae2da45c\" style=\"color: rgb(255, 255, 255);\">}<\/span><\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"thrv_wrapper thrv_text_element\">\n<h3 class=\"\" id=\"t-1638297369028\"><a class=\"tve-froala fr-basic\" name=\"_Toc82204568\" style=\"outline: none;\">11. What is the difference between static and dynamic binding in java?<\/a><\/h3>\n<ul class=\"\">\n<li>The binding which can be resolved by the compile-time is static binding. The binding which will be resolved at the run time is known as dynamic binding.<\/li>\n<li>Type information is used for resolving static binding. Object information is used for resolving dynamic binding<\/li>\n<li>Method overloading is an example of static binding. Method overriding is an example of dynamic binding<\/li>\n<li>Static binding is also known as early binding. Dynamic binding is also known as late binding<\/li>\n<\/ul>\n<p><strong>Example Code Snippet: Static Binding <\/strong><\/p>\n<\/div>\n<div class=\"thrv_wrapper thrv_contentbox_shortcode thrv-content-box tve-elem-default-pad\">\n<div class=\"tve-content-box-background\" style=\"background-image: linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)) !important; background-size: auto !important; background-position: 50% 50% !important; background-attachment: scroll !important; background-repeat: no-repeat !important; --background-image:linear-gradient(rgba(0,0,0,0.5), rgba(0,0,0,0.5))  !important; --background-size:auto auto  !important; --background-position:50% 50%  !important; --background-attachment:scroll  !important; --background-repeat:no-repeat  !important;\"><\/div>\n<div class=\"tve-cb\">\n<div class=\"thrv_wrapper thrv_text_element\" data-css=\"tve-u-17cae2e1b41\" style=\"\">\n<p><span data-css=\"tve-u-17cae2e4cd4\" style=\"color: rgb(255, 255, 255);\">\/\/Static binding<\/span><\/p>\n<p><span data-css=\"tve-u-17cae2e4cd6\" style=\"color: rgb(255, 255, 255);\">public class MainClass {<\/span><\/p>\n<p><span data-css=\"tve-u-17cae2e4cd8\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0 void print() {<\/span><\/p>\n<p><span data-css=\"tve-u-17cae2e4cd9\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 System.out.println(&#8220;Printing&#8221;);<\/span><\/p>\n<p><span data-css=\"tve-u-17cae2e4cda\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0 }<\/span><\/p>\n<p><span data-css=\"tve-u-17cae2e4cdc\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0 public static void main(String args[]) {<\/span><\/p>\n<p><span data-css=\"tve-u-17cae2e4cdd\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 MainClass mc = new MainClass();<\/span><\/p>\n<p><span data-css=\"tve-u-17cae2e4cdf\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 mc.print();<\/span><\/p>\n<p><span data-css=\"tve-u-17cae2e4ce0\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0 }<\/span><\/p>\n<p><span data-css=\"tve-u-17cae2e4ce1\" style=\"color: rgb(255, 255, 255);\">}<\/span><\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"thrv_wrapper thrv_text_element\">\n<p><strong>Example Code Snippet: Dynamic binding <\/strong><\/p>\n<\/div>\n<div class=\"thrv_wrapper thrv_contentbox_shortcode thrv-content-box tve-elem-default-pad\">\n<div class=\"tve-content-box-background\" style=\"background-image: linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)) !important; background-size: auto !important; background-position: 50% 50% !important; background-attachment: scroll !important; background-repeat: no-repeat !important; --background-image:linear-gradient(rgba(0,0,0,0.5), rgba(0,0,0,0.5))  !important; --background-size:auto auto  !important; --background-position:50% 50%  !important; --background-attachment:scroll  !important; --background-repeat:no-repeat  !important;\"><\/div>\n<div class=\"tve-cb\">\n<div class=\"thrv_wrapper thrv_text_element\" data-css=\"tve-u-17cae2e8b2a\" style=\"\">\n<p><span data-css=\"tve-u-17cae2ec0a7\" style=\"color: rgb(255, 255, 255);\">\/\/Dynamic Binding<\/span><\/p>\n<p><span data-css=\"tve-u-17cae2ec0a9\" style=\"color: rgb(255, 255, 255);\">class Fruit {<\/span><\/p>\n<p><span data-css=\"tve-u-17cae2ec0aa\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0 void print() {<\/span><\/p>\n<p><span data-css=\"tve-u-17cae2ec0ac\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 System.out.println(&#8220;This is fruit class&#8221;);<\/span><\/p>\n<p><span data-css=\"tve-u-17cae2ec0ad\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0 }<\/span><\/p>\n<p><span data-css=\"tve-u-17cae2ec0ae\" style=\"color: rgb(255, 255, 255);\">}<\/span><\/p>\n<p><span data-css=\"tve-u-17cae2ec0b0\" style=\"color: rgb(255, 255, 255);\">public class Apple extends Fruit {<\/span><\/p>\n<p><span data-css=\"tve-u-17cae2ec0b1\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0 void print() {<\/span><\/p>\n<p><span data-css=\"tve-u-17cae2ec0b2\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 System.out.println(&#8220;This is Apple&#8221;);<\/span><\/p>\n<p><span data-css=\"tve-u-17cae2ec0b4\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0 }<\/span><\/p>\n<p><span data-css=\"tve-u-17cae2ec0b5\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0 public static void main(String args[]) {<\/span><\/p>\n<p><span data-css=\"tve-u-17cae2ec0b6\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Fruit f = new Apple();<\/span><\/p>\n<p><span data-css=\"tve-u-17cae2ec0b8\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 f.print();<\/span><\/p>\n<p><span data-css=\"tve-u-17cae2ec0b9\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0 }<\/span><\/p>\n<p><span data-css=\"tve-u-17cae2ec0bb\" style=\"color: rgb(255, 255, 255);\">}<\/span><\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"thrv_wrapper thrv_text_element\">\n<p style=\"text-align: center;\"><strong><em><span style=\"text-decoration: underline;\">Course Alert<br \/><\/span><\/em><\/strong><br \/><strong>If you are interested in landing a SDET or Sr. QA Automation Engineer role, check out our popular SDET course to learn the fundamental skills required an SDET needs to perform at work. Also, I have another popular course which covers Top 150+ Interview questions most commonly asked in SDET \/ Automation interviews.<\/strong><\/p>\n<\/div>\n<div class=\"thrv_wrapper thrv-styled_list\" data-icon-code=\"icon-angle-double-right-solid\">\n<ul class=\"tcb-styled-list\">\n<li class=\"thrv-styled-list-item\" data-css=\"tve-u-17d67373ebd\">\n<div class=\"tcb-styled-list-icon\">\n<div class=\"thrv_wrapper thrv_icon tve_no_drag tcb-no-delete tcb-no-clone tcb-no-save tcb-icon-inherit-style tcb-local-vars-root tcb-icon-display\" data-css=\"tve-u-17d67541b5a\" style=\"--tcb-local-color-icon:rgb(106, 107, 108); --tcb-local-color-var:rgb(106, 107, 108);\"><svg class=\"tcb-icon\" data-id=\"icon-angle-double-right-solid\" data-name=\"\" viewbox=\"0 0 448 512\"><path d=\"M224.3 273l-136 136c-9.4 9.4-24.6 9.4-33.9 0l-22.6-22.6c-9.4-9.4-9.4-24.6 0-33.9l96.4-96.4-96.4-96.4c-9.4-9.4-9.4-24.6 0-33.9L54.3 103c9.4-9.4 24.6-9.4 33.9 0l136 136c9.5 9.4 9.5 24.6.1 34zm192-34l-136-136c-9.4-9.4-24.6-9.4-33.9 0l-22.6 22.6c-9.4 9.4-9.4 24.6 0 33.9l96.4 96.4-96.4 96.4c-9.4 9.4-9.4 24.6 0 33.9l22.6 22.6c9.4 9.4 24.6 9.4 33.9 0l136-136c9.4-9.2 9.4-24.4 0-33.8z\"><\/path><\/svg><\/div>\n<\/div>\n<p><span class=\"thrv-advanced-inline-text tve_editable tcb-styled-list-icon-text tcb-no-delete tcb-no-save\" data-css=\"tve-u-17d67360b1c\"><a class=\"tve-froala fr-basic\" href=\"https:\/\/courses.rahulshettyacademy.com\/p\/sdet-test-architect-essentials-road-to-full-stack-qa\" style=\"outline: none;\" target=\"_blank\">SDET\/Test Architect Essentials -Road to Full stack QA<\/a><\/span><\/li>\n<li class=\"thrv-styled-list-item\" data-css=\"tve-u-17d67373ebd\">\n<div class=\"tcb-styled-list-icon\">\n<div class=\"thrv_wrapper thrv_icon tve_no_drag tcb-no-delete tcb-no-clone tcb-no-save tcb-icon-inherit-style tcb-icon-display\" data-css=\"tve-u-17d67541b5a\" style=\"--tcb-local-color-icon:rgb(106, 107, 108); --tcb-local-color-var:rgb(106, 107, 108);\"><svg class=\"tcb-icon\" data-id=\"icon-angle-double-right-solid\" data-name=\"\" viewbox=\"0 0 448 512\"><path d=\"M224.3 273l-136 136c-9.4 9.4-24.6 9.4-33.9 0l-22.6-22.6c-9.4-9.4-9.4-24.6 0-33.9l96.4-96.4-96.4-96.4c-9.4-9.4-9.4-24.6 0-33.9L54.3 103c9.4-9.4 24.6-9.4 33.9 0l136 136c9.5 9.4 9.5 24.6.1 34zm192-34l-136-136c-9.4-9.4-24.6-9.4-33.9 0l-22.6 22.6c-9.4 9.4-9.4 24.6 0 33.9l96.4 96.4-96.4 96.4c-9.4 9.4-9.4 24.6 0 33.9l22.6 22.6c9.4 9.4 24.6 9.4 33.9 0l136-136c9.4-9.2 9.4-24.4 0-33.8z\"><\/path><\/svg><\/div>\n<\/div>\n<p><span class=\"thrv-advanced-inline-text tve_editable tcb-styled-list-icon-text tcb-no-delete tcb-no-save\" data-css=\"tve-u-17d67360b1c\"><a class=\"tve-froala fr-basic\" href=\"https:\/\/courses.rahulshettyacademy.com\/p\/sdet-qa-automation-interview-kit-java-logic-programs\" style=\"outline: none;\" target=\"_blank\">SDET\/QA Automation Interview Kit + Java logic Programs<\/a><\/span><\/li>\n<\/ul>\n<\/div>\n<div class=\"tcb-clear\" data-css=\"tve-u-17d6755e9a6\">\n<div class=\"thrv_wrapper thrv_contentbox_shortcode thrv-content-box\" data-css=\"tve-u-17d6755e9a8\" data-ct=\"stylebox-8983\" data-ct-name=\"Tutorial: Note Box\" data-element-name=\"Styled Box\">\n<div class=\"tve-content-box-background\" data-css=\"tve-u-17d6755e9a5\"><\/div>\n<div class=\"tve-cb tve_empty_dropzone\" data-css=\"tve-u-17d6755e9a3\">\n<div class=\"thrv_wrapper thrv_text_element tve_empty_dropzone\" data-css=\"tve-u-17d6755e9a4\">\n<h4 class=\"\"><em><strong>A Quick Note<\/strong><\/em><\/h4>\n<\/div>\n<div class=\"thrv_wrapper thrv_text_element tve_empty_dropzone\">\n<p>Please remember all these courses comes with <strong>100% Lifetime acces<\/strong><strong>s<\/strong> and <strong>free updates for Lifetime!!<\/strong><\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"thrv_wrapper thrv_text_element\">\n<p>Please click on the link <strong><span style=\"text-decoration: underline;\"><em><a class=\"tve-froala\" href=\"https:\/\/rahulshettyacademy.com\/blog\/index.php\/2021\/10\/23\/sdet-interview-questions-part-2\/\" style=\"outline: none;\" target=\"_blank\">Sr.QA and SDET Interview Questions in Java \u2013 Part 2<\/a><\/em><\/span><\/strong> to continue to part-2 series of this article.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"tcb_flag\" style=\"display: none\"><\/div>\n<\/section>\n<p><\/body><\/html><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This is Part 1 in the series of SDET Interview questions and answers in Java table of contents This is Part 1 in the series of SDET Interview questions and answers in Java 1. What is the difference between JDK, JRE, and JVM? 2. What are the different types of constructors in Java? And How [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,5],"tags":[],"class_list":["post-1214","post","type-post","status-publish","format-standard","hentry","category-interview-questions","category-java","post-wrapper","thrv_wrapper"],"_links":{"self":[{"href":"https:\/\/rahulshettyacademy.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/1214","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/rahulshettyacademy.com\/blog\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/rahulshettyacademy.com\/blog\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/rahulshettyacademy.com\/blog\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/rahulshettyacademy.com\/blog\/index.php\/wp-json\/wp\/v2\/comments?post=1214"}],"version-history":[{"count":0,"href":"https:\/\/rahulshettyacademy.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/1214\/revisions"}],"wp:attachment":[{"href":"https:\/\/rahulshettyacademy.com\/blog\/index.php\/wp-json\/wp\/v2\/media?parent=1214"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/rahulshettyacademy.com\/blog\/index.php\/wp-json\/wp\/v2\/categories?post=1214"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/rahulshettyacademy.com\/blog\/index.php\/wp-json\/wp\/v2\/tags?post=1214"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}