{"id":1298,"date":"2021-11-04T18:49:56","date_gmt":"2021-11-04T18:49:56","guid":{"rendered":"https:\/\/rahulshettyacademy.com\/blog\/index.php\/2021\/11\/04\/sdet-interview-questions-part-4\/"},"modified":"2021-11-04T18:49:56","modified_gmt":"2021-11-04T18:49:56","slug":"sdet-interview-questions-part-4","status":"publish","type":"post","link":"https:\/\/rahulshettyacademy.com\/blog\/index.php\/2021\/11\/04\/sdet-interview-questions-part-4\/","title":{"rendered":"Top SDET Interview Questions in Java &#8211; Part 4"},"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=\"1298\" id=\"tve_editor\">\n<div class=\"thrv_wrapper tve-toc tve-elem-scroll tve-toc-expandable tcb-local-vars-root\" data-animation=\"slide\" data-animation-speed=\"fast\" data-bullet-style='{\"0\":\"tve-u-17399ffbddd\",\"1\":\"tve-u-1739a0466e5\",\"2\":\"tve-u-1739a04a2bb\"}' data-columns=\"1\" data-columns-d=\"1\" data-css=\"tve-u-17cec3c7fe4\" data-ct=\"toc-60671\" data-ct-name=\"Table of Contents 03\" data-element-name=\"Table of Contents\" data-headers=\"h1,h3,h5\" data-heading-style='{\"0\":\"tve-u-17cec3c7fe9\",\"1\":\"tve-u-17cec3c7feb\",\"2\":\"tve-u-17cec3c7fec\"}' data-highlight=\"section\" data-number-style='{\"0\":\"tve-u-17cec3c7fea\",\"1\":\"tve-u-173dc888a58\",\"2\":\"tve-u-173dc8891dc\"}' data-numbering=\"basic\" data-state-default=\"expanded\" data-state-default-m=\"collapsed\" data-transition=\"fade\" 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)\" data-css=\"tve-u-17cec3c7fe5\" data-style=\"tve_sep-1\" data-thickness-d=\"1\">\n<hr class=\"tve_sep tve_sep-1\" 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-circle-outlined\" id=\"toc-bullet-0\" viewbox=\"0 0 512 512\"><path d=\"M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm0 448c-110.5 0-200-89.5-200-200S145.5 56 256 56s200 89.5 200 200-89.5 200-200 200z\"><\/path><\/symbol><symbol data-id=\"icon-circle-outlined\" id=\"toc-bullet-1\" viewbox=\"0 0 512 512\"><path d=\"M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm0 448c-110.5 0-200-89.5-200-200S145.5 56 256 56s200 89.5 200 200-89.5 200-200 200z\"><\/path><\/symbol><symbol data-id=\"icon-circle-outlined\" id=\"toc-bullet-2\" viewbox=\"0 0 512 512\"><path d=\"M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm0 448c-110.5 0-200-89.5-200-200S145.5 56 256 56s200 89.5 200 200-89.5 200-200 200z\"><\/path><\/symbol><\/svg><\/p>\n<div class=\"tve-content-box-background\" data-css=\"tve-u-17cec3c7fe6\" style=\"\"><\/div>\n<div class=\"thrv_wrapper tve-toc-title show-icon tcb-icon-display tve-no-dropzone tve-prevent-content-edit\" data-css=\"tve-u-17cec3c7fe7\" 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-arrow-circle-down-solid\" style=\"\"><svg class=\"tcb-icon\" data-id=\"icon-arrow-circle-down-solid\" data-name=\"\" viewbox=\"0 0 512 512\"><path d=\"M504 256c0 137-111 248-248 248S8 393 8 256 119 8 256 8s248 111 248 248zm-143.6-28.9L288 302.6V120c0-13.3-10.7-24-24-24h-16c-13.3 0-24 10.7-24 24v182.6l-72.4-75.5c-9.3-9.7-24.8-9.9-34.3-.4l-10.9 11c-9.4 9.4-9.4 24.6 0 33.9L239 404.3c9.4 9.4 24.6 9.4 33.9 0l132.7-132.7c9.4-9.4 9.4-24.6 0-33.9l-10.9-11c-9.5-9.5-25-9.3-34.3.4z\"><\/path><\/svg><\/div>\n<div class=\"thrv_wrapper thrv_text_element tve_no_icons\">\n<div class=\"tcb-plain-text\" style=\"\">Table of Contents<\/div>\n<\/p><\/div>\n<\/div>\n<\/div>\n<div class=\"tve-cb tve-toc-content tve-prevent-content-edit\" style=\"\">\n<div class=\"thrv_wrapper tve-toc-list tcb-no-delete tcb-no-save tcb-no-clone tve-no-dropzone\" data-css=\"tve-u-17cec3c7fe8\" style=\"\">\n<div class=\"tve-content-box-background\"><\/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-17cec3c7feb\" data-element-name=\"Heading Level 2\" data-tag=\"H3\"><a class=\"tve-toc-anchor tve-jump-scroll\" href=\"#t-1636050905349\" jump-animation=\"smooth\">1. What is Typecasting explain with small code snippet?<\/a><\/div>\n<div class=\"thrv_wrapper tve-toc-heading tve-toc-heading-level1 tve_no_icons\" data-css=\"tve-u-17cec3c7feb\" data-element-name=\"Heading Level 2\" data-tag=\"H3\"><a class=\"tve-toc-anchor tve-jump-scroll\" href=\"#t-1636050905350\" jump-animation=\"smooth\">2. Write a program to reverse a string \u00a0without using string.reverse() method<\/a><\/div>\n<div class=\"thrv_wrapper tve-toc-heading tve-toc-heading-level1 tve_no_icons\" data-css=\"tve-u-17cec3c7feb\" data-element-name=\"Heading Level 2\" data-tag=\"H3\"><a class=\"tve-toc-anchor tve-jump-scroll\" href=\"#t-1636050905351\" jump-animation=\"smooth\">3. Write a program to calculate the occurrences of each character in the string<\/a><\/div>\n<div class=\"thrv_wrapper tve-toc-heading tve-toc-heading-level1 tve_no_icons\" data-css=\"tve-u-17cec3c7feb\" data-element-name=\"Heading Level 2\" data-tag=\"H3\"><a class=\"tve-toc-anchor tve-jump-scroll\" href=\"#t-1636050905352\" jump-animation=\"smooth\">4. Write a program to check the magic number<\/a><\/div>\n<div class=\"thrv_wrapper tve-toc-heading tve-toc-heading-level1 tve_no_icons\" data-css=\"tve-u-17cec3c7feb\" data-element-name=\"Heading Level 2\" data-tag=\"H3\"><a class=\"tve-toc-anchor tve-jump-scroll\" href=\"#t-1636050905353\" jump-animation=\"smooth\">5. Write a program to check if two strings are an anagram<\/a><\/div>\n<div class=\"thrv_wrapper tve-toc-heading tve-toc-heading-level1 tve_no_icons\" data-css=\"tve-u-17cec3c7feb\" data-element-name=\"Heading Level 2\" data-tag=\"H3\"><a class=\"tve-toc-anchor tve-jump-scroll\" href=\"#t-1636050905354\" jump-animation=\"smooth\">6. Write a program to create a deadlock in java<\/a><\/div>\n<div class=\"thrv_wrapper tve-toc-heading tve-toc-heading-level1 tve_no_icons\" data-css=\"tve-u-17cec3c7feb\" data-element-name=\"Heading Level 2\" data-tag=\"H3\"><a class=\"tve-toc-anchor tve-jump-scroll\" href=\"#t-1638297868322\" jump-animation=\"smooth\">7. Consider I have data like below distance to the city from your hometown<\/a><\/div>\n<div class=\"thrv_wrapper tve-toc-heading tve-toc-heading-level2 tve_no_icons\" data-css=\"tve-u-17cec3c7fec\" data-element-name=\"Heading Level 3\" data-tag=\"H5\"><a class=\"tve-toc-anchor tve-jump-scroll\" href=\"#t-1638297868323\" jump-animation=\"smooth\">Course Alert<\/a><\/div>\n<\/div>\n<div class=\"thrv_wrapper thrv-divider tve-vert-divider\" data-color-d=\"rgba(0, 0, 0, 0)\" data-css=\"tve-u-17cec3c7fe5\" data-style=\"tve_sep-1\" data-thickness-d=\"1\">\n<hr class=\"tve_sep tve_sep-1\" 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-1636050905349\"><a class=\"tve-froala fr-basic\" name=\"_Toc82204592\" style=\"outline: none;\">1. What is Typecasting explain with small code snippet?<\/a><\/h3>\n<ul class=\"\">\n<li>Typecasting is converting data from one data type to another data type.<\/li>\n<li>Typecasting can be applied to both primitive and non-primitive types.<\/li>\n<li>Typecasting process doesn&#8217;t alter the data but alters the type.<\/li>\n<\/ul>\n<p><strong>There are two types:<\/strong><\/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<ul class=\"\">\n<li>Implicit casting<\/li>\n<li>Explicit casting<\/li>\n<\/ul>\n<p><strong>Implicit casting: <\/strong>This is known as automatic typecasting. Usually, this happens when you converting a lower data type to a higher data type<\/p>\n<p><strong> <\/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-17cec3d278d\" style=\"\">\n<p><span data-css=\"tve-u-17cec3d54d3\" style=\"color: rgb(255, 255, 255);\">class Main {<\/span><\/p>\n<p><span data-css=\"tve-u-17cec3d54d5\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0 public static void main(String args[]) {<\/span><\/p>\n<p><span data-css=\"tve-u-17cec3d54d7\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 int i = 10;<\/span><\/p>\n<p><span data-css=\"tve-u-17cec3d54d8\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 float f = i;<\/span><\/p>\n<p><span data-css=\"tve-u-17cec3d54d9\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 System.out.println(&#8220;Value of f = &#8221; +f);<\/span><\/p>\n<p><span data-css=\"tve-u-17cec3d54db\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0 }<\/span><\/p>\n<p><span data-css=\"tve-u-17cec3d54dc\" style=\"color: rgb(255, 255, 255);\">}<\/span><\/p>\n<p data-css=\"tve-u-17cec3d72dc\" style=\"\"><span data-css=\"tve-u-17cec3d54dd\" style=\"\">Output:<\/span><\/p>\n<p><span data-css=\"tve-u-17cec3d54de\" style=\"color: rgb(255, 255, 255);\">Value of f = 10.0<\/span><\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"thrv_wrapper thrv_text_element\">\n<p><strong>Explicit TypeCasting<\/strong><\/p>\n<p>Explicit casting involves assigning a data type of high range to a lower range. This casting needs to be done manually<\/p>\n<p><strong> <\/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-17cec3ddd52\" style=\"\">\n<p><span data-css=\"tve-u-17cec3dfdf2\" style=\"color: rgb(255, 255, 255);\">class Main {<\/span><\/p>\n<p><span data-css=\"tve-u-17cec3dfdf5\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0 public static void main(String args[]) {<\/span><\/p>\n<p><span data-css=\"tve-u-17cec3dfdf7\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 float f = 3.142f;<\/span><\/p>\n<p><span data-css=\"tve-u-17cec3dfdf8\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 int\u00a0 i = (int) f;<\/span><\/p>\n<p><span data-css=\"tve-u-17cec3dfdf9\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 System.out.println(&#8220;Value of i = &#8221; +i);<\/span><\/p>\n<p><span data-css=\"tve-u-17cec3dfdfb\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0 }<\/span><\/p>\n<p><span data-css=\"tve-u-17cec3dfdfc\" style=\"color: rgb(255, 255, 255);\">}<\/span><\/p>\n<p data-css=\"tve-u-17cec3e197f\" style=\"\"><span data-css=\"tve-u-17cec3dfdfd\" style=\"\">Output:<\/span><\/p>\n<p><span data-css=\"tve-u-17cec3dfdff\" style=\"color: rgb(255, 255, 255);\">Value of i = 3<\/span><\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"thrv_wrapper thrv_text_element\">\n<p><em><strong>Note: <\/strong>Why do we need typecasting?<\/em><\/p>\n<p><em>Typecasting is needed to get access to fields and methods declared on the target type or class. You cannot access them with any other type.<\/em><\/p>\n<h3 class=\"\" id=\"t-1636050905350\"><a class=\"tve-froala fr-basic\" name=\"_Toc82204593\" style=\"outline: none;\">2. Write a program to reverse a string \u00a0without using string.reverse() method<\/a><\/h3>\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-17cec3eccab\" style=\"\">\n<p><span data-css=\"tve-u-17cec3eee3e\" style=\"color: rgb(255, 255, 255);\">class Main {<\/span><\/p>\n<p><span data-css=\"tve-u-17cec3eee40\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0 public static void main(String args[]) {<\/span><\/p>\n<p><span data-css=\"tve-u-17cec3eee42\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 String string = &#8220;Rahul Shetty Academy&#8221;;<\/span><\/p>\n<p><span data-css=\"tve-u-17cec3eee43\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 String reverse = &#8220;&#8221;;<\/span><\/p>\n<p><span data-css=\"tve-u-17cec3eee45\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 for (int i = string.length() &#8211; 1; i &gt;= 0; &#8211;i) {<\/span><\/p>\n<p><span data-css=\"tve-u-17cec3eee46\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 reverse += string.charAt(i);<\/span><\/p>\n<p><span data-css=\"tve-u-17cec3eee47\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 }<\/span><\/p>\n<p><span data-css=\"tve-u-17cec3eee48\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 System.out.println(reverse);<\/span><\/p>\n<p><span data-css=\"tve-u-17cec3eee4a\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0 }<\/span><\/p>\n<p><span data-css=\"tve-u-17cec3eee4b\" style=\"color: rgb(255, 255, 255);\">}<\/span><\/p>\n<p data-css=\"tve-u-17cec3f064c\" style=\"\"><span data-css=\"tve-u-17cec3eee4c\" style=\"\">Output: ymedacA yttehS luhaR<\/span><\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"thrv_wrapper thrv_text_element\">\n<h3 class=\"\" id=\"t-1636050905351\"><a class=\"tve-froala fr-basic\" name=\"_Toc82204594\" style=\"outline: none;\">3. Write a program to calculate the occurrences of each character in the string<\/a><\/h3>\n<p><strong>Solution:<\/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-17cec3f9345\" style=\"\">\n<p><span data-css=\"tve-u-17cec3fb8aa\" style=\"color: rgb(255, 255, 255);\">import java.util.*;<\/span><\/p>\n<p><span data-css=\"tve-u-17cec3fb8ac\" style=\"color: rgb(255, 255, 255);\">class Main {<\/span><\/p>\n<p><span data-css=\"tve-u-17cec3fb8ae\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0 static void countChars(String string) {<\/span><\/p>\n<p><span data-css=\"tve-u-17cec3fb8af\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 HashMap&lt;Character, Integer&gt; charCount = new HashMap&lt;Character, Integer&gt;();<\/span><\/p>\n<p><span data-css=\"tve-u-17cec3fb8b0\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 char[] charArray = string.toCharArray();<\/span><\/p>\n<p><span data-css=\"tve-u-17cec3fb8b2\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 for (char c : charArray) {<\/span><\/p>\n<p><span data-css=\"tve-u-17cec3fb8b3\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 if (charCount.containsKey(c)) {<\/span><\/p>\n<p><span data-css=\"tve-u-17cec3fb8b4\" 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\u00a0 charCount.put(c, charCount.get(c) + 1);<\/span><\/p>\n<p><span data-css=\"tve-u-17cec3fb8b6\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 } else {<\/span><\/p>\n<p><span data-css=\"tve-u-17cec3fb8b7\" 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\u00a0 charCount.put(c, 1);<\/span><\/p>\n<p><span data-css=\"tve-u-17cec3fb8b8\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 }<\/span><\/p>\n<p><span data-css=\"tve-u-17cec3fb8ba\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 }<\/span><\/p>\n<p><span data-css=\"tve-u-17cec3fb8bb\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 for (Map.Entry entry : charCount.entrySet()) {<\/span><\/p>\n<p><span data-css=\"tve-u-17cec3fb8bc\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 System.out.println(&#8220;Character &#8220;+entry.getKey() + &#8221; Occurred &#8221; + entry.getValue() +&#8221; Time(s)&#8221;);<\/span><\/p>\n<p><span data-css=\"tve-u-17cec3fb8bd\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 }<\/span><\/p>\n<p><span data-css=\"tve-u-17cec3fb8bf\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0 }<\/span><\/p>\n<p><span data-css=\"tve-u-17cec3fb8c0\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0 public static void main(String[] args) {<\/span><\/p>\n<p><span data-css=\"tve-u-17cec3fb8c1\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 countChars(&#8220;java&#8221;);<\/span><\/p>\n<p><span data-css=\"tve-u-17cec3fb8c3\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0 }<\/span><\/p>\n<p><span data-css=\"tve-u-17cec3fb8c4\" style=\"color: rgb(255, 255, 255);\">}<\/span><\/p>\n<p><span data-css=\"tve-u-17cec3fb8c5\" style=\"color: rgb(49, 211, 27);\">Output:<\/span><\/p>\n<p><span data-css=\"tve-u-17cec3fda41\" style=\"color: rgb(49, 211, 27);\">Character a Occurred 2 Time(s)<\/span><\/p>\n<p><span data-css=\"tve-u-17cec3fda42\" style=\"color: rgb(49, 211, 27);\">Character v Occurred 1 Time(s)<\/span><\/p>\n<p><span data-css=\"tve-u-17cec3fb8c9\" style=\"color: rgb(49, 211, 27);\">Character j Occurred 1 Time(s)<\/span><\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"thrv_wrapper thrv_text_element\">\n<h3 class=\"\" id=\"t-1636050905352\"><a class=\"tve-froala fr-basic\" name=\"_Toc82204595\" style=\"outline: none;\">4. Write a program to check the magic number<\/a><\/h3>\n<p>The number is called a <strong>Magic number<\/strong>, If the sum of its digits is calculated till a single digit recursively by adding the sum of the digits after every addition. If the single-digit comes out to be 1, then the number is a magic number.<\/p>\n<p><strong>Example 1:<\/strong><\/p>\n<p>Number: 1081<\/p>\n<p>1081 = 1+0+8+1 Sum is 10<\/p>\n<p>10 = 1+0 Sum 1<\/p>\n<p>So 1081 is Magic number<\/p>\n<p><strong>Example 2:<\/strong><\/p>\n<p>Number: 1056<\/p>\n<p>1056 = 1+0+5+6 Sum is 12<\/p>\n<p>12 = 1+2 Sum is 3<\/p>\n<p>So 1056 is not a Magic number<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/p>\n<p><strong>Solution:<\/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-17cec405fce\" style=\"\">\n<p><span data-css=\"tve-u-17cec409c50\" style=\"color: rgb(255, 255, 255);\">class Main {<\/span><\/p>\n<p><span data-css=\"tve-u-17cec409c52\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0 public static void main(String[] args) {<\/span><\/p>\n<p><span data-css=\"tve-u-17cec409c54\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 int sum = 0;<\/span><\/p>\n<p><span data-css=\"tve-u-17cec409c55\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 int number = 1081;<\/span><\/p>\n<p><span data-css=\"tve-u-17cec409c56\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 int n = number;<\/span><\/p>\n<p><span data-css=\"tve-u-17cec409c58\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 while (n &gt; 0 || sum &gt; 9) {<\/span><\/p>\n<p><span data-css=\"tve-u-17cec409c59\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0\u00a0\u00a0 if (n == 0) {<\/span><\/p>\n<p><span data-css=\"tve-u-17cec409c5a\" 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\u00a0 n = sum;<\/span><\/p>\n<p><span data-css=\"tve-u-17cec409c5b\" 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\u00a0 sum = 0;<\/span><\/p>\n<p><span data-css=\"tve-u-17cec409c5d\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 }<\/span><\/p>\n<p><span data-css=\"tve-u-17cec409c5e\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 sum += n % 10;<\/span><\/p>\n<p><span data-css=\"tve-u-17cec409c5f\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 n \/= 10;<\/span><\/p>\n<p><span data-css=\"tve-u-17cec409c61\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 }<\/span><\/p>\n<p><span data-css=\"tve-u-17cec409c62\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 if (sum == 1) {<\/span><\/p>\n<p><span data-css=\"tve-u-17cec409c64\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 System.out.println(number + &#8221; is a Magic Number&#8221;);<\/span><\/p>\n<p><span data-css=\"tve-u-17cec409c65\" 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-17cec409c66\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 System.out.println(number + &#8220;is not a Magic Number&#8221;);<\/span><\/p>\n<p><span data-css=\"tve-u-17cec409c67\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 }<\/span><\/p>\n<p><span data-css=\"tve-u-17cec409c69\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0 }<\/span><\/p>\n<p><span data-css=\"tve-u-17cec409c6a\" style=\"color: rgb(255, 255, 255);\">}<\/span><\/p>\n<p><span data-css=\"tve-u-17cec409c6b\" style=\"color: rgb(40, 187, 67);\">Output:<\/span><\/p>\n<p><span data-css=\"tve-u-17cec409c6d\" style=\"color: rgb(40, 187, 67);\">1081 is a Magic Number<\/span><\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"thrv_wrapper thrv_text_element\">\n<h3 class=\"\" id=\"t-1636050905353\"><a class=\"tve-froala fr-basic\" name=\"_Toc82204596\" style=\"outline: none;\">5. Write a program to check if two strings are an anagram<\/a><\/h3>\n<p>An anagram is if two strings are having exactly the same chars and however the order of chars are different.<\/p>\n<p><strong>Example 1:<\/strong><\/p>\n<p>String 1 = ABCD<\/p>\n<p>String 2: BDCA<\/p>\n<p>The String 1 and String 2 are anagrams<\/p>\n<p><strong>Example 2:<\/strong><\/p>\n<p>String 1: Race<\/p>\n<p>String 2: Care<\/p>\n<p>String 1 and String 2 are anagrams<\/p>\n<p><strong>Solution:<\/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-17cec414915\" style=\"\">\n<p><span data-css=\"tve-u-17cec418834\" style=\"color: rgb(255, 255, 255);\">import java.util.*;<\/span><\/p>\n<p><span data-css=\"tve-u-17cec418836\" style=\"color: rgb(255, 255, 255);\">public class Main {<\/span><\/p>\n<p><span data-css=\"tve-u-17cec418837\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0 public static void main(String[] args) {<\/span><\/p>\n<p><span data-css=\"tve-u-17cec418838\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 String string1 = &#8220;race&#8221;;<\/span><\/p>\n<p><span data-css=\"tve-u-17cec41883a\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 String string2 = &#8220;care&#8221;;<\/span><\/p>\n<p><span data-css=\"tve-u-17cec41883b\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 boolean isAnagram = false;<\/span><\/p>\n<p><span data-css=\"tve-u-17cec41883c\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 if (string1.length() != string2.length()) {<\/span><\/p>\n<p><span data-css=\"tve-u-17cec41883d\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 isAnagram = false;<\/span><\/p>\n<p><span data-css=\"tve-u-17cec41883f\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 }<\/span><\/p>\n<p><span data-css=\"tve-u-17cec418840\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0 else{<\/span><\/p>\n<p><span data-css=\"tve-u-17cec418841\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 char[] char1 = string1.toCharArray();<\/span><\/p>\n<p><span data-css=\"tve-u-17cec418843\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 char[] char2 = string2.toCharArray();<\/span><\/p>\n<p><span data-css=\"tve-u-17cec418844\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Arrays.sort(char1);<\/span><\/p>\n<p><span data-css=\"tve-u-17cec418845\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Arrays.sort(char2);<\/span><\/p>\n<p><span data-css=\"tve-u-17cec418847\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 for (int i = 0; i &lt; char1.length; i++) {<\/span><\/p>\n<p><span data-css=\"tve-u-17cec418848\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 if (char1[i] != char2[i]) {<\/span><\/p>\n<p><span data-css=\"tve-u-17cec418849\" 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\u00a0 isAnagram = false;<\/span><\/p>\n<p><span data-css=\"tve-u-17cec41884a\" 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\u00a0 break;<\/span><\/p>\n<p><span data-css=\"tve-u-17cec41884c\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 }<\/span><\/p>\n<p><span data-css=\"tve-u-17cec41884d\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 isAnagram = true;<\/span><\/p>\n<p><span data-css=\"tve-u-17cec41884e\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 }<\/span><\/p>\n<p><span data-css=\"tve-u-17cec418850\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0 }<\/span><\/p>\n<p><span data-css=\"tve-u-17cec418851\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 if (isAnagram)<\/span><\/p>\n<p><span data-css=\"tve-u-17cec418852\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 System.out.println(string1 + &#8221; and &#8220;+string2+ &#8221; are Anagram&#8221;);<\/span><\/p>\n<p><span data-css=\"tve-u-17cec418853\" 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-17cec418855\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 System.out.println(string1 + &#8221; and &#8220;+string2+ &#8221; are Not Anagram&#8221;);<\/span><\/p>\n<p><span data-css=\"tve-u-17cec418856\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0 }<\/span><\/p>\n<p><span data-css=\"tve-u-17cec418857\" style=\"color: rgb(255, 255, 255);\">}<\/span><\/p>\n<p><span data-css=\"tve-u-17cec418859\" style=\"color: rgb(66, 208, 27);\">Output:<\/span><\/p>\n<p><span data-css=\"tve-u-17cec41885a\" style=\"color: rgb(66, 208, 27);\">race and care are Anagram<\/span><\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"thrv_wrapper thrv_text_element\">\n<h3 class=\"\" id=\"t-1636050905354\"><a class=\"tve-froala fr-basic\" name=\"_Toc82204597\" style=\"outline: none;\">6. Write a program to create a deadlock in java<\/a><\/h3>\n<p><strong>Deadlock<\/strong> is the situation when a first thread is waiting for an object, that is acquired by a second thread and the second thread is waiting for an object lock that is acquired by the first thread. Since both threads are waiting for each other to release the lock. This condition is called deadlock.<\/p>\n<p><strong>Solution:<\/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-17cec469f59\" style=\"\">\n<p><span data-css=\"tve-u-17cec46bfbc\" style=\"color: rgb(255, 255, 255);\">class Main {<\/span><\/p>\n<p><span data-css=\"tve-u-17cec46bfbd\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0 public static void main(String[] args) {<\/span><\/p>\n<p><span data-css=\"tve-u-17cec46bfbf\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Object resource1 = new Object();<\/span><\/p>\n<p><span data-css=\"tve-u-17cec46bfc0\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Object resource2 = new Object();<\/span><\/p>\n<p><span data-css=\"tve-u-17cec46bfc2\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Thread t1 = new Thread() {<\/span><\/p>\n<p><span data-css=\"tve-u-17cec46bfc3\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 public void run() {<\/span><\/p>\n<p><span data-css=\"tve-u-17cec46bfc4\" 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\u00a0 synchronized (resource1) {<\/span><\/p>\n<p><span data-css=\"tve-u-17cec46bfc6\" 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\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 System.out.println(&#8220;Thread 1: locked resource 1&#8221;);<\/span><\/p>\n<p><span data-css=\"tve-u-17cec46bfc7\" 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\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 try {<\/span><\/p>\n<p><span data-css=\"tve-u-17cec46bfc8\" 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\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Thread.sleep(100);<\/span><\/p>\n<p><span data-css=\"tve-u-17cec46bfca\" 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\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 } catch (Exception e) {<\/span><\/p>\n<p><span data-css=\"tve-u-17cec46bfcb\" 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\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 }<\/span><\/p>\n<p><span data-css=\"tve-u-17cec46bfcc\" 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\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 synchronized (resource2) {<\/span><\/p>\n<p><span data-css=\"tve-u-17cec46bfcd\" 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\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 System.out.println(&#8220;Thread 1: locked resource 2&#8221;);<\/span><\/p>\n<p><span data-css=\"tve-u-17cec46bfcf\" 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\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 }<\/span><\/p>\n<p><span data-css=\"tve-u-17cec46bfd0\" 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\u00a0 }<\/span><\/p>\n<p><span data-css=\"tve-u-17cec46bfd1\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 }<\/span><\/p>\n<p><span data-css=\"tve-u-17cec46bfd3\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 };<\/span><\/p>\n<p><span data-css=\"tve-u-17cec46bfd4\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Thread t2 = new Thread() {<\/span><\/p>\n<p><span data-css=\"tve-u-17cec46bfd5\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 public void run() {<\/span><\/p>\n<p><span data-css=\"tve-u-17cec46bfd7\" 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\u00a0 synchronized (resource2) {<\/span><\/p>\n<p><span data-css=\"tve-u-17cec46bfd8\" 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\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 System.out.println(&#8220;Thread 2: locked resource 2&#8221;);<\/span><\/p>\n<p><span data-css=\"tve-u-17cec46bfd9\" 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\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 try {<\/span><\/p>\n<p><span data-css=\"tve-u-17cec46bfdb\" 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\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Thread.sleep(100);<\/span><\/p>\n<p><span data-css=\"tve-u-17cec46bfdc\" 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\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 } catch (Exception e) {<\/span><\/p>\n<p><span data-css=\"tve-u-17cec46bfdd\" 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\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 }<\/span><\/p>\n<p><span data-css=\"tve-u-17cec46bfdf\" 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\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 synchronized (resource1) {<\/span><\/p>\n<p><span data-css=\"tve-u-17cec46bfe0\" 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\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 System.out.println(&#8220;Thread 2: locked resource 1&#8221;);<\/span><\/p>\n<p><span data-css=\"tve-u-17cec46bfe1\" 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\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 }<\/span><\/p>\n<p><span data-css=\"tve-u-17cec46bfe3\" 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\u00a0 }<\/span><\/p>\n<p><span data-css=\"tve-u-17cec46bfe4\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 }<\/span><\/p>\n<p><span data-css=\"tve-u-17cec46bfe5\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 };<\/span><\/p>\n<p><span data-css=\"tve-u-17cec46bfe7\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 t1.start();<\/span><\/p>\n<p><span data-css=\"tve-u-17cec46bfe8\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 t2.start();<\/span><\/p>\n<p><span data-css=\"tve-u-17cec46bfe9\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0 }<\/span><\/p>\n<p><span data-css=\"tve-u-17cec46bfeb\" style=\"color: rgb(255, 255, 255);\">}<\/span><\/p>\n<p><span data-css=\"tve-u-17cec46bfec\" style=\"color: rgb(38, 211, 48);\">Output:<\/span><\/p>\n<p><span data-css=\"tve-u-17cec46ea34\" style=\"color: rgb(38, 211, 48);\">Thread 1: locked resource 1<\/span><\/p>\n<p><span data-css=\"tve-u-17cec46bfef\" style=\"color: rgb(38, 211, 48);\">Thread 2: locked resource 2<\/span><\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"thrv_wrapper thrv_text_element\">\n<h3 class=\"\"><a class=\"tve-froala fr-basic\" name=\"_Toc82204598\" style=\"outline: none;\">7. Consider I have data like below distance to the city from your hometown<\/a><\/h3>\n<p>Bangalore, 560<\/p>\n<p>Chennai, 890<\/p>\n<p>Hyderabad, 566<\/p>\n<p>Mumbai, 788<\/p>\n<p>New Delhi, 1000<\/p>\n<p>Write a program that stores the above data in Map, and print them back by iterating over each element.<\/p>\n<p><strong>Solution:<\/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-17cec479ff2\" style=\"\">\n<p><span data-css=\"tve-u-17cec47c130\" style=\"color: rgb(255, 255, 255);\">import java.util.HashMap;<\/span><\/p>\n<p><span data-css=\"tve-u-17cec47c132\" style=\"color: rgb(255, 255, 255);\">import java.util.Map;<\/span><\/p>\n<p><span data-css=\"tve-u-17cec47c133\" style=\"color: rgb(255, 255, 255);\">import java.util.Map.Entry;<\/span><\/p>\n<p><span data-css=\"tve-u-17cec47c135\" style=\"color: rgb(255, 255, 255);\">class Main {<\/span><\/p>\n<p><span data-css=\"tve-u-17cec47c136\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0 public static void main(String[] args) {<\/span><\/p>\n<p><span data-css=\"tve-u-17cec47c138\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Map&lt;String,Integer&gt; map = new HashMap&lt;String,Integer&gt;();<\/span><\/p>\n<p><span data-css=\"tve-u-17cec47c139\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 map.put(&#8220;Bangalore&#8221;, 560);<\/span><\/p>\n<p><span data-css=\"tve-u-17cec47c13a\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 map.put(&#8220;Chennai&#8221;, 890);<\/span><\/p>\n<p><span data-css=\"tve-u-17cec47c13c\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 map.put(&#8220;Hyderabad&#8221;, 566);<\/span><\/p>\n<p><span data-css=\"tve-u-17cec47c13d\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 map.put(&#8220;Mumbai&#8221;, 788);<\/span><\/p>\n<p><span data-css=\"tve-u-17cec47c13f\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 map.put(&#8220;New Delhi&#8221;, 1000);<\/span><\/p>\n<p><span data-css=\"tve-u-17cec47c140\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><\/p>\n<p><span data-css=\"tve-u-17cec47c141\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 for(Entry&lt;String,Integer&gt; entry:map.entrySet()) {<\/span><\/p>\n<p><span data-css=\"tve-u-17cec47c143\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 System.out.println(&#8220;Distance from Hometown to &#8221; + entry.getKey()+&#8221; is &#8221; + entry.getValue()+&#8221; Kms&#8221;);<\/span><\/p>\n<p><span data-css=\"tve-u-17cec47c144\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 }<\/span><\/p>\n<p><span data-css=\"tve-u-17cec47c146\" style=\"color: rgb(255, 255, 255);\">\u00a0\u00a0\u00a0 }<\/span><\/p>\n<p><span data-css=\"tve-u-17cec47c147\" style=\"color: rgb(255, 255, 255);\">}<\/span><\/p>\n<p><span data-css=\"tve-u-17cec47c148\" style=\"color: rgb(43, 201, 33);\">Output:<\/span><\/p>\n<p><span data-css=\"tve-u-17cec47e088\" style=\"color: rgb(43, 201, 33);\">Distance from Hometown to New Delhi is 1000 Kms<\/span><\/p>\n<p><span data-css=\"tve-u-17cec47e089\" style=\"color: rgb(43, 201, 33);\">Distance from Hometown to Chennai is 890 Kms<\/span><\/p>\n<p><span data-css=\"tve-u-17cec47e08b\" style=\"color: rgb(43, 201, 33);\">Distance from Hometown to Mumbai is 788 Kms<\/span><\/p>\n<p><span data-css=\"tve-u-17cec47e08c\" style=\"color: rgb(43, 201, 33);\">Distance from Hometown to Hyderabad is 566 Kms<\/span><\/p>\n<p><span data-css=\"tve-u-17cec47c14f\" style=\"color: rgb(43, 201, 33);\">Distance from Hometown to Bangalore is 560 Kms<\/span><\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"thrv_wrapper thrv_text_element\">\n<h5 class=\"\" style=\"text-align: center;\"><em><span style=\"text-decoration: underline;\">Course Alert<\/span><\/em><\/h5>\n<p><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-17d675a37e2\" 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-17d675a37e2\" 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-17d675ac3ab\">\n<div class=\"thrv_wrapper thrv_contentbox_shortcode thrv-content-box\" data-css=\"tve-u-17d675ac3ac\" 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-17d675ac3a9\"><\/div>\n<div class=\"tve-cb tve_empty_dropzone\" data-css=\"tve-u-17d675ac3a7\">\n<div class=\"thrv_wrapper thrv_text_element tve_empty_dropzone\" data-css=\"tve-u-17d675ac3a8\">\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\u00a0<strong><em><a class=\"tve-froala fr-basic\" data-css=\"tve-u-17d722afaa8\" href=\"https:\/\/rahulshettyacademy.com\/blog\/index.php\/2021\/11\/04\/sdet-interview-questions-part-5\/\" style=\"outline: none;\" target=\"_blank\">Sr.QA and SDET Interview Questions in Java \u2013 Part 5<\/a><\/em><\/strong> to continue to part-5 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>Table of Contents 1. What is Typecasting explain with small code snippet? 2. Write a program to reverse a string \u00a0without using string.reverse() method 3. Write a program to calculate the occurrences of each character in the string 4. Write a program to check the magic number 5. Write a program to check if two [&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-1298","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\/1298","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=1298"}],"version-history":[{"count":0,"href":"https:\/\/rahulshettyacademy.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/1298\/revisions"}],"wp:attachment":[{"href":"https:\/\/rahulshettyacademy.com\/blog\/index.php\/wp-json\/wp\/v2\/media?parent=1298"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/rahulshettyacademy.com\/blog\/index.php\/wp-json\/wp\/v2\/categories?post=1298"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/rahulshettyacademy.com\/blog\/index.php\/wp-json\/wp\/v2\/tags?post=1298"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}