<?php include __DIR__ . '/../../header.php'; ?>
<div><section data-id="Interview Detail Banner" id="Interview Detail Banner" class="py-spacing44 sm:py-spacing48 xl:px-spacing80 sm:px-spacing112 px-0 !pb-0 !pt-spacing20 md:!bg-offWhite"><div class="px-spacing20 md:px-0 w-full 2xl:max-w-7xl mx-auto"><div class="row g-4"><div class="col-12 md:flex-col"><ol itemscope="" itemtype="https://schema.org/BreadcrumbList" class="flex h-8 w-auto justify-start items-center bg-transparent md:!bg-offWhite xs:!bg-yellow1"><li class="flex items-center text-xs font-normal h-8 group ease-in-out duration-500 transition text-neutral-500" itemprop="itemListElement" itemscope="" itemtype="https://schema.org/ListItem"><a href="" class="px-spacing8 h-full cursor-pointer flex rounded-128 items-center group-hover:bg-mono-black/4 duration-500 ease-in-out transition justify-center" itemprop="item"><div itemprop="name" content="Home"><div class="text-xs text-neutral-600 group-hover:font-medium group-hover:underline group-hover:underline-offset-3 group-hover:text-mono-black">Home</div></div></a><meta itemprop="position" content="1"><i class=" icon-chevron-right text-xl leading-5 text-neutral-600  md:text-neutral-400 self-center "></i></li><li class="flex items-center text-xs font-normal h-8 group ease-in-out duration-500 transition text-neutral-500" itemprop="itemListElement" itemscope="" itemtype="https://schema.org/ListItem"><a href="interview-questions" class="px-spacing8 h-full cursor-pointer flex rounded-128 items-center group-hover:bg-mono-black/4 duration-500 ease-in-out transition justify-center" itemprop="item"><div itemprop="name"><div class="text-xs text-neutral-500 group-hover:font-medium group-hover:underline group-hover:underline-offset-3 group-hover:text-mono-black max-w-50 overflow-ellipsis whitespace-nowrap overflow-hidden">Interview Questions</div></div></a><meta itemprop="position" content="2"><i class=" icon-chevron-right text-xl leading-5 text-neutral-600  md:text-neutral-400 self-center "></i></li><li class="flex items-center text-xs font-normal h-8 group ease-in-out duration-500 transition text-neutral-500" itemprop="itemListElement" itemscope="" itemtype="https://schema.org/ListItem"><a href="interview-questions/programming" class="px-spacing8 h-full cursor-pointer flex rounded-128 items-center group-hover:bg-mono-black/4 duration-500 ease-in-out transition justify-center" itemprop="item"><div itemprop="name"><div class="text-xs text-neutral-500 group-hover:font-medium group-hover:underline group-hover:underline-offset-3 group-hover:text-mono-black max-w-50 overflow-ellipsis whitespace-nowrap overflow-hidden">Programming</div></div></a><meta itemprop="position" content="3"><i class=" icon-chevron-right text-xl leading-5 text-neutral-600  md:text-neutral-400 self-center "></i></li><li class="flex items-center text-xs font-normal h-8 group ease-in-out duration-500 transition text-neutral-500" itemprop="itemListElement" itemscope="" itemtype="https://schema.org/ListItem"><span class="overflow-hidden px-spacing8 "><div itemprop="name"><div class="text-xs text-neutral-500 max-w-50 overflow-ellipsis whitespace-nowrap overflow-hidden">Java</div></div></span><meta itemprop="position" content="4"><i class=" hidden"></i></li></ol></div></div></div></section></div><div><section data-id="Interview Detail Banner" id="Interview Detail Banner" class="py-spacing44 sm:py-spacing48 xl:px-spacing80 sm:px-spacing112 px-0 bg-offWhite !py-0 !pb-0"><div class="px-spacing20 md:px-0 w-full 2xl:max-w-7xl mx-auto"><div class="row g-4"><div class="col-12 md:flex-col"><!--$--><div class="flex flex-col md:flex-row md:items-center md:justify-between bg-offWhite  md:pt-spacing20 md:pb-[48px]"><div class="md:max-w-[579px] xs:w-full"><p class="uppercase text-interview-grey-1 text-interactionNormal font-semibold pb-spacing7">Programming</p><h1 class="font-[700] text-headingBanner2 pb-spacing20 text-black">Java</h1><p class="text-greyscale1 text-interactionNormal leading-[22px] font-normal flex items-center gap-spacing6"><svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 18 18" fill="none"><path d="M8.09313 2.36439C8.46453 1.61186 9.53762 1.61185 9.90902 2.36439L11.6202 5.8317L15.4466 6.38771C16.2771 6.50838 16.6087 7.52895 16.0078 8.11472L13.239 10.8136L13.8926 14.6246C14.0345 15.4517 13.1663 16.0825 12.4235 15.6919L9.00108 13.8927L5.57864 15.6919C4.83584 16.0825 3.96769 15.4517 4.10955 14.6246L4.76318 10.8136L1.99437 8.11472C1.39343 7.52896 1.72504 6.50838 2.55551 6.38771L6.38191 5.8317L8.09313 2.36439ZM9.00108 3.06669L7.36457 6.38262C7.21708 6.68146 6.932 6.88858 6.60222 6.9365L2.94286 7.46824L5.5908 10.0493C5.82943 10.2819 5.93832 10.6171 5.88199 10.9455L5.2569 14.5901L8.52992 12.8694C8.82489 12.7143 9.17727 12.7143 9.47224 12.8694L12.7453 14.5901L12.1202 10.9455C12.0638 10.6171 12.1727 10.2819 12.4114 10.0493L15.0593 7.46824L11.3999 6.9365C11.0702 6.88858 10.7851 6.68146 10.6376 6.38262L9.00108 3.06669Z" fill="#FF9F1F"></path></svg>4.5<!-- --> Rating<span class="bg-transparent"></span><i aria-hidden="true" class="icon-book-open text-yellow-main text-base"></i> <!-- -->239<!-- --> Questions<span class="bg-transparent"></span><i aria-hidden="true" class="icon-clock text-yellow-main text-base"></i> <!-- -->90<!-- --> mins read<span class="bg-transparent"></span><svg xmlns="http://www.w3.org/2000/svg" width="15" height="11" viewBox="0 0 15 11" fill="none"><path fill-rule="evenodd" clip-rule="evenodd" d="M3.24952 2.59291C2.23066 3.44326 1.51929 4.44071 1.16018 5.00933C1.11075 5.0876 1.09048 5.12047 1.0772 5.14603C1.0712 5.15757 1.06952 5.16207 1.06839 5.16646C1.06826 5.16749 1.06809 5.16902 1.06789 5.17105C1.0672 5.17843 1.06667 5.1885 1.06667 5.2C1.06667 5.2115 1.0672 5.22157 1.06789 5.22895C1.06809 5.23098 1.06826 5.23251 1.06839 5.23354C1.06952 5.23793 1.0712 5.24243 1.0772 5.25397C1.09048 5.27953 1.11075 5.3124 1.16018 5.39067C1.51929 5.95929 2.23066 6.95674 3.24952 7.80709C4.26712 8.6564 5.55933 9.33333 7.0961 9.33333C8.63288 9.33333 9.92509 8.6564 10.9427 7.80709C11.9615 6.95674 12.6729 5.95929 13.032 5.39067C13.0815 5.3124 13.1017 5.27953 13.115 5.25396C13.121 5.24246 13.1227 5.23796 13.1238 5.23358C13.1239 5.23255 13.1241 5.23101 13.1243 5.22895C13.125 5.22157 13.1255 5.2115 13.1255 5.2C13.1255 5.1885 13.125 5.17843 13.1243 5.17105C13.1241 5.16902 13.1239 5.16749 13.1238 5.16646C13.1227 5.16207 13.121 5.15757 13.115 5.14603C13.1017 5.12047 13.0815 5.0876 13.032 5.00933C12.6729 4.44071 11.9615 3.44325 10.9427 2.59291C9.92509 1.7436 8.63288 1.06667 7.0961 1.06667C5.55933 1.06667 4.26712 1.7436 3.24952 2.59291ZM2.56604 1.77398C3.70346 0.824679 5.22954 0 7.0961 0C8.96266 0 10.4887 0.824679 11.6262 1.77398C12.7623 2.72224 13.5427 3.8204 13.9339 4.43976C13.9388 4.44758 13.9438 4.45545 13.9489 4.4634C14.0278 4.58784 14.1182 4.73042 14.1644 4.9319C14.2015 5.0936 14.2015 5.3064 14.1644 5.4681C14.1182 5.66958 14.0278 5.81216 13.9489 5.9366C13.9438 5.94455 13.9388 5.95243 13.9339 5.96024C13.5427 6.5796 12.7623 7.67775 11.6262 8.62601C10.4887 9.57532 8.96266 10.4 7.0961 10.4C5.22954 10.4 3.70346 9.57532 2.56604 8.62601C1.42987 7.67775 0.649473 6.5796 0.258315 5.96024C0.253381 5.95243 0.248386 5.94455 0.243343 5.9366C0.164414 5.81216 0.0739778 5.66958 0.027797 5.4681C-0.00926565 5.3064 -0.00926565 5.0936 0.027797 4.9319C0.0739778 4.73042 0.164414 4.58784 0.243343 4.4634C0.248385 4.45545 0.253381 4.44757 0.258314 4.43976C0.649473 3.8204 1.42987 2.72225 2.56604 1.77398ZM7.0961 3.73333C6.28609 3.73333 5.62944 4.38998 5.62944 5.2C5.62944 6.01002 6.28609 6.66667 7.0961 6.66667C7.90612 6.66667 8.56277 6.01002 8.56277 5.2C8.56277 4.38998 7.90612 3.73333 7.0961 3.73333ZM4.56277 5.2C4.56277 3.80088 5.69698 2.66667 7.0961 2.66667C8.49522 2.66667 9.62944 3.80088 9.62944 5.2C9.62944 6.59912 8.49522 7.73333 7.0961 7.73333C5.69698 7.73333 4.56277 6.59912 4.56277 5.2Z" fill="#FF9F1F"></path></svg>284<!-- --> Readers</p></div><div class="rounded-[12px] h-auto relative overflow-hidden self-auto"><img alt="Interview Detail Banner Image" fetchpriority="high" loading="eager" width="411" height="274" decoding="async"  class="object-cover rounded-[12px]" style="color:transparent" sizes="(min-width: 768px) 411px, 274px" srcSet="" src="https://images.unsplash.com/photo-1515169061895-37fbb16acd37?ixlib=rb-4.0.3&auto=format&fit=crop&w=1000&q=80"></div></div><!--/$--></div></div></div></section></div><div><section data-id="Interview_Detail_Page_Interviews_Section" id="Interview_Detail_Page_Interviews_Section" class="py-spacing44 sm:py-spacing48 xl:px-spacing80 sm:px-spacing112 px-0"><div class="px-spacing20 md:px-0 w-full 2xl:max-w-7xl mx-auto"><div class="row g-4"><div class="col-12 md:flex-col"><div class="flex flex-row relative gap-spacing80"><div class="md:min-w-[846px] xs:w-full"><h3 class="text-interview-black-1 font-[700] md:text-title2 xs:text-baseInterviewTitle pb-spacing10">Introduction</h3><div class="text-neutral7 font-normal md:text-bodyNormal xs:text-bannerPoints pb-spacing24"><p>Java is a high-level programming language used for creating web applications. It is widely used in a variety of other applications, from mobile applications to desktop software and enterprise applications. It is also commonly used in the development of Android mobile apps. Java's popularity is due to its reliability, scalability, security features, and the large community of developers and extensive libraries available for the language. Our set of Java interview questions and answers will help you prepare your interview from beginner to advanced-level. The questions are from various topics like Java syntax and data types, exception handling, multithreading, Java frameworks and libraries, best practices, and coding conventions. With these Java interview questions, you can appear for the interview more confidently.</p></div><div><section class="py-spacing44 sm:py-spacing48 xl:px-spacing80 sm:px-spacing112 px-0 bg-subdued md:bg-white !py-0 !px-0"><div class="px-spacing20 md:px-0 w-full 2xl:max-w-7xl mx-auto"><div class="row g-4"><div class="col-12 md:flex-col"><div class="flex items-center justify-center font-Inter"><div class="bg-subdued w-full md:p-spacing40 py-spacing40 rounded-custom20"><div class="flex justify-between items-center"><div class="items-center flex-1"><div class="max-w-133"><div class="text-3xl leading-9.75 font-bold text-mono-black mt-spacing6">Java Interview Questions and Answers</div></div></div></div><div class=""><div><div class="relative flex w-fit items-center max-w-full customized-x-scrollbar gap-spacing12 md:gap-spacing24 rounded-xl bg-white p-spacing8 shadow-primaryDouble my-6 md:my-spacing40"><button class="z-1 rounded-lg px-spacing16 h-10 transition-all duration-300 ease-out flex items-center gap-spacing8 whitespace-nowrap font-semibold text-primary-900 bg-primary-100 delay-300"><h3 class="text-sm md:text-base first-letter:capitalize">Beginner</h3></button><button class="z-1 rounded-lg px-spacing16 h-10 transition-all duration-300 ease-out flex items-center gap-spacing8 whitespace-nowrap bg-transparent font-medium text-neutral-800 hover:text-primary-600"><h3 class="text-sm md:text-base first-letter:capitalize">Intermediate</h3></button><button class="z-1 rounded-lg px-spacing16 h-10 transition-all duration-300 ease-out flex items-center gap-spacing8 whitespace-nowrap bg-transparent font-medium text-neutral-800 hover:text-primary-600"><h3 class="text-sm md:text-base first-letter:capitalize">Advanced</h3></button><span class="absolute block h-10 rounded-lg bg-primary-100 transition-all duration-300" style="left:0;width:0;opacity:1"></span></div></div><div class=""><div><div class="text-xl text-neutral-800 mb-spacing20 font-bold">Beginner</div><div class="relative w-full"><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-primary-main outline-2 shadow-card hover:shadow-card visible"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-t-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden">1. Is Java fully object-oriented?</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-0 text-neutral-800"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p>Java supports programming in the Object-Oriented paradigm, but it is not fully object-oriented. Java has a set of primitive data types - byte, short, char, int, long, float, double, boolean. Any variable of this type is not an object. That’s why Java is not purely an object-oriented.&nbsp;</p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow visible"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">2. What is the purpose of a wrapper class?</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p>This is a frequently asked question in Java interview questions and answers.</p><p>The wrapper classes wrap the primitive data types to introduce them as objects. The primitive values are not objects, and the developer needs to write many boilerplate codes to convert them to each other and use them in collections. To overcome these problems, Java introduced wrapper classes. These classes provide with polymorphic APIs for data type conversions and the utility methods like hashCode() and equals(). These make the values very useful members in the object-oriented environment.&nbsp;</p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow visible"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">3. What is polymorphism?</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p>Polymorphism is a property of the object-oriented programming paradigm, which denotes that an object or a method can have different forms in different contexts. We can define a method in a class with different implementations based on its arguments in Java. In this way, when the client code calls the method using the same interface with a different set of parameters, internally, it decides which implementation needs to be invoked. Let’s take an example:&nbsp;</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-4uu6vpkw5" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm"><span style="background:rgba(0, 0, 0, 0.05);padding:0 3px;font-family:monospace">class AreaCalculator {</span>&nbsp;
<span style="background:rgba(0, 0, 0, 0.05);padding:0 3px;font-family:monospace">&nbsp; double calculate(Circle c)</span>
<span style="background:rgba(0, 0, 0, 0.05);padding:0 3px;font-family:monospace">&nbsp; &nbsp; &nbsp;{ return 3.14*c.getRadius()*c.getRadius();&nbsp;</span>
<span style="background:rgba(0, 0, 0, 0.05);padding:0 3px;font-family:monospace">&nbsp; &nbsp; &nbsp;}&nbsp;</span>
<span style="background:rgba(0, 0, 0, 0.05);padding:0 3px;font-family:monospace">double calculate(Square s)&nbsp;</span>
<span style="background:rgba(0, 0, 0, 0.05);padding:0 3px;font-family:monospace">&nbsp; &nbsp; &nbsp;{ &nbsp;return s.getLength()*s.getLength();</span>
<span style="background:rgba(0, 0, 0, 0.05);padding:0 3px;font-family:monospace">&nbsp; &nbsp; &nbsp;}&nbsp;</span>
<span style="background:rgba(0, 0, 0, 0.05);padding:0 3px;font-family:monospace">}&nbsp;</span>
<span style="background:rgba(0, 0, 0, 0.05);padding:0 3px;font-family:monospace">//Client code&nbsp;</span>
<span style="background:rgba(0, 0, 0, 0.05);padding:0 3px;font-family:monospace">AreaCalculator ac = new AreaCalculator();&nbsp;</span>
<span style="background:rgba(0, 0, 0, 0.05);padding:0 3px;font-family:monospace">ac.calculate(new Circle(10));&nbsp;</span>
<span style="background:rgba(0, 0, 0, 0.05);padding:0 3px;font-family:monospace">ac.calculate(new Square(5)); </span></pre></div></div><p><span style="background:rgba(0, 0, 0, 0.05);padding:0 3px;font-family:monospace">As you see, in the AreaCalculator</span> class, there are separate implementations for <span style="background:rgba(0, 0, 0, 0.05);padding:0 3px;font-family:monospace">calculate()</span>, but from the client’s point of view, the interface is the same.&nbsp;</p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow visible"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">4. In how many ways an object can be created in Java?</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p>There are several ways we can create an object in java.&nbsp;</p><p>1. A new object can be created using the new operator on the class calling one of&nbsp;</p><p>its constructors.<span style="background:rgba(0, 0, 0, 0.05);padding:0 3px;font-family:monospace">&nbsp;MyClass o = new MyClass();&nbsp;</span></p><p>2. We can create an object using the Java reflection API - Class.newInstance() if the class has a default constructor. If the class has multiple constructors that take parameters, we can get the corresponding constructor using Class.getConstructor() method and invoke that to create a new object. <span style="background:rgba(0, 0, 0, 0.05);padding:0 3px;font-family:monospace">MyClass o = MyClass.class.newInstance(); MyClass o = MyClass.class</span>&nbsp;</p><p>.getConstructor(int.class) .newInstance(10); &nbsp;</p><p>3. We can invoke clone method on an object to create a duplicate object.&nbsp;</p><p><span style="background:rgba(0, 0, 0, 0.05);padding:0 3px;font-family:monospace">MyClass o = new MyClass(); MyClass b = (MyClass)o.clone();</span>&nbsp;</p><p>4. If a state of that object is available in a serialized form, we can deserialize it to&nbsp;</p><p>create a new object having the same state.<span style="background:rgba(0, 0, 0, 0.05);padding:0 3px;font-family:monospace">&nbsp;ObjectInputStream is = new ObjectInputStream(anIStream); MyClass o = (MyClass) is.readObject();&nbsp;</span></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow visible"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">5. What is runtime polymorphism?</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p>Polymorphism or static polymorphism decides which method needs to be invoked at the time of compilation and bind the method invocation with the call. However, there are some situations where the static binding doesn’t work. As we know, a parent class reference can point to a parent object as well as a child object. Now, if there is a method which exists in both the parent class and the child class with the same signature and we invoke the method from parent class reference, the compiler cannot decide which method to bind with the call. This will depend on which type of object the reference is pointing to at the time of running. If the reference is pointing to a parent object, then the method in the parent class will be invoked. If the pointed object is an instance of the Child class, then the child-class implementation is invoked. That’s why this is called dynamic binding or runtime polymorphism and it is said that the child class method has overridden the parent class method. Let’s take an example of this:&nbsp;class Animal {&nbsp;</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-bxljnkutx" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">public void makeSound() {&nbsp;
System.out.println(“My sound varies based on my type”);&nbsp;}&nbsp;}&nbsp;class Dog extends Animal {&nbsp;
@Override public void makeSound() {&nbsp;
System.out.println(“I bark”);&nbsp;
} } Animal a = new Animal(); a.makeSound(); a = new Dog(); a.makeSound(); </pre></div></div><p>If we run the code snippet, we’ll find that a.makeSound() printing different messages based on the object-type pointed by reference. Please note that the Override annotation is required in the child class to notify the compiler that this method is overriding the parent implementation.&nbsp;</p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">6. What is the difference between StringBuffer and StringBuilder?</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p>StringBuffer and StringBuilder expose the same kind of APIs to build a String and both are mutable classes. There is a big difference in them, though. StringBuffer is thread-safe which means it can be used as a shared object among multiple threads. On the other hand, StringBuilder is not thread-safe and should not be allowed to be modified by multiple threads without proper synchronization techniques. That’s why StringBuilder is faster than StringBuffer. In the scenario where we need to build a String object local to a method or local to a particular thread, we should prefer StringBuilder over StringBuffer.&nbsp;</p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">7. What is the difference between an interface and an abstract class? When we should prefer the interface over abstract class?</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p>A class can inherit from both an abstract class and an interface, but there are some differences. A class can extend only one abstract class while can implement multiple interfaces. An interface cannot have a constructor whereas the abstract class can have constructors which the child classes need to invoke in their constructors. An abstract class may contain fields which may be accessible by child classes to change its state. Interface, on the other hand, can contain only final variables. So, abstract class lets the child class to inherit the state and behavior while the interface is mainly used for implementing a set of behaviors in a child class. An abstract class should be preferred where there is a direct IS-A relationship between the parent and the child. We use abstract class when the different implementations have most of the behaviors common and defined by the abstract class. An interface is preferred while exposing a public API to the client code and if a class can behave differently in different context.&nbsp;</p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">8. Does Java support multiple inheritance?</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p>Java doesn’t support multiple inheritance completely as a class can extend only one class. This is not supported as this can cause ambiguity in accessing inherited fields or methods if the same member exists in the other parent class. However, the facility is provided partially through the interfaces.&nbsp;</p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">9. What do you understand by a static member of a class?</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>It's no surprise that this one pops up often in Java interview questions for freshers.</p><p>We declare a member as static if it doesn’t depend on any instance of the class, i.e., independent of any objects. These members are bound to the type and are usually accessed using the type name (rather than the object references). Static methods and fields are shared between all the objects of a class and can be accessed from any of them, whereas we cannot access the non-static members from a static method. As static methods are not bound to an object, they cannot be overridden. Static fields are initialized through a static block which is executed when the class loader loads a class. Let’s see an example:&nbsp;</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-v1yo3amsy" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">public class Countable {&nbsp;
private static int count; private int x; static {&nbsp;
count = 0; // initialize static member }&nbsp;public Countable(int x) {&nbsp;
this.x = x; Count++; // non-static can access static member }&nbsp;public int getX() {&nbsp;return x; }&nbsp;public static int getCount() {&nbsp;
return count; // only static can access static member } }&nbsp;Countable c1 = new Countable(10);&nbsp;
Countable c2 = new Countable(20); System.out.println("Object count " + Countable.getCount());&nbsp;
// should print 2 </pre></div></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">10. What is the difference between an ArrayList and LinkedList?</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p>ArrayList and LinkedList both represent a list of numbers but differ in their internal implementation. ArrayList uses an array internally to store the elements added to it. When the number of elements is about to exceed the size of the array, it allocates a new array and copies the elements to the new location. It gives constant time access to add (if it doesn’t need to expand) and get an element, but for deletion, it gives linear time complexity as it needs to shift its elements to the left. LinkedList, on the other hand, maintains a sequence of linked nodes internally for storing the elements. So, retrieves an element in linear time whereas addition and deletion take a constant time to execute.</p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">11. What is the difference between a HashTable and a HashMap?</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p>HashTable and HashMap both store key-value pairs and take a constant time to put or get operations. However, Hashtable is synchronized and can be shared to get modified by multiple threads while HashMap is not synchronized and performs better, but not suitable for the multithreaded environment as a shared object. HashTable doesn’t allow Null keys or values, bur a HashMap allows a Null key and more than one Null values.</p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">12. How a value is retrieved from a HashMap?</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p>For retrieval or storing a value, a HashMap uses two methods of its Key class -&nbsp;hashCode()&nbsp;and&nbsp;equals(). HashMap stores its entries in a large collection of buckets which can be randomly accessed using an index. To retrieve a value, first, the&nbsp;hashCode()&nbsp;method of the Key is invoked to get the hash value. This hash value is used to identify the bucket where the value would be retrieved from. While storing an entry, there might be some scenario where the calculated hash value is the same for more than one keys. This results in to enter multiple key-value pairs in the same bucket.&nbsp;</p><p>A bucket keeps its entries as a Linked List. So, while retrieving, after finding out the appropriate bucket, this linked list needs to be traversed to find the actual entry for the key. This time, the equals() method is used to compare the key of each entry in the list. Once it finds a key equal, the value from the entry is returned. There is a contract between these two methods which says if two objects are equal based on equals() method, their hashCode() value must be the same. So, if we plan to use objects of a class as the key of a HashMap, we should override both the methods - hashCode() and equals() so that this contract is maintained.&nbsp;</p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">13. What is public static void main(String args[]) in Java</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>The public static void main(String args[]) is the main method of the Java Program. It is the entry point of any Java Program. A Java program cannot be executed without the main method.</p><p>The syntax of the main method is as follows:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-46z8t2duq" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">public static void main(String args[])</pre></div></div><p>Only the args can be changed to a different name but the rest of the method carries the same syntax.</p><p>Let us analyze the main method by breaking it up:</p><ul><li class="CertTheme__listItem pt-spacing10"><strong>public</strong>: This is the access specifier/access modifier of the main method. It should be public to allow the class to access it. In case of violation of the same, the program will show an error.</li><li class="CertTheme__listItem pt-spacing10"><strong>static</strong>: At the start of the runtime, the class is devoid of any object. Thus, the main method needs to be static so that the Java Virtual Machine can set the class to the memory and call the main method. If the main method is not static then the JVM won’t be able to call it due to the absence of an object.</li><li class="CertTheme__listItem pt-spacing10"><strong>void</strong>: It is the return type of the main method. Each and every method in Java must have a return type. The main method doesn’t return any value that can be accessed by the other methods as the main method can’t be called in any other method. As soon as the main method finishes its execution the program terminates. Hence it wouldn’t be of any use to return a value.</li><li class="CertTheme__listItem pt-spacing10"><strong>main</strong>: It is the name of the main method. This name is already set and can’t be changed. If any changes are made to the main keyword then the compiler tells that the main method couldn’t be found.</li><li class="CertTheme__listItem pt-spacing10"><strong>String args[]</strong> : &nbsp;The main method can accept a single argument which is of the String type. They are also called command line arguments. They can be used and manipulated as normal arguments in the code written in the main method. They are written along with the execution statement.</li></ul><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">14. What are Wrapper Classes in Java?</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>Wrapper classes are predefined classes in Java whose objects have primitive data types. They convert primitive data types into objects and vice versa. The Wrapper Classes provide a new angle to Java which helps it put a strong foot forward against its contemporaries. Data Structures in a collection framework can store only objects and not primitive data types. They provide synchronization during multithreading. They are defined in the java.lang package.</p><p>They are converted to primitive data types and vice versa by the process of boxing and unboxing.</p><p>Typically, there are eight wrapper classes. They are linked to the primitive data types as follows:</p><div class="overflow-x-auto mt-spacing10 mb-[16.8px] md:mb-6 max-w-full"><table class="min-w-full divide-y divide-gray-200 border"><thead><tr><th class="CertTheme__tableCell CertTheme__tableCellHeader" style="border:1px solid black;width:175px;vertical-align:top;text-align:start;background-color:rgb(242, 243, 245)">Primitive Data types</th><th class="CertTheme__tableCell CertTheme__tableCellHeader" style="border:1px solid black;width:175px;vertical-align:top;text-align:start;background-color:rgb(242, 243, 245)">Wrapper Classes</th></tr></thead><tbody><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">&nbsp;byte</td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">&nbsp;Byte</td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">short</td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Short</td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">int</td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Integer</td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">long</td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Long</td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">char</td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Character</td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">bool</td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Boolean</td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">float</td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Float</td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">double</td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Double</td></tr></tbody></table></div><p>Now let us discuss about the wrapper classes:</p><ul><li class="CertTheme__listItem pt-spacing10"><strong>Byte</strong>: It wraps a primitive byte data type in an object. Its object contains a single field of type byte.</li><li class="CertTheme__listItem pt-spacing10"><strong>Character</strong>: It wraps a char primitive data type in an object. An object of type Character contains a single field, whose type is char.</li><li class="CertTheme__listItem pt-spacing10"><strong>Short</strong>: The short class wraps a primitive short type value in an object. Its object contains only a single field whose type is short.</li><li class="CertTheme__listItem pt-spacing10"><strong>Integer</strong>: The Integer class wraps a primitive int type value in an object. Its object contains only a single field whose type is int.</li><li class="CertTheme__listItem pt-spacing10"><strong>Long</strong>: &nbsp;The Long class generally wraps the primitive data type long into an object. An object of Long class contains a field with the type Long.</li><li class="CertTheme__listItem pt-spacing10"><strong>Float</strong>: The Float class wraps a primitive float type value in an object. Its object contains only a single field whose type is float.</li><li class="CertTheme__listItem pt-spacing10"><strong>Double</strong>: The Double class wraps a primitive double type value in an object. Its object contains only a single field whose type is double. This class is useful in providing various methods like a method which can be used to convert a double to a String and vice versa.</li><li class="CertTheme__listItem pt-spacing10"><strong>Boolean</strong>: It wraps a primitive boolean data type ‘bool’ in an object. Its object contains only a single parameter which is either true or false.</li></ul><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">15. Local and Instance Variable in Java</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p><strong>Local Variable</strong> in Java is a variable declared in a method body or a constructor or a block (for example for loop) and its scope lies within the method or constructor or the block.</p><p>The scope of the local variables starts from its declaration and ends when the block or method body or the constructor ends by the closing curly brace.</p><p>Access specifiers like public, private, protected can’t be used for declaring local variables.</p><p>They are implemented at the stack level internally.</p><p><strong>Instance Variables&nbsp;</strong>in Java is a data member of a class and is defined in a class.</p><p>Each object can create its own copy of the instance variable and access it separately.</p><p>The instance variables are visible for all methods, constructors and block in the class. They can be accessed directly by calling the variable name inside the class. Any changes made to the instance variables in the methods reflect in the state or value of the variable outside the scope of the method for a particular object.</p><p>The scope of the instance variable is created and destroyed when the objects are created and destroyed respectively.</p><p>Default values are given to instance variables. The default value is 0 for integers, floats, doubles and bytes, it is false for Boolean and null for object references.</p><p>They cannot be declared as static otherwise they’ll be classified as static variables.</p><p>If instance and local variables have the same name then ‘this’ keyword is used to differentiate among them.</p><p>An example program to illustrate the use of Local as well as Instance variables is given as follows.</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-ezmwja7ry" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">public class Example
{
&nbsp; &nbsp;int a=5; // a is an instance variable
&nbsp; &nbsp;public void add(int n)
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;int sum = a + n; // sum is a local variable
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println(sum); &nbsp;//accessing local variable
&nbsp; &nbsp;}
&nbsp; &nbsp;public static void main(String[] args)
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;int k=11;
&nbsp; &nbsp; &nbsp; &nbsp;Example obj= new Example(); // creating object for Example class
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println(obj.a); // accessing instance variable
&nbsp; &nbsp; &nbsp; &nbsp;obj.add(k);
&nbsp; &nbsp;}
}</pre></div></div><p>The given program produces the following output:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-56pusohir" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">$javac Example.java
$java Example
5
16</pre></div></div><p>Here, a is the instance variable while sum<strong>&nbsp;</strong>is the local variable.</p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">16. Abstract Classes vs Interfaces</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>Abstract class and Interface both are used for abstraction which is hiding the background details and representing only the essential features. But there are major differences between abstract classes and interfaces. These are given as follows:</p><div class="overflow-x-auto mt-spacing10 mb-[16.8px] md:mb-6 max-w-full"><table class="min-w-full divide-y divide-gray-200 border"><thead><tr><th class="CertTheme__tableCell CertTheme__tableCellHeader" style="border:1px solid black;width:175px;vertical-align:top;text-align:start;background-color:rgb(242, 243, 245)">Parameter<br></th><th class="CertTheme__tableCell CertTheme__tableCellHeader" style="border:1px solid black;width:175px;vertical-align:top;text-align:start;background-color:rgb(242, 243, 245)">Abstract Classes<br></th><th class="CertTheme__tableCell CertTheme__tableCellHeader" style="border:1px solid black;width:175px;vertical-align:top;text-align:start;background-color:rgb(242, 243, 245)">&nbsp;Interfaces<br></th></tr></thead><tbody><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Instance Variables<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Can have instance variables<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Cannot have instance variables<br></td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Visibility<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Can have any visibility:public, private or protected<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Have either public visibility or no visibility<br></td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Nature of methods<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Can have both abstract as well as non-abstract methods<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Only have abstract methods<br></td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Constructors<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Can have constructors<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Cannot have constructors<br></td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Association<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Can be extended by using keywords ‘extends’<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Can be implemented by using keyword ‘implements’<br></td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Nature of Association by Java class<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">A Java class can extend only one abstract class<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">A Java class can implement multiple interfaces<br></td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Provision of code<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Can provide complete code<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Just provide the signature/prototype<br></td></tr></tbody></table></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">17. What is a WAR file in Java?</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p>WAR stands for Web Application Resource or Web Application Archive. It finds its application in distribution of a collection of JAR(Java Archive) Files, Java Server Pages, Java Servlets, Java Classes, XML files, tag libraries, static web pages, and other resources that constitute a web Application.</p><p>WAR files have the file extension .war. These are extended from JAR files.</p><p>So, a .war is a .jar, but it contains web application components and is laid out according to a specific structure. A .war is designed to be deployed to a web application server such as Tomcat or Jetty or a Java EE server such as JBoss or Glassfish.</p><p>The primary advantage of a .war file is it combines all files into a single unit which reduces the transfer time from client to server.</p><p>To create a war file, we need to use the jar tool of the Java Development Kit. Go inside the project directory of your project, then write the following command:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-tg74n908x" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">jar -cvf yourproject.war *</pre></div></div><p>The -c switch is used to create file, -v is used to generate the verbose output and -f switch is used to specify the archive name of the file.</p><p>During Java runtime, verbose options can be used to tell the JVM which kind of information to see. JVM supports three verbose options out of the box. As the name suggests, verbose is for displaying the work done by JVM.</p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">18. Method Overloading vs Overriding</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p>In <strong>Method Overloading</strong>, the names of the methods in the same class are same but the arguments (type and/or number) are different.<br>In <strong>Method Overriding,&nbsp;</strong>the names and arguments of the methods are same but one of the methods is in the super class while the other is in the sub class.</p><div class="overflow-x-auto mt-spacing10 mb-[16.8px] md:mb-6 max-w-full"><table class="min-w-full divide-y divide-gray-200 border"><thead><tr><th class="CertTheme__tableCell CertTheme__tableCellHeader" style="border:1px solid black;width:175px;vertical-align:top;text-align:start;background-color:rgb(242, 243, 245)">Basis<br></th><th class="CertTheme__tableCell CertTheme__tableCellHeader" style="border:1px solid black;width:175px;vertical-align:top;text-align:start;background-color:rgb(242, 243, 245)">Method Overloading<br></th><th class="CertTheme__tableCell CertTheme__tableCellHeader" style="border:1px solid black;width:175px;vertical-align:top;text-align:start;background-color:rgb(242, 243, 245)">Method Overriding<br></th></tr></thead><tbody><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Arguments<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">The methods in overloading have different arguments.<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">The methods in overriding have similar arguments.<br></td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Polymorphism<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Overloading is a part of compile time polymorphism<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Overriding is a part of run time polymorphism.<br></td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Occurrence<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Happens at compile time.<br>The binding of the overloaded function calls it definition during compile time.<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Happens at runtime. The binding of the overridden function calls its definition during runtime.<br></td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Static Methods<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Static Methods can be overloaded.<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Static methods cannot be overridden.<br></td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Class<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Overloading is done in the same class<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Overriding is done in the parent and child class.<br></td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Type of binding<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Static binding is used for overloaded methods<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Dynamic binding is used for overridden methods<br></td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Performance<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Method Overloading gives better performance as the binding is done during compile time.<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Method Overriding gives less performance as the binding is done during runtime.<br></td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">private methods<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">private methods can be overloaded.<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">private methods cannot be overridden.<br></td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">final methods<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">final methods can be overloaded<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">final methods cannot be overridden.<br></td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Application<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Method overloading is used to increase readability of the program<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Method overriding is used to provide specific<br>implementation of the method<br></td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Return type<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Return type of the methods does not matter during method overloading.<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">In method overriding, the method should have a specific return type.<br></td></tr></tbody></table></div><p><br></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">19. Create a custom exception in Java</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>Expect to come across this popular question in Java basic interview questions.</p><p>Custom Exceptions are nothing but user-defined exceptions. Java custom exceptions are used to make and modify the exception according to the requirements of the user.</p><p>Before creating a custom exception, let us look at its prerequisites</p><ul><li class="CertTheme__listItem pt-spacing10">All exceptions that are created must be a subclass of the Throwable class</li><li class="CertTheme__listItem pt-spacing10">Use the extends keyword and extend the Exception class</li><li class="CertTheme__listItem pt-spacing10">If you want to write a runtime exception, you need to extend the RuntimeException class.</li></ul><p>Let us now create a parent custom exception which generates an exception if a number is not divisible by 3:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-vhkp0f42o" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">class CustomException extends Exception
{ &nbsp;
&nbsp;CustomException(String errormsg)
&nbsp;{
&nbsp; &nbsp;super(errormsg); &nbsp;
&nbsp;}
} &nbsp;
public class Example
{ &nbsp;
&nbsp; static void validate(int num)throws CustomException
&nbsp;{
&nbsp; &nbsp; if(num%3!=0) &nbsp;
&nbsp; &nbsp; &nbsp;throw new CustomException("Not divisible by 3"); &nbsp;
&nbsp; &nbsp; else
&nbsp; &nbsp; &nbsp;System.out.println("Divisible by 3"); &nbsp;
&nbsp; }
&nbsp; public static void main(String args[])
&nbsp; {
&nbsp; &nbsp; &nbsp;try
&nbsp; &nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp;validate(10); &nbsp;
&nbsp; &nbsp; &nbsp;}
&nbsp; &nbsp; &nbsp;catch(Exception e)
&nbsp; &nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; System.out.println("Exception caught: "+e);
&nbsp; &nbsp; &nbsp;}
&nbsp; &nbsp; &nbsp;System.out.println("Outside the try-catch block"); &nbsp;
&nbsp;}
} &nbsp;</pre></div></div><p><strong>The output for the above program is as follows:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-to1k5tbor" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">$javac Example.java
$java Example
Exception caught: CustomException: Not divisible by 3
Outside the try-catch block</pre></div></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">20. Default switch case in Java</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p>A switch statement is a decision making statement in Java. It is used to check a variable’s equality against a list of values and their subsequent statements. It is a multiway branch statement.</p><p>Each condition is called a case and the variable is checked for each case.</p><p>Syntax for switch case:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-i0t1hmf10" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">switch(expression)
{
&nbsp; case value1 :
&nbsp; &nbsp; &nbsp;// Statements
&nbsp; &nbsp; &nbsp;break; // optional
&nbsp;
&nbsp; case value2 :
&nbsp; &nbsp; &nbsp;// Statements
&nbsp; &nbsp; &nbsp;break; // optional
&nbsp; &nbsp; &nbsp; .
&nbsp; &nbsp; &nbsp; .
&nbsp; &nbsp; &nbsp; .
&nbsp; &nbsp; &nbsp; .
&nbsp; &nbsp;default : // This is the default switch case
&nbsp; &nbsp; &nbsp;// Statements
}</pre></div></div><p>The <strong>default statement</strong> is optional, and can appear anywhere inside the <strong>switch</strong> block.<br><br>If there is no match with a constant expression, the statement associated with the <strong>default</strong> keyword is executed. If the <strong>default</strong> keyword is not used, control passes to the statement following the switch block.</p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">21. Exception vs Error in Java</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p><strong>Errors&nbsp;</strong>in Java are a part of the java.lang.error class. <strong>Exceptions&nbsp;</strong>in Java a part of the java.lang.Exception class. Both are a part of the <strong>java.lang.Throwable</strong> class.</p><div class="overflow-x-auto mt-spacing10 mb-[16.8px] md:mb-6 max-w-full"><table class="min-w-full divide-y divide-gray-200 border"><thead><tr><th class="CertTheme__tableCell CertTheme__tableCellHeader" style="border:1px solid black;width:175px;vertical-align:top;text-align:start;background-color:rgb(242, 243, 245)">Basis<br></th><th class="CertTheme__tableCell CertTheme__tableCellHeader" style="border:1px solid black;width:175px;vertical-align:top;text-align:start;background-color:rgb(242, 243, 245)">Errors<br></th><th class="CertTheme__tableCell CertTheme__tableCellHeader" style="border:1px solid black;width:175px;vertical-align:top;text-align:start;background-color:rgb(242, 243, 245)">Exceptions<br></th></tr></thead><tbody><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Type<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Errors in Java are of the unchecked type.<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Exceptions in Java are both of the checked and unchecked type.<br></td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Occurrence<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Errors occur at the run time and are oblivious to knowledge of the compiler.<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Exceptions also occur at run time but checked exceptions are known to the compiler.<br></td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Class<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">They’re defined in java.lang.Error class<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">They’re a part of the java.lang.Exception class<br></td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Dependency<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">They are caused by the environment in which the compiler is run.<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">The program is solely responsible for generation of exceptions.<br></td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Recovery<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Recovery from an error is impossible.<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Recovery from exceptions is possible through try-catch blocks.<br></td></tr></tbody></table></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">22. What is the difference between a=a+b and a+=b</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>The <strong>a=a+b</strong> statement has an assignment operator = and a arithmetic operator + while <strong>a+=b</strong> has a arithmetic assignment operator +=. Apart from this there is only a slight difference between the two.</p><p>For similar integer or byte or float data types both the expressions would compile.</p><p>But if one value(a) is byte and the other(b) is int, <strong>a=a+b</strong> will not compile as <strong>byte+int</strong> is not byte</p><p>On the other hand, a+=b will compile as the arithmetic assignment operator will do an implicit type casting.</p><p>Take for example,</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-pj0yy5bpc" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">public class Example
{
&nbsp; &nbsp;public static void main(String []args)
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;byte a=2;
&nbsp; &nbsp; &nbsp; &nbsp;int b=3;
&nbsp; &nbsp; &nbsp; &nbsp;a=a+b; // generates an error as byte+int=int
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println(a);
&nbsp; &nbsp;}
}</pre></div></div><p>The above program generates an error</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-12e9d3mnt" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">$javac Example.java
Example.java:7: error: incompatible types: possible lossy conversion from int to byte
&nbsp; &nbsp; &nbsp; &nbsp;a=a+b;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ^
1 error</pre></div></div><p>But if we take a+=b</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-qphmukwwu" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">public class Example
{
&nbsp; &nbsp;public static void main(String []args)
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;byte a=2;
&nbsp; &nbsp; &nbsp; &nbsp;int b=3;
&nbsp; &nbsp; &nbsp; &nbsp;a+=b; // compiles
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println(a);
&nbsp; &nbsp;}
}</pre></div></div><p>This code is error free and will generate the following output:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-4a4ufinx2" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">$javac Example.java
$java Example
5</pre></div></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">23. Transient keyword in Java</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p>The <strong>transient&nbsp;</strong>keyword in Java is a variable modifier. It finds its application in serializiation. During serialization, if we don’t want to write the state of the particular variable in the byte stream, we use the transient keyword. When the JVM comes up to the transient keyword, it ignores the original state of the variable and stores a default value of that data type i.e. 0 for int, 0 for byte, 0.0 for float,etc.</p><p>As static variables are also ignored by the JVM, there is no use of writing transient with them though this won’t generate an error.</p><p>As final variables are directly serialized by their values, there is no use of making them transient although this would not give a compile time error.</p><p>The transient keyword is useful for security and data hiding. It is a good practice to use the transient keyword with private access specification.</p><p>An example program where the effect of the transient keyword during serialization and deserialization is shown below:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-g0yzc91lq" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">import java.io.*;
public class Example implements Serializable
{
&nbsp; &nbsp;int a = 1, b = 2; &nbsp; &nbsp; &nbsp;// instance variables
&nbsp; &nbsp;transient int c = 3; &nbsp; // transient variable
&nbsp; &nbsp;// transient is rendered affectless with static and final
&nbsp; &nbsp;transient final int d = 4;
&nbsp; &nbsp;transient static int e = 5;
&nbsp; &nbsp;public static void main(String[] args) throws Exception
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;Example input = new Example();
&nbsp; &nbsp; &nbsp; &nbsp;// serialization
&nbsp; &nbsp; &nbsp; &nbsp;FileOutputStream fo = new FileOutputStream("example_file.txt");
&nbsp; &nbsp; &nbsp; &nbsp;ObjectOutputStream obj = new ObjectOutputStream(fo);
&nbsp; &nbsp; &nbsp; &nbsp;obj.writeObject(input);
&nbsp; &nbsp; &nbsp; &nbsp;// de-serialization
&nbsp; &nbsp; &nbsp; &nbsp;FileInputStream fi = new FileInputStream("example_file.txt");
&nbsp; &nbsp; &nbsp; &nbsp;ObjectInputStream o = new ObjectInputStream(fi);
&nbsp; &nbsp; &nbsp; &nbsp;Example x = (Example)o.readObject();
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println("a = " + x.a);
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println("b = " + x.b);
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println("c = " + x.c);
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println("d = " + x.d); &nbsp;&nbsp;
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println("e = " + x.e);
&nbsp; &nbsp;}
}</pre></div></div><p><strong><span style="color:rgb(0, 0, 0)">The output of the program is:</span></strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-u9lhpy4fv" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">$javac Example.java
$java Example
a = 1
b = 2
c = 0
d = 4
e = 5</pre></div></div><p>We can notice that the transient variable c has been set to its default value i.e. 0 while there is no change in the final, static and the instance variables.</p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">24. Usage of Final keyword in Java</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>The <strong>final&nbsp;</strong>keyword is a type of modifier in Java. It is of the non-access type. It can only be applied to a variable, method or a class.</p><p>Class that are final cannot be extended. Methods that are final cannot be used for method overriding in child class.</p><p>The final variables have constant value which are not changeable throughout the program. This means they need to be initialized along with their declaration, otherwise they would be blank final variables, which can be later initialized only once. If a final variable is used as a reference to an object, it cannot be used as a reference to another object.</p><p><br>1. If we try to change the value of the final variable, it will generate an error:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-9t0erf9s8" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm"> public class Example &nbsp;
{&nbsp;
&nbsp; &nbsp; static final int x=10;&nbsp;
&nbsp; &nbsp; &nbsp;&nbsp;
&nbsp; &nbsp; public static void main(String args[])&nbsp;
&nbsp; &nbsp; {&nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;x = 5; // re-assignment of final variable
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;System.out.println(x);
&nbsp; &nbsp; }&nbsp;
}</pre></div></div><p>This program will generate a compile time error</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-7oepd1j40" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">$javac Example.java
Example.java:9: error: cannot assign a value to final variable x
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;x= 5;&nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;^
1 error</pre></div></div><p>2. If we try to inherit a final class in a subclass, the compiler will show an error.</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-sikyq9ukh" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">final class Superclass
{
static int x=5;
}
public class Example extends Superclass
{ &nbsp;
&nbsp; &nbsp;public static void main(String []args)
&nbsp; &nbsp;{
&nbsp; &nbsp; System.out.println(x);
&nbsp; &nbsp;}
}</pre></div></div><p>The error message is as follows:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-zwnvborey" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">$javac Example.java
Example.java:5: error: cannot inherit from final Superclass
public class Example extends Superclass
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;^
1 error</pre></div></div><p>3. If we try to override a final class, it will generate an error:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-e75k8di8p" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">class Superclass
{
&nbsp;int x=5;
&nbsp;final void add()
{
&nbsp; &nbsp; int j=x+5;
&nbsp; &nbsp; System.out.println(j);
}
}
public class Example extends Superclass
{ &nbsp;
&nbsp; &nbsp;void add()
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;int a=5,b=10;
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println(a+b);
&nbsp; &nbsp;}
&nbsp; &nbsp;public static void main(String []args)
&nbsp; &nbsp;{
&nbsp; &nbsp; Example e=new Example();
&nbsp; &nbsp; e.add();
&nbsp; &nbsp;}
}</pre></div></div><p>The error generated is as follows</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-sn8y9ndio" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">$javac Example.java
Example.java:12: error: add() in Example cannot override add() in Superclass
&nbsp; &nbsp;void add()
&nbsp; &nbsp; &nbsp; &nbsp; ^
&nbsp;overridden method is final
1 error</pre></div></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">25. What does “static” mean in public static void main(String args[])?</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>The public static void main(String args[]) is the main method of the Java Program. It is the most important Java Method. It is the entry point of any Java Program. A Java Program cannot be executed without the main method.</p><p>The static keyword acts as an access modifier. When the Java Virtual Machine calls out to the main method, it has no object to call to. Hence, we use static to permit its call from the class.</p><p>If we do not use static in public static void main(String args[]), then the compiler will give an error message.</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-ma1flp68d" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">public class Example
{
&nbsp; &nbsp;public void main(String args[])
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println("Hello");
&nbsp; &nbsp;}
}</pre></div></div><p><strong>The output window is as follows</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-vqz29an3i" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">$javac Example.java
$java Example
Error: Main method is not static in class Example, please define the main method as:
&nbsp; public static void main(String[] args)</pre></div></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">26. ByteCode in Java</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p>During compile time, the Java Compiler converts the Source Code into the ByteCode.</p><p>ByteCode is a highly developed set of instructions given to the Java Virtual Machine to generate the machine code. It is the machine code in the form of the .class file. Analogies can be made to the assembler in C++. It is called ByteCode because each instruction is of 1-2 bytes.</p><p>One of the main features in Java which distinguishes it from other Object-Oriented Languages is that it is Platform Independent. This Platform Independence is achieved through the Java ByteCode.</p><p>The components required to execute the bytecode are provided by the Java Virtual Machine, which invocates the processor to allot the needed resources. JVMs are based on stacks so they implement stacks to read and process the bytecode.</p><p>Some ByteCode instructions are as follows:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-80l4aghfs" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">1: istore_1
2: iload_1
3: sipush 1000
6: if_icmpge 44
9: iconst_2
10: istore_2</pre></div></div><p>The Code Segment is the memory segment that holds the ByteCode.</p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">27. Constructor vs Method</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>The following is the difference:</p><div class="overflow-x-auto mt-spacing10 mb-[16.8px] md:mb-6 max-w-full"><table class="min-w-full divide-y divide-gray-200 border"><thead><tr><th class="CertTheme__tableCell CertTheme__tableCellHeader" style="border:1px solid black;width:175px;vertical-align:top;text-align:start;background-color:rgb(242, 243, 245)">Basis</th><th class="CertTheme__tableCell CertTheme__tableCellHeader" style="border:1px solid black;width:175px;vertical-align:top;text-align:start;background-color:rgb(242, 243, 245)">Constructor</th><th class="CertTheme__tableCell CertTheme__tableCellHeader" style="border:1px solid black;width:175px;vertical-align:top;text-align:start;background-color:rgb(242, 243, 245)">Method</th></tr></thead><tbody><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Return type</td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Constructors in Java have no return type, not even void.</td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Methods in Java always return a value or they are void</td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Nomenclature</td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Constructors have same name as the class</td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Methods have any other legal name apart from the class name</td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Relation with Objects</td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Constructors are used to initialize the state of the object</td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Methods are used to show the behavior of the object</td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Overriding</td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Constructor overriding is not possible in Java</td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Method Overriding is possible in Java</td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Static</td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Constructors can never be declared as static</td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Methods can be declared as static</td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Invocation</td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Constructors are only invoked when an object is created using the ‘new’ keyword</td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Methods are invoked by a class name,their own name or by an object.</td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Execution</td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Constructors will be executed only one time per object</td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Methods can be executed a number of time per object</td></tr></tbody></table></div><p>An example program to show the use of constructor and method is as follows:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-8lmprxrq8" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">public class Example
{
&nbsp; &nbsp;Example()
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println("You are in a constructor");
&nbsp; &nbsp;}
&nbsp; &nbsp;public void print()
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println("You are in a method");
&nbsp; &nbsp;}
&nbsp; &nbsp;public static void main(String []args)
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;Example e = new Example();
&nbsp; &nbsp; &nbsp; &nbsp;e.print();
&nbsp; &nbsp;}
}</pre></div></div><p>The output for the following is as follows:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-8xfxb2wgk" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">$javac Example.java
$java Example
You are in a constructor
You are in a method</pre></div></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">28. Compile-time vs Runtime Polymorphism in Java</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>The following is the comparison:</p><div class="overflow-x-auto mt-spacing10 mb-[16.8px] md:mb-6 max-w-full"><table class="min-w-full divide-y divide-gray-200 border"><thead><tr><th class="CertTheme__tableCell CertTheme__tableCellHeader" style="border:1px solid black;width:175px;vertical-align:top;text-align:start;background-color:rgb(242, 243, 245)">Basis</th><th class="CertTheme__tableCell CertTheme__tableCellHeader" style="border:1px solid black;width:175px;vertical-align:top;text-align:start;background-color:rgb(242, 243, 245)">Compile-time Polymorphism</th><th class="CertTheme__tableCell CertTheme__tableCellHeader" style="border:1px solid black;width:175px;vertical-align:top;text-align:start;background-color:rgb(242, 243, 245)">Run-time Polymorphism</th></tr></thead><tbody><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Definition</td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start"><br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start"><br></td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Alternate name</td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Compile-time Polymorphism is also known as Static Polymorphism</td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Runtime Polymorphism is also known as Dynamic Polymorphism</td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Occurrence</td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">It occurs during compile time</td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">It occurs during runtime</td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Implementation</td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">It is implemented through Method Overloading</td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">It is implemented through Method Overriding</td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Speed</td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Method Execution is quicker</td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Method Execution is slower</td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Feature</td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">It increases the readability of the program</td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">It provides specific implementation to the program</td></tr></tbody></table></div><p>An example for the implementation of compile time polymorphism using method overloading is given below:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-gfkceelu9" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">class Overload
{
&nbsp; &nbsp;public void display(char c)
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp; System.out.println(c);
&nbsp; &nbsp;}
&nbsp; &nbsp;public void display(char c, int num) &nbsp;
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp; System.out.println(c + " "+num);
&nbsp; &nbsp;}
}
public class Example
{
&nbsp; public static void main(String args[])
&nbsp; {
&nbsp; &nbsp; &nbsp; Overload obj = new Overload();
&nbsp; &nbsp; &nbsp; obj.display('s');
&nbsp; &nbsp; &nbsp; obj.display('s',12);
&nbsp; }
}</pre></div></div><p>The output of the above program is:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-ltrhc2x5b" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">$javac Example.java
$java Example
s
s 12</pre></div></div><p>An example for the implementation of run-time polymorphism using method overriding is given as follows:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-11k22vpvt" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">class SuperClass
{
&nbsp; &nbsp;void display() { System.out.println("SuperClass"); }
}
class SubClass extends SuperClass
{
&nbsp; &nbsp;void display()
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println("Subclass");
&nbsp; &nbsp;}
}
public class Example
{
&nbsp; &nbsp;public static void main(String[] args)
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;SuperClass obj1 = new SuperClass();
&nbsp; &nbsp; &nbsp; &nbsp;obj1.display();
&nbsp; &nbsp; &nbsp; &nbsp;SuperClass obj2 = new SubClass();
&nbsp; &nbsp; &nbsp; &nbsp;obj2.display();
&nbsp; &nbsp;}
}</pre></div></div><p><strong>The output is as follows:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-hjco1gqjz" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">$javac Example.java
$java Example
SuperClass
Subclass</pre></div></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">29. String Pool in Java</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>String Pool in Java is a pool or collection of Strings stored in the Java Heap Memory. When initialize a String using double quotes, it first searches for String with same value in the String pool. If it matches, it just returns the reference otherwise, it generates a new String in the String pool and then it returns its reference.</p><p>The possibility of the String Pool exists only due to the immutability of the String in Java.</p><p>In case of the creation of String using the <strong>new&nbsp;</strong>operator, the String class is entitled to create a new String in the String Pool.</p><p>For example,</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-y8jx5xvi5" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">public class Example
{
&nbsp; &nbsp;public static void main(String[] args)
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;String s1 = "Hello";
&nbsp; &nbsp; &nbsp; &nbsp;String s2 = "Hello";
&nbsp; &nbsp; &nbsp; &nbsp;String s3 = new String("Hello");
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println("Do s1 and s2 have the same address? "+ (s1==s2));
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println("Do s1 and s2 have the same address? "+ (s1==s3));
&nbsp; &nbsp;}
}</pre></div></div><p>The output will show that s1 and s2 have the same address due to implementation of String Pool. String s3 though will have a different address due to the use of the new keyword.</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-3fh7lyg00" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">$javac Example.java
$java Example
Do s1 and s2 have the same address? true
Do s1 and s2 have the same address? false</pre></div></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">30. If I write System.exit(0); at the end of the try block, will the finally block still execute?</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>No, the finally block will not execute. The System.exit() method is a predefined method of the java.lang package. It exits the current program by termination of the running of Java Virtual Machine.</p><p>The System.exit() method has a status code represented by an integer value. Usually the status code is 0. A non-zero status code means unusual termination of the Java program.</p><p>The syntax for the exit method in the java.lang package is as follows is as follows</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-2ysgwbced" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">public static void exit(int status_code);</pre></div></div><p>The finally block in Java usually executes everything irrespective of what is written in the try and catch block. An aberration is made when the System.exit() function is written in the try block.</p><p><strong>For example,</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-xremzq3gf" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">public class Example
{
&nbsp; &nbsp;public static void main(String[] args)
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;try
&nbsp; &nbsp; &nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp; System.out.println("In try block");
&nbsp; &nbsp; &nbsp; &nbsp; System.exit(0);
&nbsp; &nbsp; &nbsp; &nbsp; int a=1/0;
&nbsp; &nbsp; &nbsp; &nbsp;}
&nbsp; &nbsp; &nbsp; &nbsp;catch(ArithmeticException e)
&nbsp; &nbsp; &nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;System.out.println("Exception Caught");
&nbsp; &nbsp; &nbsp; &nbsp;}
&nbsp; &nbsp; &nbsp; &nbsp;finally
&nbsp; &nbsp; &nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;System.out.println("In finally block");
&nbsp; &nbsp; &nbsp; &nbsp;}
&nbsp; &nbsp;}
}</pre></div></div><p><strong>The output is as follows:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-8r44zews0" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">$javac Example.java
$java Example
In try block</pre></div></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">31. When is the constructor of a class invoked?</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>Expect to come across this popular question in Java interview questions experienced.</p><p>The constructor of a class is invoked at the time of object creation. Each time an object is created using the <strong>new</strong> keyword, the constructor gets invoked. The constructor initializes the data members of the same class.</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-tcrbx2s7d" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">class Example
{
&nbsp;Example() // constructor
&nbsp;{
&nbsp; }
}
Example obj=new Example(); // invokes above constructor</pre></div></div><p>A constructor is used to initialize the state of the object. It contains a list of statements that are executed at the time of creation of an object.</p><p>For example,</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-ri9gj3fm4" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">public class Example
{
&nbsp; &nbsp;Example() &nbsp;// constructor of class Example
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println("This is a constructor");
&nbsp; &nbsp;}
&nbsp; &nbsp;public static void main(String []args)
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;Example e=new Example();
&nbsp; &nbsp; &nbsp; &nbsp;// constructor Example() is invoked by creation of new object e &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp;}
}</pre></div></div><p><strong>The output of the above is as follows:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-kzhh0ouoi" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">$javac Example.java
$java Example
This is a constructor</pre></div></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">32. How to differentiate between the size and capacity of a Vector in Java?</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>Vectors in Java are dynamic data structures which can expand when a new element is added to them. They are synchronized and contain many methods that are not a part of the Collections framework in Java.</p><p>Vectors in Java have two methods call size() and capacity() which are in relation with the number of elements of the Vector.</p><p>The size() returns the number of elements the vector is currently holding. It increases or decreases whenever elements are inserted or deleted to/from a vector respectively.</p><p>The capacity()&nbsp;returns the maximum number a elements a vector can hold. Since the vector is an expandable data structure, its capacity is not fixed. We can set the initial value of the capacity.</p><p>The Vector() constructor initializes the initial capacity of the vector to be 10.</p><p>For example,</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-wily1vgwl" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">import java.util.*; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// Vector is a class of the java.util package
public class Example
{
&nbsp;public static void main (String[] args)
&nbsp;{
&nbsp; &nbsp;Vector v = new Vector(); // creating new Vector object
&nbsp; &nbsp;System.out.println("Vector Size: " + v.size()); &nbsp;// prints the current size of the Vector
&nbsp; &nbsp;v.addElement(10);
&nbsp; &nbsp;v.addElement(20);
&nbsp; &nbsp;System.out.println("Vector Size: " + v.size());
&nbsp; &nbsp;v.addElement(5);
&nbsp; &nbsp;System.out.println("Vector Size: " + v.size());
&nbsp; &nbsp;System.out.println("Vector Capacity: " + v.capacity()); &nbsp;//prints the capacity of the vector
&nbsp;}
}</pre></div></div><p><strong>The output will be the following:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-kb4o38jvf" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">$javac Example.java
$java Example
Vector Size: 0
Vector Size: 2
Vector Size: 3
Vector Capacity: 10</pre></div></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">33. The yield method of the Thread Class</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p>The yield()<strong>&nbsp;</strong>method of the Thread class is used to temporarily stop the execution of the thread and carry out the execution.</p><p>For the java.lang.Thread class, the syntax for the yield method is as follows:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-e4i13s6m7" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">public static void yield()</pre></div></div><p>Execution of a thread is prevented by three ways namely yield(), sleep(), join().</p><p>In certain situations where one thread is taking exceedingly more time to complete its execution, we need to find a solution to delay the execution of the thread which completes its execution quickly in between if something important is pending. The yield() provides an answer to this problem.</p><p>For example,</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-730uj36ni" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">import java.lang.*;
class ExampleThread extends Thread
{
&nbsp; &nbsp;public void run()
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;for (int i=0; i&lt;2 ; i++)
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;System.out.println(Thread.currentThread().getName() + " in control");
&nbsp; &nbsp;}
}
public class Example
{
&nbsp; &nbsp;public static void main(String[]args)
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;ExampleThread t = new ExampleThread();
&nbsp; &nbsp; &nbsp; &nbsp;t.start(); &nbsp;// this calls the run() method
&nbsp; &nbsp; &nbsp; &nbsp;for (int i=0; i&lt;2; i++)
&nbsp; &nbsp; &nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Thread.yield();
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;System.out.println(Thread.currentThread().getName() &nbsp;+ " in control");
&nbsp; &nbsp; &nbsp; &nbsp;}
&nbsp; &nbsp;}
}</pre></div></div><p><strong>The output of the above program is:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-gwcuosqdb" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">$javac Example.java
$java Example
Thread-0 in control
Thread-0 in control
main in control
main in control</pre></div></div><p>The output may differ from system to system but the probability of execution of the yield() thread is more.</p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">34. Can try statements be nested in Java?</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p class="CertTheme__paragraph" data-mode="standard"><br></p><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><span>A common basic Java program for interviews, don't miss this one.</span></p><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><span>Yes, try statements can be nested in Java.</span></p><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><span>A try block within a try block is called nested try block.</span></p><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><span>The syntax for a nested try block is as follows:</span></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-gwa6dt0bh" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm"><span class="CertTheme__tokenAttr">try</span><span> &nbsp;</span><span class="CertTheme__tokenComment">// outer try block &nbsp; &nbsp; &nbsp; &nbsp;</span><br><span class="CertTheme__tokenPunctuation">{</span><span> &nbsp;</span><br><span>&nbsp; &nbsp;statements</span><span class="CertTheme__tokenPunctuation">;</span><span> &nbsp;</span><br><span>&nbsp; &nbsp;</span><span class="CertTheme__tokenAttr">try</span><span> &nbsp;</span><span class="CertTheme__tokenComment">// inner try block</span><br><span>&nbsp; &nbsp;</span><span class="CertTheme__tokenPunctuation">{</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp;statements</span><span class="CertTheme__tokenPunctuation">;</span><span> &nbsp;</span><br><span>&nbsp; &nbsp;</span><span class="CertTheme__tokenPunctuation">}</span><br><span>&nbsp; &nbsp;</span><span class="CertTheme__tokenAttr">catch</span><span class="CertTheme__tokenPunctuation">(</span><span>Exception e</span><span class="CertTheme__tokenPunctuation">)</span><span> &nbsp;</span><span class="CertTheme__tokenComment">// inner catch block</span><br><span>&nbsp; &nbsp;</span><span class="CertTheme__tokenPunctuation">{</span><br><span>&nbsp; &nbsp;</span><span class="CertTheme__tokenPunctuation">}</span><br><span class="CertTheme__tokenPunctuation">}</span><span> &nbsp;</span><br><span class="CertTheme__tokenAttr">catch</span><span class="CertTheme__tokenPunctuation">(</span><span>Exception x</span><span class="CertTheme__tokenPunctuation">)</span><span> &nbsp;</span><span class="CertTheme__tokenComment">// outer catch block</span><br><span class="CertTheme__tokenPunctuation">{</span><span> &nbsp;</span><br><span class="CertTheme__tokenPunctuation">}</span></pre></div></div><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><span>The following is an example for nested try block:</span></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-fr72rw8cy" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm"><span class="CertTheme__tokenAttr">public</span><span> </span><span class="CertTheme__tokenAttr">class</span><span> </span><span class="CertTheme__tokenFunction">Example</span><br><span class="CertTheme__tokenPunctuation">{</span><br><span>&nbsp; &nbsp; </span><span class="CertTheme__tokenAttr">public</span><span> </span><span class="CertTheme__tokenAttr">static</span><span> </span><span class="CertTheme__tokenAttr">void</span><span> </span><span class="CertTheme__tokenFunction">main</span><span class="CertTheme__tokenPunctuation">(</span><span>String</span><span class="CertTheme__tokenPunctuation">[</span><span class="CertTheme__tokenPunctuation">]</span><span> args</span><span class="CertTheme__tokenPunctuation">)</span><br><span>&nbsp; &nbsp; </span><span class="CertTheme__tokenPunctuation">{</span><br><span>&nbsp; &nbsp; &nbsp; int</span><span class="CertTheme__tokenPunctuation">[</span><span class="CertTheme__tokenPunctuation">]</span><span> n</span><span class="CertTheme__tokenOperator">=</span><span class="CertTheme__tokenPunctuation">{</span><span class="CertTheme__tokenProperty">1</span><span class="CertTheme__tokenPunctuation">,</span><span class="CertTheme__tokenProperty">2</span><span class="CertTheme__tokenPunctuation">,</span><span class="CertTheme__tokenProperty">3</span><span class="CertTheme__tokenPunctuation">,</span><span class="CertTheme__tokenProperty">4</span><span class="CertTheme__tokenPunctuation">,</span><span class="CertTheme__tokenProperty">5</span><span class="CertTheme__tokenPunctuation">,</span><span class="CertTheme__tokenProperty">6</span><span class="CertTheme__tokenPunctuation">}</span><span class="CertTheme__tokenPunctuation">;</span><br><span>&nbsp; &nbsp; &nbsp; int</span><span class="CertTheme__tokenPunctuation">[</span><span class="CertTheme__tokenPunctuation">]</span><span> d</span><span class="CertTheme__tokenOperator">=</span><span class="CertTheme__tokenPunctuation">{</span><span class="CertTheme__tokenProperty">1</span><span class="CertTheme__tokenPunctuation">,</span><span class="CertTheme__tokenProperty">2</span><span class="CertTheme__tokenPunctuation">,</span><span class="CertTheme__tokenProperty">0</span><span class="CertTheme__tokenPunctuation">,</span><span class="CertTheme__tokenProperty">3</span><span class="CertTheme__tokenPunctuation">}</span><span class="CertTheme__tokenPunctuation">;</span><br><span>&nbsp; &nbsp; &nbsp; </span><span class="CertTheme__tokenAttr">for</span><span class="CertTheme__tokenPunctuation">(</span><span>int i</span><span class="CertTheme__tokenOperator">=</span><span class="CertTheme__tokenProperty">0</span><span class="CertTheme__tokenPunctuation">;</span><span>i</span><span class="CertTheme__tokenOperator">&lt;</span><span>n</span><span class="CertTheme__tokenPunctuation">.</span><span>length</span><span class="CertTheme__tokenPunctuation">;</span><span>i</span><span class="CertTheme__tokenOperator">++</span><span class="CertTheme__tokenPunctuation">)</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="CertTheme__tokenPunctuation">{</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span class="CertTheme__tokenAttr">try</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="CertTheme__tokenPunctuation">{</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="CertTheme__tokenAttr">try</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="CertTheme__tokenPunctuation">{</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;System</span><span class="CertTheme__tokenPunctuation">.</span><span>out</span><span class="CertTheme__tokenPunctuation">.</span><span class="CertTheme__tokenFunction">println</span><span class="CertTheme__tokenPunctuation">(</span><span>n</span><span class="CertTheme__tokenPunctuation">[</span><span>i</span><span class="CertTheme__tokenPunctuation">]</span><span class="CertTheme__tokenOperator">+</span><span class="CertTheme__tokenSelector">"/"</span><span class="CertTheme__tokenOperator">+</span><span>d</span><span class="CertTheme__tokenPunctuation">[</span><span>i</span><span class="CertTheme__tokenPunctuation">]</span><span class="CertTheme__tokenOperator">+</span><span class="CertTheme__tokenSelector">"="</span><span class="CertTheme__tokenOperator">+</span><span>n</span><span class="CertTheme__tokenPunctuation">[</span><span>i</span><span class="CertTheme__tokenPunctuation">]</span><span class="CertTheme__tokenOperator">/</span><span>d</span><span class="CertTheme__tokenPunctuation">[</span><span>i</span><span class="CertTheme__tokenPunctuation">]</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">;</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span class="CertTheme__tokenPunctuation">}</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span class="CertTheme__tokenAttr">catch</span><span class="CertTheme__tokenPunctuation">(</span><span>ArithmeticException e</span><span class="CertTheme__tokenPunctuation">)</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span class="CertTheme__tokenPunctuation">{</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;System</span><span class="CertTheme__tokenPunctuation">.</span><span>out</span><span class="CertTheme__tokenPunctuation">.</span><span class="CertTheme__tokenFunction">println</span><span class="CertTheme__tokenPunctuation">(</span><span class="CertTheme__tokenSelector">"Division by zero not Possible"</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">;</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span class="CertTheme__tokenPunctuation">}</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="CertTheme__tokenPunctuation">}</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="CertTheme__tokenAttr">catch</span><span class="CertTheme__tokenPunctuation">(</span><span>ArrayIndexOutOfBoundsException e</span><span class="CertTheme__tokenPunctuation">)</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="CertTheme__tokenPunctuation">{</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; System</span><span class="CertTheme__tokenPunctuation">.</span><span>out</span><span class="CertTheme__tokenPunctuation">.</span><span class="CertTheme__tokenFunction">println</span><span class="CertTheme__tokenPunctuation">(</span><span class="CertTheme__tokenSelector">"Array Index is out of bounds"</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">;</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="CertTheme__tokenPunctuation">}</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="CertTheme__tokenPunctuation">}</span><br><span>&nbsp; &nbsp; &nbsp;</span><span class="CertTheme__tokenPunctuation">}</span><br><span class="CertTheme__tokenPunctuation">}</span></pre></div></div><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><b><strong class="CertTheme__textBold">The output is:</strong></b></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-lq4ukzc3p" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm"><span>$javac Example</span><span class="CertTheme__tokenPunctuation">.</span><span>java</span><br><span>$java Example</span><br><span class="CertTheme__tokenProperty">1</span><span class="CertTheme__tokenOperator">/</span><span class="CertTheme__tokenProperty">1</span><span> </span><span class="CertTheme__tokenOperator">=</span><span> </span><span class="CertTheme__tokenProperty">1</span><br><span class="CertTheme__tokenProperty">2</span><span class="CertTheme__tokenOperator">/</span><span class="CertTheme__tokenProperty">2</span><span> </span><span class="CertTheme__tokenOperator">=</span><span> </span><span class="CertTheme__tokenProperty">1</span><br><span>Division by zero not Possible</span><br><span class="CertTheme__tokenProperty">4</span><span class="CertTheme__tokenOperator">/</span><span class="CertTheme__tokenProperty">3</span><span> </span><span class="CertTheme__tokenOperator">=</span><span> </span><span class="CertTheme__tokenProperty">1</span><br><span>Array Index is out </span><span class="CertTheme__tokenAttr">of</span><span> bounds</span><br><span>Array Index is out </span><span class="CertTheme__tokenAttr">of</span><span> bounds</span></pre></div></div><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><br></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">35. Working of JVM</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p>JVM stands for Java Virtual Machine. It is the driving force that provides the run time environment. It converts the Java ByteCode into machine code. It is an abstract machine that provides the specification for execution of a Java program during runtime.</p><p>JVM loads the byte code and verifies it. It also runs the code and provides runtime environment.</p><p>During compile time, the Java Compiler converts the Source Code into the ByteCode. The components required to execute the bytecode are provided by the Java Virtual Machine, which invocates the processor to allot the needed resources. JVMs are based on stacks so they implement stacks to read and process the bytecode.</p><p>In other words when we compile a .java file, files with nomenclature same to that of the class are created with the extension .class by the Java Compiler. These files contain the byte code. There are various steps involved when a .class file is executed. These steps provide a detailed account of the Java Virtual Machine.</p><p><img alt="JVM Language Classes" loading="lazy" width="100" height="100" decoding="async"  class="fr-fic fr-dib" style="color:transparent;width:100%;height:auto;background-size:cover;background-position:50% 50%;background-repeat:no-repeat;background-image:url(&quot;data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http%3A//www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cfilter id='b' color-interpolation-filters='sRGB'%3E%3CfeGaussianBlur stdDeviation='20'/%3E%3C/filter%3E%3Cimage preserveAspectRatio='none' filter='url(%23b)' x='0' y='0' height='100%25' width='100%25' href='data:image/svg+xml;base64,CiAgPHN2ZyB3aWR0aD0iMTAwIiBoZWlnaHQ9IjEwMCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIj4KICAgIDxkZWZzPgogICAgICA8bGluZWFyR3JhZGllbnQgaWQ9ImciPgogICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNjY2MiIG9mZnNldD0iMjAlIiAvPgogICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNkZGQiIG9mZnNldD0iNTAlIiAvPgogICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNlZWUiIG9mZnNldD0iNzAlIiAvPgogICAgICA8L2xpbmVhckdyYWRpZW50PgogICAgPC9kZWZzPgogICAgPHJlY3Qgd2lkdGg9IjEwMCIgaGVpZ2h0PSIxMDAiIGZpbGw9IiNlZWUiIC8+CiAgICA8cmVjdCBpZD0iciIgd2lkdGg9IjEwMCIgaGVpZ2h0PSIxMDAiIGZpbGw9InVybCgjZykiIC8+CiAgICA8YW5pbWF0ZSB4bGluazpocmVmPSIjciIgYXR0cmlidXRlTmFtZT0ieCIgZnJvbT0iLTEwMCIgdG89IjEwMCIgZHVyPSIxcyIgcmVwZWF0Q291bnQ9ImluZGVmaW5pdGUiICAvPgogIDwvc3ZnPg=='/%3E%3C/svg%3E&quot;)" sizes="(min-width: 767px) 50vw, 100vw" srcSet="" src="https://images.unsplash.com/photo-1523240795612-9a054b0db644?ixlib=rb-4.0.3&auto=format&fit=crop&w=1000&q=80"></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">36. What is the difference between final, finalize and finally?</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>There are quite a few differences between<strong>&nbsp;</strong>final, finalize and finally.</p><ul><li class="CertTheme__listItem pt-spacing10"><strong>final</strong> is a keyword which is used to curtail the class, method or variable on which it is applied. A final class cannot be inherited by a subclass, a method declared as final cannot be overridden or a variable declared as final cannot be updated.</li><li class="CertTheme__listItem pt-spacing10"><strong>finalize</strong> is a method which is used to clean up the processing before the garbage collection in java. It is called by the garbage collector of an object when there are no further references to that object.</li><li class="CertTheme__listItem pt-spacing10"><strong>finally</strong> is a block which is a part of the try-catch-finally flow block and is used to execute code irrespective of the handling of exceptions in the try and catch blocks.</li></ul><p>The finalize, unlike final and finally is not a reserved keyword in Java. The finalize method can be invoked explicitly which leads to it being executed as a normal method call and wouldn’t lead to destruction of the object.</p><p>Let us see a program which violates the use of the final keyword:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-kg9mbh98t" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">public class Example
{ &nbsp;
&nbsp; &nbsp;public static void main(String[] args)
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;final int x=1; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;x++;
&nbsp; &nbsp; }
}</pre></div></div><p>The program will generate a compile time error as a final variable can’t be updated:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-z25px7vw2" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">$javac Example.java
Example.java:6: error: cannot assign a value to final variable x
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;x++;//Compile Time Error &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;^
1 error</pre></div></div><p>&nbsp;Now let us look at the use of finally keyword in Java:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-u719ar4f9" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">public class Example
{
&nbsp; &nbsp;public static void main(String[] args)
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;try
&nbsp; &nbsp; &nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp; System.out.println("In try block");
&nbsp; &nbsp; &nbsp; &nbsp; int a=1/0;
&nbsp; &nbsp; &nbsp; &nbsp;}
&nbsp; &nbsp; &nbsp; &nbsp;catch(ArithmeticException e)
&nbsp; &nbsp; &nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;System.out.println("Exception Caught");
&nbsp; &nbsp; &nbsp; &nbsp;}
&nbsp; &nbsp; &nbsp; &nbsp;finally
&nbsp; &nbsp; &nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;System.out.println("In finally block");
&nbsp; &nbsp; &nbsp; &nbsp;}
&nbsp; &nbsp;}
}</pre></div></div><p><strong>The program will give the following output:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-99i9dsbsz" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">$javac Example.java
$java Example
In try block
Exception Caught
In finally block</pre></div></div><p>Now let us look at the overriding of finalize method in Java:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-w4ielfjma" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">public class Example
{
&nbsp; &nbsp;public static void main(String[] args)
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;String str = new String("Example");
&nbsp; &nbsp; &nbsp; &nbsp;str = null;
&nbsp; &nbsp; &nbsp; &nbsp;System.gc(); // prompts the JVM to call the Garbage Collector
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println("End of main method");
&nbsp; &nbsp;}
&nbsp; &nbsp;public void finalize()
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println("This is the finalize method");
&nbsp; &nbsp;}
}</pre></div></div><p><strong>The output is as follows:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-pphsfp8sl" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">$javac Example.java
$java Example
End of main method</pre></div></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">37. Can we have an empty catch block?</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>Yes, we can have an empty catch block in Java. This is a bad practice though and shouldn’t be implemented.</p><p>Generally, the try block has the code which is capable of producing exceptions. Whenever something out of the blue or malicious is written in the try block, it generates an exception which is caught by the catch block. The catch block identifies(catches), handles the exceptions and usually prompts the user on what is wrong.</p><p>If the catch block is empty then you will have no idea what went wrong with your code.</p><p>Take for example, division by zero when handled by an empty catch block</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-sggm050ze" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">public class Example
{
&nbsp; &nbsp;public static void main(String[] args)
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;try
&nbsp; &nbsp; &nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;int a=4 ,b=0;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;int c=a/b;
&nbsp; &nbsp; &nbsp; &nbsp;}
&nbsp; &nbsp; &nbsp; &nbsp;catch(ArithmeticException e)
&nbsp; &nbsp; &nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;}
&nbsp; &nbsp;}
}</pre></div></div><p>The catch block catches the exception but doesn’t print anything. This makes the user think that there is no exception in the code.</p><p>$javac Example.java</p><p>$java Example</p><p>But when the catch block is not empty, it gives a sense of awareness to the user about the exception.</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-cmu1o9b6n" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">public class Example
{
&nbsp; &nbsp;public static void main(String[] args)
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;try
&nbsp; &nbsp; &nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;int a=4, b=0;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;int c=a/b;
&nbsp; &nbsp; &nbsp; &nbsp;}
&nbsp; &nbsp; &nbsp; &nbsp;catch(ArithmeticException e)
&nbsp; &nbsp; &nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;System.out.println("Division by zero is illegal");
&nbsp; &nbsp; &nbsp; &nbsp;}
&nbsp; &nbsp;}
}</pre></div></div><p><strong>The output for the following is as follows</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-hwe1b36r1" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">$javac Example.java
$java Example
Division by zero is illegal</pre></div></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">38. Scope of Access Specifiers in Java</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>A Java access specifier shows the capability to specific classes to access a given class and its components. They are also called access modifiers. They help limit the scope of the class, constructor, variables and methods.<br><br>Basically, there are four access specifiers in Java</p><ul><li class="CertTheme__listItem pt-spacing10">Default (No keyword required)</li><li class="CertTheme__listItem pt-spacing10">Public</li><li class="CertTheme__listItem pt-spacing10">Private</li><li class="CertTheme__listItem pt-spacing10">Protected</li></ul><p>The following table illustrates the visibility of the access specifiers</p><div class="overflow-x-auto mt-spacing10 mb-[16.8px] md:mb-6 max-w-full"><table class="min-w-full divide-y divide-gray-200 border"><thead><tr><th class="CertTheme__tableCell CertTheme__tableCellHeader" style="border:1px solid black;width:175px;vertical-align:top;text-align:start;background-color:rgb(242, 243, 245)">Access Specifiers</th><th class="CertTheme__tableCell CertTheme__tableCellHeader" style="border:1px solid black;width:175px;vertical-align:top;text-align:start;background-color:rgb(242, 243, 245)">default</th><th class="CertTheme__tableCell CertTheme__tableCellHeader" style="border:1px solid black;width:175px;vertical-align:top;text-align:start;background-color:rgb(242, 243, 245)">private</th><th class="CertTheme__tableCell CertTheme__tableCellHeader" style="border:1px solid black;width:175px;vertical-align:top;text-align:start;background-color:rgb(242, 243, 245)">public</th><th class="CertTheme__tableCell CertTheme__tableCellHeader" style="border:1px solid black;width:175px;vertical-align:top;text-align:start;background-color:rgb(242, 243, 245)">protected</th></tr></thead><tbody><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Accessible within same class</td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Yes</td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Yes</td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Yes</td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Yes</td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Accessible to other classes in same package</td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Yes</td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">No</td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Yes</td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Yes</td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Accessible within the subclass inside the same package</td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Yes</td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">No</td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Yes</td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Yes</td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Accessible within the subclass outside the package</td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">No</td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">No</td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Yes</td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Yes</td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Accessible to other non subclasses outside the package</td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">No</td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">No</td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Yes</td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">No</td></tr></tbody></table></div><p>Let us see an example:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-zhqjoc8e9" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">class Scope
{
&nbsp; &nbsp;private int x=5; &nbsp; &nbsp; &nbsp; &nbsp; // a private variable can only be accessed in the same class
&nbsp; &nbsp;protected int k=10; &nbsp;// a protected variable can be accessed in the subclass
&nbsp; &nbsp;public void print() &nbsp; &nbsp;// a public method which can be accessed anywhere
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println(x);
&nbsp; &nbsp;}
}
public class Example extends Scope
{
&nbsp; &nbsp;public static void main(String[] args)
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;Scope s=new Scope();
&nbsp; &nbsp; &nbsp; &nbsp;s.print();
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println(s.k);
&nbsp; &nbsp;}
}</pre></div></div><p><strong>The program gives the following output:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-4m566nses" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">$javac Example.java
$java Example
5
10</pre></div></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">39. Java Example to check if a string is empty or not</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>To check whether a string is empty or not is an easy task since Java comes with a function isEmpty () for this.</p><p>Let us see an example:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-zfxzpjh4d" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">public class Example {
&nbsp;public static void main(String[] args) {
&nbsp; &nbsp;String s = ""; &nbsp;
&nbsp; &nbsp;System.out.println("Is the string empty? "+s.isEmpty()); &nbsp;
&nbsp;}
}</pre></div></div><p><strong>The output:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-tdm45k3ug" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">Is the string empty? true</pre></div></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">40. Java instanceOf operator</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>Java uses the instanceOf operator to check the type of object during the time of execution of a Java program.</p><p>The instanceOf operator is used to check whether a particular object is an instance of a parent class, child class or an interface.</p><p>The instanceOf operator returns a boolean value, either true or false. It is used as a type comparison operator because it compares the object with its type. If applied to a variable having a null value, the operator will always return a false value.</p><p>For example,</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-7zfqdcab0" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">public class Example
{
&nbsp;public static void main(String args[])
&nbsp; {
&nbsp; &nbsp; Example obj=new Example();
&nbsp; &nbsp; System.out.println(obj instanceof Example);
&nbsp; }
}</pre></div></div><p><strong>The output is as follows:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-0cqztixpz" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">$javac Example.java
$java Example
True</pre></div></div><p>Here is another example when instanceOf operator is used against a instance having null value</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-i9y6383x7" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">public class Example
{ &nbsp;
public static void main(String args[])
{ &nbsp;
&nbsp;Example obj=null; &nbsp;
&nbsp;System.out.println(obj instanceof Example);
} &nbsp;
} &nbsp;</pre></div></div><p><strong>The output is as follows</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-ycw7aoslj" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">$javac Example.java
$java Example
False</pre></div></div><p>The instanceOf operator is also useful in downcasting. Downcasting is the process when the child class type refers to the object of the parent class. If Downcasting is performed directly, a ClassCastException is generated. The instanceOf operator provides the means for downcasting. This can be done via typecasting:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-pwlkd7s89" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">class Parent
{
// empty class
} &nbsp; &nbsp;
public class Example extends Parent
{ &nbsp;
&nbsp;static void downcast(Parent p)
&nbsp;{
&nbsp; &nbsp;if(p instanceof Example)
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; Example d = (Example)p;
&nbsp; &nbsp; &nbsp; System.out.println("Downcasting successful"); &nbsp;
&nbsp; &nbsp;}
&nbsp;}
&nbsp;public static void main (String [] args)
&nbsp;{
&nbsp; &nbsp;Parent obj=new Example(); &nbsp;
&nbsp; &nbsp;Example.downcast(obj); &nbsp;
&nbsp;} &nbsp; &nbsp;
}</pre></div></div><p><strong>The output is as follows:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-h3cwxgl6p" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">$javac Example.java
$java Example
Downcasting successful</pre></div></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">41. ArrayList vs Vector in Java</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>The java.util.ArrayList class extends the AbstractList class. It is a part of the collection framework. The ArrayList is initialized a size which is capable of increasing or decreasing its size when objects are separated from the collection.</p><p>The java.util.Vector class represents dynamic data structures which can expand when a new element is added to them. Vectors are synchronized and contain many methods that are not a part of the Collections framework in Java.</p><p>Here are a few key differences between Vectors and ArrayList:</p><div class="overflow-x-auto mt-spacing10 mb-[16.8px] md:mb-6 max-w-full"><table class="min-w-full divide-y divide-gray-200 border"><thead><tr><th class="CertTheme__tableCell CertTheme__tableCellHeader" style="border:1px solid black;width:175px;vertical-align:top;text-align:start;background-color:rgb(242, 243, 245)">Basis<br></th><th class="CertTheme__tableCell CertTheme__tableCellHeader" style="border:1px solid black;width:175px;vertical-align:top;text-align:start;background-color:rgb(242, 243, 245)">Vector<br></th><th class="CertTheme__tableCell CertTheme__tableCellHeader" style="border:1px solid black;width:175px;vertical-align:top;text-align:start;background-color:rgb(242, 243, 245)">ArrayList<br></th></tr></thead><tbody><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Threads<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Vector thread is thread safe as only one thread is allowed to work at a time<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">ArrayList is not thread safe as multiple threads are allowed to work at a time<br></td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Synchronization<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Every method available in Vector is Synchronized<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Every method available in ArrayList is not Synchronized<br></td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Performance<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Threads are required to hold-up on Vector object and hence their performance is low as compared to ArrayList.<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Threads are not required to hold-up on ArrayList object and hence their performance is high as compared to Vector<br></td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Growth<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Doubles its size when it grows<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Grows by half of its size<br></td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Application<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Multi user application<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Single user application<br></td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Legacy class<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Vector is a legacy class, introduced in JDK 1.0<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">ArrayList is a non legacy class, introduced in JDK 1.2<br></td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Traversal<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Uses enumeration for traversal.<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Uses Iterator/ListIterator for traversal.<br></td></tr></tbody></table></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">42. Generate Random Numbers in Java</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>Java imparts us with three ways to generate random numbers. The three ways are:</p><ul><li class="CertTheme__listItem pt-spacing10">Using the java.util.Random class</li><li class="CertTheme__listItem pt-spacing10">Using the java.util.Math.random() method</li><li class="CertTheme__listItem pt-spacing10">Using the java.util.concurrent.ThreadLocalRandom class</li></ul><p><strong>The java.util.Random class</strong></p><p>We create an object of this class and call predefined methods such as nextInt() and nextDouble() using this object.</p><p>Random numbers of several data types can be produced by this method.</p><p>Suppose If we pass an argument x to nextInt() then we would get any random integer from 0 to x-1.</p><p>For example,</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-p4vgrpv7x" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">import java.util.Random;
public class Example
{
&nbsp; &nbsp; &nbsp;public static void main(String args[])
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;Random r= new Random();
&nbsp; &nbsp; &nbsp; &nbsp;int r1 = r.nextInt(20); &nbsp; // generates random integers from 0 to 19
&nbsp; &nbsp; &nbsp; &nbsp;int r2 = r.nextInt(100); // generates random integers from 0 to 99
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println("The first random number generated is: "+r1);
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println("The second random number generated is "+r2);
&nbsp; &nbsp;}
}</pre></div></div><p>The subsequent output is as follows:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-c0u8tgn8b" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">$javac Example.java
$java Example
The first random number generated is: 2
The second random number generated is 23</pre></div></div><p><strong>The Math.random() method</strong></p><p>The Math.random() is a method of the java.util.Math class. It returns a positive double value between 0.0 (inclusive) and 1.0 (exclusive).</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-tialmm6wj" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">import java.util.*;
public class Example
{ &nbsp;&nbsp;
&nbsp; &nbsp;public static void main(String args[])
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;double x=Math.random();
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println("Random number between 0.0 and 1.0 is "+x);
&nbsp; &nbsp;}
}</pre></div></div><p>The random output for the following is as follows:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-7yljocdzi" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">$javac Example.java
$java Example
Random number between 0.0 and 1.0 is 0.7534013549366972</pre></div></div><p><strong>The ThreadLocalRandom Class</strong></p><p>This is a relatively new feature introduced in JDK 1.7.</p><p>The ThreadLocalRandom gives random values for integers, doubles, floats and booleans.</p><p>For example,</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-57u24fu81" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">import java.util.concurrent.ThreadLocalRandom;
public class Example
{
&nbsp; &nbsp;public static void main(String args[])
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;int intVal = ThreadLocalRandom.current().nextInt();
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println("A random integer : " + intVal);
&nbsp; &nbsp; &nbsp; &nbsp;double doubVal = ThreadLocalRandom.current().nextDouble();
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println("A random double number : "+doubVal);
&nbsp; &nbsp;}
}</pre></div></div><p>The output is as follows:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-uvidoiwl0" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">$javac Example.java
$java Example
A random integer : 1700060375
A random double number : 0.24593329857940383</pre></div></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">43. Jagged Arrays in Java</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>Jagged <a href="blog/programming/what-is-an-array" target="_blank">arrays</a> in Java are multidimensional arrays in which each element itself is an array of varying size as well as dimensions. Thus, they’re often referred to as an array of arrays.</p><p>Syntax for a two-dimensional jagged array for fixed rows and variable columns,</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-l31ispq6a" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">data_type array_name[][]= new data_type [array_size][];
&nbsp; &nbsp;(OR)
data_type[][] array_name=new data_type[array_size][];</pre></div></div><p>Take for example a Jagger integer array of size 4:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-a24yr6iy7" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">int arr[][] = new int[4][];</pre></div></div><p>This row has 4 rows and each row has varying amount of columns which might later be specified.</p><p>We can either declare the array and initialize the elements directly:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-u1qbeic4a" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">arr[0] = new int[] {13, 42};
arr[1] = new int[] {34, 43, 95};
arr[2] = new int[] {69, 71, 83, 29};
arr[3] = new int[] {10,11};</pre></div></div><p>or, we can just declare the array elements without initializing them.</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-beqpquh1g" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">arr[0] = new int[2];
arr[1] = new int[3];
arr[2] = new int[4];
arr [3] = new int[2];</pre></div></div><p>For example,</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-auhejdmtu" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">public class Example
{
&nbsp; &nbsp;public static void main(String[] args)
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;int arr[][] = new int[4][]; // creating a Jagged Array of 4 rows
&nbsp; &nbsp; &nbsp; &nbsp;arr[0] = new int[]{1,2,3,4}; &nbsp;// the first row has 4 columns
&nbsp; &nbsp; &nbsp; &nbsp;arr[1] = new int[]{5,6,7}; &nbsp;// the second row has 3 columns
&nbsp; &nbsp; &nbsp; &nbsp;arr[2] = new int[]{10,20,30}; // the third row has 3 columns
&nbsp; &nbsp; &nbsp; &nbsp;arr[3] = new int[]{2,4,2,4}; // &nbsp;the fourth row has 4 columns
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println("The elements of the Jagged Array are...");
&nbsp; &nbsp; &nbsp; &nbsp;for (int i=0; i&lt;arr.length; i++)
&nbsp; &nbsp; &nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;for (int j=0; j&lt;arr[i].length; j++)
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;System.out.print(arr[i][j] + " ");
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;System.out.println();
&nbsp; &nbsp; &nbsp; &nbsp;}
&nbsp; &nbsp;}
}</pre></div></div><p><strong>The output is the following:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-9k949uk70" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">$javac Example.java
$java Example
The elements of the Jagged Array are...
1 2 3 4
5 6 7
10 20 30
2 4 2 4</pre></div></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">44. Iterator vs Enumeration in Java</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>Both Iterator and Enumeration are interfaces belonging to the java.util package. They are used for traversal of collection objects.</p><p>Although Iterator and Enumeration have the same functionality of traversal, there are quite a few differences between them. Some of the differences are given below:</p><div class="overflow-x-auto mt-spacing10 mb-[16.8px] md:mb-6 max-w-full"><table class="min-w-full divide-y divide-gray-200 border"><thead><tr><th class="CertTheme__tableCell CertTheme__tableCellHeader" style="border:1px solid black;width:175px;vertical-align:top;text-align:start;background-color:rgb(242, 243, 245)">Basis<br></th><th class="CertTheme__tableCell CertTheme__tableCellHeader" style="border:1px solid black;width:175px;vertical-align:top;text-align:start;background-color:rgb(242, 243, 245)">Iterator<br></th><th class="CertTheme__tableCell CertTheme__tableCellHeader" style="border:1px solid black;width:175px;vertical-align:top;text-align:start;background-color:rgb(242, 243, 245)">Enumeration<br></th></tr></thead><tbody><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Introduction<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Iterator interface was introduced in JDK 1.2<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Enumeration interface existed since JDK 1.0<br></td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Functions<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Iterator can be used for traversal as well as to remove an element from a given Collection object.<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Enumeration can only perform traversal through the collection object.<br></td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Nature<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Iterator is fail-fast is nature. It throws a ConcurrentModificationException if any modification other than the remove() method &nbsp;is done to the collection while iteration.<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Enumeration is fail-safe in nature. It does not throw any exceptions during modification of the Collection Object during an iteration.<br></td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Legacy<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Classes like ArrayList, HashSet and HashMap in the collection framework are traversed by Iterator<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Traversal of legacy classes like Vector and Stack is done through Enumeration<br></td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Safety<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Iterator is safer and more robust than Enumeration<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Enumeration is more vulnerable due to its fail-safe nature.<br></td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Methods<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">hasNext() &nbsp;<br>next()<br>remove()<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">hasMoreElements()<br>nextElement()<br>-<br></td></tr></tbody></table></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">45. Local Inner Class in Java</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>A class created in a block( method body or a loop or conditional clauses) is called as a local inner class. They are not a member of the class they are enclosed in. They rather, associate themselves to the block they are defined in. Local inner class can be declared as final or abstract. They cannot be instantiated out of their scope i.e. &nbsp;the block they are created in.</p><p>We can say that they are a form of non-static nested classes.</p><p>For example,</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-cv7kyadp1" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">public class Example
{
&nbsp; final int y=12;
&nbsp; void disp()
&nbsp;{
&nbsp; &nbsp; class Inner
&nbsp; &nbsp; {
&nbsp; &nbsp; &nbsp; void print()
&nbsp; &nbsp; &nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;System.out.println(y);
&nbsp; &nbsp; &nbsp; &nbsp;}
&nbsp; &nbsp; }
&nbsp; &nbsp; Inner i=new Inner();
&nbsp; &nbsp; i.print();
&nbsp; }
&nbsp;public static void main(String args[])
{
&nbsp; Example obj=new Example();
&nbsp; obj.disp();
&nbsp;}
}</pre></div></div><p><strong>The output is as follows</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-jj1eepynb" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">$javac Example.java
$java Example
12</pre></div></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">46. What type of parameter passing does Java support?</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>There are basically two types of parameter passing:</p><ul><li class="CertTheme__listItem pt-spacing10"><strong>Pass by value</strong></li><li class="CertTheme__listItem pt-spacing10"><strong>Pass by reference</strong></li></ul><p>Java supports Pass by value.</p><p>Passing by value means that when a method is called, a copy of the parameters is sent to the memory. When we are using the parameters inside the method or the block, the actual arguments aren’t used but the copy of those arguments (formal parameters) are worked with. There is no change in the actual parameters.</p><p>Passing by reference means that the changes in the parameters will be reflected in the original value . This occurs because the method receives the memory address of the parameters i.e. the address of the parameters.</p><p>What Java does is that it passes the reference of the object by value.</p><p>In Java, arguments are always passed by value irrespective of their original variable type. Each time a method is called, a copy is created in the stack memory and its version is passed to the method.</p><p><strong>There are two situations which arise:</strong></p><ul><li class="CertTheme__listItem pt-spacing10"><strong>The original variable type is primitive:</strong> If the original variable type is primitive, then a copy is created in the stack memory and is further passed to the method.</li><li class="CertTheme__listItem pt-spacing10"><strong>The original variable type is non-primitive:</strong> If the original variable type is non-primitive, then a new reference is formed in the stack memory which points to the actual parameters and this new reference is sent to the method.</li></ul><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">47. HashSet vs TreeSet in Java</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>The HashSet class implements the Set interface, supported by a Hashtable. Due to the implementation of the Set Interface, duplicate values are not allowed. The underlying data structure for a HashSet is a Hashtable.</p><p>The TreeSet class implements the SortedSet interface, which in turn extends the Set interface. Objects are stored in a sorted ascending order. The underlying data structure for TreeSet is a tree.</p><p>Here are a few notable differences between a HashSet and a TreeSet:</p><div class="overflow-x-auto mt-spacing10 mb-[16.8px] md:mb-6 max-w-full"><table class="min-w-full divide-y divide-gray-200 border"><thead><tr><th class="CertTheme__tableCell CertTheme__tableCellHeader" style="border:1px solid black;width:175px;vertical-align:top;text-align:start;background-color:rgb(242, 243, 245)">Basis<br></th><th class="CertTheme__tableCell CertTheme__tableCellHeader" style="border:1px solid black;width:175px;vertical-align:top;text-align:start;background-color:rgb(242, 243, 245)">HashSet<br></th><th class="CertTheme__tableCell CertTheme__tableCellHeader" style="border:1px solid black;width:175px;vertical-align:top;text-align:start;background-color:rgb(242, 243, 245)">TreeSet<br></th></tr></thead><tbody><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Performance<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">HashSet in Java offers faster performance than TreeSet<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">TreeSet in Java is slower than HashSet for most of the generic operations like add, remove and search.<br></td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Underlying data structure<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">HashSet has hashtable as its underlying data structure.<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">TreeSet has a red black tree as its underlying data structure.<br></td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Null element<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">HashSet does allow one null element<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">TreeSet doesn’t allow any null element to be present<br></td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Implementation<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">It is implemented by HashMap<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">It is implemented by TreeMap<br></td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Interface<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">HashSet implements the Set interface.<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">TreeSet implements the SortedSet interface. SortedSet interface extends the Set interface.<br></td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Sorting<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">HashSet is not in sorted order<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">TreeSet is sorted in ascending order<br></td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Comparison<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">HashSet applies the equals() method for comparison<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">TreeSet applies the compareTo() method for comparison.<br></td></tr></tbody></table></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">48. Types of memory areas allocated by JVM</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>JVM stands for Java Virtual Machine. It is the driving force that provides the run time environment. It converts the Java ByteCode into machine code. It is an abstract machine that provides the specification for execution of a Java program during runtime.</p><p>When we compile a .java file, files with nomenclature same to that of the class are created with the extension .class by the Java Compiler. These files contain the byte code. There are various steps involved when a .class file is executed. These steps provide a detailed account of the Java Virtual Machine.</p><p>There are typically 6 types of memory areas allocated in JVM.</p><ul><li class="CertTheme__listItem pt-spacing10"><strong>Classloader</strong>: Classloader is a subsystem of JVM and a part of the Java Runtime Environment which dynamically loads class in the JVM.</li><li class="CertTheme__listItem pt-spacing10"><strong>Method Area</strong>: Method Area is common across all threads. It consists of per-class elements such as constant pool, fields, method data and code and constructor codes. This area gets created during the JVM start-up. If the memory isn’t sufficient then it gives an OutOfMemoryError.</li><li class="CertTheme__listItem pt-spacing10"><strong>Heap</strong>: Variables assigned with this memory structure can be administered during runtime. This leads to dynamic memory allocation.</li><li class="CertTheme__listItem pt-spacing10"><strong>Stack</strong>: If the amount of memory required is known beforehand, memory is allocated using stacks.</li><li class="CertTheme__listItem pt-spacing10"><strong>Program Counter Register</strong>: It contains the address of the Java virtual machine instruction currently being executed. Programs are a set of instructions given to a computer for performing few specific tasks. The Program Counter Register carries the address of the forthcoming instructions.</li><li class="CertTheme__listItem pt-spacing10"><strong>Native Method Stack</strong>: It is a collection of all the native methods used in the application.</li></ul><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">49. Purpose of finalize() in Java</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>The finalize() is a method which is used to clean up the processing before the garbage collection in java. It is called by the garbage collector of an object when there are no further references to that object.</p><p>finalize() is overridden by a child class to get rid of the system resources or to conduct other cleanup. The exception raised by this method is called the Throwable exception.</p><p>The java.lang.Object.finalize() method does not take any parameters and does not return a value.</p><p>Now let us look at the overriding of finalize() method in Java,</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-gbqb4uerk" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">public class Example
{
&nbsp; &nbsp;public static void main(String[] args)
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;String str = new String("Example");
&nbsp; &nbsp; &nbsp; &nbsp;str = null;
&nbsp; &nbsp; &nbsp; &nbsp;System.gc(); // prompts the JVM to call the Garbage Collector
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println("End of main method");
&nbsp; &nbsp;}
&nbsp; &nbsp;public void finalize()
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println("This is the finalize method");
&nbsp; &nbsp;}
}</pre></div></div><p><strong>The output is as follows</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-nfns9sbkk" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">$javac Example.java
$java Example
End of main method</pre></div></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">50. A Java program begins with a call to which function?</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>When a Java program begins, the public static void main(String []args) method is called.</p><p>When the Java program needs to be executed, the system looks for the main entry point in the program. This is provided through the main method,</p><p>The public static void main(String args[]) is the main method of the Java Program. It is the most important Java Method. It is the entry point of any Java Program. A Java Program cannot be executed without the main method.</p><p>Only the args can be changed to a different name but the rest of the method carries the same syntax.</p><p><strong>Let us analyze the main method by breaking it up:</strong></p><ul><li class="CertTheme__listItem pt-spacing10"><strong>public</strong> : This is the access specifier/access modifier of the main method. It should be public to allow the class to access it. In case of violation of the same, the program will show an error.</li><li class="CertTheme__listItem pt-spacing10"><strong>static</strong> : At the start of the runtime, the class is devoid of any object. Thus, the main method needs to be static so that the Java Virtual Machine can set the class to the memory and call the main method. If the main method is not static then the JVM won’t be able to call it due to the absence of an object.</li><li class="CertTheme__listItem pt-spacing10"><strong>void</strong> : It is the return type of the main method. Each and every method in Java must have a return type.The main method doesn’t return any value that can be accessed by the other methods as the main method can’t be called in any other method. As soon as the main method finishes its execution the program terminates. Hence it wouldn’t be of any use to return a value. If any value is returned then the compiler will show an unexpected return value error.</li><li class="CertTheme__listItem pt-spacing10"><strong>main</strong>: It is the name of the main method. This name is already set and can’t be changed. If any changes are made to the main keyword then the compiler tells that the main method couldn’t be found.</li><li class="CertTheme__listItem pt-spacing10"><strong>String args[]</strong>: &nbsp;The main method can accept a single argument which is of the String type. They are also called command line arguments. They can be used and manipulated as normal arguments in the code written in the main method. They are written along with the execution statement.</li></ul><p><strong>The following program will illustrate that the main method is run at first:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-7t1dkwkv9" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">public class Example
{
&nbsp; &nbsp;void display()
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println("This is the display method");
&nbsp; &nbsp;}
&nbsp; public static void main(String[] args) // the main method
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println("This is the main method");
&nbsp; &nbsp; &nbsp; &nbsp;Example obj = new Example();
&nbsp; &nbsp; &nbsp; &nbsp;obj.display(); // invokes display method
&nbsp; &nbsp;}
}</pre></div></div><p><strong>The output is as follows:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-rh5rqxdgb" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">$javac Example.java
$java Example
This is the main method
This is the display method</pre></div></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">51. What is JIT compiler?</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p>JIT stands for Just In Time. JIT compiler is a program which converts the Java ByteCode into processor level instructions.</p><p>The JIT compiler runs after the program has begun and compiles the bytecode while the program is running into a quicker and more local processor level directive set.</p><p>After you've completed writing a Java program, the source code are compiled by the Java compiler into bytecode. Then the bytecode is converted into processor level instructions by the JIT compiler. Thus the JIT compiler acts as a second compiler.</p><p>The JIT compiler runs simultaneously with the execution of the program. It compiles the bytecode into platform-specific executable code that is instantly executed.</p><p>Once the code is re-compiled by the JIT compiler, it runs relatively quickly on the system.</p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">52. HashMap vs Hashtable in Java</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><ul><li class="CertTheme__listItem pt-spacing10"><strong>HashMap</strong> in Java is a part of the collection class in the java.util package. It is based on Maps and is used for storage of data in Key and Value pairs.</li></ul><p>HashMap extends the AbstractMap class and also implements the Cloneable and Serializable interface.</p><ul><li class="CertTheme__listItem pt-spacing10"><strong>Hashtable</strong> in Java was an original part of the java.util package and was implementation of a Dictionary. It was updated by JDK 1.2 and implemented the Map Interface. Currently, it is a part of the collections framework. It also stores data in Key and Value pairs.</li></ul><p>Despite of the similarities, HashMap and HashTable have few differences. Let us have a look at them.</p><div class="overflow-x-auto mt-spacing10 mb-[16.8px] md:mb-6 max-w-full"><table class="min-w-full divide-y divide-gray-200 border"><thead><tr><th class="CertTheme__tableCell CertTheme__tableCellHeader" style="border:1px solid black;width:175px;vertical-align:top;text-align:start;background-color:rgb(242, 243, 245)">Basis</th><th class="CertTheme__tableCell CertTheme__tableCellHeader" style="border:1px solid black;width:175px;vertical-align:top;text-align:start;background-color:rgb(242, 243, 245)">HashMap</th><th class="CertTheme__tableCell CertTheme__tableCellHeader" style="border:1px solid black;width:175px;vertical-align:top;text-align:start;background-color:rgb(242, 243, 245)">Hashtable</th></tr></thead><tbody><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Null keys/values</td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Null key/values are allowed in HashMap. It allows one null key and multiple null values.</td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Null key/values are not allowed in Hashtable</td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Synchronization</td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">HashMap is not synchronized and is not thread safe. It can’t be shared amongst multiple threads without appropriate synchronization.</td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Hashtable is synchronized and thread safe.</td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Nature of iterator</td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">HashMap iterator is fail fast in nature.</td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Hashtable iterator is fail safe in nature.</td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Introduction</td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">HashMap was introduced in JDK 1.2</td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Hashtable is a legacy class.</td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Performance</td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">HashMap is fast.</td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Hashtable is slower than HashMap</td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Parent Class</td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">AbstractMap is the parent class for HashMap</td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Dictionary is the parent class for Hashtable</td></tr></tbody></table></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">53. NumberFormatException in Java</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>A NumberFormatException in Java is an exception of the java.lang package which is thrown when we try to convert a String into a numeric data type such as int, float, double, long and short. This happens when the String does not have an appropriate format.</p><p>Take for example, we try to parse a String which is not of numeric type into an integer:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-0921monkq" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">public class Example
{
&nbsp; &nbsp;public static void main(String[] args)
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;String str = "Number";
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;int intVal = Integer.parseInt(str);
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;System.out.println(intVal);
&nbsp; &nbsp;}
}</pre></div></div><p>The above code will throw a NumberFormatException:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-rgzr1gvbm" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">$javac Example.java
$java -Xmx128M -Xms16M Example
Exception in thread "main" java.lang.NumberFormatException: For input string: "Number"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Integer.parseInt(Integer.java:580)
at java.lang.Integer.parseInt(Integer.java:615)
at Example.main(Example.java:8)</pre></div></div><p>But if the String is of numeric type, it will successfully parse it to an integer</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-0pkwjq4zg" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">public class Example
{
&nbsp; &nbsp;public static void main(String[] args)
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;String str = "12";
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;int intVal = Integer.parseInt(str);
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;System.out.println(intVal);
&nbsp; &nbsp;}
}</pre></div></div><p><strong>The output is the following:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-7u824g7w6" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">$javac Example.java
$java -Xmx128M -Xms16M Example
12</pre></div></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">54. StringBuffer vs StringBuilder in Java</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>StringBuffer class which is related to class String that gives most of the usage of strings. StringBuffer is a mutable, expandable and writable sequence of characters.</p><p>StringBuilder is a class whose objects are similar to String objects barring that they can be changed. The size and matter of the sequence of characters can be modified through method calling statements.</p><div class="overflow-x-auto mt-spacing10 mb-[16.8px] md:mb-6 max-w-full"><table class="min-w-full divide-y divide-gray-200 border"><thead><tr><th class="CertTheme__tableCell CertTheme__tableCellHeader" style="border:1px solid black;width:175px;vertical-align:top;text-align:start;background-color:rgb(242, 243, 245)">Basis<br></th><th class="CertTheme__tableCell CertTheme__tableCellHeader" style="border:1px solid black;width:175px;vertical-align:top;text-align:start;background-color:rgb(242, 243, 245)">StringBuffer<br></th><th class="CertTheme__tableCell CertTheme__tableCellHeader" style="border:1px solid black;width:175px;vertical-align:top;text-align:start;background-color:rgb(242, 243, 245)">StringBuilder<br></th></tr></thead><tbody><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Introduction<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">StringBuffer in Java was introduced in JDK 1.0.<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">StringBuilder in Java was introduced in JDK 1.5.<br></td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Synchronization<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Every method present in StringBuffer class is synchronized.<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Every method present in StringBuilder class is not synchronized.<br></td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Performance<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Performance is low<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Performance is relatively high<br></td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Thread Safe<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">StringBuffer Object is thread safe.<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">StringBuilder Object is not thread safe.<br></td></tr></tbody></table></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">55. Difference between a ClassNotFoundException and NoClassDefFoundError?</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>ClassNotFoundException and NoClassDefFoundError both occur when a class is not found during runtime.</p><p>ClassNotFoundException is an exception that is thrown when we try to load a class while execution of a Java program.</p><p>NoClassDefFoundError is an error which is thrown when a class marks it presence during compile time but isn’t available during runtime.</p><p>Despite their similarity of a missing class during runtime, there are a quite a few differences between ClassNotFoundException and NoClassDefFoundError.</p><div class="overflow-x-auto mt-spacing10 mb-[16.8px] md:mb-6 max-w-full"><table class="min-w-full divide-y divide-gray-200 border"><thead><tr><th class="CertTheme__tableCell CertTheme__tableCellHeader" style="border:1px solid black;width:175px;vertical-align:top;text-align:start;background-color:rgb(242, 243, 245)">Basis<br></th><th class="CertTheme__tableCell CertTheme__tableCellHeader" style="border:1px solid black;width:175px;vertical-align:top;text-align:start;background-color:rgb(242, 243, 245)">ClassNotFoundException<br></th><th class="CertTheme__tableCell CertTheme__tableCellHeader" style="border:1px solid black;width:175px;vertical-align:top;text-align:start;background-color:rgb(242, 243, 245)">NoClassDefFoundError<br></th></tr></thead><tbody><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Parent class<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">ClassNotFoundException is a child class of java.lang.Exception<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">NoClassDefFoundError is a child class of java.lang.Error<br></td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Occurrence<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">It occurs when an application tries to load a class during runtime which is not updated in the classpath<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">It occurs when the system doesn’t find the class definition during runtime which was present during compile time.<br></td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Thrown by<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">It is thrown by the application (program). Some methods like Class.forName(), loadClass() and findSystemClass() cause this exception.<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">It is thrown by the Java Runtime System.<br></td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Condition<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">It occurs when the classpath is not updated in accordance to the Java Archive files<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">It occurs when class definition is missing during runtime.<br></td></tr></tbody></table></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">56. Print stack trace information in Java</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>A stack trace is a characterization of a call stack at a particular instant, with each element depicting a method call statement. The stack trace contains all the call statements from the start of a thread until the point of generation of exception.</p><p>When the stack trace is printed, the point of generation is exception is printed first, followed by method call statements, which help us identify the root cause of failure.</p><p><strong>Here is an example of printing the stack trace in Java:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-yatdpt24h" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">public class Example
{
&nbsp; public static void main (String args[])
&nbsp; {
&nbsp; &nbsp; &nbsp; int arr[] = {1,2,3,4};
&nbsp; &nbsp; &nbsp; int num1=10, num2=0;
&nbsp; &nbsp; &nbsp; int ans;
&nbsp; &nbsp; &nbsp; try
&nbsp; &nbsp; &nbsp; {
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;System.out.println("The output is...");
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ans = num1/num2;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;System.out.println("The result is " +ans);
&nbsp; &nbsp; &nbsp; &nbsp;}
&nbsp; &nbsp; &nbsp; catch (ArithmeticException ex)
&nbsp; &nbsp; &nbsp; {
&nbsp; &nbsp; &nbsp; &nbsp; ex.printStackTrace();
&nbsp; &nbsp; &nbsp; }
&nbsp; }
}</pre></div></div><p><strong>The output is as follows:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-3qu6gyoge" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">$javac Example.java
$java Example
The output is...
java.lang.ArithmeticException: / by zero
at Example.main(Example.java:11)</pre></div></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">57. How to sort a Short array in Java</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>The Arrays.sort() method is provided in Java to sort Short array.</p><p>Let us see an example:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-ha84n217n" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">import java.util.*;
public class Example {
&nbsp; &nbsp; public static void main(String []args){
&nbsp; &nbsp; short[] shortArr = new short[] { 35, 25, 18, 45, 77, 21, 3 };
&nbsp; &nbsp; System.out.println("Unsorted:");
&nbsp; &nbsp; for (short a : shortArr) {
&nbsp; &nbsp; &nbsp;System.out.print(a+" ");
&nbsp; &nbsp; }
&nbsp; &nbsp; System.out.println("\nSorted Array = ");
&nbsp; &nbsp; // sort array
&nbsp; &nbsp; Arrays.sort(shortArr);
&nbsp; &nbsp; for (short a : shortArr) {
&nbsp; &nbsp; &nbsp;System.out.print(a+" ");
&nbsp; &nbsp; }
&nbsp; &nbsp; System.out.println();
&nbsp; &nbsp; }
}</pre></div></div><p><strong>The output:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-c70053vw5" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">Unsorted:
35 25 18 45 77 21 3
Sorted Array =
3 18 21 25 35 45 77</pre></div></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">58. Convert hexadecimal number to decimal number in Java</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>The parseInt() method converts hexadecimal to decimal. It can even convert octal to decimal. You just need to set the radix. For hexadecimal, the radix is 16.<br><br>The following is an example:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-7gmbgw31a" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">public class Demo
{
&nbsp; public static void main( String args[] )
&nbsp; {
&nbsp; &nbsp; &nbsp; // hexadecimal string
&nbsp; &nbsp; &nbsp; String str = "298";
&nbsp; &nbsp; &nbsp; // hex to decimal
&nbsp; &nbsp; &nbsp; System.out.println("Decimal = "+Integer.parseInt(str, 16));
&nbsp; }
}</pre></div></div><p><strong>The output:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-fccel7lvv" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">Decimal = 664</pre></div></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">59. How can we subtract hours from current time in Java?</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>To subtract hours, you need to use the HOUR_OF_DAY constant. Within that, include the number with the negative sign. This would be the hours you want to reduce. All this is done under the Calendar add() method.</p><p>The following is an example:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-fkk20wdfz" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">import java.util.Calendar;
public class Example {
&nbsp;public static void main(String[] args) {
&nbsp; &nbsp;Calendar c = Calendar.getInstance();
&nbsp; &nbsp;System.out.println("Date : " + c.getTime());
&nbsp; &nbsp;// 2 hours subtracted
&nbsp; &nbsp;c.add(Calendar.HOUR_OF_DAY, -2);
&nbsp; &nbsp;System.out.println("After subtracting 2 hrs : " + c.getTime());
&nbsp;}
}</pre></div></div><p><strong>Here is the output:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-e04uzeshs" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">Date : Sun Dec 16 16:28:53 UTC 2018
After subtracting 2 hrs : Sun Dec 16 14:28:53 UTC 2018</pre></div></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">60. How to replace every occurrence of a character in Java?</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>To replace every occurrence of a character, use the replace() method in Java.</p><p>Let’s say the following is the string:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-1ysn31lut" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">Tables and Chairs</pre></div></div><p>And for every occurrence of “a”, you need to replace it with “z”.</p><p>The following is the example that would replace every occurrence of “a” with “z”:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-9gush1a42" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">public class Example {
&nbsp;public static void main(String[] args) {
&nbsp; &nbsp; // Initial string
&nbsp; &nbsp; String str = "Tables and Chairs";
&nbsp; &nbsp; System.out.println("Initial String = "+str);
&nbsp; &nbsp; // replacing character
&nbsp; &nbsp; String res = str.replace('a', 'z');
&nbsp; &nbsp; // displaying the new string
&nbsp; &nbsp; System.out.println("New string = "+res);
&nbsp;}
}</pre></div></div><p><strong>The output:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-z92sdxsjw" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">Initial String = Tables and Chairs
New string = Tzbles znd Chzirs</pre></div></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">61. How to add leading zeros in Java?</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>We can add leading zeros to a number in Java. Let us see how:</p><p>The number we are taking as an example:</p><p>15</p><p>We will add 6 leading zeros to the above number using the following code. Here, we are working on the String.format() method to achieve the same:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-s6l34y90g" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">import java.util.Formatter;
public class Example {
&nbsp; &nbsp;public static void main(String args[]) {
&nbsp; &nbsp; &nbsp;int a = 15;
&nbsp; &nbsp; &nbsp;System.out.println("Value = "+a);
&nbsp; &nbsp; &nbsp;// adding leading zeros
&nbsp; &nbsp; &nbsp;String res = String.format("%08d", a);
&nbsp; &nbsp; &nbsp;System.out.println("Updated = " + res);
&nbsp; &nbsp;}
}</pre></div></div><p><strong>The output:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-85zd4nijo" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">Value = 15
Updated = 00000015</pre></div></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">62. Get all digits from a string in Java</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>To display the digits from a string, use Regular Expression.</p><p>The string (with digits):</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-xnujeyx3j" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">12345example</pre></div></div><p>To get the digits use the \\D<strong>&nbsp;</strong>flag and the replaceAll():</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-8vy79gyhh" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">replaceAll("\\D", ""))</pre></div></div><p>The example:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-cs5bpwoww" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">public class Example {
&nbsp;public static void main(String[] args) {
&nbsp; &nbsp;// string with digits
&nbsp; &nbsp;String s = "12345example";
&nbsp; &nbsp;System.out.println("Our String = "+s);
&nbsp; &nbsp;// display digits
&nbsp; &nbsp;System.out.println("Get digits from the string = "+s.replaceAll("\\D", ""));
&nbsp;}
}</pre></div></div><p><strong>The output displays only the digits:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-ajvcwkt4y" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">Our String = 12345example
Get digits from the string = 12345</pre></div></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">63. How to split String with Comma (,) in Java</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>The split() method is used to split a string on the basis of regular expression. The first parameter is the same regular expression, whereas if the second parameter is zero, it returns all the strings matching the Regular Expression.</p><p>Our sample string:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-i7chuose8" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">The TV, and the remote</pre></div></div><p>To split the string with comma, the following is the example:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-t7v9y8fwz" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">public class Example {
&nbsp;public static void main(String[] args) {
&nbsp; &nbsp; &nbsp;String s = "The TV, and the remote";
&nbsp; &nbsp; &nbsp;System.out.println("Initial String = "+s);
&nbsp; &nbsp; &nbsp;String[] str = s.split("[,]", 0);
&nbsp; &nbsp; &nbsp;System.out.println("\nSplitted string: ");
&nbsp; &nbsp; &nbsp;for(String val: str){
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println(val);
&nbsp; &nbsp; &nbsp;}
&nbsp; }
}</pre></div></div><p><strong>The output:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-qht0706q8" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">Initial String = The TV, and the remote
Splitted string:
The TV
and the remote</pre></div></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">64. Does size of operator exist in Java?</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>No, sizeof operator doesn’t exist in Java.</p><p>All primitive data types in Java such as int, char, float, double, long, short have a predefined size in Java. Hence there is no specific requirement of the sizeof operator.</p><p>Also, in Java, size of the primitive data types is independent of the platform i.e. Windows, Linux.</p><p>An int variable will take 4 bytes in both 32 and 64 bit and in both Windows and Linux operating systems.</p><p>The size of boolean is not fixed and depends on the JVM. Different JVMs might have different boolean size. Mostly the size of boolean is 1 bit.</p><p>Here are a few primitive data types with their fixed sizes</p><div class="overflow-x-auto mt-spacing10 mb-[16.8px] md:mb-6 max-w-full"><table class="min-w-full divide-y divide-gray-200 border"><thead><tr><th class="CertTheme__tableCell CertTheme__tableCellHeader" style="border:1px solid black;width:175px;vertical-align:top;text-align:start;background-color:rgb(242, 243, 245)">Data type</th><th class="CertTheme__tableCell CertTheme__tableCellHeader" style="border:1px solid black;width:175px;vertical-align:top;text-align:start;background-color:rgb(242, 243, 245)">Default size</th></tr></thead><tbody><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">char</td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">2 bytes</td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">byte</td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">1 byte</td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">short</td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">2 byte</td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">int</td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">4 bytes</td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">long</td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">8 bytes</td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">float</td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">4 bytes</td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">double</td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">8 bytes</td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">boolean</td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">1 bit</td></tr></tbody></table></div><p>Since Java 8, all primitive wrapper classes provide a SIZE constant in bits. Since 1 byte= 8 bits, we divide the constant by 8 to obtain the size of the wrapper class in bytes.</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-jmllg8ir9" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">public class Example
{
&nbsp;public static void main (String[] args)
&nbsp;{
&nbsp; &nbsp;System.out.println(" char: " + (Character.SIZE/8) + " bytes");
&nbsp; &nbsp;System.out.println(" byte: " + (Byte.SIZE/8) + " bytes");
&nbsp; &nbsp;System.out.println(" short: " + (Short.SIZE/8) + " bytes");
&nbsp; &nbsp;System.out.println(" int: " + (Integer.SIZE/8) + " bytes");
&nbsp; &nbsp;System.out.println(" long: " + (Long.SIZE/8) + " bytes");
&nbsp; &nbsp;System.out.println(" float: " + (Float.SIZE/8) + " bytes");
&nbsp; &nbsp;System.out.println(" double: " + (Double.SIZE/8) + " bytes");
&nbsp;}
}</pre></div></div><p><strong>The output of the program is as follows:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-0k3lmdddx" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">$javac Example.java
$java Example
char: 2 bytes
byte: 1 bytes
short: 2 bytes
int: 4 bytes
long: 8 bytes
float: 4 bytes
double: 8 bytes</pre></div></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">65. Checked Exception vs Unchecked Exception with examples</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>The exceptions which are checked during compile time are called checked exceptions. When method throws checked exceptions, they must either be handled by the try-catch block or must declare the exception using the throws keyword. In case of violation, it will show a compile time error.</p><p>Unchecked exceptions are the exceptions that are not checked during compile time. If the code throws an unchecked exception and even if it is not handled, it will not generate a compile time error. This is dangerous as unchecked exceptions generally generate runtime errors. All unchecked exceptions are a child class of RuntimeException Class:</p><div class="overflow-x-auto mt-spacing10 mb-[16.8px] md:mb-6 max-w-full"><table class="min-w-full divide-y divide-gray-200 border"><thead><tr><th class="CertTheme__tableCell CertTheme__tableCellHeader" style="border:1px solid black;width:175px;vertical-align:top;text-align:start;background-color:rgb(242, 243, 245)">Checked Exception</th><th class="CertTheme__tableCell CertTheme__tableCellHeader" style="border:1px solid black;width:175px;vertical-align:top;text-align:start;background-color:rgb(242, 243, 245)">Unchecked Exception</th></tr></thead><tbody><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Checked Exceptions are checked by the compiler.</td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Unchecked exceptions are not checked by the compiler.</td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">It is a subclass of Exception class</td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">It is the subclass of RuntimeException class</td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">They are required to be handled by the try catch block or be rethrown by a method using the throws keyword</td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">They are not restricted</td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Checked Exceptions are generated for errors that cannot be directly prevented &nbsp;from occuring</td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Unchecked Exceptions are generated for errors that can be directly prevented from occuring</td></tr></tbody></table></div><p>Example of a Checked Exception by reading a file which is not created:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-hijxw1blm" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">import java.io.File;
import java.io.FileReader;
public class Example
{
&nbsp; public static void main(String args[])
&nbsp; {
&nbsp; &nbsp; &nbsp;File f = new File("D://abc.txt");


&nbsp; &nbsp; &nbsp;// file abc is not created, it generates a FileNotFoundException
&nbsp; &nbsp; &nbsp;FileReader obj= new FileReader(f);
&nbsp; }
}</pre></div></div><p>The exception generated is as follows</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-ikeq11e4k" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">$javac Example.java
Example.java:8: error: unreported exception FileNotFoundException; must be caught or declared to be thrown
&nbsp; &nbsp; &nbsp;FileReader obj= new FileReader(f);
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;^
1 error</pre></div></div><p>Now, let us see an example of an unchecked exception:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-27xftsgib" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">public class Example
{
&nbsp; public static void main(String args[])
&nbsp; {
&nbsp; &nbsp; &nbsp;int val1=10;
&nbsp; &nbsp; &nbsp;int val2=0;
&nbsp; &nbsp; &nbsp;int ans=val1/val2;
&nbsp; &nbsp; &nbsp;System.out.println(ans);
&nbsp; }
}</pre></div></div><p><strong>The output is as follows:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-dzexmya46" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">$javac Example.java
$java &nbsp;Example
Exception in thread "main" java.lang.ArithmeticException: / by zero
at Example.main(Example.java:7)</pre></div></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">66. Check whether a value is uppercase or not</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>To check for uppercase, you need to test the value from ‘A’ to ‘Z’.<br>Let us see an example:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-vlq9k74k2" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">public class Example {
&nbsp; &nbsp; public static void main(String []args) {
&nbsp; &nbsp; &nbsp; &nbsp;char C = 'B';
&nbsp; &nbsp; &nbsp; &nbsp;if (C &gt;= 'A' &amp;&amp; C &lt;= 'Z') {
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;System.out.println("Uppercase!");
&nbsp; &nbsp; &nbsp; &nbsp;} else {
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;System.out.println("Lowecase!");
&nbsp; &nbsp; &nbsp; &nbsp;}
&nbsp; &nbsp; }
}</pre></div></div><p><strong>The output:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-tl4fs91lu" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">Uppercase!</pre></div></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">67. Unsupported Operation Exception in Java</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>Unsupported Operation Exception is an exception thrown by Java during the time of execution of the Java program. It is included in the java.lang package.</p><p>Unsupported Operation Exception is a part of the Collections framework in Java.</p><p>It is a subclass of the Runtime Exception class which is a subclass of the Exception class which, in turn extends the Throwable class.</p><p>The class definition is as follows:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-iccedrczm" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">public class Unsupported Operation Exception extends Runtime Exception</pre></div></div><p>Here is a sample program for Unsupported Operation Exception:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-1m29qs21r" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">import java.util.*;
public class Example
{
&nbsp;public static void main(String[] args)
&nbsp;{
&nbsp; &nbsp;List aList = new ArrayList();
&nbsp; &nbsp;aList.add('a');
&nbsp; &nbsp;aList.add('b');
&nbsp; &nbsp;List newList = Collections.unmodifiableList(aList);
&nbsp; &nbsp;newList.add('c');
&nbsp;}
}</pre></div></div><p><strong>The output displays an error:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-f48lwn61d" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">$javac Example.java.
$java Example
Exception in thread "main" java.lang.Unsupported Operation Exception
at java.util.Collections$UnmodifiableCollection.add(Collections.java:1055)
at Example.main(Example.java:10)</pre></div></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">68. What is the Locale Class in Java</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>A Locale Class is used to perform locale operations and supply locale information to the client or user.</p><p>Locale is defined as a set of parameters that represents a geographical location or place where some operation occurs.</p><p><strong>The locale class is declared as follows:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-s0v2exem9" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">public final class Locale
&nbsp; extends Object
&nbsp; implements Cloneable, Serializable</pre></div></div><p><strong>The Locale class uses the following constructors:</strong></p><ul><li class="CertTheme__listItem pt-spacing10"><strong>Locale(String L) :&nbsp;</strong>Initializes locale from the language code passed as an argument . &nbsp;&nbsp;</li><li class="CertTheme__listItem pt-spacing10"><strong>Locale(String L, String C) :&nbsp;</strong>Initializes locale from the &nbsp;language, country code passed as arguments. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</li><li class="CertTheme__listItem pt-spacing10"><strong>Locale(String L, String C, String V) :&nbsp;</strong>Initializes locale from the &nbsp;language, country, variant passed as arguments.</li></ul><p>The following program is an example for the implementation of the locale class:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-2drvbpyme" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">import java.text.SimpleDateFormat;
import java.util.Locale;
public class Example
{
&nbsp; &nbsp;public static void main(String[] args)
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;Locale arr[] = SimpleDateFormat.getAvailableLocales();
&nbsp; &nbsp; &nbsp; &nbsp;for (int i = 1; i &lt;=15; i++)
&nbsp; &nbsp; &nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp; System.out.printf("\n%s (%s) " ,arr[i].getDisplayName(), arr[i].toString());
&nbsp; &nbsp; &nbsp; &nbsp;}
&nbsp; &nbsp;}
}</pre></div></div><p><strong>The output of the following is as follows</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-m66kzft4c" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">javac Example.java
$java Example
Arabic (United Arab Emirates) (ar_AE)
Arabic (Jordan) (ar_JO)
Arabic (Syria) (ar_SY)
Croatian (Croatia) (hr_HR)
French (Belgium) (fr_BE)
Spanish (Panama) (es_PA)
Maltese (Malta) (mt_MT)
Spanish (Venezuela) (es_VE)
Bulgarian (bg)
Chinese (Taiwan) (zh_TW)
Italian (it)
Korean (ko)
Ukrainian (uk)
Latvian (lv)
Danish (Denmark) (da_DK)</pre></div></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">69. How to make a class Singleton</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p class="CertTheme__paragraph" data-mode="standard"><br></p><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><span>Singleton class is a class which has only a single object. This means you can instantiate the class only once.When we declare the constructor of the class as private, it will limit the scope of the creation of the object.If we return an instance of the object to a static method, we can handle the object creation inside the class itself.</span></p><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><span>We create a static block for the creation of an object.</span></p><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><span>For example,</span></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-ezrck9u09" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm"><span class="CertTheme__tokenAttr">public</span><span> </span><span class="CertTheme__tokenAttr">class</span><span> </span><span class="CertTheme__tokenFunction">Example</span><br><span class="CertTheme__tokenPunctuation">{</span><br><span>&nbsp; &nbsp;</span><span class="CertTheme__tokenAttr">private</span><span> </span><span class="CertTheme__tokenAttr">static</span><span> Example obj</span><span class="CertTheme__tokenPunctuation">;</span><br><span>&nbsp; &nbsp;</span><span class="CertTheme__tokenAttr">static</span><br><span>&nbsp; &nbsp;</span><span class="CertTheme__tokenPunctuation">{</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp;obj </span><span class="CertTheme__tokenOperator">=</span><span> </span><span class="CertTheme__tokenAttr">new</span><span> </span><span class="CertTheme__tokenFunction">Example</span><span class="CertTheme__tokenPunctuation">(</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">;</span><span> </span><span class="CertTheme__tokenComment">// creation of object in a static block</span><br><span>&nbsp; &nbsp;</span><span class="CertTheme__tokenPunctuation">}</span><br><span>&nbsp; &nbsp;</span><span class="CertTheme__tokenAttr">private</span><span> </span><span class="CertTheme__tokenFunction">Example</span><span class="CertTheme__tokenPunctuation">(</span><span class="CertTheme__tokenPunctuation">)</span><span> </span><span class="CertTheme__tokenPunctuation">{</span><span> </span><span class="CertTheme__tokenPunctuation">}</span><span> &nbsp; </span><span class="CertTheme__tokenComment">// declaring the constructor as private</span><br><span>&nbsp; &nbsp;</span><span class="CertTheme__tokenAttr">public</span><span> </span><span class="CertTheme__tokenAttr">static</span><span> Example </span><span class="CertTheme__tokenFunction">getObject</span><span class="CertTheme__tokenPunctuation">(</span><span class="CertTheme__tokenPunctuation">)</span><br><span>&nbsp; &nbsp;</span><span class="CertTheme__tokenPunctuation">{</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp;</span><span class="CertTheme__tokenAttr">return</span><span> obj</span><span class="CertTheme__tokenPunctuation">;</span><span> &nbsp; &nbsp;&nbsp;</span><br><span>&nbsp; &nbsp;</span><span class="CertTheme__tokenPunctuation">}</span><br><span>&nbsp; &nbsp;</span><span class="CertTheme__tokenAttr">public</span><span> </span><span class="CertTheme__tokenAttr">void</span><span> </span><span class="CertTheme__tokenFunction">print</span><span class="CertTheme__tokenPunctuation">(</span><span class="CertTheme__tokenPunctuation">)</span><br><span>&nbsp; &nbsp;</span><span class="CertTheme__tokenPunctuation">{</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp;System</span><span class="CertTheme__tokenPunctuation">.</span><span>out</span><span class="CertTheme__tokenPunctuation">.</span><span class="CertTheme__tokenFunction">println</span><span class="CertTheme__tokenPunctuation">(</span><span class="CertTheme__tokenSelector">"Just for checking"</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">;</span><br><span>&nbsp; &nbsp;</span><span class="CertTheme__tokenPunctuation">}</span><br><span>&nbsp; &nbsp;</span><span class="CertTheme__tokenAttr">public</span><span> </span><span class="CertTheme__tokenAttr">static</span><span> </span><span class="CertTheme__tokenAttr">void</span><span> </span><span class="CertTheme__tokenFunction">main</span><span class="CertTheme__tokenPunctuation">(</span><span>String</span><span class="CertTheme__tokenPunctuation">[</span><span class="CertTheme__tokenPunctuation">]</span><span> args</span><span class="CertTheme__tokenPunctuation">)</span><br><span>&nbsp; &nbsp;</span><span class="CertTheme__tokenPunctuation">{</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp;Example e </span><span class="CertTheme__tokenOperator">=</span><span> </span><span class="CertTheme__tokenFunction">getObject</span><span class="CertTheme__tokenPunctuation">(</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">;</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp;e</span><span class="CertTheme__tokenPunctuation">.</span><span class="CertTheme__tokenFunction">print</span><span class="CertTheme__tokenPunctuation">(</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">;</span><br><span>&nbsp; &nbsp;</span><span class="CertTheme__tokenPunctuation">}</span><br><span class="CertTheme__tokenPunctuation">}</span></pre></div></div><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><br></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">70. Hierarchy of Java Exception Classes</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p>Exceptions in Java are a part of the java.lang.Exception class. It is an issue that arises during the execution of a program.</p><p>All Exception classes in Java are subordinates of the java.lang.Exception class. The java.lang.Exception class is a child class of the Throwable class.</p><p>Another subclass of the Throwable class is the java.lang.Error class. Errors are anomalous conditions that occur in a Java program due to many failures. They cannot be handled by the Java program. Usually, programs can’t recuperate from errors.</p><p><img alt="Exceptions in Java Java Exception Classes" loading="lazy" width="100" height="100" decoding="async"  class="fr-fic fr-dib" style="color:transparent;width:100%;height:auto;background-size:cover;background-position:50% 50%;background-repeat:no-repeat;background-image:url(&quot;data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http%3A//www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cfilter id='b' color-interpolation-filters='sRGB'%3E%3CfeGaussianBlur stdDeviation='20'/%3E%3C/filter%3E%3Cimage preserveAspectRatio='none' filter='url(%23b)' x='0' y='0' height='100%25' width='100%25' href='data:image/svg+xml;base64,CiAgPHN2ZyB3aWR0aD0iMTAwIiBoZWlnaHQ9IjEwMCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIj4KICAgIDxkZWZzPgogICAgICA8bGluZWFyR3JhZGllbnQgaWQ9ImciPgogICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNjY2MiIG9mZnNldD0iMjAlIiAvPgogICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNkZGQiIG9mZnNldD0iNTAlIiAvPgogICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNlZWUiIG9mZnNldD0iNzAlIiAvPgogICAgICA8L2xpbmVhckdyYWRpZW50PgogICAgPC9kZWZzPgogICAgPHJlY3Qgd2lkdGg9IjEwMCIgaGVpZ2h0PSIxMDAiIGZpbGw9IiNlZWUiIC8+CiAgICA8cmVjdCBpZD0iciIgd2lkdGg9IjEwMCIgaGVpZ2h0PSIxMDAiIGZpbGw9InVybCgjZykiIC8+CiAgICA8YW5pbWF0ZSB4bGluazpocmVmPSIjciIgYXR0cmlidXRlTmFtZT0ieCIgZnJvbT0iLTEwMCIgdG89IjEwMCIgZHVyPSIxcyIgcmVwZWF0Q291bnQ9ImluZGVmaW5pdGUiICAvPgogIDwvc3ZnPg=='/%3E%3C/svg%3E&quot;)" sizes="(min-width: 767px) 50vw, 100vw" srcSet="" src="https://images.unsplash.com/photo-1531482615713-2afd69097998?ixlib=rb-4.0.3&auto=format&fit=crop&w=1000&q=80"></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">71. Get the cause of an exception in Java</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>A staple in Java programming interview questions, be prepared to answer this one.</p><p>In Java, we use the getCause() method, which returns the cause of the exception or returns null if the cause of the exception is not known.</p><p>The declaration of the java.lang.Throwable.getCause() is</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-5hs8o41ia" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">public Throwable getCause()</pre></div></div><p>The getCause() method doesn’t accept any arguments and doesn’t throw an exception. It returns the cause that was provided by one of its constructors or that was determined by formation of the initCause(Throwable) method.</p><p>Let us see an example on the working of the getCause() method as we try to compile a program with ArrayIndexOutOfBoundsException:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-hgbrhceld" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">public class Example
{
&nbsp; public static void main(String[] args) throws Exception
&nbsp; {
&nbsp; &nbsp; &nbsp; try
&nbsp; &nbsp; &nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;myException();
&nbsp; &nbsp; &nbsp; &nbsp;}
&nbsp; &nbsp; &nbsp; catch(Exception e)
&nbsp; &nbsp; &nbsp; {
&nbsp; &nbsp; &nbsp; &nbsp; System.err.println("Cause = " + e.getCause());
&nbsp; &nbsp; &nbsp; }
&nbsp; }
&nbsp; public static void myException() throws Exception
&nbsp; {
&nbsp; &nbsp; &nbsp; &nbsp;int arr[]={1,3,5};
&nbsp; &nbsp; &nbsp; &nbsp;try
&nbsp; &nbsp; &nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;System.out.println(arr[8]); &nbsp;// generates an ArrayIndexOutOfBoundsException
&nbsp; &nbsp; &nbsp; &nbsp;}
&nbsp; &nbsp; &nbsp; catch(ArrayIndexOutOfBoundsException aie)
&nbsp; &nbsp; &nbsp; {
&nbsp; &nbsp; &nbsp; &nbsp;Exception e = new Exception(); // creating Exception class object
&nbsp; &nbsp; &nbsp; &nbsp;throw (Exception) &nbsp;// throwing the exception to be caught by catch block in main()
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;e.initCause(aie); // supplies the cause to getCause()
&nbsp; &nbsp; &nbsp; }
&nbsp; }
} &nbsp; </pre></div></div><p><strong>The output is as follows:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-aa56gp973" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">$javac Example.java
$java Example
Cause = java.lang.ArrayIndexOutOfBoundsException: 8</pre></div></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">72. Print stack trace information in Java</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>The printStackTrace() method assists the programmer to find the trace of the actual error. It prints the throwable and its backtrace in the standard error stream.</p><p>It is a method of the java.lang.Throwable Class. The printStackTrace() method &nbsp;doesn’t have any parameter and doesn’t return any value.</p><p>The java.lang.Throwable.printStackTrace() method is declared as follows</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-t34u0td1v" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">public void printStackTrace()</pre></div></div><p>The printStackTrace() method is a very useful tool in diagnosing exceptions.</p><p>Let us see an example when a program prints the stack trace information when we divide a number by zero to generate an ArithmeticException:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-l8uufc83p" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">public class Example
{
&nbsp; public static void main(String[] args)
&nbsp; {
&nbsp; &nbsp; &nbsp; try
&nbsp; &nbsp; &nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp; int x=1/0; // generates ArithmeticException
&nbsp; &nbsp; &nbsp; &nbsp;}
&nbsp; &nbsp; &nbsp; &nbsp;catch(ArithmeticException e)
&nbsp; &nbsp; &nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;e.printStackTrace(); //prints the stack trace information
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;System.out.println("Caught you dividing by zero!");
&nbsp; &nbsp; &nbsp; &nbsp;}
&nbsp; }
}</pre></div></div><p><strong>The program generates the following output wherein we are printing the stack trace:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-asbr8t780" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">$javac Example.java
$java Example
Caught dividing by zero!
java.lang.ArithmeticException: / by zero
at Example.main(Example.java:7)</pre></div></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">73. What is meant by Ordered and Sorted in Java collections?</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p class="CertTheme__paragraph" data-mode="standard"><br></p><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><b><strong class="CertTheme__textBold">Ordered in Java Collection</strong></b></p><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><span>An ordered collection in Java mean that the elements of the collection have a definite order. The order of the elements is unconstrained by their value. In other words, the order of the elements in the ordered collection does not depend on their value. An example for an ordered Java collection is a List</span><b><strong class="CertTheme__textBold">.</strong></b></p><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><span>List in Java are interface that extend the Collection interface. Java List allows us to exercise control over the index for insertion of elements. List allows searching and access of elements by their index. Duplicate elements can be stored in a List.</span></p><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><span>Instances of the list can be created by the new keyword along with the ArrayList, LinkedList, Vector and Stack classes.</span></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-e52926gqd" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm"><span>List arrayListObj </span><span class="CertTheme__tokenOperator">=</span><span> </span><span class="CertTheme__tokenAttr">new</span><span> </span><span class="CertTheme__tokenFunction">ArrayList</span><span class="CertTheme__tokenPunctuation">(</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">;</span><br><span>List stackObj </span><span class="CertTheme__tokenOperator">=</span><span> </span><span class="CertTheme__tokenAttr">new</span><span> </span><span class="CertTheme__tokenFunction">Stack</span><span class="CertTheme__tokenPunctuation">(</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">;</span><br><span>List linkedListObj </span><span class="CertTheme__tokenOperator">=</span><span> </span><span class="CertTheme__tokenAttr">new</span><span> </span><span class="CertTheme__tokenFunction">LinkedList</span><span class="CertTheme__tokenPunctuation">(</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">;</span><br><span>List vectorObj </span><span class="CertTheme__tokenOperator">=</span><span> </span><span class="CertTheme__tokenAttr">new</span><span> </span><span class="CertTheme__tokenFunction">Vector</span><span class="CertTheme__tokenPunctuation">(</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">;</span></pre></div></div><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><span>After JDK 1.5, we can limit the type of object we want in the List,</span></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-syrr0zbv3" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm"><span>List</span><span class="CertTheme__tokenOperator">&lt;</span><span>Obj</span><span class="CertTheme__tokenOperator">&gt;</span><span> list </span><span class="CertTheme__tokenOperator">=</span><span> </span><span class="CertTheme__tokenAttr">new</span><span> </span><span class="CertTheme__tokenFunction">List</span><span class="CertTheme__tokenOperator">&lt;</span><span>Obj</span><span class="CertTheme__tokenOperator">&gt;</span><span class="CertTheme__tokenPunctuation">(</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">;</span></pre></div></div><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><b><strong class="CertTheme__textBold">Let us see an example of a List in Java:</strong></b></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-il0x636fl" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm"><span class="CertTheme__tokenAttr">import</span><span> java</span><span class="CertTheme__tokenPunctuation">.</span><span>util</span><span class="CertTheme__tokenPunctuation">.</span><span class="CertTheme__tokenOperator">*</span><span class="CertTheme__tokenPunctuation">;</span><br><span class="CertTheme__tokenAttr">public</span><span> </span><span class="CertTheme__tokenAttr">class</span><span> </span><span class="CertTheme__tokenFunction">Example</span><br><span class="CertTheme__tokenPunctuation">{</span><br><span>&nbsp; </span><span class="CertTheme__tokenAttr">public</span><span> </span><span class="CertTheme__tokenAttr">static</span><span> </span><span class="CertTheme__tokenAttr">void</span><span> </span><span class="CertTheme__tokenFunction">main</span><span class="CertTheme__tokenPunctuation">(</span><span>String</span><span class="CertTheme__tokenPunctuation">[</span><span class="CertTheme__tokenPunctuation">]</span><span> args</span><span class="CertTheme__tokenPunctuation">)</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="CertTheme__tokenPunctuation">{</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp;List</span><span class="CertTheme__tokenOperator">&lt;</span><span>Integer</span><span class="CertTheme__tokenOperator">&gt;</span><span> list </span><span class="CertTheme__tokenOperator">=</span><span> </span><span class="CertTheme__tokenAttr">new</span><span> </span><span class="CertTheme__tokenFunction">ArrayList</span><span class="CertTheme__tokenOperator">&lt;</span><span>Integer</span><span class="CertTheme__tokenOperator">&gt;</span><span class="CertTheme__tokenPunctuation">(</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">;</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp;list</span><span class="CertTheme__tokenPunctuation">.</span><span class="CertTheme__tokenFunction">add</span><span class="CertTheme__tokenPunctuation">(</span><span class="CertTheme__tokenProperty">0</span><span class="CertTheme__tokenPunctuation">,</span><span class="CertTheme__tokenProperty">6</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">;</span><span> </span><span class="CertTheme__tokenComment">// adds element 6 at index 0</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp;list</span><span class="CertTheme__tokenPunctuation">.</span><span class="CertTheme__tokenFunction">add</span><span class="CertTheme__tokenPunctuation">(</span><span class="CertTheme__tokenProperty">1</span><span class="CertTheme__tokenPunctuation">,</span><span class="CertTheme__tokenProperty">3</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">;</span><span> </span><span class="CertTheme__tokenComment">// adds element 3 at index 1</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp;list</span><span class="CertTheme__tokenPunctuation">.</span><span class="CertTheme__tokenFunction">add</span><span class="CertTheme__tokenPunctuation">(</span><span class="CertTheme__tokenProperty">2</span><span class="CertTheme__tokenPunctuation">,</span><span class="CertTheme__tokenProperty">9</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">;</span><span> </span><span class="CertTheme__tokenComment">// adds element 9 at index 2</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp;System</span><span class="CertTheme__tokenPunctuation">.</span><span>out</span><span class="CertTheme__tokenPunctuation">.</span><span class="CertTheme__tokenFunction">println</span><span class="CertTheme__tokenPunctuation">(</span><span>list</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">;</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp;list</span><span class="CertTheme__tokenPunctuation">.</span><span class="CertTheme__tokenFunction">remove</span><span class="CertTheme__tokenPunctuation">(</span><span class="CertTheme__tokenProperty">1</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">;</span><span> </span><span class="CertTheme__tokenComment">// removes element at index = 1</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp;System</span><span class="CertTheme__tokenPunctuation">.</span><span>out</span><span class="CertTheme__tokenPunctuation">.</span><span class="CertTheme__tokenFunction">println</span><span class="CertTheme__tokenPunctuation">(</span><span>list</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">;</span><br><span>&nbsp; &nbsp;</span><span class="CertTheme__tokenPunctuation">}</span></pre></div></div><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><b><strong class="CertTheme__textBold">The output is as follows</strong></b></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-rb1kg9thx" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm"><span>$javac Example</span><span class="CertTheme__tokenPunctuation">.</span><span>java</span><br><span>$java Example</span><br><span class="CertTheme__tokenPunctuation">[</span><span class="CertTheme__tokenProperty">6</span><span class="CertTheme__tokenPunctuation">,</span><span> </span><span class="CertTheme__tokenProperty">3</span><span class="CertTheme__tokenPunctuation">,</span><span> </span><span class="CertTheme__tokenProperty">9</span><span class="CertTheme__tokenPunctuation">]</span><br><span class="CertTheme__tokenPunctuation">[</span><span class="CertTheme__tokenProperty">6</span><span class="CertTheme__tokenPunctuation">,</span><span> </span><span class="CertTheme__tokenProperty">9</span><span class="CertTheme__tokenPunctuation">]</span></pre></div></div><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><b><strong class="CertTheme__textBold">Sorted in Java Collection</strong></b></p><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><span>A sorted collection in Java is a collection whose elements have a definite order and the order is constrained by the values of the elements. In other words, the order of the elements is dependent on the values of the elements.</span></p><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><span>An example for a sorted collection in Java is a SortedSet.</span></p><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><span>SortedSet is an interface which extends the Set interface in Java. All the components in SortedSet are bound to implement the Comparator interface in Java.</span></p><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><b><strong class="CertTheme__textBold">Let us see an example of a SortedSet:</strong></b></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-g8wtmgl1m" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm"><span class="CertTheme__tokenAttr">import</span><span> java</span><span class="CertTheme__tokenPunctuation">.</span><span>util</span><span class="CertTheme__tokenPunctuation">.</span><span class="CertTheme__tokenOperator">*</span><span class="CertTheme__tokenPunctuation">;</span><br><span class="CertTheme__tokenAttr">public</span><span> </span><span class="CertTheme__tokenAttr">class</span><span> </span><span class="CertTheme__tokenFunction">Example</span><br><span class="CertTheme__tokenPunctuation">{</span><br><span>&nbsp; </span><span class="CertTheme__tokenAttr">public</span><span> </span><span class="CertTheme__tokenAttr">static</span><span> </span><span class="CertTheme__tokenAttr">void</span><span> </span><span class="CertTheme__tokenFunction">main</span><span class="CertTheme__tokenPunctuation">(</span><span>String</span><span class="CertTheme__tokenPunctuation">[</span><span class="CertTheme__tokenPunctuation">]</span><span> args</span><span class="CertTheme__tokenPunctuation">)</span><br><span>&nbsp; </span><span class="CertTheme__tokenPunctuation">{</span><br><span>&nbsp; &nbsp; &nbsp;SortedSet set </span><span class="CertTheme__tokenOperator">=</span><span> </span><span class="CertTheme__tokenAttr">new</span><span> </span><span class="CertTheme__tokenFunction">TreeSet</span><span class="CertTheme__tokenPunctuation">(</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">;</span><span> </span><span class="CertTheme__tokenComment">// creating a SortedSet object set</span><br><span>&nbsp; &nbsp; &nbsp;set</span><span class="CertTheme__tokenPunctuation">.</span><span class="CertTheme__tokenFunction">add</span><span class="CertTheme__tokenPunctuation">(</span><span class="CertTheme__tokenProperty">10</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">;</span><span> &nbsp;</span><span class="CertTheme__tokenComment">// adding 10 to the SortedSet</span><br><span>&nbsp; &nbsp; &nbsp;set</span><span class="CertTheme__tokenPunctuation">.</span><span class="CertTheme__tokenFunction">add</span><span class="CertTheme__tokenPunctuation">(</span><span class="CertTheme__tokenProperty">1</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">;</span><span> &nbsp; </span><span class="CertTheme__tokenComment">// adding 1 to the SortedSet</span><br><span>&nbsp; &nbsp; &nbsp;set</span><span class="CertTheme__tokenPunctuation">.</span><span class="CertTheme__tokenFunction">add</span><span class="CertTheme__tokenPunctuation">(</span><span class="CertTheme__tokenProperty">4</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">;</span><span> &nbsp; </span><span class="CertTheme__tokenComment">// adding 4 to the SortedSet</span><br><span>&nbsp; &nbsp; &nbsp;Iterator i </span><span class="CertTheme__tokenOperator">=</span><span> set</span><span class="CertTheme__tokenPunctuation">.</span><span class="CertTheme__tokenFunction">iterator</span><span class="CertTheme__tokenPunctuation">(</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">;</span><span> </span><span class="CertTheme__tokenComment">// creating an iterator</span><br><span>&nbsp; &nbsp; &nbsp;</span><span class="CertTheme__tokenComment">// iterating through the SortedSet by checking for the presence of next element</span><br><span>&nbsp; &nbsp; &nbsp;</span><span class="CertTheme__tokenAttr">while</span><span> </span><span class="CertTheme__tokenPunctuation">(</span><span>i</span><span class="CertTheme__tokenPunctuation">.</span><span class="CertTheme__tokenFunction">hasNext</span><span class="CertTheme__tokenPunctuation">(</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">)</span><br><span>&nbsp; &nbsp; &nbsp;</span><span class="CertTheme__tokenPunctuation">{</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp; Object obj </span><span class="CertTheme__tokenOperator">=</span><span> i</span><span class="CertTheme__tokenPunctuation">.</span><span class="CertTheme__tokenFunction">next</span><span class="CertTheme__tokenPunctuation">(</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">;</span><span> </span><span class="CertTheme__tokenComment">// acquiring the element</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp; System</span><span class="CertTheme__tokenPunctuation">.</span><span>out</span><span class="CertTheme__tokenPunctuation">.</span><span class="CertTheme__tokenFunction">println</span><span class="CertTheme__tokenPunctuation">(</span><span>obj</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">;</span><br><span>&nbsp; &nbsp; &nbsp;</span><span class="CertTheme__tokenPunctuation">}</span><br><span>&nbsp; </span><span class="CertTheme__tokenPunctuation">}</span><br><span class="CertTheme__tokenPunctuation">}</span></pre></div></div><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><b><strong class="CertTheme__textBold">The output is as follows:</strong></b></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-44jdggzu0" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm"><span>$javac Example</span><span class="CertTheme__tokenPunctuation">.</span><span>java</span><br><span>$java Example</span><br><span class="CertTheme__tokenProperty">1</span><br><span class="CertTheme__tokenProperty">4</span><br><span class="CertTheme__tokenProperty">10</span></pre></div></div><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><br></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">74. How Java achieves Platform Independence?</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p>Java is a platform independent programming language. It can operate on any platform i.e. operating system with little or no change.</p><p>The Java Virtual Machine plays a pivotal role in making Java a platform independent language. When the Java program is compiled, a .class file is created by the Java compiler. This .class file contains nothing but Java ByteCode. The Java ByteCode is a highly developed set of instructions given to the Java Virtual Machine to generate the machine code. It is the machine code in the form of the .class file . ByteCode is independent on the version of JVM.</p><p>JVM is dependent on the system. So when the .class file is ported to the other system, that system’s JVM runs the bytecode and converts it into a machine level code which the system can understand. Thus Java achieves platform independence.</p><p>An important point to be taken in consideration is that the Java Virtual Machine does not have any knowledge in regard to the programming language. It only is aware of the binary format of the ByteCode and confirm that the .class file is as per Java ByteCode specification thus eliminating errors of running bad Java ByteCodes:</p><p><img alt="Java achieves Platform" loading="lazy" width="100" height="100" decoding="async"  class="fr-fic fr-dib" style="color:transparent;width:100%;height:auto;background-size:cover;background-position:50% 50%;background-repeat:no-repeat;background-image:url(&quot;data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http%3A//www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cfilter id='b' color-interpolation-filters='sRGB'%3E%3CfeGaussianBlur stdDeviation='20'/%3E%3C/filter%3E%3Cimage preserveAspectRatio='none' filter='url(%23b)' x='0' y='0' height='100%25' width='100%25' href='data:image/svg+xml;base64,CiAgPHN2ZyB3aWR0aD0iMTAwIiBoZWlnaHQ9IjEwMCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIj4KICAgIDxkZWZzPgogICAgICA8bGluZWFyR3JhZGllbnQgaWQ9ImciPgogICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNjY2MiIG9mZnNldD0iMjAlIiAvPgogICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNkZGQiIG9mZnNldD0iNTAlIiAvPgogICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNlZWUiIG9mZnNldD0iNzAlIiAvPgogICAgICA8L2xpbmVhckdyYWRpZW50PgogICAgPC9kZWZzPgogICAgPHJlY3Qgd2lkdGg9IjEwMCIgaGVpZ2h0PSIxMDAiIGZpbGw9IiNlZWUiIC8+CiAgICA8cmVjdCBpZD0iciIgd2lkdGg9IjEwMCIgaGVpZ2h0PSIxMDAiIGZpbGw9InVybCgjZykiIC8+CiAgICA8YW5pbWF0ZSB4bGluazpocmVmPSIjciIgYXR0cmlidXRlTmFtZT0ieCIgZnJvbT0iLTEwMCIgdG89IjEwMCIgZHVyPSIxcyIgcmVwZWF0Q291bnQ9ImluZGVmaW5pdGUiICAvPgogIDwvc3ZnPg=='/%3E%3C/svg%3E&quot;)" sizes="(min-width: 767px) 50vw, 100vw" srcSet="" src="https://images.unsplash.com/photo-1516321318423-f06f85e504b3?ixlib=rb-4.0.3&auto=format&fit=crop&w=1000&q=80"></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">75. Implement Runnable vs Extend Thread in Java</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p class="CertTheme__paragraph" data-mode="standard"><br></p><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><span>We have the ability to define a Thread in two ways:</span></p><ol class="CertTheme__ol1 pt-spacing10"><li value="1" class="CertTheme__listItem pt-spacing10"><span>By extending the Thread class</span></li><li value="2" class="CertTheme__listItem pt-spacing10"><span>By implementing the Interface</span></li></ol><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><span>By the first technique, the Thread class is extended. Since Java doesn’t support multiple inheritance, we can’t extend any other class. This is a shortcoming as the benefits of inheritance can’t be completely exploited.</span></p><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><span>By the second technique, the Runnable interface is implemented. We can extend any other class and use the advantages of inheritance completely.</span></p><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><span>Let us see a program where we extend the Thread class:</span></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-ccuvwm7zr" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm"><span class="CertTheme__tokenAttr">public</span><span> </span><span class="CertTheme__tokenAttr">class</span><span> </span><span class="CertTheme__tokenFunction">Example</span><span> </span><span class="CertTheme__tokenAttr">extends</span><span> </span><span class="CertTheme__tokenFunction">Thread</span><span> &nbsp;</span><span class="CertTheme__tokenComment">// any other class can’t be extended</span><br><span class="CertTheme__tokenPunctuation">{</span><br><span>&nbsp; &nbsp;</span><span class="CertTheme__tokenAttr">public</span><span> </span><span class="CertTheme__tokenAttr">void</span><span> </span><span class="CertTheme__tokenFunction">run</span><span class="CertTheme__tokenPunctuation">(</span><span class="CertTheme__tokenPunctuation">)</span><br><span>&nbsp; &nbsp;</span><span class="CertTheme__tokenPunctuation">{</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp;System</span><span class="CertTheme__tokenPunctuation">.</span><span>out</span><span class="CertTheme__tokenPunctuation">.</span><span class="CertTheme__tokenFunction">println</span><span class="CertTheme__tokenPunctuation">(</span><span class="CertTheme__tokenSelector">"Thread running"</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">;</span><br><span>&nbsp; &nbsp;</span><span class="CertTheme__tokenPunctuation">}</span><br><span>&nbsp; &nbsp;</span><span class="CertTheme__tokenAttr">public</span><span> </span><span class="CertTheme__tokenAttr">static</span><span> </span><span class="CertTheme__tokenAttr">void</span><span> </span><span class="CertTheme__tokenFunction">main</span><span class="CertTheme__tokenPunctuation">(</span><span>String</span><span class="CertTheme__tokenPunctuation">[</span><span class="CertTheme__tokenPunctuation">]</span><span> args</span><span class="CertTheme__tokenPunctuation">)</span><br><span>&nbsp; &nbsp;</span><span class="CertTheme__tokenPunctuation">{</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp;Example obj </span><span class="CertTheme__tokenOperator">=</span><span> </span><span class="CertTheme__tokenAttr">new</span><span> </span><span class="CertTheme__tokenFunction">Example</span><span class="CertTheme__tokenPunctuation">(</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">;</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp;obj</span><span class="CertTheme__tokenPunctuation">.</span><span class="CertTheme__tokenFunction">start</span><span class="CertTheme__tokenPunctuation">(</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">;</span><span> </span><span class="CertTheme__tokenComment">// it calls the run() method</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp;System</span><span class="CertTheme__tokenPunctuation">.</span><span>out</span><span class="CertTheme__tokenPunctuation">.</span><span class="CertTheme__tokenFunction">println</span><span class="CertTheme__tokenPunctuation">(</span><span class="CertTheme__tokenSelector">"Thread starting"</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">;</span><br><span>&nbsp; &nbsp;</span><span class="CertTheme__tokenPunctuation">}</span><br><span class="CertTheme__tokenPunctuation">}</span></pre></div></div><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><span>The output is as follows:</span></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-v5u8ccmca" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm"><span>$javac Example</span><span class="CertTheme__tokenPunctuation">.</span><span>java</span><br><span>$java Example</span><br><span>Thread starting</span><br><span>Thread running</span></pre></div></div><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><span>Let us now see the implementation of the Runnable interface</span></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-a2hif14vs" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm"><span class="CertTheme__tokenAttr">class</span><span> </span><span class="CertTheme__tokenFunction">Parent</span><br><span class="CertTheme__tokenPunctuation">{</span><br><span>&nbsp; &nbsp;</span><span class="CertTheme__tokenAttr">public</span><span> </span><span class="CertTheme__tokenAttr">static</span><span> </span><span class="CertTheme__tokenAttr">void</span><span> </span><span class="CertTheme__tokenFunction">method</span><span class="CertTheme__tokenPunctuation">(</span><span class="CertTheme__tokenPunctuation">)</span><br><span>&nbsp; &nbsp;</span><span class="CertTheme__tokenPunctuation">{</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp;System</span><span class="CertTheme__tokenPunctuation">.</span><span>out</span><span class="CertTheme__tokenPunctuation">.</span><span class="CertTheme__tokenFunction">println</span><span class="CertTheme__tokenPunctuation">(</span><span class="CertTheme__tokenSelector">"This is an extended class"</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">;</span><br><span>&nbsp; &nbsp;</span><span class="CertTheme__tokenPunctuation">}</span><br><span class="CertTheme__tokenPunctuation">}</span><br><span class="CertTheme__tokenComment">// since Runnable is a interface, class Example can extend class Parent</span><br><span class="CertTheme__tokenAttr">public</span><span> </span><span class="CertTheme__tokenAttr">class</span><span> </span><span class="CertTheme__tokenFunction">Example</span><span> </span><span class="CertTheme__tokenAttr">extends</span><span> </span><span class="CertTheme__tokenFunction">Parent</span><span> </span><span class="CertTheme__tokenAttr">implements</span><span> </span><span class="CertTheme__tokenFunction">Runnable</span><br><span class="CertTheme__tokenPunctuation">{</span><br><span>&nbsp; &nbsp;</span><span class="CertTheme__tokenAttr">public</span><span> </span><span class="CertTheme__tokenAttr">void</span><span> </span><span class="CertTheme__tokenFunction">run</span><span class="CertTheme__tokenPunctuation">(</span><span class="CertTheme__tokenPunctuation">)</span><br><span>&nbsp; &nbsp;</span><span class="CertTheme__tokenPunctuation">{</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp;System</span><span class="CertTheme__tokenPunctuation">.</span><span>out</span><span class="CertTheme__tokenPunctuation">.</span><span class="CertTheme__tokenFunction">println</span><span class="CertTheme__tokenPunctuation">(</span><span class="CertTheme__tokenSelector">"Thread running"</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">;</span><br><span>&nbsp; &nbsp;</span><span class="CertTheme__tokenPunctuation">}</span><br><span>&nbsp; &nbsp;</span><span class="CertTheme__tokenAttr">public</span><span> </span><span class="CertTheme__tokenAttr">static</span><span> </span><span class="CertTheme__tokenAttr">void</span><span> </span><span class="CertTheme__tokenFunction">main</span><span class="CertTheme__tokenPunctuation">(</span><span>String</span><span class="CertTheme__tokenPunctuation">[</span><span class="CertTheme__tokenPunctuation">]</span><span> args</span><span class="CertTheme__tokenPunctuation">)</span><br><span>&nbsp; &nbsp;</span><span class="CertTheme__tokenPunctuation">{</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp;Example obj </span><span class="CertTheme__tokenOperator">=</span><span> </span><span class="CertTheme__tokenAttr">new</span><span> </span><span class="CertTheme__tokenFunction">Example</span><span class="CertTheme__tokenPunctuation">(</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">;</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp;obj</span><span class="CertTheme__tokenPunctuation">.</span><span class="CertTheme__tokenFunction">method</span><span class="CertTheme__tokenPunctuation">(</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">;</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp;Thread t </span><span class="CertTheme__tokenOperator">=</span><span> </span><span class="CertTheme__tokenAttr">new</span><span> </span><span class="CertTheme__tokenFunction">Thread</span><span class="CertTheme__tokenPunctuation">(</span><span>obj</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">;</span><span> </span><span class="CertTheme__tokenComment">// creating a new thread t</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp;t</span><span class="CertTheme__tokenPunctuation">.</span><span class="CertTheme__tokenFunction">start</span><span class="CertTheme__tokenPunctuation">(</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">;</span><span> </span><span class="CertTheme__tokenComment">// calls the run() method</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp;System</span><span class="CertTheme__tokenPunctuation">.</span><span>out</span><span class="CertTheme__tokenPunctuation">.</span><span class="CertTheme__tokenFunction">println</span><span class="CertTheme__tokenPunctuation">(</span><span class="CertTheme__tokenSelector">"Thread starting"</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">;</span><br><span>&nbsp; &nbsp;</span><span class="CertTheme__tokenPunctuation">}</span><br><span class="CertTheme__tokenPunctuation">}</span></pre></div></div><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><b><strong class="CertTheme__textBold">The output is as follows:</strong></b></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-ez1livkb1" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm"><span>$javac Example</span><span class="CertTheme__tokenPunctuation">.</span><span>java</span><br><span>$java &nbsp;Example</span><br><span>This is an extended </span><span class="CertTheme__tokenAttr">class</span><br><span class="CertTheme__tokenFunction">Thread</span><span> starting</span><br><span>Thread running</span></pre></div></div><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><br></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">76. Hierarchy of InputStream and OutputStream in Java</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>The InputStream is an abstract class of the java.io package. It is the parent class of all the subclasses related to input in the form of sequence of bytes.</p><p><img alt="Hierarchy of InputStream and OutputStream in Java" loading="lazy" width="100" height="100" decoding="async"  class="fr-fic fr-dib" style="color:transparent;width:100%;height:auto;background-size:cover;background-position:50% 50%;background-repeat:no-repeat;background-image:url(&quot;data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http%3A//www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cfilter id='b' color-interpolation-filters='sRGB'%3E%3CfeGaussianBlur stdDeviation='20'/%3E%3C/filter%3E%3Cimage preserveAspectRatio='none' filter='url(%23b)' x='0' y='0' height='100%25' width='100%25' href='data:image/svg+xml;base64,CiAgPHN2ZyB3aWR0aD0iMTAwIiBoZWlnaHQ9IjEwMCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIj4KICAgIDxkZWZzPgogICAgICA8bGluZWFyR3JhZGllbnQgaWQ9ImciPgogICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNjY2MiIG9mZnNldD0iMjAlIiAvPgogICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNkZGQiIG9mZnNldD0iNTAlIiAvPgogICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNlZWUiIG9mZnNldD0iNzAlIiAvPgogICAgICA8L2xpbmVhckdyYWRpZW50PgogICAgPC9kZWZzPgogICAgPHJlY3Qgd2lkdGg9IjEwMCIgaGVpZ2h0PSIxMDAiIGZpbGw9IiNlZWUiIC8+CiAgICA8cmVjdCBpZD0iciIgd2lkdGg9IjEwMCIgaGVpZ2h0PSIxMDAiIGZpbGw9InVybCgjZykiIC8+CiAgICA8YW5pbWF0ZSB4bGluazpocmVmPSIjciIgYXR0cmlidXRlTmFtZT0ieCIgZnJvbT0iLTEwMCIgdG89IjEwMCIgZHVyPSIxcyIgcmVwZWF0Q291bnQ9ImluZGVmaW5pdGUiICAvPgogIDwvc3ZnPg=='/%3E%3C/svg%3E&quot;)" sizes="(min-width: 767px) 50vw, 100vw" srcSet="" src="https://images.unsplash.com/photo-1510511459019-1d227f4220b3?ixlib=rb-4.0.3&auto=format&fit=crop&w=1000&q=80"></p><ul><li class="CertTheme__listItem pt-spacing10">FileInputStream consists of input bytes from a file.</li><li class="CertTheme__listItem pt-spacing10">ByteArrayInputStream&nbsp;reads the next byte of data from the input stream.</li><li class="CertTheme__listItem pt-spacing10">FilterInputStream returns the approximate number of bytes that can be read from the input stream. It consists of the DataInputStream,&nbsp;BufferedInputStream&nbsp;and&nbsp;PushBackInputStream&nbsp;classes.</li><li class="CertTheme__listItem pt-spacing10">PipedInputStream can be used to read data and is piped with PipedOutputStream. A pipe is said to be a link between two threads running in JVM simultaneously.</li><li class="CertTheme__listItem pt-spacing10">ObjectInputStream is used to deserialize primitive data types and objects previously written by the ObjectOutputStream.</li></ul><p>The OutputStream is an abstract class of the java.io package. It is the parent all the subclasses related to input in the form of sequence of bytes.</p><p><img alt="Hierarchy of InputStream and OutputStream in Java" loading="lazy" width="100" height="100" decoding="async"  class="fr-fic fr-dib" style="color:transparent;width:100%;height:auto;background-size:cover;background-position:50% 50%;background-repeat:no-repeat;background-image:url(&quot;data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http%3A//www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cfilter id='b' color-interpolation-filters='sRGB'%3E%3CfeGaussianBlur stdDeviation='20'/%3E%3C/filter%3E%3Cimage preserveAspectRatio='none' filter='url(%23b)' x='0' y='0' height='100%25' width='100%25' href='data:image/svg+xml;base64,CiAgPHN2ZyB3aWR0aD0iMTAwIiBoZWlnaHQ9IjEwMCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIj4KICAgIDxkZWZzPgogICAgICA8bGluZWFyR3JhZGllbnQgaWQ9ImciPgogICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNjY2MiIG9mZnNldD0iMjAlIiAvPgogICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNkZGQiIG9mZnNldD0iNTAlIiAvPgogICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNlZWUiIG9mZnNldD0iNzAlIiAvPgogICAgICA8L2xpbmVhckdyYWRpZW50PgogICAgPC9kZWZzPgogICAgPHJlY3Qgd2lkdGg9IjEwMCIgaGVpZ2h0PSIxMDAiIGZpbGw9IiNlZWUiIC8+CiAgICA8cmVjdCBpZD0iciIgd2lkdGg9IjEwMCIgaGVpZ2h0PSIxMDAiIGZpbGw9InVybCgjZykiIC8+CiAgICA8YW5pbWF0ZSB4bGluazpocmVmPSIjciIgYXR0cmlidXRlTmFtZT0ieCIgZnJvbT0iLTEwMCIgdG89IjEwMCIgZHVyPSIxcyIgcmVwZWF0Q291bnQ9ImluZGVmaW5pdGUiICAvPgogIDwvc3ZnPg=='/%3E%3C/svg%3E&quot;)" sizes="(min-width: 767px) 50vw, 100vw" srcSet="" src="https://images.unsplash.com/photo-1510511459019-1d227f4220b3?ixlib=rb-4.0.3&auto=format&fit=crop&w=1000&q=80"></p><ul><li class="CertTheme__listItem pt-spacing10">FileOutputStream is a output stream used for writing data into a file.</li><li class="CertTheme__listItem pt-spacing10">ByteArrayOutputStream allows us to seize data written to a stream in an array.</li><li class="CertTheme__listItem pt-spacing10">FilterOutputStream is the parent class of all those classes which filter output streams. It is extended by many subclasses including DataOutputStream, BufferedOutputStream and PrintStream.</li><li class="CertTheme__listItem pt-spacing10">PipedOutputStream is piped with the PipedInputStream.</li><li class="CertTheme__listItem pt-spacing10">ObjectOutputStream writes primitive objects, data types and graphs to the OutputStream.</li></ul><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">77. Role of JDK, JRE and JVM</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>Details about JDK, JRE and JVM in Java are given as follows:</p><h3><span style="color:rgb(0, 0, 0)">Java Development Kit (JDK)</span></h3><p>The Java SE, Jakarta EE or the Java Me are platforms whose implementation is done by the Java Development Kit. The basic contents of the JDK are resources for a Java application and the JVM. A list of some of the JDK programming tools is given as follows:</p><ol class="CertTheme__ol1 pt-spacing10"><li class="CertTheme__listItem pt-spacing10">pack200 - This is a JAR compression tool.</li><li class="CertTheme__listItem pt-spacing10">appletviewer - This runs and debugs the Java applets without using a web browser.</li><li class="CertTheme__listItem pt-spacing10">javah - This is used to write the native methods and is a stub generator as well as C header.</li><li class="CertTheme__listItem pt-spacing10">JConsole - This is a graphic management tool.</li><li class="CertTheme__listItem pt-spacing10">jstack -This prints the stack traces of java threads</li></ol><h3><span style="color:rgb(0, 0, 0)">Java Runtime Environment (JRE)</span></h3><p>The Java Runtime Environment consists of the Java Virtual Machine, supporting files and core classes. This is basically the minimum requirements to execute a Java application. The JRE is actually a component of the JDK but it can be downloaded separately from the rest.</p><p>Some of the components of the JRE are given as follows:</p><ol class="CertTheme__ol1 pt-spacing10"><li class="CertTheme__listItem pt-spacing10">Java Virtual Machine and Server Virtual Machines.</li><li class="CertTheme__listItem pt-spacing10">User Interface Toolkits such as Java 2D, AWT, Sound, Swing etc.</li><li class="CertTheme__listItem pt-spacing10">Base libraries such as I/O, Beans, JNI, Networking etc.</li><li class="CertTheme__listItem pt-spacing10">Lang and Util base libraries such as Zip, Collections, Versioning etc.</li><li class="CertTheme__listItem pt-spacing10">Deployment techniques</li></ol><h3><span style="color:rgb(0, 0, 0)">Java Virtual Machine (JVM)</span></h3><p>The Java Virtual Machine allows a computer to run Java programs. It can also run programs in other languages that are beforehand compiled to Java bytecode. The JVM is a virtual machine.</p><p>Some of the operations performed by the JVM are given as follows:</p><ol class="CertTheme__ol1 pt-spacing10"><li class="CertTheme__listItem pt-spacing10">The code can be loaded and executed by the Java Virtual Machine.</li><li class="CertTheme__listItem pt-spacing10">The JVM also provides the runtime environment.</li><li class="CertTheme__listItem pt-spacing10">The code is verified by using the JVM.</li></ol><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">78. Difference between static and non-static variables in Java</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>Any variable is a class in Java can either be static or non-static. Some of the differences between static and non-static variables in Java is given as following:</p><div class="overflow-x-auto mt-spacing10 mb-[16.8px] md:mb-6 max-w-full"><table class="min-w-full divide-y divide-gray-200 border"><thead><tr><th class="CertTheme__tableCell CertTheme__tableCellHeader" style="border:1px solid black;width:175px;vertical-align:top;text-align:start;background-color:rgb(242, 243, 245)">Static Variables<br></th><th class="CertTheme__tableCell CertTheme__tableCellHeader" style="border:1px solid black;width:175px;vertical-align:top;text-align:start;background-color:rgb(242, 243, 245)">Non-static variables<br></th></tr></thead><tbody><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">The static keywords are defined using the keyword static.<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">The non-static keywords do not contain the keyword static.<br></td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Static variables can be accessed using a class reference as there is only a single copy of them.<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Non-static variables can be accessed using only an object reference.<br></td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">The memory for static variables is allocated when the class is loaded.<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">The memory for non-static variables is allocated when an object of the class is created.<br></td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Every object of the class shares the static variable i.e. it is common for every object.<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">All objects of the class have their own copy of a non-static variable i.e the non-static variables are specific for objects.<br></td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">The memory for static variables is allocated only one time.<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">The memory for non-static variables is allocated whenever a new object of the class is created.<br></td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Static variables can also be called class variables as memory for static variables is allocated when the class is loaded.<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Non-static variables can also be called instance variables as memory for non-static variables is allocated whenever a new instance of the class is created.<br></td></tr></tbody></table></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">79. Primitive types in Java</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>The primitive data types in Java are boolean, byte, char, short, int, long, float and double. These data types have no special capabilities and are only single values.</p><p>A table that demonstrates all the primitive types in Java is as follows:</p><div class="overflow-x-auto mt-spacing10 mb-[16.8px] md:mb-6 max-w-full"><table class="min-w-full divide-y divide-gray-200 border"><thead><tr><th class="CertTheme__tableCell CertTheme__tableCellHeader" style="border:1px solid black;width:175px;vertical-align:top;text-align:start;background-color:rgb(242, 243, 245)">Type</th><th class="CertTheme__tableCell CertTheme__tableCellHeader" style="border:1px solid black;width:175px;vertical-align:top;text-align:start;background-color:rgb(242, 243, 245)">Default Value</th><th class="CertTheme__tableCell CertTheme__tableCellHeader" style="border:1px solid black;width:175px;vertical-align:top;text-align:start;background-color:rgb(242, 243, 245)">Size (in bits)</th><th class="CertTheme__tableCell CertTheme__tableCellHeader" style="border:1px solid black;width:175px;vertical-align:top;text-align:start;background-color:rgb(242, 243, 245)">Description</th></tr></thead><tbody><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">boolean</td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">false</td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">1</td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">This signifies true or false</td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">byte</td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">0</td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">8</td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Two’s complement integer</td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">char</td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">\u0000</td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">16</td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Unicode Character</td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">short</td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">0</td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">16</td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Two’s complement integer</td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">int</td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">0</td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">32</td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Two’s complement integer</td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">long</td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">0</td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">64</td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Two’s complement integer</td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">float</td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">0.0</td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">32</td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">IEEE 754 floating point</td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">double</td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">0.0</td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">64</td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">IEEE 754 floating point</td></tr></tbody></table></div><p>A program that demonstrates all the primitive types in Java is given as follows:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-x7gbza1ys" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">public class Demo
{
&nbsp; &nbsp;public static void main(String []args)
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;boolean var1 = true;
&nbsp; &nbsp; &nbsp; &nbsp;byte var2 = 127;
&nbsp; &nbsp; &nbsp; &nbsp;char var3 = 'A';
&nbsp; &nbsp; &nbsp; &nbsp;short var4 = -2000;
&nbsp; &nbsp; &nbsp; &nbsp;int var5 = 5000;
&nbsp; &nbsp; &nbsp; &nbsp;long var6 = 10000;
&nbsp; &nbsp; &nbsp; &nbsp;float var7 = 75.8756f;
&nbsp; &nbsp; &nbsp; &nbsp;double var8 = 28.84642387;
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println("boolean: " + var1); &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println("byte: " + var2); &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println("char: " + var3); &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println("short: " + var4); &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println("int: " + var5); &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println("long: " + var6); &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println("float: " + var7); &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println("double: " + var8); &nbsp;
&nbsp; &nbsp; }
}</pre></div></div><p><strong>The output of the above program is as follows:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-cec878ort" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">boolean: true
byte: 127
char: A
short: -2000
int: 5000
long: 10000
float: 75.8756
double: 28.84642387</pre></div></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">80. Why multiple inheritance is not supported in Java?</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p>A key part of object-oriented programming is multiple inheritance. This means that a class inherits the properties of multiple classes.</p><p>However, multiple inheritance may lead to many problems. Some of these are:</p><ol class="CertTheme__ol1 pt-spacing10"><li class="CertTheme__listItem pt-spacing10">The diamond problem occurs when 2 classes (B and C) inherit from a single class(A) and then a class(D) inherits these 2 classes(B and C) using multiple inheritance. This leads to multiple copies of class members of class A in class D which can create problems.</li><li class="CertTheme__listItem pt-spacing10">The ambiguity problem occurs if a class inherits from 2 classes that contain the same name for a class member. Then there is ambiguity in the inherited class when that class member is required.</li></ol><p>The above problems are one of the reasons that Java doesn't support multiple inheritance.</p><p>A program that demonstrates the diamond problem in Java is given as follows:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-mwwdzwfhk" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">public class A
{
&nbsp; &nbsp;void display()
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println("This is class A");
&nbsp; &nbsp;}
}
public class B extends A
{
&nbsp; &nbsp;void display() &nbsp;
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println("This is class B");
&nbsp; &nbsp;}
}
public class C extends A
{
&nbsp; &nbsp;void display()
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println("This is class C");
&nbsp; &nbsp;}
}
public class D extends B, C
{
&nbsp; public static void main(String args[])
&nbsp; {
&nbsp; &nbsp; &nbsp; D obj = new D();
&nbsp; &nbsp; &nbsp; D.display();
&nbsp; }
}</pre></div></div><p>The above program leads to an error as multiple inheritance is not allowed Java.</p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">81. This keyword in Java</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>The this keyword in Java refers to the current object and so is a reference variable. Some of the uses of the this keyword is given as follows:</p><ol class="CertTheme__ol1 pt-spacing10"><li class="CertTheme__listItem pt-spacing10">The current class object can be pointed to by using the this keyword.</li><li class="CertTheme__listItem pt-spacing10">The this keyword can be used in a constructor call as an argument.</li><li class="CertTheme__listItem pt-spacing10">The current class constructor can be invoked using this().</li><li class="CertTheme__listItem pt-spacing10">The current class method can be invoked implicitly using this keyword.</li><li class="CertTheme__listItem pt-spacing10">The this keyword can be used in a method call as an argument.</li></ol><p>A program that demonstrates this keyword in Java is given as follows:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-bxu8ufz3i" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">class Employee</pre></div></div><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-mr43ifx9w" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">{ &nbsp;
&nbsp; &nbsp;int empNo; &nbsp;
&nbsp; &nbsp;String name; &nbsp;
&nbsp; &nbsp;int salary; &nbsp;
&nbsp; &nbsp;Employee(int empNo, String name, int salary)
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;this.empNo = empNo; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp;this.name = name; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp;this.salary = salary; &nbsp;
&nbsp; &nbsp;}
&nbsp; &nbsp;void print()
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println("Employee Number = " + empNo);
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println("Name = " + name);
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println("Salary = " + salary);
&nbsp; &nbsp;}
} &nbsp;
public class Demo
{ &nbsp;
&nbsp; &nbsp;public static void main(String args[])
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;Employee emp1 = new Employee(1, "Amy", 20000); &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp;Employee emp2 = new Employee(2, "Harry", 15000);
&nbsp; &nbsp; &nbsp; &nbsp;Employee emp3 = new Employee(3, "Peter", 50000);
&nbsp; &nbsp; &nbsp; &nbsp;emp1.print(); &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp;emp2.print(); &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp;emp3.print(); &nbsp;
&nbsp; &nbsp;}
}</pre></div></div><p><strong>The output of the above program is as follows:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-uw21t0nlv" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">Employee Number = 1
Name = Amy
Salary = 20000
Employee Number = 2
Name = Harry
Salary = 15000
Employee Number = 3
Name = Peter
Salary = 50000</pre></div></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">82. Check if a given string is a palindrome in Java</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>A string is said to be palindrome if it is read the same forwards and backwards. An example of this is given as follows:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-6hab9mle3" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">String = madam
The above string is palindrome.</pre></div></div><p>A program that checks if a string is palindrome in Java is given as follows:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-06awlr1e4" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">public class Example
{
&nbsp; &nbsp;public static void main(String args[])
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;String str = "madam";
&nbsp; &nbsp; &nbsp; &nbsp;String strrev = "";
&nbsp; &nbsp; &nbsp; &nbsp;int n = str.length();
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println("String: " + str);
&nbsp; &nbsp; &nbsp; &nbsp;for(int i = n - 1; i &gt;= 0; i--)
&nbsp; &nbsp; &nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;strrev = strrev + str.charAt(i);
&nbsp; &nbsp; &nbsp; &nbsp;}
&nbsp; &nbsp; &nbsp; &nbsp;if(str.equalsIgnoreCase(strrev))
&nbsp; &nbsp; &nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;System.out.println("The above string is palindrome.");
&nbsp; &nbsp; &nbsp; &nbsp;}
&nbsp; &nbsp; &nbsp; &nbsp;else
&nbsp; &nbsp; &nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;System.out.println("The above string is not palindrome.");
&nbsp; &nbsp; &nbsp; &nbsp;}
&nbsp; &nbsp;}
}</pre></div></div><p><strong>The output of the above program is as follows:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-nhhmdrk0h" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">String: madam
The above string is palindrome.</pre></div></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">83. Heap Space in Java</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>The Heap Space in Java is allocated the memory to the Objects and the JRE classes by the Java runtime. All the objects in the application are created in the heap space. The objects in the heap space are globally accessible from any place in the application and so they have a lifetime for the whole application execution.</p><p>The Memory Model of the heap space is divided into parts known as generations. Details about these are given as follows:</p><p><strong>1. Young Generation</strong></p><p>All the new objects are allocated in the young generation and they age here. When this place fills up, then minor garbage collection occurs.</p><p><strong>2. Old Generation</strong></p><p>All the longer existing objects are stored in the old generation. When objects in the young generation reach a certain age threshold, they are moved to the old generation.</p><p><strong>3. Permanent Generation</strong></p><p>The Java metadata for runtime classes is stored in the permanent generation,.</p><p>Some of the important features of Heap space in Java are given as follows:</p><ol class="CertTheme__ol1 pt-spacing10"><li class="CertTheme__listItem pt-spacing10">The heap space contains the young generation, old generation and the permanent generation.</li><li class="CertTheme__listItem pt-spacing10">The stack memory is faster than the heap space in Java.</li><li class="CertTheme__listItem pt-spacing10">The error java.lang.OutOfMemoryError is thrown if the heap space is full.</li><li class="CertTheme__listItem pt-spacing10">The heap space is not thread safe. It needs synchronization methods for safety purposes</li></ol><p>Some of the differences between stack memory and heap memory are given as follows:</p><ol class="CertTheme__ol1 pt-spacing10"><li class="CertTheme__listItem pt-spacing10">Stack memory is faster than heap memory as its memory allocation procedure is much more simple.</li><li class="CertTheme__listItem pt-spacing10">The stack memory is only used by a thread whereas the heap memory is required by all the application parts.</li><li class="CertTheme__listItem pt-spacing10">The stack memory is only accessible by the individual thread but the heap memory objects can be accessed globally.</li><li class="CertTheme__listItem pt-spacing10">The stack memory is comparatively short lived while the heap memory exists for the whole execution of the application.</li><li class="CertTheme__listItem pt-spacing10">The stack memory management is done using LIFO but it is more complicated for heap memory as that is used by the whole application.</li></ol><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">84. Copy Constructor in Java</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>The main usage of the copy constructor is to create an object of a class by initializing it with another object of the same class. A copy constructor in Java is not available by default like in C++, but needs to be explicitly created.</p><p>A program that demonstrates a copy constructor in Java is given as follows:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-sc001sqoy" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">class Employee
{ &nbsp;
&nbsp; &nbsp;int empNo; &nbsp;
&nbsp; &nbsp;String name; &nbsp;
&nbsp; &nbsp;int salary; &nbsp;
&nbsp; &nbsp;Employee(int eNo, String n, int sal)
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;empNo = eNo; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp;name = n; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp;salary = sal; &nbsp;
&nbsp; &nbsp;}
&nbsp; &nbsp;Employee( Employee e)
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;empNo = e.empNo; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp;name = e.name; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp;salary = e.salary; &nbsp;
&nbsp; &nbsp;}
&nbsp; &nbsp;void print()
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println("Employee Number = " + empNo);
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println("Name = " + name);
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println("Salary = " + salary);
&nbsp; &nbsp;}
} &nbsp;
public class Demo
{ &nbsp;
&nbsp; &nbsp;public static void main(String args[])
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;Employee emp1 = new Employee(1, "John", 25000); &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp;Employee emp2 = new Employee(emp1);
&nbsp; &nbsp; &nbsp; &nbsp;emp1.print(); &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp;emp2.print(); &nbsp;
&nbsp; &nbsp;}
}</pre></div></div><p><strong>The output of the above program is as follows:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-9nwcytcs5" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">Employee Number = 1
Name = John
Salary = 25000
Employee Number = 1
Name = John
Salary = 25000</pre></div></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">85. Process vs Thread in Java</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>The terms process and thread are often used in multithreading in Java. A major difference between a process and a thread is that a process is a program that is currently executing while a thread is a subpart of the process.</p><p>The differences between a process and a thread in detail are given as follows:</p><div class="overflow-x-auto mt-spacing10 mb-[16.8px] md:mb-6 max-w-full"><table class="min-w-full divide-y divide-gray-200 border"><thead><tr><th class="CertTheme__tableCell CertTheme__tableCellHeader" style="border:1px solid black;width:175px;vertical-align:top;text-align:start;background-color:rgb(242, 243, 245)">Process<br></th><th class="CertTheme__tableCell CertTheme__tableCellHeader" style="border:1px solid black;width:175px;vertical-align:top;text-align:start;background-color:rgb(242, 243, 245)">Thread<br></th></tr></thead><tbody><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">A process is a program that is currently executing.<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">A thread is a subpart of the process.<br></td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">A process is also known as a heavyweight task.<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">A thread is also known as a lightweight task.<br></td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Communication between two processes is quite complicated and expensive.<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Communication between two threads is comparatively less expensive.<br></td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">All the processes have a separate address space as they are individual entities.<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">The threads of a single process share the address space of the process as they are a part of the process.<br></td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Context switching between two processes is quite expensive.<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Context switching between two threads is less expensive than that between processes.<br></td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">An individual process has its own global variables, address space, files, accounting information etc.<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">A thread has its own stack, register and program counter. The rest of the components are shared by all the threads of a process.<br></td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">A computer system can run multiple processes concurrently in process multitasking.<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">A computer system can run multiple threads of a program concurrently in thread multitasking.<br></td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Java does not control process multitasking.<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Java does controls thread multitasking.<br></td></tr></tbody></table></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">86. Garbage Collection in Java</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>The Garbage collection in Java destroys all those objects that are not in use any more. So basically, garbage collection helps free the heap memory by removing the unreachable objects i.e. the objects that don’t have any reference to them.</p><p>The different ways that an object is made eligible for garbage collection by the programmer is given as follows:</p><ol class="CertTheme__ol1 pt-spacing10"><li class="CertTheme__listItem pt-spacing10">The reference variable to the object is reassigned.</li><li class="CertTheme__listItem pt-spacing10">The reference variable to the object is set is null.</li><li class="CertTheme__listItem pt-spacing10">An island of isolation</li><li class="CertTheme__listItem pt-spacing10">An object is created inside a method.</li></ol><p>After an object is eligible for garbage collection, the garbage collector can be run by requesting the Java Virtual Machine. This can be done using the following methods:</p><ol class="CertTheme__ol1 pt-spacing10"><li class="CertTheme__listItem pt-spacing10">The Runtime.getRuntime().gc() method can be called to run the garbage collector by requesting the Java Virtual Machine.</li><li class="CertTheme__listItem pt-spacing10">The System.gc() method can be called to run the garbage collector by requesting the Java Virtual Machine.</li></ol><p>A program that demonstrates running the garbage collector by requesting the Java Virtual Machine is given as follows:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-anxp5xvkt" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">public class Demo
{
&nbsp; &nbsp;public static void main(String[] args) throws InterruptedException
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;Demo obj = new Demo();
&nbsp; &nbsp; &nbsp; &nbsp;obj = null;
&nbsp; &nbsp; &nbsp; &nbsp;System.gc();
&nbsp; &nbsp;}
&nbsp; &nbsp;@Override
&nbsp; &nbsp;protected void finalize() throws Throwable
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println("The garbage collector is called...");
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println("The object that is garbage collected is: " + this);
&nbsp; &nbsp;}
}</pre></div></div><p><strong>The output of the above program is as follows:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-gnqgjlden" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">The garbage collector is called...
The object that is garbage collected is: Demo@7978f9b4</pre></div></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">87. Java equals() method vs == operator</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p class="CertTheme__paragraph" data-mode="standard"><br></p><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><span>The equals() method and the == operator in Java are both used to find if two objects are equal. However, while equals() is a method, == is an operator. Also, equals() compares the object values while == checks if the objects point to the same memory location.</span></p><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><span>A program that demonstrates the == operator is given as follows:</span></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-dbgxbyzvl" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm"><span class="CertTheme__tokenAttr">public</span><span> </span><span class="CertTheme__tokenAttr">class</span><span> </span><span class="CertTheme__tokenFunction">Demo</span><br><span class="CertTheme__tokenPunctuation">{</span><br><span>&nbsp; &nbsp;</span><span class="CertTheme__tokenAttr">public</span><span> </span><span class="CertTheme__tokenAttr">static</span><span> </span><span class="CertTheme__tokenAttr">void</span><span> </span><span class="CertTheme__tokenFunction">main</span><span class="CertTheme__tokenPunctuation">(</span><span>String</span><span class="CertTheme__tokenPunctuation">[</span><span class="CertTheme__tokenPunctuation">]</span><span> args</span><span class="CertTheme__tokenPunctuation">)</span><br><span>&nbsp; &nbsp;</span><span class="CertTheme__tokenPunctuation">{</span><span> &nbsp; &nbsp; &nbsp;</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp;System</span><span class="CertTheme__tokenPunctuation">.</span><span>out</span><span class="CertTheme__tokenPunctuation">.</span><span class="CertTheme__tokenFunction">println</span><span class="CertTheme__tokenPunctuation">(</span><span class="CertTheme__tokenProperty">67</span><span> </span><span class="CertTheme__tokenOperator">==</span><span> </span><span class="CertTheme__tokenProperty">67</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">;</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp;System</span><span class="CertTheme__tokenPunctuation">.</span><span>out</span><span class="CertTheme__tokenPunctuation">.</span><span class="CertTheme__tokenFunction">println</span><span class="CertTheme__tokenPunctuation">(</span><span class="CertTheme__tokenSelector">'u'</span><span> </span><span class="CertTheme__tokenOperator">==</span><span> </span><span class="CertTheme__tokenSelector">'v'</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">;</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp;System</span><span class="CertTheme__tokenPunctuation">.</span><span>out</span><span class="CertTheme__tokenPunctuation">.</span><span class="CertTheme__tokenFunction">println</span><span class="CertTheme__tokenPunctuation">(</span><span class="CertTheme__tokenSelector">'A'</span><span> </span><span class="CertTheme__tokenOperator">==</span><span> </span><span class="CertTheme__tokenProperty">65.0</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">;</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp;System</span><span class="CertTheme__tokenPunctuation">.</span><span>out</span><span class="CertTheme__tokenPunctuation">.</span><span class="CertTheme__tokenFunction">println</span><span class="CertTheme__tokenPunctuation">(</span><span class="CertTheme__tokenProperty">false</span><span> </span><span class="CertTheme__tokenOperator">==</span><span> </span><span class="CertTheme__tokenProperty">true</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">;</span><span> &nbsp;&nbsp;</span><br><span>&nbsp; &nbsp;</span><span class="CertTheme__tokenPunctuation">}</span><br><span class="CertTheme__tokenPunctuation">}</span></pre></div></div><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><b><strong class="CertTheme__textBold">The output of the above program is as follows:</strong></b></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-ee2iqlt4d" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm"><span class="CertTheme__tokenProperty">true</span><br><span class="CertTheme__tokenProperty">false</span><br><span class="CertTheme__tokenProperty">true</span><br><span class="CertTheme__tokenProperty">false</span></pre></div></div><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><span>A program that demonstrates the equals() method is given as follows:</span></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-sadez16iz" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm"><span class="CertTheme__tokenAttr">public</span><span> </span><span class="CertTheme__tokenAttr">class</span><span> </span><span class="CertTheme__tokenFunction">Demo</span><br><span class="CertTheme__tokenPunctuation">{</span><br><span>&nbsp; &nbsp;</span><span class="CertTheme__tokenAttr">public</span><span> </span><span class="CertTheme__tokenAttr">static</span><span> </span><span class="CertTheme__tokenAttr">void</span><span> </span><span class="CertTheme__tokenFunction">main</span><span class="CertTheme__tokenPunctuation">(</span><span>String</span><span class="CertTheme__tokenPunctuation">[</span><span class="CertTheme__tokenPunctuation">]</span><span> args</span><span class="CertTheme__tokenPunctuation">)</span><br><span>&nbsp; &nbsp;</span><span class="CertTheme__tokenPunctuation">{</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp;String str1 </span><span class="CertTheme__tokenOperator">=</span><span> </span><span class="CertTheme__tokenAttr">new</span><span> </span><span class="CertTheme__tokenFunction">String</span><span class="CertTheme__tokenPunctuation">(</span><span class="CertTheme__tokenSelector">"apple"</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">;</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp;String str2 </span><span class="CertTheme__tokenOperator">=</span><span> </span><span class="CertTheme__tokenAttr">new</span><span> </span><span class="CertTheme__tokenFunction">String</span><span class="CertTheme__tokenPunctuation">(</span><span class="CertTheme__tokenSelector">"apple"</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">;</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp;String str3 </span><span class="CertTheme__tokenOperator">=</span><span> </span><span class="CertTheme__tokenAttr">new</span><span> </span><span class="CertTheme__tokenFunction">String</span><span class="CertTheme__tokenPunctuation">(</span><span class="CertTheme__tokenSelector">"mango"</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">;</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp;System</span><span class="CertTheme__tokenPunctuation">.</span><span>out</span><span class="CertTheme__tokenPunctuation">.</span><span class="CertTheme__tokenFunction">println</span><span class="CertTheme__tokenPunctuation">(</span><span>str1</span><span class="CertTheme__tokenPunctuation">.</span><span class="CertTheme__tokenFunction">equals</span><span class="CertTheme__tokenPunctuation">(</span><span>str2</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">;</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp;System</span><span class="CertTheme__tokenPunctuation">.</span><span>out</span><span class="CertTheme__tokenPunctuation">.</span><span class="CertTheme__tokenFunction">println</span><span class="CertTheme__tokenPunctuation">(</span><span>str1</span><span class="CertTheme__tokenPunctuation">.</span><span class="CertTheme__tokenFunction">equals</span><span class="CertTheme__tokenPunctuation">(</span><span>str3</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">;</span><br><span>&nbsp; &nbsp;</span><span class="CertTheme__tokenPunctuation">}</span><br><span class="CertTheme__tokenPunctuation">}</span></pre></div></div><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><b><strong class="CertTheme__textBold">The output of the above program is as follows:</strong></b></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-dm2wxe2li" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm"><span class="CertTheme__tokenProperty">true</span><br><span class="CertTheme__tokenProperty">false</span></pre></div></div><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><br></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">88. Thread Life Cycle in Java</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p>The Thread Life Cycle in Java contains 5 states. This means that the thread can be in any of these 5 states. A diagram to understand the states in the thread life cycle is given below:</p><p><img alt="Thread Life Cycle in Java" loading="lazy" width="100" height="100" decoding="async"  class="fr-fic fr-dib" style="color:transparent;width:100%;height:auto;background-size:cover;background-position:50% 50%;background-repeat:no-repeat;background-image:url(&quot;data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http%3A//www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cfilter id='b' color-interpolation-filters='sRGB'%3E%3CfeGaussianBlur stdDeviation='20'/%3E%3C/filter%3E%3Cimage preserveAspectRatio='none' filter='url(%23b)' x='0' y='0' height='100%25' width='100%25' href='data:image/svg+xml;base64,CiAgPHN2ZyB3aWR0aD0iMTAwIiBoZWlnaHQ9IjEwMCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIj4KICAgIDxkZWZzPgogICAgICA8bGluZWFyR3JhZGllbnQgaWQ9ImciPgogICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNjY2MiIG9mZnNldD0iMjAlIiAvPgogICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNkZGQiIG9mZnNldD0iNTAlIiAvPgogICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNlZWUiIG9mZnNldD0iNzAlIiAvPgogICAgICA8L2xpbmVhckdyYWRpZW50PgogICAgPC9kZWZzPgogICAgPHJlY3Qgd2lkdGg9IjEwMCIgaGVpZ2h0PSIxMDAiIGZpbGw9IiNlZWUiIC8+CiAgICA8cmVjdCBpZD0iciIgd2lkdGg9IjEwMCIgaGVpZ2h0PSIxMDAiIGZpbGw9InVybCgjZykiIC8+CiAgICA8YW5pbWF0ZSB4bGluazpocmVmPSIjciIgYXR0cmlidXRlTmFtZT0ieCIgZnJvbT0iLTEwMCIgdG89IjEwMCIgZHVyPSIxcyIgcmVwZWF0Q291bnQ9ImluZGVmaW5pdGUiICAvPgogIDwvc3ZnPg=='/%3E%3C/svg%3E&quot;)" sizes="(min-width: 767px) 50vw, 100vw" srcSet="" src="https://images.unsplash.com/photo-1540316687405-b04ebbbddfb1?ixlib=rb-4.0.3&auto=format&fit=crop&w=1000&q=80"></p><p>The 5 states in a thread life cycle are:</p><ul><li class="CertTheme__listItem pt-spacing10"><strong>New</strong></li></ul><p>When an instance of the thread class has been created but the start() method is not invoked, then the thread is in the new state.</p><ul><li class="CertTheme__listItem pt-spacing10"><strong>Runnable</strong></li></ul><p>When the start() method has been invoked but the thread scheduler has not selected the thread for execution, then the thread is in the runnable state.</p><ul><li class="CertTheme__listItem pt-spacing10"><strong>Running</strong></li></ul><p>If the thread scheduler has selected a thread and it is currently running, then it is in the running state.</p><ul><li class="CertTheme__listItem pt-spacing10"><strong>Blocked (Non-runnable)</strong></li></ul><p>When a thread is not eligible to run but still alive, then it is in the blocked state.</p><ul><li class="CertTheme__listItem pt-spacing10"><strong>Terminated</strong></li></ul><p>When the run() method of a thread exits, then it is in the terminated state.</p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">89. Display Java Runtime Environment (JRE) version</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>To get the JRE version in Java, use the predefined System.property() and include the key as “java.version” as shown below:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-kmp12cdje" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">public class Example {
&nbsp; public static void main(String[] args) {
&nbsp; &nbsp; System.out.println(System.getProperty("java.version"));
&nbsp; }
}</pre></div></div><p><strong>The output displays the version:&nbsp;</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-x6zj64mey" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">1.8.0_141</pre></div></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">90. Throw vs Throws keyword in Java</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>Both the throw and throws keywords in Java are related to exception handling. Differences between these two keywords are given as follows:</p><div class="overflow-x-auto mt-spacing10 mb-[16.8px] md:mb-6 max-w-full"><table class="min-w-full divide-y divide-gray-200 border"><thead><tr><th class="CertTheme__tableCell CertTheme__tableCellHeader" style="border:1px solid black;width:175px;vertical-align:top;text-align:start;background-color:rgb(242, 243, 245)">Throw</th><th class="CertTheme__tableCell CertTheme__tableCellHeader" style="border:1px solid black;width:175px;vertical-align:top;text-align:start;background-color:rgb(242, 243, 245)">Throws</th></tr></thead><tbody><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">An exception is explicitly thrown using the throw keyword.</td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">An exception is declared using the throws keyword.</td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">The throw keyword is followed by an instance.</td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">The throws keyword is followed by a class.</td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">The throw keyword only cannot propagate a checked exception.</td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">The throws keyword can propagate a checked exception.</td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">It is not possible to throw multiple exceptions.</td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Multiple exceptions can be declared using throws keyword.</td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">The throw keyword is used within a method.</td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">The throws keyword is used with the method signature.</td></tr></tbody></table></div><p>A program that demonstrates throw keyword in Java is given as follows:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-vmkpet41h" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">public class Demo
{ &nbsp;
&nbsp; static void checkMarks(int marks)
&nbsp; {
&nbsp; &nbsp; if(marks &lt; 40) &nbsp;
&nbsp; &nbsp; &nbsp;throw new ArithmeticException("You failed"); &nbsp;
&nbsp; &nbsp; else
&nbsp; &nbsp; &nbsp;System.out.println("Congratulations! You passed"); &nbsp;
&nbsp; }
&nbsp; public static void main(String args[])
&nbsp; {
&nbsp; &nbsp; &nbsp;System.out.println("Test Report");
&nbsp; &nbsp; &nbsp;checkMarks(29); &nbsp;
&nbsp;}
}</pre></div></div><p><strong>The output of the above program is as follows:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-or0s6ghb4" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">Test Report
Exception in thread "main" java.lang.ArithmeticException: You failed
at Demo.checkMarks(Demo.java:6)
at Demo.main(Demo.java:16)</pre></div></div><p>A program that demonstrates throws keyword in Java is given as follows:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-kpr9uiwfv" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">public class Demo
{
&nbsp; &nbsp;public static void main(String[] args) throws InterruptedException
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;Thread.sleep(1000);
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println("Demonstration of throws keyword");
&nbsp; &nbsp;}
}</pre></div></div><p><strong>The output of the above program is as follows:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-qn87urua2" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">Demonstration of throws keyword</pre></div></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">91. New features in Java 11</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p>Some of the new features of Java 11 are given as follows:</p><p><strong>1. Local-Variable Syntax for Lambda Parameters</strong></p><p>The Local-Variable Type Inference was introduced by JDK 10 that simplified the code as the type of the local variable did not need to be explicitly stated. This syntax is extended by JEP 32 for use to the parameters of Lambda expressions.</p><p><strong>2. Single-File Source-Code Programs</strong></p><p>Java is criticized as quite a complex language. However, JEP 330 simplifies this a little bit by eliminating the need to compile a single file application.</p><p><strong>3. HTTP Client (Standard)</strong></p><p>The Java SE 11 standard contains the HTTP client API as its part. A new module and package is introduced i.e. java.net.http. Some of the main types defined in this are as follows:</p><ul><li class="CertTheme__listItem pt-spacing10">HttpRequest</li><li class="CertTheme__listItem pt-spacing10">HttpResponse</li><li class="CertTheme__listItem pt-spacing10">HttpClient</li><li class="CertTheme__listItem pt-spacing10">WebSocket</li></ul><p><strong>4. Remove the Java EE and CORBA Modules</strong></p><p>There are 6 modules included in the java.se.ee meta-module that are not a part of the Java SE 11 standard. The modules that are affected are:</p><ul><li class="CertTheme__listItem pt-spacing10">transaction</li><li class="CertTheme__listItem pt-spacing10">activation</li><li class="CertTheme__listItem pt-spacing10">corba</li><li class="CertTheme__listItem pt-spacing10">xml.ws</li><li class="CertTheme__listItem pt-spacing10">xml.ws.annotation</li><li class="CertTheme__listItem pt-spacing10">xml.bind</li></ul><p><strong>5. New APIs</strong></p><p>There are a lot of APA’s that are included in the JDK 11 result. There are available as the HTTP is a part of the standard and also because the Flight Recorder is included.</p></div></div></div></div><div class="relative"><div class="mt-spacing20 z-10 relative text-center flex justify-center mt-0"><button class="flex items-center gap-x-spacing8 py-spacing4"><span class="text-sm underline font-semibold text-mono-black">View all questions</span><i class="icon-chevron-down-double text-xl leading-5 text-neutral-800"></i></button></div><div class="absolute bottom-0 block h-32 w-full bg-gradient-to-t from-subdued/100 from-30% md:from-40%"></div></div></div></div></div><div class="hidden"><div><div class="text-xl text-neutral-800 mb-spacing20 font-bold">Intermediate</div><div class="relative w-full"><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-primary-main outline-2 shadow-card hover:shadow-card visible"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-t-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden">1. Does Java use Pointers?</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-0 text-neutral-800"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>No, Java doesn’t exactly use pointers. Pointers are variables which store the exact address of another variable in their memory. Due to its feature of security and robustness, Java shimmies away from this concept of pointers which forms a major part of C and C++ in memory addressing.</p><p>If we know the address of a variable, we can access and modify it from anywhere even if it is private which is self-contradictory and hence Java doesn’t use pointers. Instead of using a pointer, Java sticks to a safer option called references<strong>.</strong></p><p>A reference is an address that shows the location of storage of the object’s variables and methods. We never actually use objects or copies of objects when we assign objects to variables or methods. Instead we use references to those objects.</p><p>References though,</p><ul><li class="CertTheme__listItem pt-spacing10">Cannot perform arithmetic operations</li><li class="CertTheme__listItem pt-spacing10">Can’t be assigned an address</li><li class="CertTheme__listItem pt-spacing10">Can’t be set to point to a variable without an object</li></ul><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow visible"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">2. Display last two digits of the current year in Java</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>To display the last two digits of the current year, use the date character y as shown in the below example:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-ax5051ry1" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">import java.util.Date;
public class Example {
&nbsp;public static void main(String[] args) throws Exception {
&nbsp; &nbsp; Date date = new Date();
&nbsp; &nbsp; System.out.printf("Two-digit Year = %ty\n",date);
&nbsp;}
}</pre></div></div><p><strong>The output display 18 for the current year 2018:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-z1foomqea" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">Two-digit Year = 18</pre></div></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow visible"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">3. Check if a string begins with a specific substring</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>The startsWith() method is used to check whether a string begins with a specific string or not.</p><p>Here, we are checking whether the given string begins with the substring “one”:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-3lcu0oy0o" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">public class Example {
&nbsp;public static void main(String[] args) {
&nbsp; &nbsp; String s = "OneAndOnly";
&nbsp; &nbsp; if(s.startsWith("one")) {
&nbsp; &nbsp; &nbsp; System.out.println("Begins with the specified word!");
&nbsp; &nbsp; }
&nbsp; &nbsp; else {
&nbsp; &nbsp; &nbsp; System.out.println("Does not begin with the specified word!"); &nbsp;&nbsp;
&nbsp; &nbsp; }
&nbsp;}
}</pre></div></div><p><strong>The output:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-5wvkiyi6n" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">Begins with the specified word!</pre></div></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow visible"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">4. Check if a string ends with a specific substring</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>The endsWith() method is used to check whether a string ends with a specific string or not.</p><p>Here, we are checking whether the given string ends with the substring “one”:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-g9h6gikqa" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">public class Example {
&nbsp;public static void main(String[] args) {
&nbsp; &nbsp; String s = "Mobile Phone";
&nbsp; &nbsp; if(s.endsWith("one")) {
&nbsp; &nbsp; &nbsp; System.out.println("Ends with the specified word!");
&nbsp; &nbsp; }
&nbsp; &nbsp; else {
&nbsp; &nbsp; &nbsp; System.out.println("Does not end with the specified word!"); &nbsp;&nbsp;
&nbsp; &nbsp; }
&nbsp;}
}</pre></div></div><p><strong>The output:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-1m5v2zmhz" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">Ends with the specified word!</pre></div></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow visible"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">5. C++ vs Java</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>C++ and Java are programming languages with many differences and similarities. C++ supports both procedural as well as object-oriented programming language while Java is purely an object oriented programming language.</p><p>The major differences between C++ and Java are given as follows:</p><div class="overflow-x-auto mt-spacing10 mb-[16.8px] md:mb-6 max-w-full"><table class="min-w-full divide-y divide-gray-200 border"><thead><tr><th class="CertTheme__tableCell CertTheme__tableCellHeader" style="border:1px solid black;width:175px;vertical-align:top;text-align:start;background-color:rgb(242, 243, 245)">C++<br></th><th class="CertTheme__tableCell CertTheme__tableCellHeader" style="border:1px solid black;width:175px;vertical-align:top;text-align:start;background-color:rgb(242, 243, 245)">Java<br></th></tr></thead><tbody><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">The main usage of C++ is for system programming.<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">The main usage of Java is for application programming.<br></td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Structures and Unions are supported by C++.<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Structures and Unions are not supported by Java.<br></td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">There is no build-in support for threads in C++.<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">There is build-in support for threads in Java.<br></td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">The goto statement is supported by C++.<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">The goto statement is not supported by Java.<br></td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">The &gt;&gt;&gt; operator is not supported by C++.<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">The &gt;&gt;&gt; operator is supported by Java.<br></td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Operator overloading is supported by C++.<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Operator overloading is not supported by Java.<br></td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Call by value and call by reference are both supported by C++.<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Only call by value is supported by C++.<br></td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">C++ is platform dependent.<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Java is platform independent.<br></td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Single root hierarchy is not possible in C++.<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Single root hierarchy is possible in Java as everything is derived from java.lang.Object.<br></td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">There is no support for documentation comments in C++.<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">There is support for documentation comments in Java to provide documentation for Java code.<br></td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Multiple inheritance is supported in C++.<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Multiple inheritance is not supported in Java.<br></td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">There is a virtual keyword in C++. It is used to override a function.<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">There is no virtual keyword in Java. Override of all non-static functions is possible by default.<br></td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">C++ is quite interactive with hardware.<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Java is not so interactive with hardware.<br></td></tr></tbody></table></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">6. Advantages of Packages in Java</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>A package in Java is a group of different sub-packages, interfaces, classes etc. that are of a similar type. The two types of packages are build-in packages and user defined packages. Some of the build-in packages are awt, swing, lang, util. javax, sql etc.</p><p>Some of the advantages of packages in Java are given as follows:</p><ol class="CertTheme__ol1 pt-spacing10"><li class="CertTheme__listItem pt-spacing10">Packages are quite useful as they group together similar sub-packages, interfaces, classes etc. This helps the programmers to understand which of the enumerations, sub-packages, annotations, interfaces, classes etc. are related.</li><li class="CertTheme__listItem pt-spacing10">Related classes in Java can be easily located using Packages.</li><li class="CertTheme__listItem pt-spacing10">Access Control can be provided easily using packages.</li><li class="CertTheme__listItem pt-spacing10">Individual packages can be defined by programmers to group together enumerations, sub-packages, annotations, interfaces, classes etc.</li><li class="CertTheme__listItem pt-spacing10">There are no name conflicts with names in other packages as a package creates a new namespace.</li></ol><p>A program that demonstrates a package in Java is given as follows:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-q98wnacop" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">package packageExample;
public class Demo
{ &nbsp;
public static void main(String args[])
{ &nbsp;
&nbsp; &nbsp;System.out.println("This is a package example"); &nbsp;
} &nbsp;
}</pre></div></div><p><strong>The output of the above program is as follows:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-ll4mzdokl" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">This is a package example</pre></div></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">7. Why Java doesn’t support multiple inheritance?</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p>An important part of object-oriented programming is multiple inheritance. This means that a class inherits the properties of multiple classes.</p><p>However, multiple inheritance may lead to many problems. Some of these are:</p><ul><li class="CertTheme__listItem pt-spacing10">The diamond problem occurs when 2 classes (B and C) inherit from a single class(A) and then a class(D) inherits these 2 classes (B and C) using multiple inheritance. This leads to multiple copies of class members of class A in class D which can create problems.</li><li class="CertTheme__listItem pt-spacing10">The ambiguity problem occurs if a class inherits from 2 classes that contain the same name for a class member. Then there is ambiguity in the inherited class when that class member is required.</li></ul><p>The above problems are one of the reasons that Java doesn't support multiple inheritance.</p><p>A program that demonstrates the diamond problem in Java is given as follows:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-dw9wx21l4" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">public class A
{
&nbsp; &nbsp;void display()
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println("This is class A");
&nbsp; &nbsp;}
}
public class B extends A
{
&nbsp; &nbsp;void display() &nbsp;
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println("This is class B");
&nbsp; &nbsp;}
}
public class C extends A
{
&nbsp; &nbsp;void display()
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println("This is class C");
&nbsp; &nbsp;}
}
public class D extends B, C
{
&nbsp; public static void main(String args[])
&nbsp; {
&nbsp; &nbsp; &nbsp; D obj = new D();
&nbsp; &nbsp; &nbsp; D.display();
&nbsp; }
}</pre></div></div><p>The above program leads to an error as multiple inheritance is not allowed Java.</p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">8. Default value of local variable in Java?</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>Local variables in Java are those declared locally in methods, code blocks, constructors etc. When the program control enters the methods, code blocks, constructors etc. then the local variables are created and when the program control leaves the methods, code blocks, constructors etc. then the local variables are destroyed.</p><p>The local variables do not have any default values in Java. This means that they should be declared and assigned a value before the variables are used for the first time. Other the compiler throws an error.</p><p>A program that demonstrates local variables in Java is given as follows:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-knrfgkuip" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">public class Demo
{
&nbsp; public void func()
&nbsp; {
&nbsp; &nbsp; &nbsp;int num;
&nbsp; &nbsp; &nbsp;System.out.println("The number is : " + num);
&nbsp; }
&nbsp; public static void main(String args[])
&nbsp; {
&nbsp; &nbsp; &nbsp;Demo obj = new Demo();
&nbsp; &nbsp; &nbsp;obj.func();
&nbsp; }
}</pre></div></div><p>The above program contains a local variable num. It leads to an error “variable num might not have been initialized”</p><p>The correct version of the above program is given as follows:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-z9yz5tyq0" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">public class Demo
{
&nbsp; public void func()
&nbsp; {
&nbsp; &nbsp; &nbsp;int num = 50;
&nbsp; &nbsp; &nbsp;System.out.println("The number is : " + num);
&nbsp; }
&nbsp; public static void main(String args[])
&nbsp; {
&nbsp; &nbsp; &nbsp;Demo obj = new Demo();
&nbsp; &nbsp; &nbsp;obj.func();
&nbsp; }
}</pre></div></div><p><strong>The output of the above program is as follows:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-5ine17nuv" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">The number is : 50</pre></div></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">9. What are the types of variables a class can have?</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>The different types of variables in Java are local variables, instance variables and class variables. Details about these are given as follows:</p><h3><span style="color:rgb(0, 0, 0)">Local Variables</span></h3><p>Local variables in Java are those declared locally in methods, code blocks, constructors etc. When the program control enters the methods, code blocks, constructors etc. then the local variables are created and when the program control leaves the methods, code blocks, constructors etc. then the local variables are destroyed.</p><p><strong>A program that demonstrates local variables in Java is given as follows:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-09y9bgsp7" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">public class Demo
{
&nbsp; public void func()
&nbsp; {
&nbsp; &nbsp; &nbsp;int num = 50;
&nbsp; &nbsp; &nbsp;System.out.println("The number is : " + num);
&nbsp; }
&nbsp; public static void main(String args[])
&nbsp; {
&nbsp; &nbsp; &nbsp;Demo obj = new Demo();
&nbsp; &nbsp; &nbsp;obj.func();
&nbsp; }
}</pre></div></div><p><strong>The output of the above program is as follows:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-1c7baorsp" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">The number is : 50</pre></div></div><h3><span style="color:rgb(0, 0, 0)">Instance Variables</span></h3><p>Instance variables in Java are those variables that are declared outside a block, method, constructor etc. but inside a class. These variables are created when the class object is created and similarly, they are destroyed when the class object is destroyed.</p><p><strong>A program that demonstrates instance variables in Java is given as follows:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-84r0rdrgx" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">public class Demo
{
&nbsp; int num;
&nbsp; Demo(int n)
&nbsp; {
&nbsp; &nbsp; &nbsp;num = n;
&nbsp; }
&nbsp; public void display()
&nbsp; {
&nbsp; &nbsp; &nbsp;System.out.println("The number is: " + num);
&nbsp; }
&nbsp; public static void main(String args[])
&nbsp; {
&nbsp; &nbsp; &nbsp;Demo obj = new Demo(20);
&nbsp; &nbsp; &nbsp;obj.display();
&nbsp; }
}</pre></div></div><p><strong>The output of the above program is as follows:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-haxsmjh2e" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">The number is: 20</pre></div></div><h3><span style="color:rgb(0, 0, 0)">Class Variables</span></h3><p>Class variables or Static variables are defined using the static keyword. These variables are declared inside a class but outside a method, code block etc. Class variables last for the program lifetime i.e. they are created at the start of the program and destroyed at the end of the program.</p><p><strong>A program that demonstrates class variables in Java is given as follows:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-reg17qya4" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">public class Demo
{
&nbsp; int num;
&nbsp; static int count;
&nbsp; Demo(int n)
&nbsp; {
&nbsp; &nbsp; &nbsp;num = n;
&nbsp; &nbsp; &nbsp;count ++;
&nbsp; }
&nbsp; public void display()
&nbsp; {
&nbsp; &nbsp; &nbsp;System.out.println("The number is: " + num);
&nbsp; }
&nbsp; public static void main(String args[])
&nbsp; {
&nbsp; &nbsp; &nbsp;Demo obj1 = new Demo(20);
&nbsp; &nbsp; &nbsp;obj1.display();
&nbsp; &nbsp; &nbsp;Demo obj2 = new Demo(50);
&nbsp; &nbsp; &nbsp;obj2.display();
&nbsp; &nbsp; &nbsp;System.out.println("The total objects of class Demo are: " + count);
&nbsp; }
}</pre></div></div><p><strong>The output of the above program is as follows:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-4sieaalki" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">The number is: 20
The number is: 50
The total objects of class Demo are: 2</pre></div></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">10. Big Decimal negate value</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>Use the Big Decimal negate() method to negate a BigDecimal value in Java.<br>Let us see a simple example:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-ljcz9f7r8" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">import java.math.*;
public class Example {
&nbsp; public static void main(String[] args) {
&nbsp; &nbsp; &nbsp;BigDecimal b1, b2;
&nbsp; &nbsp; &nbsp;b1 = new BigDecimal("879879");
&nbsp; &nbsp; &nbsp;b2 = b1.negate();
&nbsp; &nbsp; &nbsp;System.out.println("Negated = " +b2);
&nbsp; }
}</pre></div></div><p><strong>The output:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-q9uwl897y" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">Negated = -879879</pre></div></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">11. Association in Java</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p>A relationship between two classes that can be established using their objects is known as association in Java. The two forms of association are Composition and Aggregation. The types of association can be one-to-one, many-to-one, one-to-many, many-to-many etc.</p><p>A program that demonstrates association in Java is given as follows:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-ntdzdkysx" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">class Teacher
{
&nbsp; &nbsp;private String name;
&nbsp; &nbsp;private int age;
&nbsp; &nbsp;private String subject;
&nbsp; &nbsp;Teacher(String name, int age, String subject)
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;this.name = name;
&nbsp; &nbsp; &nbsp; &nbsp;this.age = age;
&nbsp; &nbsp; &nbsp; &nbsp;this.subject = subject;
&nbsp; &nbsp;}
&nbsp; &nbsp;public String retTeacherName()
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;return this.name;
&nbsp; &nbsp;}
&nbsp; &nbsp;public String retTeacherSubject()
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;return this.subject;
&nbsp; &nbsp;}
} &nbsp;
class Student
{
&nbsp; &nbsp;private int rno;
&nbsp; &nbsp;private String name;
&nbsp; &nbsp;Student(int rno, String name) &nbsp;
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;this.rno = rno;
&nbsp; &nbsp; &nbsp; &nbsp;this.name = name;
&nbsp; &nbsp;}
&nbsp; &nbsp;public String retStudentName()
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;return this.name;
&nbsp; &nbsp;}
}
public class Association &nbsp;
{
&nbsp; &nbsp;public static void main (String[] args) &nbsp;
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;Teacher t = new Teacher("Amy", 25, "Maths");
&nbsp; &nbsp; &nbsp; &nbsp;Student s1 = new Student(12, "John");
&nbsp; &nbsp; &nbsp; &nbsp;Student s2 = new Student(15, "Susan");
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println(t.retTeacherName() + " teaches " + t.retTeacherSubject() + " to students " + s1.retStudentName() + " and " + s2.retStudentName()) ;
&nbsp; &nbsp;}
}</pre></div></div><p><strong>The output of the above program is as follows:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-5li4zg7y2" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">Amy teaches Maths to students John and Susan</pre></div></div><p>In the above program, the two classes Teacher and Student are associated as a teacher may teach multiple students. This is a one-to-many relationship.</p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">12. Aggregation in Java</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p>Aggregation is a type of weak association that specifies a HAS-A relationship. Both the objects of a class in an aggregation can exist individually. Also, aggregation is a one-way relationship. For example - A class in a school has students but the opposite is not true.</p><p>A program that demonstrates aggregation in Java is given as follows:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-cgaogdyhu" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">class School
{
&nbsp; &nbsp;private String name;
&nbsp; &nbsp;School(String name)
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;this.name = name;
&nbsp; &nbsp;}
&nbsp; &nbsp;public String retClassName()
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;return this.name;
&nbsp; &nbsp;}
} &nbsp;
class Student
{
&nbsp; &nbsp;private int rno;
&nbsp; &nbsp;private String name;
&nbsp; &nbsp;Student(int rno, String name) &nbsp;
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;this.rno = rno;
&nbsp; &nbsp; &nbsp; &nbsp;this.name = name;
&nbsp; &nbsp;}
&nbsp; &nbsp;public String retStudentName()
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;return this.name;
&nbsp; &nbsp;}
}
public class AssociationDemo
{
&nbsp; &nbsp;public static void main (String[] args) &nbsp;
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;School c = new School("XII B");
&nbsp; &nbsp; &nbsp; &nbsp;Student s1 = new Student(1, "John");
&nbsp; &nbsp; &nbsp; &nbsp;Student s2 = new Student(2, "Susan");
&nbsp; &nbsp; &nbsp; &nbsp;Student s3 = new Student(3, "Mary");
&nbsp; &nbsp; &nbsp; &nbsp;Student s4 = new Student(4, "Adam");
&nbsp; &nbsp; &nbsp; &nbsp;Student s5 = new Student(5, "Lucy");
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println("The students in school class " + c.retClassName() + " are:") ;
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println(s1.retStudentName());
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println(s2.retStudentName());
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println(s3.retStudentName());
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println(s4.retStudentName());
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println(s5.retStudentName());
&nbsp; &nbsp;}
}</pre></div></div><p><strong>The output of the above program is as follows:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-4r1hou776" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">The students in school class XII B are:
John
Susan
Mary
Adam
Lucy</pre></div></div><p>In the above program, there is a HAS-A relationship between School class and student as a class in a school has multiple students.</p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">13. Which Java operator has the highest precedence?</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p>The operator precedence in Java determines the order of evaluation for the operators in an expression. The Java operator that has the highest precedence can be seen from the table given below:</p><div class="overflow-x-auto mt-spacing10 mb-[16.8px] md:mb-6 max-w-full"><table class="min-w-full divide-y divide-gray-200 border"><thead><tr><th class="CertTheme__tableCell CertTheme__tableCellHeader" style="border:1px solid black;width:175px;vertical-align:top;text-align:start;background-color:rgb(242, 243, 245)">Operator<br></th><th class="CertTheme__tableCell CertTheme__tableCellHeader" style="border:1px solid black;width:175px;vertical-align:top;text-align:start;background-color:rgb(242, 243, 245)">Sign<br></th><th class="CertTheme__tableCell CertTheme__tableCellHeader" style="border:1px solid black;width:175px;vertical-align:top;text-align:start;background-color:rgb(242, 243, 245)">Associativity<br></th></tr></thead><tbody><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Postfix<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">++ --<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Left to Right<br></td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Unary<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">++ -- + - ! (type)<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Right to Left<br></td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Multiplicative<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">* / %<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Left to Right<br></td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Additive<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">+ -<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Left to Right<br></td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Shift<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">&gt;&gt; &lt;&lt; &gt;&gt;&gt;<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Left to Right<br></td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Relational<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">&lt; &gt; &lt;= &gt;=<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Left to Right<br></td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Equality<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">== !=<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Left to Right<br></td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Bitwise AND<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">&amp;<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Left to Right<br></td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Bitwise XOR<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">^<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Left to Right<br></td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Bitwise OR<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">|<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Left to Right<br></td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Logical AND<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">&amp;&amp;<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Left to Right<br></td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Logical OR<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">||<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Left to Right<br></td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Conditional<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">?:<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Right to Left<br></td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Assignment<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">= += -= *= /= %= ^= |= &gt;&gt;= &lt;&lt;= &nbsp;<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Right to Left<br></td></tr></tbody></table></div><p>As is obvious from the above table, the postfix operators (++ --) have the highest precedence in Java.</p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">14. Java Stack Memory</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p class="CertTheme__paragraph" data-mode="standard"><br></p><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><span>The Stack memory in Java is used for thread execution. Specific values are stored in the stack memory that are available for a short time. Also, stack memory may contain data references to objects getting referred from the method that are in the heap memory.</span></p><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><span>The order in Stack memory is Last In First Out (LIFO). A block is created in the stack memory for all the primitive values and references to other objects in a method when that method is invoked. After the end of the method, the memory block in the stack memory is free and can be used by another method.</span></p><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><span>In general, the size of the stack memory is quite less as compared to the heap memory.</span></p><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><span>Some of the important features of Java Stack Memory are given as follows:</span></p><ol class="CertTheme__ol1 pt-spacing10"><li value="1" class="CertTheme__listItem pt-spacing10"><span>The stack memory can grow if more methods are called and it also shrinks if more methods are returned.</span></li><li value="2" class="CertTheme__listItem pt-spacing10"><span>The error java.lang.StackOverFlowError is thrown if the stack memory is full.</span></li><li value="3" class="CertTheme__listItem pt-spacing10"><span>As long is the method with the variables is running, those variables exist inside the stack. After method is returned, the variables are deleted.</span></li><li value="4" class="CertTheme__listItem pt-spacing10"><span>The memory access time of stack memory is less than that of heap memory.</span></li><li value="5" class="CertTheme__listItem pt-spacing10"><span>The variables are automatically allocated and delocated in stack memory according to the method.</span></li><li value="6" class="CertTheme__listItem pt-spacing10"><span>Each thread has its own stack and so the stack memory is thread safe.</span></li></ol><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><span>Some of the differences between stack memory and heap memory are given as follows:</span></p><ol class="CertTheme__ol1 pt-spacing10"><li value="1" class="CertTheme__listItem pt-spacing10"><span>The stack memory is only used by a thread whereas the heap memory is required by all the application parts.</span></li><li value="2" class="CertTheme__listItem pt-spacing10"><span>The stack memory management is done using LIFO but it is more complicated for heap memory as that is used by the whole application.</span></li><li value="3" class="CertTheme__listItem pt-spacing10"><span>The stack memory is comparatively short lived while the heap memory exists for the whole execution of the application.</span></li><li value="4" class="CertTheme__listItem pt-spacing10"><span>Stack memory is faster than heap memory as its memory allocation procedure is much more simple.</span></li><li value="5" class="CertTheme__listItem pt-spacing10"><span>The stack memory is only accessible by the individual thread but the heap memory objects can be accessed globally.</span></li></ol><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><br></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">15. States of a Thread in Java</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p>The thread life cycle in Java contains 5 states. This means that the thread can be in any of these 5 states. The 5 states in a thread life cycle are demonstrated with the help of a diagram as follows:</p><p><img alt="Life cycle of a thread" loading="lazy" width="100" height="100" decoding="async"  class="fr-fic fr-dib" style="color:transparent;width:100%;height:auto;background-size:cover;background-position:50% 50%;background-repeat:no-repeat;background-image:url(&quot;data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http%3A//www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cfilter id='b' color-interpolation-filters='sRGB'%3E%3CfeGaussianBlur stdDeviation='20'/%3E%3C/filter%3E%3Cimage preserveAspectRatio='none' filter='url(%23b)' x='0' y='0' height='100%25' width='100%25' href='data:image/svg+xml;base64,CiAgPHN2ZyB3aWR0aD0iMTAwIiBoZWlnaHQ9IjEwMCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIj4KICAgIDxkZWZzPgogICAgICA8bGluZWFyR3JhZGllbnQgaWQ9ImciPgogICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNjY2MiIG9mZnNldD0iMjAlIiAvPgogICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNkZGQiIG9mZnNldD0iNTAlIiAvPgogICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNlZWUiIG9mZnNldD0iNzAlIiAvPgogICAgICA8L2xpbmVhckdyYWRpZW50PgogICAgPC9kZWZzPgogICAgPHJlY3Qgd2lkdGg9IjEwMCIgaGVpZ2h0PSIxMDAiIGZpbGw9IiNlZWUiIC8+CiAgICA8cmVjdCBpZD0iciIgd2lkdGg9IjEwMCIgaGVpZ2h0PSIxMDAiIGZpbGw9InVybCgjZykiIC8+CiAgICA8YW5pbWF0ZSB4bGluazpocmVmPSIjciIgYXR0cmlidXRlTmFtZT0ieCIgZnJvbT0iLTEwMCIgdG89IjEwMCIgZHVyPSIxcyIgcmVwZWF0Q291bnQ9ImluZGVmaW5pdGUiICAvPgogIDwvc3ZnPg=='/%3E%3C/svg%3E&quot;)" sizes="(min-width: 767px) 50vw, 100vw" srcSet="" src="https://images.unsplash.com/photo-1544197150-b99a580bb7a8?ixlib=rb-4.0.3&auto=format&fit=crop&w=1000&q=80"></p><p><strong>1. New</strong></p><p>When an instance of the thread class has been created but the start() method is not invoked, then the thread is in the new state.</p><p><strong>2. Runnable</strong></p><p>When the start() method has been invoked but the thread scheduler has not selected the thread for execution, then the thread is in the runnable state.</p><p><strong>3. Running</strong></p><p>If the thread scheduler has selected a thread and it is currently running, then it is in the running state.</p><p><strong>4. Blocked (Non-runnable)</strong></p><p>When a thread is not eligible to run but still alive, then it is in the blocked state.</p><p><strong>5. Terminated</strong></p><p>When the run() method of a thread exits, then it is in the terminated state.</p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">16. BigInteger negate value</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>Use the BigInteger negate() method to nagate a BigInteger value in Java.</p><p>Let us see a simple example:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-6ehuse7ga" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">import java.math.*;
public class Example {
&nbsp; public static void main(String[] args) {
&nbsp; &nbsp; &nbsp;BigInteger b1, b2;
&nbsp; &nbsp; &nbsp;b1 = new BigInteger("35");
&nbsp; &nbsp; &nbsp;b2 = b1.negate();
&nbsp; &nbsp; &nbsp;System.out.println("Negated = " +b2);
&nbsp; }
}</pre></div></div><p><strong>The output:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-rdwlack3o" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">Negated = -35</pre></div></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">17. Role of throw and throws keyword in Java</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>Both the throw and throws keywords in Java are related to exception handling. Details about these are given as follows:</p><h3><span style="color:rgb(0, 0, 0)">The throw keyword</span></h3><p>An exception can be thrown explicitly from a method or a code block using the throw keyword. Mainly custom exceptions are thrown using this keyword. Also, throw can be used to throw checked or unchecked exceptions.</p><p>A program that demonstrates throw keyword in Java is given as follows:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-gpdwl0dyo" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">public class Demo
{ &nbsp;
&nbsp; static void checkMarks(int marks)
&nbsp; {
&nbsp; &nbsp; if(marks &lt; 40) &nbsp;
&nbsp; &nbsp; &nbsp;throw new ArithmeticException("You failed"); &nbsp;
&nbsp; &nbsp; else
&nbsp; &nbsp; &nbsp;System.out.println("Congratulations! You passed"); &nbsp;
&nbsp; }
&nbsp; public static void main(String args[])
&nbsp; {
&nbsp; &nbsp; &nbsp;System.out.println("Test Report");
&nbsp; &nbsp; &nbsp;checkMarks(29); &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp;}
}</pre></div></div><p>The output of the above program is as follows:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-nmlrz4ctb" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">Test Report
Exception in thread "main" java.lang.ArithmeticException: You failed
at Demo.checkMarks(Demo.java:6)
at Demo.main(Demo.java:16)</pre></div></div><h3><span style="color:rgb(0, 0, 0)">The throws keyword</span></h3><p>The signature of a method can contain the throws keyword to signify that the specified method can throw any one of the listed type exceptions. The exception can be handled using a try catch block by the caller of the method.</p><p>A program that demonstrates throws keyword in Java is given as follows:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-as5cvrrgv" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">public class Demo
{
&nbsp; &nbsp;public static void main(String[] args)throws InterruptedException
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;Thread.sleep(1000);
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println("Demonstration of throws keyword");
&nbsp; &nbsp;}
}</pre></div></div><p><strong>The output of the above program is as follows:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-d4k43iq09" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">Demonstration of throws keyword</pre></div></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">18. Role of default constructor in Java</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p>A default constructor is a constructor without parameters that is automatically created if there is no constructor written by the programmer. All the data members in a class are initialized by the default constructor to their default values.</p><p>The default values of numeric data types is 0, of references is null, of floating point numbers is 0.0 and of booleans is false.</p><p>A program that demonstrates a default constructor in Java is given as follows:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-19uk1d9e4" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">class Student
{
&nbsp; int rollNumber;
&nbsp; String name;
&nbsp; float marks;
}
public class Demo
{
&nbsp; &nbsp;public static void main(String args[])
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp;Student s = new Student();
&nbsp; &nbsp; &nbsp;System.out.println(s.rollNumber);
&nbsp; &nbsp; &nbsp;System.out.println(s.name);
&nbsp; &nbsp; &nbsp;System.out.println(s.marks);
&nbsp; &nbsp;}
}</pre></div></div><p><strong>The output of the above program is as follows:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-gy0sbjpmi" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">0
null
0.0</pre></div></div><p>In the above program, the default constructor is called when an object s of class Student is created. Then the default values of the data members of class Student are printed.</p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">19. Default vs Protected access specifiers in Java</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p class="CertTheme__paragraph" data-mode="standard"><br></p><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><span>The access specifiers in Java specify the scope of the data members, constructors, methods etc. of the class. Details about the default and protected access specifiers are given as follows:</span></p><h3 class="CertTheme__h3" dir="ltr"><span>Default Access Specifier</span></h3><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><span>The default access specifier is used when no access specifier is clearly provided by the programmer. The data members, constructors, methods etc. that have the default access specifier are only accessible in the same package.</span></p><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><span>A program that demonstrates the default access specifier in Java is given as follows:</span></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-9lyxctbwd" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm"><span class="CertTheme__tokenAttr">package</span><span> pack1</span><span class="CertTheme__tokenPunctuation">;</span><span> &nbsp;</span><br><span class="CertTheme__tokenAttr">class</span><span> </span><span class="CertTheme__tokenFunction">C1</span><br><span class="CertTheme__tokenPunctuation">{</span><span> &nbsp;</span><br><span>&nbsp; &nbsp;</span><span class="CertTheme__tokenAttr">void</span><span> </span><span class="CertTheme__tokenFunction">print</span><span class="CertTheme__tokenPunctuation">(</span><span class="CertTheme__tokenPunctuation">)</span><br><span>&nbsp; &nbsp;</span><span class="CertTheme__tokenPunctuation">{</span><span> System</span><span class="CertTheme__tokenPunctuation">.</span><span>out</span><span class="CertTheme__tokenPunctuation">.</span><span class="CertTheme__tokenFunction">println</span><span class="CertTheme__tokenPunctuation">(</span><span class="CertTheme__tokenSelector">"This is in package p1"</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">;</span><br><span>&nbsp; &nbsp;</span><span class="CertTheme__tokenPunctuation">}</span><br><span class="CertTheme__tokenPunctuation">}</span><span> &nbsp;</span></pre></div></div><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-v2x1qa8zh" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm"><span class="CertTheme__tokenAttr">package</span><span> pack2</span><span class="CertTheme__tokenPunctuation">;</span><span> &nbsp;</span><br><span class="CertTheme__tokenAttr">import</span><span> pack1</span><span class="CertTheme__tokenPunctuation">.</span><span class="CertTheme__tokenOperator">*</span><span class="CertTheme__tokenPunctuation">;</span><span> &nbsp;</span><br><span class="CertTheme__tokenAttr">class</span><span> </span><span class="CertTheme__tokenFunction">C2</span><br><span class="CertTheme__tokenPunctuation">{</span><span> &nbsp;</span><br><span>&nbsp; </span><span class="CertTheme__tokenAttr">public</span><span> </span><span class="CertTheme__tokenAttr">static</span><span> </span><span class="CertTheme__tokenAttr">void</span><span> </span><span class="CertTheme__tokenFunction">main</span><span class="CertTheme__tokenPunctuation">(</span><span>String args</span><span class="CertTheme__tokenPunctuation">[</span><span class="CertTheme__tokenPunctuation">]</span><span class="CertTheme__tokenPunctuation">)</span><br><span>&nbsp; </span><span class="CertTheme__tokenPunctuation">{</span><br><span>&nbsp; </span><span class="CertTheme__tokenProperty">C1</span><span> obj </span><span class="CertTheme__tokenOperator">=</span><span> </span><span class="CertTheme__tokenAttr">new</span><span> </span><span class="CertTheme__tokenFunction">C1</span><span class="CertTheme__tokenPunctuation">(</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">;</span><br><span>&nbsp; obj</span><span class="CertTheme__tokenPunctuation">.</span><span class="CertTheme__tokenFunction">print</span><span class="CertTheme__tokenPunctuation">(</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">;</span><br><span>&nbsp; </span><span class="CertTheme__tokenPunctuation">}</span><br><span class="CertTheme__tokenPunctuation">}</span><span> &nbsp;</span></pre></div></div><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><span>Execution of the above program results in compile time error as the access specifier of class C1 and print() is default and so they cannot be accessed from outside the package pack1.</span></p><h3 class="CertTheme__h3" dir="ltr"><span>Protected Access Specifier</span></h3><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><span>The protected access specifier can be used on the class data members or methods with the protected keyword. This means that the data members are accessible inside the package and in other packages using inheritance. The protected access specifier cannot be directly applied on a class but it can be applied on a data member, constructor or method.</span></p><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><span>A program that demonstrates the protected access specifier in Java is given as follows:</span></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-4wmo4q72u" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm"><span class="CertTheme__tokenAttr">package</span><span> pack1</span><span class="CertTheme__tokenPunctuation">;</span><span> &nbsp;</span><br><span class="CertTheme__tokenAttr">public</span><span> </span><span class="CertTheme__tokenAttr">class</span><span> </span><span class="CertTheme__tokenFunction">C1</span><br><span class="CertTheme__tokenPunctuation">{</span><span> &nbsp;</span><br><span>&nbsp; &nbsp;</span><span class="CertTheme__tokenAttr">protected</span><span> </span><span class="CertTheme__tokenAttr">void</span><span> </span><span class="CertTheme__tokenFunction">print</span><span class="CertTheme__tokenPunctuation">(</span><span class="CertTheme__tokenPunctuation">)</span><br><span>&nbsp; &nbsp;</span><span class="CertTheme__tokenPunctuation">{</span><span> System</span><span class="CertTheme__tokenPunctuation">.</span><span>out</span><span class="CertTheme__tokenPunctuation">.</span><span class="CertTheme__tokenFunction">println</span><span class="CertTheme__tokenPunctuation">(</span><span class="CertTheme__tokenSelector">"This is in package p1"</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">;</span><br><span>&nbsp; &nbsp;</span><span class="CertTheme__tokenPunctuation">}</span><br><span class="CertTheme__tokenPunctuation">}</span><span> &nbsp;</span></pre></div></div><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><span>Another package:</span></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-x6jxq8n3q" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm"><span class="CertTheme__tokenAttr">package</span><span> pack2</span><span class="CertTheme__tokenPunctuation">;</span><span> &nbsp;</span><br><span class="CertTheme__tokenAttr">import</span><span> pack1</span><span class="CertTheme__tokenPunctuation">.</span><span class="CertTheme__tokenOperator">*</span><span class="CertTheme__tokenPunctuation">;</span><span> &nbsp;</span><br><span class="CertTheme__tokenAttr">class</span><span> </span><span class="CertTheme__tokenFunction">C2</span><span> </span><span class="CertTheme__tokenAttr">extends</span><span> </span><span class="CertTheme__tokenFunction">C1</span><br><span class="CertTheme__tokenPunctuation">{</span><span> &nbsp;</span><br><span>&nbsp; </span><span class="CertTheme__tokenAttr">public</span><span> </span><span class="CertTheme__tokenAttr">static</span><span> </span><span class="CertTheme__tokenAttr">void</span><span> </span><span class="CertTheme__tokenFunction">main</span><span class="CertTheme__tokenPunctuation">(</span><span>String args</span><span class="CertTheme__tokenPunctuation">[</span><span class="CertTheme__tokenPunctuation">]</span><span class="CertTheme__tokenPunctuation">)</span><br><span>&nbsp; </span><span class="CertTheme__tokenPunctuation">{</span><br><span>&nbsp; </span><span class="CertTheme__tokenProperty">C1</span><span> obj </span><span class="CertTheme__tokenOperator">=</span><span> </span><span class="CertTheme__tokenAttr">new</span><span> </span><span class="CertTheme__tokenFunction">C1</span><span class="CertTheme__tokenPunctuation">(</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">;</span><br><span>&nbsp; obj</span><span class="CertTheme__tokenPunctuation">.</span><span class="CertTheme__tokenFunction">print</span><span class="CertTheme__tokenPunctuation">(</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">;</span><br><span>&nbsp; </span><span class="CertTheme__tokenPunctuation">}</span><br><span class="CertTheme__tokenPunctuation">}</span></pre></div></div><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><b><strong class="CertTheme__textBold">The output of the above program is as follows:</strong></b></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-0i5fhmsac" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm"><span>This is </span><span class="CertTheme__tokenAttr">in</span><span> </span><span class="CertTheme__tokenAttr">package</span><span> p1</span></pre></div></div><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><br></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">20. Explain JRE (Java Runtime Environment)</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p>The Java Runtime Environment consists of the Java Virtual Machine, supporting files and core classes. This is basically the minimum requirements to execute a Java application. The JRE is actually a component of the JDK but it can be downloaded separately from the rest.</p><p>Some of the components of the JRE are given as follows:</p><ol class="CertTheme__ol1 pt-spacing10"><li class="CertTheme__listItem pt-spacing10">User Interface Toolkits such as Java 2D, AWT, Sound, Swing etc.</li><li class="CertTheme__listItem pt-spacing10">Java Virtual Machine and Server Virtual Machines.</li><li class="CertTheme__listItem pt-spacing10">Lang and Util base libraries such as Zip, Collections, Versioning etc.</li><li class="CertTheme__listItem pt-spacing10">Deployment techniques</li><li class="CertTheme__listItem pt-spacing10">Base libraries such as I/O, Beans, JNI, Networking etc.</li></ol><h3><span style="color:rgb(0, 0, 0)">JRE working with the JVM</span></h3><p>The Java programs are executed by the Java Virtual Machine which is a running software system. The Java Runtime Environment on the other hand, is a on-disk system that starts the JVM to execute the Java code by combining it with the required libraries.</p><p>In short, the software and libraries that are necessary to run the Java programs are contained in the Java Runtime Environment.</p><p>A diagram that demonstrates that the JRE contains the JVM is given as follows:</p><p><img alt="Java Runtime Environment" loading="lazy" width="100" height="100" decoding="async"  class="fr-fic fr-dib" style="color:transparent;width:100%;height:auto;background-size:cover;background-position:50% 50%;background-repeat:no-repeat;background-image:url(&quot;data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http%3A//www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cfilter id='b' color-interpolation-filters='sRGB'%3E%3CfeGaussianBlur stdDeviation='20'/%3E%3C/filter%3E%3Cimage preserveAspectRatio='none' filter='url(%23b)' x='0' y='0' height='100%25' width='100%25' href='data:image/svg+xml;base64,CiAgPHN2ZyB3aWR0aD0iMTAwIiBoZWlnaHQ9IjEwMCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIj4KICAgIDxkZWZzPgogICAgICA8bGluZWFyR3JhZGllbnQgaWQ9ImciPgogICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNjY2MiIG9mZnNldD0iMjAlIiAvPgogICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNkZGQiIG9mZnNldD0iNTAlIiAvPgogICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNlZWUiIG9mZnNldD0iNzAlIiAvPgogICAgICA8L2xpbmVhckdyYWRpZW50PgogICAgPC9kZWZzPgogICAgPHJlY3Qgd2lkdGg9IjEwMCIgaGVpZ2h0PSIxMDAiIGZpbGw9IiNlZWUiIC8+CiAgICA8cmVjdCBpZD0iciIgd2lkdGg9IjEwMCIgaGVpZ2h0PSIxMDAiIGZpbGw9InVybCgjZykiIC8+CiAgICA8YW5pbWF0ZSB4bGluazpocmVmPSIjciIgYXR0cmlidXRlTmFtZT0ieCIgZnJvbT0iLTEwMCIgdG89IjEwMCIgZHVyPSIxcyIgcmVwZWF0Q291bnQ9ImluZGVmaW5pdGUiICAvPgogIDwvc3ZnPg=='/%3E%3C/svg%3E&quot;)" sizes="(min-width: 767px) 50vw, 100vw" srcSet="" src="https://images.unsplash.com/photo-1555066931-4365d14bab8c?ixlib=rb-4.0.3&auto=format&fit=crop&w=1000&q=80"></p><h3><span style="color:rgb(0, 0, 0)">Installing the JRE</span></h3><p>The Java Runtime Environment is essentially a software that is installed on the computer that runs the Java programs. Normally, Java is installed on the computer and the JRE is included. However, if anytime it is required to install or upgrade the JRE manually, it can be done by downloading the current JRE version from Oracle.</p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">21. Role of Java Sockets</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p>The Java Sockets are used for communication between two computers using the TCP protocol. The communication between the client and server occurs when they read from and write to the sockets as required. The class java.net.Socket provides a representation for sockets in Java and the class java.net.ServerSocket allows the server programs to listen for clients and create connections with them.</p><p>The steps to create a TCP connection between two computers using sockets is given as follows:</p><ol class="CertTheme__ol1 pt-spacing10"><li class="CertTheme__listItem pt-spacing10">A ServerSocket object is instantiated by the server and this denotes the port number for communication.</li><li class="CertTheme__listItem pt-spacing10">Then the accept() method of the ServerSocket class is invoked by the server. This method waits until the till the time the client can connect to the server on the specified port.</li><li class="CertTheme__listItem pt-spacing10">The client instantiates a Socket object while a server is waiting. This object specifies the server name as well as the port number.</li><li class="CertTheme__listItem pt-spacing10">The Socket class constructor tries to connect the client and the server on the required port number. After communication establishment, the client can communicate with the server using a Socket object.</li><li class="CertTheme__listItem pt-spacing10">The accept() method on the server side returns a reference to the socket that is connected to the client’s socket.</li></ol><p>The communication can occur using the Output stream and Input stream after the connections are established.</p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">22. ArrayList vs LinkedList in Java</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p class="CertTheme__paragraph" data-mode="standard"><br></p><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><span>ArrayList and LinkedList are very important lists in Java. While the ArrayList implements a dynamic array, the LinkedList implements a doubly linked list.</span></p><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><span>Some of the differences between Arraylist and LinkedList are given as follows:</span></p><ol class="CertTheme__ol1 pt-spacing10"><li value="1" class="CertTheme__listItem pt-spacing10"><span>It is easier and much faster to insert elements in LinkedList as compared to ArrayList. The time complexity for insertion in ArrayList is O(n) in worst case while it is O(1) in LinkedList.</span></li><li value="2" class="CertTheme__listItem pt-spacing10"><span>Deletion of elements is also easier in LinkedList as compared to ArrayList. However, the time complexity for deletion in ArrayList and LinkedList is O(n) in worst case.</span></li><li value="3" class="CertTheme__listItem pt-spacing10"><span>The time required to find if an element is available in both ArrayList and LinkedList is O(n) in the worst case. But binary search can be used on a sorted ArrayList to reduce this time to O(log n).</span></li><li value="4" class="CertTheme__listItem pt-spacing10"><span>There is more memory overhead in LinkedList as compared to ArrayList. This is because in LinkedList each node contains the data and address of the previous and next nodes while in ArrayList each index contains the data only.</span></li></ol><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><span>A program that demonstrates ArrayList in Java is given as follows:</span></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-q7xetwj41" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm"><span class="CertTheme__tokenAttr">import</span><span> java</span><span class="CertTheme__tokenPunctuation">.</span><span>util</span><span class="CertTheme__tokenPunctuation">.</span><span>ArrayList</span><span class="CertTheme__tokenPunctuation">;</span><br><span class="CertTheme__tokenAttr">public</span><span> </span><span class="CertTheme__tokenAttr">class</span><span> </span><span class="CertTheme__tokenFunction">ArrayListDemo</span><br><span class="CertTheme__tokenPunctuation">{</span><br><span>&nbsp; &nbsp;</span><span class="CertTheme__tokenAttr">public</span><span> </span><span class="CertTheme__tokenAttr">static</span><span> </span><span class="CertTheme__tokenAttr">void</span><span> </span><span class="CertTheme__tokenFunction">main</span><span class="CertTheme__tokenPunctuation">(</span><span>String</span><span class="CertTheme__tokenPunctuation">[</span><span class="CertTheme__tokenPunctuation">]</span><span> args</span><span class="CertTheme__tokenPunctuation">)</span><br><span>&nbsp; &nbsp;</span><span class="CertTheme__tokenPunctuation">{</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp;ArrayList</span><span class="CertTheme__tokenOperator">&lt;</span><span>String</span><span class="CertTheme__tokenOperator">&gt;</span><span> al</span><span class="CertTheme__tokenOperator">=</span><span> </span><span class="CertTheme__tokenAttr">new</span><span> </span><span class="CertTheme__tokenFunction">ArrayList</span><span class="CertTheme__tokenOperator">&lt;</span><span>String</span><span class="CertTheme__tokenOperator">&gt;</span><span class="CertTheme__tokenPunctuation">(</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">;</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp;al</span><span class="CertTheme__tokenPunctuation">.</span><span class="CertTheme__tokenFunction">add</span><span class="CertTheme__tokenPunctuation">(</span><span class="CertTheme__tokenSelector">"Apple"</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">;</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp;al</span><span class="CertTheme__tokenPunctuation">.</span><span class="CertTheme__tokenFunction">add</span><span class="CertTheme__tokenPunctuation">(</span><span class="CertTheme__tokenSelector">"Orange"</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">;</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp;al</span><span class="CertTheme__tokenPunctuation">.</span><span class="CertTheme__tokenFunction">add</span><span class="CertTheme__tokenPunctuation">(</span><span class="CertTheme__tokenSelector">"Guava"</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">;</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp;al</span><span class="CertTheme__tokenPunctuation">.</span><span class="CertTheme__tokenFunction">add</span><span class="CertTheme__tokenPunctuation">(</span><span class="CertTheme__tokenSelector">"Mango"</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">;</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp;al</span><span class="CertTheme__tokenPunctuation">.</span><span class="CertTheme__tokenFunction">add</span><span class="CertTheme__tokenPunctuation">(</span><span class="CertTheme__tokenSelector">"Peach"</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">;</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp;System</span><span class="CertTheme__tokenPunctuation">.</span><span>out</span><span class="CertTheme__tokenPunctuation">.</span><span class="CertTheme__tokenFunction">println</span><span class="CertTheme__tokenPunctuation">(</span><span>al</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">;</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp;al</span><span class="CertTheme__tokenPunctuation">.</span><span class="CertTheme__tokenFunction">remove</span><span class="CertTheme__tokenPunctuation">(</span><span class="CertTheme__tokenProperty">2</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">;</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp;System</span><span class="CertTheme__tokenPunctuation">.</span><span>out</span><span class="CertTheme__tokenPunctuation">.</span><span class="CertTheme__tokenFunction">println</span><span class="CertTheme__tokenPunctuation">(</span><span>al</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">;</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp;</span><span class="CertTheme__tokenAttr">if</span><span> </span><span class="CertTheme__tokenPunctuation">(</span><span>al</span><span class="CertTheme__tokenPunctuation">.</span><span class="CertTheme__tokenFunction">contains</span><span class="CertTheme__tokenPunctuation">(</span><span class="CertTheme__tokenSelector">"Apple"</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">)</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;System</span><span class="CertTheme__tokenPunctuation">.</span><span>out</span><span class="CertTheme__tokenPunctuation">.</span><span class="CertTheme__tokenFunction">println</span><span class="CertTheme__tokenPunctuation">(</span><span class="CertTheme__tokenSelector">"Apple found in ArrayList"</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">;</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp;</span><span class="CertTheme__tokenAttr">else</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;System</span><span class="CertTheme__tokenPunctuation">.</span><span>out</span><span class="CertTheme__tokenPunctuation">.</span><span class="CertTheme__tokenFunction">println</span><span class="CertTheme__tokenPunctuation">(</span><span class="CertTheme__tokenSelector">"Apple not found in ArrayList"</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">;</span><br><span>&nbsp; &nbsp;</span><span class="CertTheme__tokenPunctuation">}</span><br><span class="CertTheme__tokenPunctuation">}</span></pre></div></div><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><b><strong class="CertTheme__textBold">The output of the above program is as follows:</strong></b></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-e42ftw2z0" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm"><span class="CertTheme__tokenPunctuation">[</span><span>Apple</span><span class="CertTheme__tokenPunctuation">,</span><span> Orange</span><span class="CertTheme__tokenPunctuation">,</span><span> Guava</span><span class="CertTheme__tokenPunctuation">,</span><span> Mango</span><span class="CertTheme__tokenPunctuation">,</span><span> Peach</span><span class="CertTheme__tokenPunctuation">]</span><br><span class="CertTheme__tokenPunctuation">[</span><span>Apple</span><span class="CertTheme__tokenPunctuation">,</span><span> Orange</span><span class="CertTheme__tokenPunctuation">,</span><span> Mango</span><span class="CertTheme__tokenPunctuation">,</span><span> Peach</span><span class="CertTheme__tokenPunctuation">]</span><br><span>Apple found </span><span class="CertTheme__tokenAttr">in</span><span> ArrayList</span></pre></div></div><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><span>A program that demonstrates LinkedList in Java is given as follows:</span></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-wbdg6l6et" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm"><span class="CertTheme__tokenAttr">import</span><span> java</span><span class="CertTheme__tokenPunctuation">.</span><span>util</span><span class="CertTheme__tokenPunctuation">.</span><span>LinkedList</span><span class="CertTheme__tokenPunctuation">;</span><br><span class="CertTheme__tokenAttr">public</span><span> </span><span class="CertTheme__tokenAttr">class</span><span> </span><span class="CertTheme__tokenFunction">LinkedListDemo</span><br><span class="CertTheme__tokenPunctuation">{</span><br><span>&nbsp; &nbsp;</span><span class="CertTheme__tokenAttr">public</span><span> </span><span class="CertTheme__tokenAttr">static</span><span> </span><span class="CertTheme__tokenAttr">void</span><span> </span><span class="CertTheme__tokenFunction">main</span><span class="CertTheme__tokenPunctuation">(</span><span>String</span><span class="CertTheme__tokenPunctuation">[</span><span class="CertTheme__tokenPunctuation">]</span><span> args</span><span class="CertTheme__tokenPunctuation">)</span><br><span>&nbsp; &nbsp;</span><span class="CertTheme__tokenPunctuation">{</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp;LinkedList l </span><span class="CertTheme__tokenOperator">=</span><span> </span><span class="CertTheme__tokenAttr">new</span><span> </span><span class="CertTheme__tokenFunction">LinkedList</span><span class="CertTheme__tokenPunctuation">(</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">;</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp;l</span><span class="CertTheme__tokenPunctuation">.</span><span class="CertTheme__tokenFunction">add</span><span class="CertTheme__tokenPunctuation">(</span><span class="CertTheme__tokenSelector">"Apple"</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">;</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp;l</span><span class="CertTheme__tokenPunctuation">.</span><span class="CertTheme__tokenFunction">add</span><span class="CertTheme__tokenPunctuation">(</span><span class="CertTheme__tokenSelector">"Orange"</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">;</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp;l</span><span class="CertTheme__tokenPunctuation">.</span><span class="CertTheme__tokenFunction">add</span><span class="CertTheme__tokenPunctuation">(</span><span class="CertTheme__tokenSelector">"Guava"</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">;</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp;l</span><span class="CertTheme__tokenPunctuation">.</span><span class="CertTheme__tokenFunction">add</span><span class="CertTheme__tokenPunctuation">(</span><span class="CertTheme__tokenSelector">"Mango"</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">;</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp;l</span><span class="CertTheme__tokenPunctuation">.</span><span class="CertTheme__tokenFunction">add</span><span class="CertTheme__tokenPunctuation">(</span><span class="CertTheme__tokenSelector">"Peach"</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">;</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp;System</span><span class="CertTheme__tokenPunctuation">.</span><span>out</span><span class="CertTheme__tokenPunctuation">.</span><span class="CertTheme__tokenFunction">println</span><span class="CertTheme__tokenPunctuation">(</span><span>l</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">;</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp;l</span><span class="CertTheme__tokenPunctuation">.</span><span class="CertTheme__tokenFunction">remove</span><span class="CertTheme__tokenPunctuation">(</span><span class="CertTheme__tokenProperty">0</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">;</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp;System</span><span class="CertTheme__tokenPunctuation">.</span><span>out</span><span class="CertTheme__tokenPunctuation">.</span><span class="CertTheme__tokenFunction">println</span><span class="CertTheme__tokenPunctuation">(</span><span>l</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">;</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp;</span><span class="CertTheme__tokenAttr">if</span><span> </span><span class="CertTheme__tokenPunctuation">(</span><span>l</span><span class="CertTheme__tokenPunctuation">.</span><span class="CertTheme__tokenFunction">contains</span><span class="CertTheme__tokenPunctuation">(</span><span class="CertTheme__tokenSelector">"Apple"</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">)</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;System</span><span class="CertTheme__tokenPunctuation">.</span><span>out</span><span class="CertTheme__tokenPunctuation">.</span><span class="CertTheme__tokenFunction">println</span><span class="CertTheme__tokenPunctuation">(</span><span class="CertTheme__tokenSelector">"Apple found in LinkedList"</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">;</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp;</span><span class="CertTheme__tokenAttr">else</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;System</span><span class="CertTheme__tokenPunctuation">.</span><span>out</span><span class="CertTheme__tokenPunctuation">.</span><span class="CertTheme__tokenFunction">println</span><span class="CertTheme__tokenPunctuation">(</span><span class="CertTheme__tokenSelector">"Apple not found in LinkedList"</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">;</span><br><span>&nbsp; &nbsp;</span><span class="CertTheme__tokenPunctuation">}</span><br><span class="CertTheme__tokenPunctuation">}</span></pre></div></div><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><b><strong class="CertTheme__textBold">The output of the above program is as follows:</strong></b></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-3bpoazym8" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm"><span class="CertTheme__tokenPunctuation">[</span><span>Apple</span><span class="CertTheme__tokenPunctuation">,</span><span> Orange</span><span class="CertTheme__tokenPunctuation">,</span><span> Guava</span><span class="CertTheme__tokenPunctuation">,</span><span> Mango</span><span class="CertTheme__tokenPunctuation">,</span><span> Peach</span><span class="CertTheme__tokenPunctuation">]</span><br><span class="CertTheme__tokenPunctuation">[</span><span>Orange</span><span class="CertTheme__tokenPunctuation">,</span><span> Guava</span><span class="CertTheme__tokenPunctuation">,</span><span> Mango</span><span class="CertTheme__tokenPunctuation">,</span><span> Peach</span><span class="CertTheme__tokenPunctuation">]</span><br><span>Apple not found </span><span class="CertTheme__tokenAttr">in</span><span> LinkedList</span></pre></div></div><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><br></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">23. Collections API in Java</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>A group of objects can be stored and manipulated using an architecture that is provided by the Collections API in Java. All the possible operations in Java such as searching, sorting, deletion, insertion etc. can be performed using the Java Collections.</p><p>A hierarchy of collections in Java is given as follows:</p><p><img alt="Collections API in Java" loading="lazy" width="100" height="100" decoding="async"  class="fr-fic fr-dib" style="color:transparent;width:100%;height:auto;background-size:cover;background-position:50% 50%;background-repeat:no-repeat;background-image:url(&quot;data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http%3A//www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cfilter id='b' color-interpolation-filters='sRGB'%3E%3CfeGaussianBlur stdDeviation='20'/%3E%3C/filter%3E%3Cimage preserveAspectRatio='none' filter='url(%23b)' x='0' y='0' height='100%25' width='100%25' href='data:image/svg+xml;base64,CiAgPHN2ZyB3aWR0aD0iMTAwIiBoZWlnaHQ9IjEwMCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIj4KICAgIDxkZWZzPgogICAgICA8bGluZWFyR3JhZGllbnQgaWQ9ImciPgogICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNjY2MiIG9mZnNldD0iMjAlIiAvPgogICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNkZGQiIG9mZnNldD0iNTAlIiAvPgogICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNlZWUiIG9mZnNldD0iNzAlIiAvPgogICAgICA8L2xpbmVhckdyYWRpZW50PgogICAgPC9kZWZzPgogICAgPHJlY3Qgd2lkdGg9IjEwMCIgaGVpZ2h0PSIxMDAiIGZpbGw9IiNlZWUiIC8+CiAgICA8cmVjdCBpZD0iciIgd2lkdGg9IjEwMCIgaGVpZ2h0PSIxMDAiIGZpbGw9InVybCgjZykiIC8+CiAgICA8YW5pbWF0ZSB4bGluazpocmVmPSIjciIgYXR0cmlidXRlTmFtZT0ieCIgZnJvbT0iLTEwMCIgdG89IjEwMCIgZHVyPSIxcyIgcmVwZWF0Q291bnQ9ImluZGVmaW5pdGUiICAvPgogIDwvc3ZnPg=='/%3E%3C/svg%3E&quot;)" sizes="(min-width: 767px) 50vw, 100vw" srcSet="" src="https://images.unsplash.com/photo-1513258496099-48135e5d3c8f?ixlib=rb-4.0.3&auto=format&fit=crop&w=1000&q=80"></p><p>Some of the characteristics of the Collections API in Java are given as follows:</p><ol class="CertTheme__ol1 pt-spacing10"><li class="CertTheme__listItem pt-spacing10">There are some Collections that don’t allow duplicate elements.</li><li class="CertTheme__listItem pt-spacing10">Some Collections may use linked lists to store the elements. All the elements in a linked list have a reference to the previous and the next elements in the linked list. It is easier and much faster to insert elements in LinkedList as compared to ArrayList.</li><li class="CertTheme__listItem pt-spacing10">Some Collections may use arrays to store the elements. The array can be resized dynamically to store more and more elements as required.</li><li class="CertTheme__listItem pt-spacing10">Some Collections may use hash tables to store the elements. These tables contain specific keys for all the elements that they store.</li><li class="CertTheme__listItem pt-spacing10">Some Collections may use trees to store the elements. Tree based storage is quite useful for storing elements.</li></ol><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">24. Marker Interface in Java</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p>An empty interface that contains no fields or methods is known as a marker interface. Realistic examples of a marker interface are Serializable interface, Cloneable interface and Remote interface. Details about these interfaces are given as follows:</p><h3><span style="color:rgb(0, 0, 0)">Serializable Interface</span></h3><p>The serializable interface makes an object eligible to save its state in a file. This interface is stored in the java.io package. The classes in which the serializable interface is not implemented do not have their states serialized or deserialized.</p><h3><span style="color:rgb(0, 0, 0)">Cloneable Interface</span></h3><p>The cloneable interface is implemented by a class that indicates it is allowed for a clone() method in the Object class to make field-to field copy of the class instances. The java.lang package contains the cloneable interface.</p><p>The exception CloneNotSupportedException is thrown if the clone() method is invoked for a class that has no implementation of the cloneable interface. The classes that have an implementation of this interface usually override the Object.clone() method by convention.</p><h3><span style="color:rgb(0, 0, 0)">Remote Interface</span></h3><p>An object that is stored on a machine and can be accessed from another machine is known as a remote object. The remote interface is required to flag an object and convert it into a remote object. The java.rmi package contains the remote interface.</p><p>The interfaces whose methods can be invoked using a non-local virtual machine can also be identified by the remote interface. Also, the Remote Method Invocation (RMI) has some convenience class that can be extended using the remote object implementations and these facilitate the creation of the remote objects.</p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">25. Best Practices of Exception Handling in Java</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p>Exception handling is the process that deals with the occurrence of exceptions during computation. Some of the best practices of exception handling in Java are given as follows:</p><ul><li class="CertTheme__listItem pt-spacing10"><strong>Put clean up code in a finally block</strong></li></ul><p>There are many resources that are used in a try block that need to be closed afterwards. However, these resources should not be closed in the end of the try block as it may never be reached if any exception is thrown. So, all the cleanup code should be in the finally block for better results.</p><ul><li class="CertTheme__listItem pt-spacing10"><strong>Do not catch throwable</strong></li></ul><p>The superclass of all the exceptions and errors is throwable. It should never be used in a catch clause as it will catch all exceptions and errors, some of which may be outside the control of the application and so unable to be handled.</p><ul><li class="CertTheme__listItem pt-spacing10"><strong>Use descriptive messages with exceptions</strong></li></ul><p>Descriptive messages should be provided with exceptions that help to understand why the exception was reported to the monitoring tool or the log file. The descriptive messages should be precise and describe the exceptional event problem as clearly as possible.</p><ul><li class="CertTheme__listItem pt-spacing10"><strong>Document the specified exceptions</strong></li></ul><p>All the exceptions that are specified in the method signature should also be documented in the Javadoc. This is quite useful as it provides the caller with more information that helps to handle or avoid the exception as required.</p><ul><li class="CertTheme__listItem pt-spacing10"><strong>Never ignore exceptions</strong></li></ul><p>Never ignore an exception under the assumption that it will never occur. This is faulty as the code may change in unforeseen ways in the future and the exceptions thought not required as a particular event would never occur might just occur.</p><ul><li class="CertTheme__listItem pt-spacing10"><strong>Catch the most specific exception first</strong></li></ul><p>The most specific exception class should be catched first and the less specific catch blocks should be provided later as the first catch block that matches an exception gets executed. So, if the less specific exception catch block is given first, then the control may never reach the more specific exception catch block.</p><ul><li class="CertTheme__listItem pt-spacing10"><strong>Use more specific exceptions</strong></li></ul><p>It is better to have as specific exceptions as possible as they make the API easier to understand. This means that the class which is the best fit for the exceptional event should be used and unspecified exceptions should be avoided.</p><ul><li class="CertTheme__listItem pt-spacing10"><strong>Do not log and throw exceptions</strong></li></ul><p>Do not log and rethrow exceptions as it leads to multiple error messages for the same exception. These additional error messages are quite useless as they do not provide any extra information. If any additional information is required, the exception should be caught and wrapped in a custom one.</p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">26. Convert string to date in Java</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>The compare() method is used in Java to compare two doubles.<br>Let us see an example:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-xk75hb2tu" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">import java.lang.*;
public class Example {
&nbsp; &nbsp;public static void main(String args[]) {
&nbsp; &nbsp; &nbsp;Double val1 = new Double("488.11");
&nbsp; &nbsp; &nbsp;Double val2 = new Double("445.78");
&nbsp; &nbsp; &nbsp;int a = &nbsp;Double.compare(val1, val2);
&nbsp; &nbsp; &nbsp;if(a &gt; 0) {
&nbsp; &nbsp; &nbsp; &nbsp; System.out.println("Value 1 is greater than Value 2");
&nbsp; &nbsp; &nbsp;} else if(a &lt; 0) {
&nbsp; &nbsp; &nbsp; &nbsp; System.out.println("Value 1 is less than Value 2");
&nbsp; &nbsp; &nbsp;} else {
&nbsp; &nbsp; &nbsp; &nbsp; System.out.println("Equal!");
&nbsp; &nbsp; &nbsp;}
&nbsp; &nbsp;}
}</pre></div></div><p><strong>The output:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-8cm9dh1mo" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">Value 1 is greater than Value 2</pre></div></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">27. Comparable vs Comparator interface in Java</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>There are two interfaces to sort the objects using the class data members. These are comparable interface and comparator interface. Details about these are given as follows:</p><h3><span style="color:rgb(0, 0, 0)">Comparable Interface</span></h3><p>The comparable interface provides a single sorting sequence. This means that a single element of the collection can be used as the basis for the sorting. The compareTo() method is used by the comparable interface to sort the elements. The java.lang package contains the comparable interface.</p><p>A program that demonstrates the comparable interface is given as follows:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-kuoyylyjk" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">import java.io.*;
import java.util.*;
class Student implements Comparable&lt;Student&gt;
{
&nbsp; &nbsp;private int rollNumber;;
&nbsp; &nbsp;private String name;
&nbsp; &nbsp;private double marks;
&nbsp; &nbsp;public int compareTo(Student s)
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;return this.rollNumber - s.rollNumber;
&nbsp; &nbsp;}
&nbsp; &nbsp;public Student(int rno, String n, double m)
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;this.rollNumber = rno;
&nbsp; &nbsp; &nbsp; &nbsp;this.name = n;
&nbsp; &nbsp; &nbsp; &nbsp;this.marks = m;
&nbsp; &nbsp;}
&nbsp; &nbsp;public int getRNo()
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;return rollNumber;
&nbsp; &nbsp;}
&nbsp; &nbsp;public String getName() &nbsp;&nbsp;
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;return name;
&nbsp; &nbsp;}
&nbsp; &nbsp;public double getMarks() &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;return marks; &nbsp;
&nbsp; &nbsp;}
}
public class Demo
{
&nbsp; &nbsp;public static void main(String[] args)
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;ArrayList&lt;Student&gt; list = new ArrayList&lt;Student&gt;();
&nbsp; &nbsp; &nbsp; &nbsp;list.add(new Student(23, "Harry", 87.5));
&nbsp; &nbsp; &nbsp; &nbsp;list.add(new Student(1, "Amy", 85.5));
&nbsp; &nbsp; &nbsp; &nbsp;list.add(new Student(15, "John", 55.0));
&nbsp; &nbsp; &nbsp; &nbsp;list.add(new Student(45, "James", 95.0));
&nbsp; &nbsp; &nbsp; &nbsp;list.add(new Student(7, "Sally", 78.0));
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println("Original Student List: ");
&nbsp; &nbsp; &nbsp; &nbsp;for (Student s: list)
&nbsp; &nbsp; &nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;System.out.println(s.getRNo() + " " +
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; s.getName() + " " +
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; s.getMarks());
&nbsp; &nbsp; &nbsp; &nbsp;}
&nbsp; &nbsp; &nbsp; &nbsp;Collections.sort(list);
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println("\nStudent List after sorting according to their Roll Number: ");
&nbsp; &nbsp; &nbsp; &nbsp;for (Student s: list)
&nbsp; &nbsp; &nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;System.out.println(s.getRNo() + " " +
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; s.getName() + " " +
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; s.getMarks());
&nbsp; &nbsp; &nbsp; &nbsp;}
&nbsp; &nbsp;}
}</pre></div></div><p><strong>The output of the above program is as follows:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-u5ari98fo" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">Original Student List:
23 Harry 87.5
1 Amy 85.5
15 John 55.0
45 James 95.0
7 Sally 78.0
Student List after sorting according to their Roll Number:
1 Amy 85.5
7 Sally 78.0
15 John 55.0
23 Harry 87.5
45 James 95.0</pre></div></div><h3><span style="color:rgb(0, 0, 0)">Comparator Interface</span></h3><p>The comparator interface provides multiple sorting sequences. This means that multiple elements of the collection can be used as the basis for the sorting. The compare() method is used by the comparator interface to sort the elements. The java.util package contains the comparator interface.</p><p>A program that demonstrates the comparator interface is given as follows:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-y0nr7353t" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">import java.io.*;
import java.util.*;
class Student implements Comparable&lt;Student&gt;
{
&nbsp; &nbsp;private int rollNumber;;
&nbsp; &nbsp;private String name;
&nbsp; &nbsp;private double marks;
&nbsp; &nbsp;public int compareTo(Student s)
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;return this.rollNumber - s.rollNumber;
&nbsp; &nbsp;}
&nbsp; &nbsp;public Student(int rno, String n, double m)
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;this.rollNumber = rno;
&nbsp; &nbsp; &nbsp; &nbsp;this.name = n;
&nbsp; &nbsp; &nbsp; &nbsp;this.marks = m;
&nbsp; &nbsp;}
&nbsp; &nbsp;public int getRNo()
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;return rollNumber;
&nbsp; &nbsp;}
&nbsp; &nbsp;public String getName() &nbsp;&nbsp;
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;return name;
&nbsp; &nbsp;}
&nbsp; &nbsp;public double getMarks() &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;return marks; &nbsp;
&nbsp; &nbsp;}
}
class MarksCompare implements Comparator&lt;Student&gt;
{
&nbsp; &nbsp;public int compare(Student s1, Student s2)
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;if (s1.getMarks() &lt; s2.getMarks())
&nbsp; &nbsp; &nbsp; &nbsp;return -1;
&nbsp; &nbsp; &nbsp; &nbsp;if (s1.getMarks() &gt; s2.getMarks())
&nbsp; &nbsp; &nbsp; &nbsp;return 1;
&nbsp; &nbsp; &nbsp; &nbsp;else
&nbsp; &nbsp; &nbsp; &nbsp;return 0;
&nbsp; &nbsp;}
}
class NameCompare implements Comparator&lt;Student&gt;
{
&nbsp; &nbsp;public int compare(Student s1, Student s2)
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;return s1.getName().compareTo(s2.getName());
&nbsp; &nbsp;}
}
public class Main
{
&nbsp; &nbsp;public static void main(String[] args)
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;ArrayList&lt;Student&gt; list = new ArrayList&lt;Student&gt;();
&nbsp; &nbsp; &nbsp; &nbsp;list.add(new Student(23, "Harry", 87.5));
&nbsp; &nbsp; &nbsp; &nbsp;list.add(new Student(1, "Amy", 85.5));
&nbsp; &nbsp; &nbsp; &nbsp;list.add(new Student(15, "John", 55.0));
&nbsp; &nbsp; &nbsp; &nbsp;list.add(new Student(45, "James", 95.0));
&nbsp; &nbsp; &nbsp; &nbsp;list.add(new Student(7, "Sally", 78.0));
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println("Original Student List: ");
&nbsp; &nbsp; &nbsp; &nbsp;for (Student s: list)
&nbsp; &nbsp; &nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;System.out.println(s.getRNo() + " " +
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; s.getName() + " " +
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; s.getMarks());
&nbsp; &nbsp; &nbsp; &nbsp;}
&nbsp; &nbsp; &nbsp; &nbsp;Collections.sort(list);
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println("\nStudent List sorted by Roll Number: ");
&nbsp; &nbsp; &nbsp; &nbsp;for (Student s: list)
&nbsp; &nbsp; &nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;System.out.println(s.getRNo() + " " +
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; s.getName() + " " +
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; s.getMarks());
&nbsp; &nbsp; &nbsp; &nbsp;}
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println("\nStudent List sorted by Marks: ");
&nbsp; &nbsp; &nbsp; &nbsp;MarksCompare mc = new MarksCompare();
&nbsp; &nbsp; &nbsp; &nbsp;Collections.sort(list, mc);
&nbsp; &nbsp; &nbsp; &nbsp;for (Student s: list)
&nbsp; &nbsp; &nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;System.out.println(s.getRNo() + " " +
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; s.getName() + " " +
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; s.getMarks());
&nbsp; &nbsp; &nbsp; &nbsp;}
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println("\nStudent List sorted by Name: ");
&nbsp; &nbsp; &nbsp; &nbsp;NameCompare nc = new NameCompare();
&nbsp; &nbsp; &nbsp; &nbsp;Collections.sort(list, nc);
&nbsp; &nbsp; &nbsp; &nbsp;for (Student s: list)
&nbsp; &nbsp; &nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;System.out.println(s.getRNo() + " " +
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; s.getName() + " " +
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; s.getMarks());
&nbsp; &nbsp; &nbsp; &nbsp;}
&nbsp; &nbsp;}
}</pre></div></div><p><strong>The output of the above program is as follows:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-2veyi9a0p" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">Original Student List:
23 Harry 87.5
1 Amy 85.5
15 John 55.0
45 James 95.0
7 Sally 78.0
Student List sorted by Roll Number:
1 Amy 85.5
7 Sally 78.0
15 John 55.0
23 Harry 87.5
45 James 95.0
Student List sorted by Marks:
15 John 55.0
7 Sally 78.0
1 Amy 85.5
23 Harry 87.5
45 James 95.0
Student List sorted by Name:
1 Amy 85.5
23 Harry 87.5
45 James 95.0
15 John 55.0
7 Sally 78.0</pre></div></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">28. Anonymous Inner Class in Java</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p>An anonymous class is an inner class that does not have any name in Java. Only a single object of this class is created. An instance of an object can be created with more features such as overloading methods of a class by using the anonymous inner class. This can be done without having to subclass a class.</p><p>A program that demonstrates the anonymous inner class in Java is given as follows:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-tx10ym9sp" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">interface Num
{
&nbsp; &nbsp;int num = 50;
&nbsp; &nbsp;void getNum();
}
public class Demo
{
&nbsp; &nbsp;public static void main(String[] args)
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;Num obj = new Num()
&nbsp; &nbsp; &nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;@Override
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;public void getNum()
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;System.out.print("The number is: " + num);
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}
&nbsp; &nbsp; &nbsp; &nbsp;};
&nbsp; &nbsp; &nbsp; &nbsp;obj.getNum();
&nbsp; &nbsp;}
}</pre></div></div><p>In the above example an anonymous inner class is used and the object of that is created as well as copied in the class code.</p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">29. Priority Queue in Java</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>The priority queue is a data structure in which elements are handled based on their priority. The priority heap is the basis of the priority queue. Also, priority queues are unbound queues and they do not allow NULL pointers.</p><p>A program that demonstrates priority queue in Java is given as follows:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-os1herkyh" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">import java.util.*;
public class Demo
{
&nbsp; &nbsp;public static void main(String args[])
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;PriorityQueue&lt;String&gt; p = new PriorityQueue&lt;String&gt;();
&nbsp; &nbsp; &nbsp; &nbsp;p.add("Apple");
&nbsp; &nbsp; &nbsp; &nbsp;p.add("Mango");
&nbsp; &nbsp; &nbsp; &nbsp;p.add("Orange");
&nbsp; &nbsp; &nbsp; &nbsp;p.add("Peach");
&nbsp; &nbsp; &nbsp; &nbsp;p.add("Guava");
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println("The priority queue elements are:");
&nbsp; &nbsp; &nbsp; &nbsp;Iterator i1 = p.iterator();
&nbsp; &nbsp; &nbsp; &nbsp;while (i1.hasNext())
&nbsp; &nbsp; &nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;System.out.println(i1.next());
&nbsp; &nbsp; &nbsp; &nbsp;}
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println("\nThe element with highest priority is: " + p.peek());
&nbsp; &nbsp; &nbsp; &nbsp;p.poll();
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println("\nThe priority queue elements after removing an element with poll function are:");
&nbsp; &nbsp; &nbsp; &nbsp;Iterator&lt;String&gt; i2 = p.iterator();
&nbsp; &nbsp; &nbsp; &nbsp;while (i2.hasNext())
&nbsp; &nbsp; &nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;System.out.println(i2.next());
&nbsp; &nbsp; &nbsp; &nbsp;}
&nbsp; &nbsp;}
}</pre></div></div><p><strong>The output of the above program is as follows:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-fibxjccy5" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">The priority queue elements are:
Apple
Guava
Orange
Peach
Mango
The element with highest priority is: Apple
The priority queue elements after removing an element with poll function are:
Guava
Mango
Orange
Peach</pre></div></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">30. Composition in Java</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p>The two entities in composition are quite dependent on each other i.e. one entity cannot exist without the other. Basically, composition is a restricted form of aggregation.</p><p>A program that demonstrates composition in Java is given as follows:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-vebat9hk2" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">import java.io.*;
import java.util.*;
class Department
{
&nbsp; &nbsp;public String name;
&nbsp; &nbsp;Department(String name)
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;this.name = name;
&nbsp; &nbsp;}
}
class College
{
&nbsp; &nbsp;private final List&lt;Department&gt; departments;
&nbsp; &nbsp;College (List&lt;Department&gt; departments)
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;this.departments = departments; &nbsp;
&nbsp; &nbsp;}
&nbsp; &nbsp;public List&lt;Department&gt; getDepartments()
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; return departments; &nbsp;&nbsp;
&nbsp; &nbsp;}
}
public class Demo
{
&nbsp; &nbsp;public static void main (String[] args) &nbsp;
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;Department d1 = new Department("Computer Science");
&nbsp; &nbsp; &nbsp; &nbsp;Department d2 = new Department("Electrical");
&nbsp; &nbsp; &nbsp; &nbsp;Department d3 = new Department("Mechanical");
&nbsp; &nbsp; &nbsp; &nbsp;Department d4 = new Department("Information Technology");
&nbsp; &nbsp; &nbsp; &nbsp;Department d5 = new Department("Civil");
&nbsp; &nbsp; &nbsp; &nbsp;List&lt;Department&gt; departments = new ArrayList&lt;Department&gt;();
&nbsp; &nbsp; &nbsp; &nbsp;departments.add(d1);
&nbsp; &nbsp; &nbsp; &nbsp;departments.add(d2);
&nbsp; &nbsp; &nbsp; &nbsp;departments.add(d3);
&nbsp; &nbsp; &nbsp; &nbsp;departments.add(d4);
&nbsp; &nbsp; &nbsp; &nbsp;departments.add(d5);
&nbsp; &nbsp; &nbsp; &nbsp;College c = new College(departments);
&nbsp; &nbsp; &nbsp; &nbsp;List&lt;Department&gt; dpt = c.getDepartments();
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println("The different departments in college are: ");
&nbsp; &nbsp; &nbsp; &nbsp;for(Department d : dpt)
&nbsp; &nbsp; &nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;System.out.println(d.name);
&nbsp; &nbsp; &nbsp; &nbsp;}
&nbsp; &nbsp;}
}</pre></div></div><p><strong>The output of the above program is as follows:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-35zrrb6fy" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">The different departments in college are:
Computer Science
Electrical
Mechanical
Information Technology
Civil</pre></div></div><p>The above program is an example of composition as the departments and college are dependent on each other. There would be no departments without a college.</p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">31. Need of Thread in Java</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p>Threads in Java help to achieve parallelism in a program. This means that multiple operations can be performed at the same time using multithreading.</p><p>The most important usage of threads can be achieved using multithreading. This means that multiple tasks can be done simultaneously using multithreading. Some of the major uses of multithreading in Java are given as follows:</p><ul><li class="CertTheme__listItem pt-spacing10"><strong>Reduction of response time</strong></li></ul><p>The response time for a particular problem can be reduced by dividing it into smaller chunks and assigning each of these chunks to a thread. This means that multiple threads can be used to solve the problem in a relatively lesser time.</p><ul><li class="CertTheme__listItem pt-spacing10"><strong>Multiple tasks can run in parallel</strong></li></ul><p>Multiple tasks can run in parallel using multithreading. An example of this is event handling or drawing which can be performed at the same time using multiple threads.</p><p>Also, multiple threads are required in a Graphical User Interface as a thread is performing a particular function, other threads are required for more user tasks as the GUI cannot be frozen.</p><ul><li class="CertTheme__listItem pt-spacing10"><strong>Multiple clients can be served at the same time</strong></li></ul><p>In a client server application, many clients can connect to the server using multiple threads. This means that a client does not have to wait until the request of the previous client has been serviced by the server.</p><ul><li class="CertTheme__listItem pt-spacing10"><strong>The CPU power can be used to its full advantage</strong></li></ul><p>Threads can be used to utilize the full CPU power and increase the throughput of the system. If there are multiple cores to the CPU, then multiple threads are required to run in parallel across these cores to optimize the system performance.</p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">32. Thread Priority in Java</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p class="CertTheme__paragraph" data-mode="standard"><br></p><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><span>In multithreading, each thread is assigned a priority. The processor is assigned to the thread by the scheduler based on its priority i.e. the highest priority thread is assigned the processor first and so on.</span></p><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><span>The three static values defined in the Thread class for the priority of a thread are given as follows:</span></p><ul class="CertTheme__ul"><li value="1" class="CertTheme__listItem pt-spacing10"><b><strong class="CertTheme__textBold">MAX_PRIORITY</strong></b></li></ul><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><span>This is the maximum thread priority with value 10.</span></p><ul class="CertTheme__ul"><li value="1" class="CertTheme__listItem pt-spacing10"><b><strong class="CertTheme__textBold">NORM_PRIORITY</strong></b></li></ul><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><span>This is the default thread priority with value 5.</span></p><ul class="CertTheme__ul"><li value="1" class="CertTheme__listItem pt-spacing10"><b><strong class="CertTheme__textBold">MIN_PRIORITY</strong></b></li></ul><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><span>This is the minimum thread priority with value 1.</span></p><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><span>A program that demonstrates thread priority in Java is given as follows:</span></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-piu7zonf6" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm"><span class="CertTheme__tokenAttr">import</span><span> java</span><span class="CertTheme__tokenPunctuation">.</span><span>lang</span><span class="CertTheme__tokenPunctuation">.</span><span class="CertTheme__tokenOperator">*</span><span class="CertTheme__tokenPunctuation">;</span><br><span class="CertTheme__tokenAttr">public</span><span> </span><span class="CertTheme__tokenAttr">class</span><span> </span><span class="CertTheme__tokenFunction">ThreadPriorityDemo</span><span> </span><span class="CertTheme__tokenAttr">extends</span><span> </span><span class="CertTheme__tokenFunction">Thread</span><br><span class="CertTheme__tokenPunctuation">{</span><br><span>&nbsp; &nbsp;</span><span class="CertTheme__tokenAttr">public</span><span> </span><span class="CertTheme__tokenAttr">static</span><span> </span><span class="CertTheme__tokenAttr">void</span><span> </span><span class="CertTheme__tokenFunction">main</span><span class="CertTheme__tokenPunctuation">(</span><span>String</span><span class="CertTheme__tokenPunctuation">[</span><span class="CertTheme__tokenPunctuation">]</span><span>args</span><span class="CertTheme__tokenPunctuation">)</span><br><span>&nbsp; &nbsp;</span><span class="CertTheme__tokenPunctuation">{</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp;ThreadPriorityDemo thread1 </span><span class="CertTheme__tokenOperator">=</span><span> </span><span class="CertTheme__tokenAttr">new</span><span> </span><span class="CertTheme__tokenFunction">ThreadPriorityDemo</span><span class="CertTheme__tokenPunctuation">(</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">;</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp;ThreadPriorityDemo thread2 </span><span class="CertTheme__tokenOperator">=</span><span> </span><span class="CertTheme__tokenAttr">new</span><span> </span><span class="CertTheme__tokenFunction">ThreadPriorityDemo</span><span class="CertTheme__tokenPunctuation">(</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">;</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp;ThreadPriorityDemo thread3 </span><span class="CertTheme__tokenOperator">=</span><span> </span><span class="CertTheme__tokenAttr">new</span><span> </span><span class="CertTheme__tokenFunction">ThreadPriorityDemo</span><span class="CertTheme__tokenPunctuation">(</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">;</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp;System</span><span class="CertTheme__tokenPunctuation">.</span><span>out</span><span class="CertTheme__tokenPunctuation">.</span><span class="CertTheme__tokenFunction">println</span><span class="CertTheme__tokenPunctuation">(</span><span class="CertTheme__tokenSelector">"Default thread priority of thread1: "</span><span> </span><span class="CertTheme__tokenOperator">+</span><span> thread1</span><span class="CertTheme__tokenPunctuation">.</span><span class="CertTheme__tokenFunction">getPriority</span><span class="CertTheme__tokenPunctuation">(</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">;</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp;System</span><span class="CertTheme__tokenPunctuation">.</span><span>out</span><span class="CertTheme__tokenPunctuation">.</span><span class="CertTheme__tokenFunction">println</span><span class="CertTheme__tokenPunctuation">(</span><span class="CertTheme__tokenSelector">"Default thread priority of thread2: "</span><span> </span><span class="CertTheme__tokenOperator">+</span><span> thread2</span><span class="CertTheme__tokenPunctuation">.</span><span class="CertTheme__tokenFunction">getPriority</span><span class="CertTheme__tokenPunctuation">(</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">;</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp;System</span><span class="CertTheme__tokenPunctuation">.</span><span>out</span><span class="CertTheme__tokenPunctuation">.</span><span class="CertTheme__tokenFunction">println</span><span class="CertTheme__tokenPunctuation">(</span><span class="CertTheme__tokenSelector">"Default thread priority of thread3: "</span><span> </span><span class="CertTheme__tokenOperator">+</span><span> thread3</span><span class="CertTheme__tokenPunctuation">.</span><span class="CertTheme__tokenFunction">getPriority</span><span class="CertTheme__tokenPunctuation">(</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">;</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp;thread1</span><span class="CertTheme__tokenPunctuation">.</span><span class="CertTheme__tokenFunction">setPriority</span><span class="CertTheme__tokenPunctuation">(</span><span class="CertTheme__tokenProperty">8</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">;</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp;thread2</span><span class="CertTheme__tokenPunctuation">.</span><span class="CertTheme__tokenFunction">setPriority</span><span class="CertTheme__tokenPunctuation">(</span><span class="CertTheme__tokenProperty">3</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">;</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp;thread3</span><span class="CertTheme__tokenPunctuation">.</span><span class="CertTheme__tokenFunction">setPriority</span><span class="CertTheme__tokenPunctuation">(</span><span class="CertTheme__tokenProperty">6</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">;</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp;System</span><span class="CertTheme__tokenPunctuation">.</span><span>out</span><span class="CertTheme__tokenPunctuation">.</span><span class="CertTheme__tokenFunction">println</span><span class="CertTheme__tokenPunctuation">(</span><span class="CertTheme__tokenSelector">"New thread priority of thread1: "</span><span> </span><span class="CertTheme__tokenOperator">+</span><span> thread1</span><span class="CertTheme__tokenPunctuation">.</span><span class="CertTheme__tokenFunction">getPriority</span><span class="CertTheme__tokenPunctuation">(</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">;</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp;System</span><span class="CertTheme__tokenPunctuation">.</span><span>out</span><span class="CertTheme__tokenPunctuation">.</span><span class="CertTheme__tokenFunction">println</span><span class="CertTheme__tokenPunctuation">(</span><span class="CertTheme__tokenSelector">"New thread priority of thread2: "</span><span> </span><span class="CertTheme__tokenOperator">+</span><span> thread2</span><span class="CertTheme__tokenPunctuation">.</span><span class="CertTheme__tokenFunction">getPriority</span><span class="CertTheme__tokenPunctuation">(</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">;</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp;System</span><span class="CertTheme__tokenPunctuation">.</span><span>out</span><span class="CertTheme__tokenPunctuation">.</span><span class="CertTheme__tokenFunction">println</span><span class="CertTheme__tokenPunctuation">(</span><span class="CertTheme__tokenSelector">"New thread priority of thread3: "</span><span> </span><span class="CertTheme__tokenOperator">+</span><span> thread3</span><span class="CertTheme__tokenPunctuation">.</span><span class="CertTheme__tokenFunction">getPriority</span><span class="CertTheme__tokenPunctuation">(</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">;</span><br><span>&nbsp; &nbsp;</span><span class="CertTheme__tokenPunctuation">}</span><br><span class="CertTheme__tokenPunctuation">}</span></pre></div></div><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><b><strong class="CertTheme__textBold">The output of the above program is as follows:</strong></b></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-lq3uh0nj9" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm"><span>Default thread priority </span><span class="CertTheme__tokenAttr">of</span><span> </span><span>thread1</span><span class="CertTheme__tokenOperator">:</span><span> </span><span class="CertTheme__tokenProperty">5</span><br><span>Default thread priority </span><span class="CertTheme__tokenAttr">of</span><span> </span><span>thread2</span><span class="CertTheme__tokenOperator">:</span><span> </span><span class="CertTheme__tokenProperty">5</span><br><span>Default thread priority </span><span class="CertTheme__tokenAttr">of</span><span> </span><span>thread3</span><span class="CertTheme__tokenOperator">:</span><span> </span><span class="CertTheme__tokenProperty">5</span><br><span>New thread priority </span><span class="CertTheme__tokenAttr">of</span><span> </span><span>thread1</span><span class="CertTheme__tokenOperator">:</span><span> </span><span class="CertTheme__tokenProperty">8</span><br><span>New thread priority </span><span class="CertTheme__tokenAttr">of</span><span> </span><span>thread2</span><span class="CertTheme__tokenOperator">:</span><span> </span><span class="CertTheme__tokenProperty">3</span><br><span>New thread priority </span><span class="CertTheme__tokenAttr">of</span><span> </span><span>thread3</span><span class="CertTheme__tokenOperator">:</span><span> </span><span class="CertTheme__tokenProperty">6</span></pre></div></div><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><br></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">33. Memory Management in Java</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p>Memory Management is a vital part of Java and it is very important to understand it. The memory in Java is divided into two main parts, the stack and the heap. A diagram that demonstrates this is given as follows:</p><p><img alt="Memory Management in Java" loading="lazy" width="100" height="100" decoding="async"  class="fr-fic fr-dib" style="color:transparent;width:100%;height:auto;background-size:cover;background-position:50% 50%;background-repeat:no-repeat;background-image:url(&quot;data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http%3A//www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cfilter id='b' color-interpolation-filters='sRGB'%3E%3CfeGaussianBlur stdDeviation='20'/%3E%3C/filter%3E%3Cimage preserveAspectRatio='none' filter='url(%23b)' x='0' y='0' height='100%25' width='100%25' href='data:image/svg+xml;base64,CiAgPHN2ZyB3aWR0aD0iMTAwIiBoZWlnaHQ9IjEwMCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIj4KICAgIDxkZWZzPgogICAgICA8bGluZWFyR3JhZGllbnQgaWQ9ImciPgogICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNjY2MiIG9mZnNldD0iMjAlIiAvPgogICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNkZGQiIG9mZnNldD0iNTAlIiAvPgogICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNlZWUiIG9mZnNldD0iNzAlIiAvPgogICAgICA8L2xpbmVhckdyYWRpZW50PgogICAgPC9kZWZzPgogICAgPHJlY3Qgd2lkdGg9IjEwMCIgaGVpZ2h0PSIxMDAiIGZpbGw9IiNlZWUiIC8+CiAgICA8cmVjdCBpZD0iciIgd2lkdGg9IjEwMCIgaGVpZ2h0PSIxMDAiIGZpbGw9InVybCgjZykiIC8+CiAgICA8YW5pbWF0ZSB4bGluazpocmVmPSIjciIgYXR0cmlidXRlTmFtZT0ieCIgZnJvbT0iLTEwMCIgdG89IjEwMCIgZHVyPSIxcyIgcmVwZWF0Q291bnQ9ImluZGVmaW5pdGUiICAvPgogIDwvc3ZnPg=='/%3E%3C/svg%3E&quot;)" sizes="(min-width: 767px) 50vw, 100vw" srcSet="" src="https://images.unsplash.com/photo-1517048676732-dce42f022dc7?ixlib=rb-4.0.3&auto=format&fit=crop&w=1000&q=80"></p><p>Details about the stack and the heap memory in Java is given as follows:</p><h3><span style="color:rgb(0, 0, 0)">Stack Memory in Java</span></h3><p>The Stack memory in Java is used for thread execution. Specific values are stored in the thread stack that are available for a short time. Also, stack memory may contain data references to objects getting referred from the method that are in the heap memory.</p><p>The order in Thread Stack memory is Last In First Out (LIFO). A block is created in the stack memory for all the primitive values and references to other objects in a method when that method is invoked. After the end of the method, the memory block in the stack memory is free and can be used by another method.</p><h3><span style="color:rgb(0, 0, 0)">Heap Memory in Java</span></h3><p>The heap memory in Java is memory allocated &nbsp;to the Objects and the JRE classes by the Java runtime. All the objects in the application are created in the heap memory. The objects in the heap memory are globally accessible from any place in the application and so they have a lifetime for the whole application execution.</p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">34. ArrayList vs Vectors in Java</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>The list interface in Java can be maintained using both ArrayList and Vector and both of them use dynamically resizable arrays as their internal data structure. So, the major differences between these are given as follows:</p><div class="overflow-x-auto mt-spacing10 mb-[16.8px] md:mb-6 max-w-full"><table class="min-w-full divide-y divide-gray-200 border"><thead><tr><th class="CertTheme__tableCell CertTheme__tableCellHeader" style="border:1px solid black;width:175px;vertical-align:top;text-align:start;background-color:rgb(242, 243, 245)">ArrayList<br></th><th class="CertTheme__tableCell CertTheme__tableCellHeader" style="border:1px solid black;width:175px;vertical-align:top;text-align:start;background-color:rgb(242, 243, 245)">Vector<br></th></tr></thead><tbody><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">The ArrayList is not synchronized i.e. many threads can work on the ArrayList at the same time.<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Vector is synchronized i.e. only one thread can access the Vector at a time.<br></td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">The ArrayList is fast as compared to vector since it is not synchronized.<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">The Vector is slow as compared to ArrayList since it is synchronized.<br></td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">If the number of elements exceed the capacity of the ArrayList, then it increases its current array size by 50%.<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">If the number of elements exceed the capacity of the Vector, then it doubles its current array size.<br></td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">The traversal of elements in ArrayList is done using Iterator interface only.<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">The traversal of elements in Vector is done using Enumeration and Iterator interface.<br></td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">The ArrayList is not a legacy class.<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">The Vector is a legacy class.<br></td></tr></tbody></table></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">35. super vs this in Java</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>Both super and this are keywords in Java. Details about these are given as follows:</p><h3><span style="color:rgb(0, 0, 0)">The super keyword</span></h3><p>The super keyword is a reserved keyword in Java that is used to refer to the immediate parent class. The super keyword can also invoke the method and constructor of the immediate parent class.</p><p>A program that demonstrates the super keyword is given as follows:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-n5erbt7uo" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">class A
{
&nbsp; &nbsp;int x = 26;
&nbsp; &nbsp;static int y = 15;
}
public class B extends A
{
&nbsp; &nbsp;void display()
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println(super.x);
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println(super.y);
&nbsp; &nbsp;}
&nbsp; &nbsp;public static void main(String[] args)
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;B obj = new B();
&nbsp; &nbsp; &nbsp; &nbsp;obj.display();
&nbsp; &nbsp;}
}</pre></div></div><p><strong>The output of the above program is as follows:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-06rnxyp57" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">26
15</pre></div></div><h3><span style="color:rgb(0, 0, 0)">The this keyword</span></h3><p>The this keyword is a reserved keyword in Java that is used to refer to the current class instance variable. The this keyword can also invoke the method and constructor of the current class. It can also be passed as an argument in the method or constructor call.</p><p>A program that demonstrates the super keyword is given as follows:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-is8xil51i" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">public class Demo
{
&nbsp; &nbsp;int x = 25;
&nbsp; &nbsp;static int y = 12;
&nbsp; &nbsp;void display()
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;this.x = 250;
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println(x);
&nbsp; &nbsp; &nbsp; &nbsp;this.y = 120;
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println(y);
&nbsp; &nbsp;}
&nbsp; &nbsp;public static void main(String[] args)
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;Demo obj = new Demo();
&nbsp; &nbsp; &nbsp; &nbsp;obj.display();
&nbsp; &nbsp;}
}</pre></div></div><p><strong>The output of the above program is as follows:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-nrnpdjcok" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">250
120</pre></div></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">36. Serialization vs Deserialization in Java</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>Serialization in Java involves writing the object state into a byte stream so that it can be sent to a database or a disk. Deserialization is the reverse process wherein the stream is converted into the object.</p><p>The java.io.Serializable interface is implemented by default by the String class as well as all the wrapper classes. The functionality to serialize the objects is provided by the writeObject() method of ObjectOutputStream class. Deserialization of objects and primitive data is done using ObjectInputStream.</p><p>A program that demonstrates serialization and deserialization in Java is given as follows:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-e56pcjayj" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">import java.io.*;
class Employee implements Serializable
{
&nbsp; &nbsp;int empID;
&nbsp; &nbsp;String name;
&nbsp; &nbsp;Employee(int e, String n)
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;this.empID = e;
&nbsp; &nbsp; &nbsp; &nbsp;this.name = n;
&nbsp; &nbsp;}
}
public class Demo
{
&nbsp; &nbsp;public static void main(String[] args)
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;Employee emp1 = new Employee(251,"Jason Scott"); &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp;FileOutputStream f = new FileOutputStream("file.txt"); &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp;ObjectOutputStream o = new ObjectOutputStream(f); &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp;o.writeObject(emp1); &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp;o.flush(); &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp;ObjectInputStream i = new ObjectInputStream(new FileInputStream("file.txt")); &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp;Employee emp2 = (Employee)i.readObject(); &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println(emp2.empID + " " + emp2.name); &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp;i.close(); &nbsp;
&nbsp; &nbsp;}
}</pre></div></div><p><strong>The output of the above program is as follows:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-c9ksdxqeu" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">251 Jason Scott</pre></div></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">37. Stop a Thread in Java</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>Stopping a thread in Java can be a little complicated as there is no working stop method. This is quite different than starting a thread in Java as there is a start() method available. When Java was first released, there was a stop() method in Thread class, but that has since been deprecated.</p><p>A program that demonstrates how to stop a thread in Java using a personal stop() method is given as follows:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-hrn91s2fn" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">import static java.lang.Thread.currentThread;
import java.util.concurrent.TimeUnit;
public class Demo
{
&nbsp; &nbsp;public static void main(String args[]) throws InterruptedException
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;Server ser = new Server();
&nbsp; &nbsp; &nbsp; &nbsp;Thread thread = new Thread(ser, "T1");
&nbsp; &nbsp; &nbsp; &nbsp;thread.start();
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println(currentThread().getName() + " is stopping Server thread");
&nbsp; &nbsp; &nbsp; &nbsp;ser.stop();
&nbsp; &nbsp; &nbsp; &nbsp;TimeUnit.MILLISECONDS.sleep(200);
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println(currentThread().getName() + " is finished now");
&nbsp; &nbsp;}
}
class Server implements Runnable
{
&nbsp; &nbsp;private volatile boolean exit = false;
&nbsp; &nbsp;public void run()
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;while(!exit)
&nbsp; &nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;System.out.println("The Server is running");
&nbsp; &nbsp; &nbsp;}
&nbsp; &nbsp; &nbsp;System.out.println("The Server is now stopped");
&nbsp; &nbsp;}
&nbsp; &nbsp;public void stop()
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;exit = true; &nbsp;
&nbsp; &nbsp;}
}</pre></div></div><p><strong>The output of the above program is as follows:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-omdvcy2lk" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">main is stopping Server thread
The Server is running
The Server is now stopped
main is finished now</pre></div></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">38. Difference between inner class and nested class in Java?</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>A nested class in Java is declared inside a class or interface. There are two types of nested classes i.e. static and non-static. The non-static nested classes are known as inner class in Java whereas the static nested classes are merely known as nested class.</p><p>A program that demonstrates an inner class in Java is given as follows:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-3diw6yvnj" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">class Outer
{
&nbsp; class Inner
&nbsp; {
&nbsp; &nbsp; &nbsp;public void display()
&nbsp; &nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; System.out.println("Inside the inner class method");
&nbsp; &nbsp; &nbsp;}
&nbsp; }
}
public class Main
{
&nbsp; public static void main(String[] args)
&nbsp; {
&nbsp; &nbsp; &nbsp; Outer.Inner obj = new Outer().new Inner();
&nbsp; &nbsp; &nbsp; obj.display();
&nbsp; }
}</pre></div></div><p><strong>The output of the above program is as follows:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-29qq7rs8i" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">Inside the inner class method</pre></div></div><p>A program that demonstrates the nested class in Java is given as follows:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-voy7xx605" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">class Outer
{ &nbsp;
&nbsp; static int num = 67; &nbsp;
&nbsp; static class Inner
&nbsp; {
&nbsp; &nbsp; &nbsp;public void display()
&nbsp; &nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; System.out.println("The number is: " + num);
&nbsp; &nbsp; &nbsp;}
&nbsp; }
}
public class Main
{
&nbsp; public static void main(String[] args)
&nbsp; {
&nbsp; &nbsp; &nbsp; Outer.Inner obj = new Outer.Inner();
&nbsp; &nbsp; &nbsp; obj.display();
&nbsp; }
}</pre></div></div><p><strong>The output of the above program is as follows:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-y3jmc8bg4" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">The number is: 67</pre></div></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">39. Difference between declaring a variable and defining a variable in Java</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>Declaring a variable implies giving a data type to the variable such as int, float, char etc. An example of this is given as follows:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-xzzh40iie" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">int val;</pre></div></div><p>Defining a variable implies assigning a value to the declared variable. This value is stored in the variable. An example of this is given as follows:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-1ghnxnkl9" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">val = 5;</pre></div></div><p>A program that demonstrates declaring a variable and defining a variable in Java is given as follows:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-n8tsossoo" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">public class Demo
{
&nbsp; public static void main(String[] args)
&nbsp; {
&nbsp; &nbsp; &nbsp; int val; &nbsp; &nbsp;//declaring a variable
&nbsp; &nbsp; &nbsp; val = 5; &nbsp; //defining a variable
&nbsp; &nbsp; &nbsp; System.out.println("val = " + val);
&nbsp; }
}</pre></div></div><p><strong>The output of the above program is as follows:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-9x99snjtz" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">val = 5</pre></div></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">40. Why Strings in Java are Immutable?</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p>Expect to come across this popular question in Java technical interview questions.</p><p>Strings in Java are immutable. This means that they are unchangeable or unmodifiable. There are several reasons for this. Some of these are given below:</p><ul><li class="CertTheme__listItem pt-spacing10"><strong>Synchronization and Concurrency</strong></li></ul><p>Synchronization issues are solved by making strings in Java as immutable. This is &nbsp;because they automatically become thread safe if they are immutable.</p><ul><li class="CertTheme__listItem pt-spacing10"><strong>Class Loading</strong></li></ul><p>Class Loading has string arguments. If Strings were mutable, then wrong classes could be loaded as mutable objects change their state.</p><ul><li class="CertTheme__listItem pt-spacing10"><strong>Security</strong></li></ul><p>Network connections, urls, database connections, usernames/passwords etc. have parameters that are represented as String. These parameters could be easily changed if the Strings were mutable and that would be a security breach.</p><p>A program that demonstrates Strings is given as follows:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-lm2t8fxlc" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">public class Demo
{ &nbsp;
public static void main(String args[])
{ &nbsp;
&nbsp; String str = "Snow"; &nbsp;
&nbsp; str.concat("White"); &nbsp;
&nbsp; System.out.println(str);
} &nbsp;
} &nbsp;</pre></div></div><p><strong>The output of the above program is as follows:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-kvqdvz6qz" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">Snow</pre></div></div><p>In the above program, only Snow is printed as Strings are immutable objects.</p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">41. Java vs Python</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>Both Java and Python are high level languages. Some of the differences between these languages are given as follows:</p><div class="overflow-x-auto mt-spacing10 mb-[16.8px] md:mb-6 max-w-full"><table class="min-w-full divide-y divide-gray-200 border"><thead><tr><th class="CertTheme__tableCell CertTheme__tableCellHeader" style="border:1px solid black;width:175px;vertical-align:top;text-align:start;background-color:rgb(242, 243, 245)">Java</th><th class="CertTheme__tableCell CertTheme__tableCellHeader" style="border:1px solid black;width:175px;vertical-align:top;text-align:start;background-color:rgb(242, 243, 245)">Python</th></tr></thead><tbody><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start"><p>Java has longer lines of code that are more complex as compared to Python. For example:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-oj5so3m45" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">public class Demo
{ &nbsp;
public static void main(String args[])
{ &nbsp;
&nbsp; System.out.println(“Hello World”);
} &nbsp;
}</pre></div></div></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start"><p>Python has shorter and easier lines of code as compared to Java. For example:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-jo7qygp9i" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">print(““Hello World”)</pre></div></div><br></td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start"><p>The type of the variable that is used should be declared in Java.</p></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start"><p>There is no need to declare the type of variable in Python as it is dynamically typed. This is known as duck typing.</p></td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start"><p>JVM is available almost everywhere because of the high portability of Java.</p></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start"><p>Python is also portable but it is not as popular as Java</p></td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start"><p>Each statement in Java requires a semicolon at the end.</p></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start"><p>statements in Python do not require a semicolon at the end.</p></td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start"><p>Java database connectivity is quite popular (JDBC) and so Java is frequently used with databases.</p></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start"><p>Python is not used with databases frequently as its database access layers are weaker than JDBC.</p></td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start"><p>Java is more complicated to use than Python as there is no dynamic programming and the codes are also larger.</p></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start"><p>Python is easier to use than Java as dynamic programming is used and the codes are also shorter.</p></td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start"><p>Java is faster than Python.</p></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start"><p>Python is slower than Java.</p></td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start"><p>Curly braces are mandatory in Java to define a block.</p></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start"><p>Curly braces are not required in Python but indentation is mandatory.</p></td></tr></tbody></table></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">42. How Java Threads communicate with each other?</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>Inter-thread communication involves the communication of Java threads with each other. The three methods are Java that are used to implement inter-thread communication are given as follows:</p><ul><li class="CertTheme__listItem pt-spacing10"><strong>wait()</strong></li></ul><p>This method causes the current thread to release the lock. This is done until a specific amount of time has passed or another thread calls the notify() or notifyAll() method for this object.</p><ul><li class="CertTheme__listItem pt-spacing10"><strong>notify()</strong></li></ul><p>This method wakes a single thread out of multiple threads on the current object’s monitor. The choice of thread is arbitrary.</p><ul><li class="CertTheme__listItem pt-spacing10"><strong>notifyAll()</strong></li></ul><p>This method wakes up all the threads that are on the current object’s monitor.</p><p>A program that demonstrates inter-thread communication in Java is given as follows:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-kw0h6e19j" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">class BankCustomer
{ &nbsp;
&nbsp; &nbsp;int balAmount = 10000; &nbsp;
&nbsp; &nbsp;synchronized void withdrawMoney(int amount)
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println("Withdrawing money"); &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp;balAmount -= amount; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println("The balance amount is: " + balAmount); &nbsp;
&nbsp; &nbsp;}
&nbsp; &nbsp;synchronized void depositMoney(int amount)
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println("Depositing money"); &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp;balAmount += amount; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println("The balance amount is: " + balAmount); &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp;notify(); &nbsp;
&nbsp; &nbsp;}
} &nbsp;
public class Demo
{ &nbsp;
&nbsp; &nbsp;public static void main(String args[])
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;final BankCustomer cust = new BankCustomer(); &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp;new Thread()
&nbsp; &nbsp; &nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;public void run()
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;cust.withdrawMoney(5000);
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}
&nbsp; &nbsp; &nbsp; &nbsp;}.start(); &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp;new Thread()
&nbsp; &nbsp; &nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;public void run()
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;cust.depositMoney(2000);
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}
&nbsp; &nbsp; &nbsp; &nbsp;}.start(); &nbsp;
&nbsp; &nbsp;}
}</pre></div></div><p><strong>The output of the above program is as follows:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-31gqezn6m" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">Withdrawing money
The balance amount is: 5000
Depositing money
The balance amount is: 7000</pre></div></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">43. Avoid Deadlock in Java?</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p>A deadlock is a situation that usually occurs in multi-threading or multi-tasking. It means that two or more threads are waiting indefinitely on each other to release the resources they require to complete their execution.</p><p>Deadlocks can be avoided in Java by trying to avoid the possibilities that give rise to them. These possibilities cannot be completely erased but they can definitely be lessened.</p><p>Some of the ways to avoid deadlocks in Java are given as follows:</p><ul><li class="CertTheme__listItem pt-spacing10"><strong>Avoid unnecessary locks</strong></li></ul><p>Using unnecessary locks can lead to deadlock so only those members should be locked that are actually required.</p><ul><li class="CertTheme__listItem pt-spacing10"><strong>Avoid nested locks</strong></li></ul><p>Nested locks to multiple threads are the main reason for deadlocks. So, locks to multiple threads should be avoided if one thread has already been locked.</p><ul><li class="CertTheme__listItem pt-spacing10"><strong>Use Thread.join</strong></li></ul><p>If one thread is waiting for another then deadlock occurs. So, Thread.join can be used if the deadlock condition appears for the maximum time required for the execution.</p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">44. Serialize and Deserialize an Object in Java</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>Serialization is the process of changing the state of an object into the byte stream so that the byte stream can return back into a copy of the object</p><p>In Java, an object is said to be serializable if its class or parent classes implement either the Serializable interface or the Externalizable interface.</p><p>Deserialization is converting the serialized object back into a copy of the object.</p><p>During serialization, if we don’t want to write the state of the particular variable in the byte stream, we use the <strong>transient&nbsp;</strong>keyword. When the JVM comes up to the transient keyword, it ignores the original state of the variable and stores a default value of that data type i.e. 0 for int, 0 for byte, 0.0 for float,etc.</p><p>Serialization of an object is done through the FileOutputStream and ObjectOutputStream.</p><p>Suppose we create an object obj of class Example:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-ynca60w2b" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">Example obj = new Example();</pre></div></div><p>It is serialized as follows:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-xa9pygn1u" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">FileOutputStream fos = new FileOutputStream("file_name.txt");
ObjectOutputStream oos = new ObjectOutputStream(fos);
oos.writeObject(obj);</pre></div></div><p>The serialized object is deserialized using FileInputStream and ObjectInputStream. The byte stream reverts back to the copy of the object i.e. x</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-omy2f01nl" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">FileInputStream fis = new FileInputStream("file_name.txt");
ObjectInputStream ois = new ObjectInputStream(fis);
Example x = (Example)ois.readObject();</pre></div></div><p>Let us see an program for serialization along with deserialization of an object named obj :</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-1whbk830p" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">import java.io.*;
public class Example implements Serializable
{
&nbsp; &nbsp;int a = 1, b = 2; &nbsp; &nbsp; &nbsp;// instance variable
&nbsp; &nbsp;transient int c = 3; &nbsp; // transient variable
&nbsp; &nbsp;public static void main(String[] args) throws Exception
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;Example obj = new Example();
&nbsp; &nbsp; &nbsp; &nbsp;// serialization
&nbsp; &nbsp; &nbsp; &nbsp;FileOutputStream fos = new FileOutputStream("example_file.txt");
&nbsp; &nbsp; &nbsp; &nbsp;ObjectOutputStream oos = new ObjectOutputStream(fos);
&nbsp; &nbsp; &nbsp; &nbsp;oos.writeObject(obj);
&nbsp; &nbsp; &nbsp; &nbsp;// de-serialization
&nbsp; &nbsp; &nbsp; &nbsp;FileInputStream fis = new FileInputStream("example_file.txt");
&nbsp; &nbsp; &nbsp; &nbsp;ObjectInputStream ois = new ObjectInputStream(fis);
&nbsp; &nbsp; &nbsp; &nbsp;Example x = (Example)ois.readObject();
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println("a = " + x.a);
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println("b = " + x.b);
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println("c = " + x.c); &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;
&nbsp; &nbsp;}
}</pre></div></div><p><strong>The output is as follows:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-glk0mpk8l" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">$javac Example.java
$java Example
a = 1
b = 2
c = 0</pre></div></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">45. Can we override private methods in Java?</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p>No, private methods cannot be overridden in Java. The private keyword limits the scope of the method, variable or class with which it is declared.</p><p>Private methods in Java are not visible to any other class which limits their scope to the class in which they are declared.</p><p>Let us see what happens when we try to override a private method:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-2tjlbf2vo" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">class Parent
{
&nbsp; private void display()
&nbsp;{
&nbsp; &nbsp; System.out.println("Super class"); &nbsp; &nbsp; &nbsp;
&nbsp;}
}
public class Example extends Parent
{
&nbsp;void display() &nbsp; // trying to override display()
&nbsp;{
&nbsp; &nbsp; System.out.println("Sub class"); &nbsp;&nbsp;
&nbsp;}
&nbsp;public static void main(String[] args)
&nbsp;{
&nbsp; &nbsp; &nbsp;Parent obj = new Example(); &nbsp;
&nbsp; &nbsp; &nbsp;obj.display();
&nbsp;} &nbsp;
}</pre></div></div><p><strong>The output is as follows:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-uz4gk1q8j" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">$javac Example.java
Example.java:17: error: display() has private access in Parent
&nbsp; &nbsp; &nbsp;obj.method();
&nbsp; &nbsp; &nbsp; &nbsp; ^
1 error</pre></div></div><p>The program gives a compile time error showing that display() has private access in Parent class and hence cannot be overridden in the subclass Example.</p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">46. Multi-catch block in Java</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>Before Java 7 when we needed to handle more than one exception, we required multiple catch blocks to handle those exceptions.</p><p>Let us see an example:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-7bzbnz7wf" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">import java.util.*;
public class Example
{
&nbsp; &nbsp;public static void main(String args[])
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;Scanner sc = new Scanner(System.in);
&nbsp; &nbsp; &nbsp; &nbsp;try
&nbsp; &nbsp; &nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;int n=Integer.parseInt(sc.next());
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;System.out.println(n/0);
&nbsp; &nbsp; &nbsp; &nbsp;}
&nbsp; &nbsp; &nbsp; &nbsp;catch (ArithmeticException ex)
&nbsp; &nbsp; &nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;System.out.println("Exception caught " + ex);
&nbsp; &nbsp; &nbsp; &nbsp;}
&nbsp; &nbsp; &nbsp; &nbsp;catch (NumberFormatException ex)
&nbsp; &nbsp; &nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;System.out.println("Exception caught " + ex);
&nbsp; &nbsp; &nbsp; &nbsp;}
&nbsp; &nbsp;}
}</pre></div></div><p>The output here depends on the input.</p><p>When we input an integer it will generate an arithmetic exception.</p><p>For the following input:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-qkgtymkhk" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">3</pre></div></div><p><strong>The output would be as follows:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-qx63b06wz" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">$javac Example.java
$java Example</pre></div></div><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-cb43dldhw" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">Exception caught java.lang.ArithmeticException: / by zero</pre></div></div><p>For a String or character input, the output would be different.</p><p>For the following input:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-mlgmx0pev" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">Hello</pre></div></div><p><strong>The output would is as follows:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-be2hqmlye" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">$javac Example.java
$java Example
Exception caught java.lang.NumberFormatException: For input string: "Hello"</pre></div></div><p>From Java 7, the <strong>multi-catch&nbsp;</strong>block was introduced in Java</p><p>A single catch block could catch multiple exceptions which are separated <strong>|&nbsp;</strong>symbol.</p><p>Let us see an example for the multi-catch block:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-l0uozomtw" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">import java.util.*;
public class Example
{
&nbsp; &nbsp;public static void main(String args[])
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;Scanner sc = new Scanner(System.in);
&nbsp; &nbsp; &nbsp; &nbsp;try
&nbsp; &nbsp; &nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;int n=Integer.parseInt(sc.next());
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;System.out.println(n/0);
&nbsp; &nbsp; &nbsp; &nbsp;}
&nbsp; &nbsp; &nbsp; &nbsp;catch (NumberFormatException | ArithmeticException ex)
&nbsp; &nbsp; &nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;System.out.println("Exception caught " + ex);
&nbsp; &nbsp; &nbsp; &nbsp;}
&nbsp; &nbsp;}
}</pre></div></div><p>When we input an integer it will generate an arithmetic exception.</p><p>For the following input:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-qu2hfc6ay" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">3</pre></div></div><p><strong>The output would be as follows:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-yp4f1us04" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">$javac Example.java
$java Example
Exception caught java.lang.ArithmeticException: / by zero</pre></div></div><p>For a String or character input, the output would be different.</p><p>For the following input:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-lripggx76" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">Hello</pre></div></div><p><strong>The output would is as follows:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-lcnuz0t15" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">$javac Example.java
$java Example
Exception caught java.lang.NumberFormatException: For input string: "Hello"</pre></div></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">47. Java Annotations</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>Annotations in Java are a form syntactic metadata which are used to convey additional information about a program’s elements like constructors, methods, instance variables and classes.</p><p>They always start with <strong>@&nbsp;</strong>symbol. Annotations have no direct effect in the compilation of the program.</p><p>On the other side, annotations do not completely act like comments as they can transform the compiler’s perspective about the program.</p><p>Let us see an example where annotations effect the output of a program. We are trying to override a private method . This will generate an error.</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-k29kuy9ji" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">class Parent
{
&nbsp; private void display()
&nbsp;{
&nbsp; &nbsp; System.out.println("Super class"); &nbsp; &nbsp; &nbsp;
&nbsp;}
}
public class Example extends Parent
{ &nbsp;&nbsp;
&nbsp; &nbsp;//using the Override annotation
&nbsp; &nbsp;@Override
&nbsp;void display() &nbsp; // trying to override display()
&nbsp;{
&nbsp; &nbsp; System.out.println("Sub class"); &nbsp;&nbsp;
&nbsp;}
&nbsp;public static void main(String[] args)
&nbsp;{
&nbsp; &nbsp; &nbsp;Parent obj = new Example(); &nbsp;
&nbsp; &nbsp; &nbsp;obj.display();
&nbsp;} &nbsp;
}</pre></div></div><p><strong>The output is as follows:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-1232ale02" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">$javac Example.java
Example.java:11: error: method does not override or implement a method from a supertype
&nbsp; &nbsp;@Override
&nbsp; &nbsp;^
Example.java:19: error: display() has private access in Parent
&nbsp; &nbsp; &nbsp;obj.display();
&nbsp; &nbsp; &nbsp; &nbsp; ^
2 errors</pre></div></div><p>Basically, Annotations are divided into three categories</p><ol class="CertTheme__ol1 pt-spacing10"><li class="CertTheme__listItem pt-spacing10">Marker Annotations</li><li class="CertTheme__listItem pt-spacing10">Full Annotations</li><li class="CertTheme__listItem pt-spacing10">Single value Annotations</li></ol><p>Marker Annotations: They are used to point out at declaration. These annotations do not have any parameters.</p><p>For example:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-5vxtbn5qq" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">@ExampleAnnotation()</pre></div></div><p><strong>@Override&nbsp;</strong>is an example of a marker annotation.</p><p><strong>Full Annotations</strong>: These annotations consist of multiple variables’ name,value, pairs.</p><p>For example:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-6okwgql3p" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">@ExampleAnnotation(name=”Program”, value=”Java”)</pre></div></div><p><strong>Single value Annotations</strong>: These annotations consist only a single member with a shorthand value.</p><p>For example:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-c72buu2k0" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">@ExampleAnnotation(“running”)</pre></div></div><p>There are a few built-in/ primitive annotations in Java.</p><p>3 of the built-in annotations are included in the java.lang package. They are as follows</p><ul><li class="CertTheme__listItem pt-spacing10">@Deprecated</li><li class="CertTheme__listItem pt-spacing10">&nbsp;@Override</li><li class="CertTheme__listItem pt-spacing10">@SuppressWarnings</li></ul><p>4 of them are imported the java.lang.annotation class, namely:</p><ul><li class="CertTheme__listItem pt-spacing10">@Retention</li><li class="CertTheme__listItem pt-spacing10">@Documented</li><li class="CertTheme__listItem pt-spacing10">@Inherited</li><li class="CertTheme__listItem pt-spacing10">@Target</li></ul><div class="overflow-x-auto mt-spacing10 mb-[16.8px] md:mb-6 max-w-full"><table class="min-w-full divide-y divide-gray-200 border"><thead><tr><th class="CertTheme__tableCell CertTheme__tableCellHeader" style="border:1px solid black;width:175px;vertical-align:top;text-align:start;background-color:rgb(242, 243, 245)">Annotation<br></th><th class="CertTheme__tableCell CertTheme__tableCellHeader" style="border:1px solid black;width:175px;vertical-align:top;text-align:start;background-color:rgb(242, 243, 245)">Description<br></th></tr></thead><tbody><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">@Deprecated<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">A marker annotation that indicates that the declaration is outdated and has been updated<br></td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">@Override<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">A marker annotation used when a method overrides another method from a parent class<br></td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">@SuppressWarnings<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">It is used to generate compiler warnings<br></td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">@Documented<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">It is a marker annotation that &nbsp;tells a tool that an annotation is to be documented<br></td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">@Inherited<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">It is used only on declaration of an annotation<br></td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">@Target<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">It acts as an annotation to another annotation<br></td></tr></tbody></table></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">48. Lambda Expressions in Java 8</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>Lambda expressions in Java are expressions which implement functional interfaces. Functional interfaces are those interfaces that have only one abstract method.</p><p>These expressions were created to reduce the unwieldy overhead code of an anonymous class. An anonymous class is a local class devoid of a name and is declared and instantiated at the same time.</p><p>Until Java 8, even for the simplest of operations, additional syntactical code was written with anonymous classes . Lambda expressions were introduced to remove this shortcoming.</p><p>The syntax:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-e0zlksni5" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">lambda operator-&gt;body</pre></div></div><p>lambda operator is an parameter list can have 0, 1 or multiple parameters.</p><p><strong>Zero parameter:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-t9xkqq95l" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">()-&gt;System.out.println(“I have no argument”);</pre></div></div><p><strong>One parameter:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-d2uc8b9ip" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">(arg)-&gt;System.out.println(“I have one argument”+arg)</pre></div></div><p><strong>Multiple parameters:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-d85eytyrg" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">(arg1,arg2)-&gt;System.out.println(“I have many arguments”+arg1+“ ”+arg2)</pre></div></div><p>Let us use lambda expression to print even integers from a list:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-093kwiend" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">import java.util.*;
public class Example
{
&nbsp; &nbsp;public static void main(String args[])
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;List&lt;Integer&gt; list = new ArrayList&lt;Integer&gt;();
&nbsp; &nbsp; &nbsp; &nbsp;for(int i=1;i&lt;=10;i++) &nbsp;// adding 1 to 10 in the integer ArrayList
&nbsp; &nbsp; &nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;list.add(i);
&nbsp; &nbsp; &nbsp; &nbsp;}
&nbsp; &nbsp; &nbsp; // printing even elements in list using lambda expression
&nbsp; &nbsp; &nbsp; &nbsp;list.forEach(arg -&gt; { if (arg%2 == 0) System.out.println(arg); });
&nbsp; &nbsp;}
}</pre></div></div><p><strong>The output is as follows:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-848gujr8x" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">$javac Example.java
$java Example
2
4
6
8
10</pre></div></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">49. Can we increase the size of a Java array after its declaration?</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p>The size of a primitive array cannot be increased in Java as it is fixed. If we try to increase the size of the primitive array, it would lead to an ArrayIndexOutOfBoundsException.</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-r86syr47t" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">import java.util.*;
public class Example
{
&nbsp; &nbsp;public static void main(String args[])
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;int size=10;
&nbsp; &nbsp; &nbsp; int arr[]=new int[size];
&nbsp; &nbsp; &nbsp; for(int i=0;i&lt;10;i++) &nbsp; // initializing the array with values from 0 to 9
&nbsp; &nbsp; &nbsp; {
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; arr[i]=i;
&nbsp; &nbsp; &nbsp; }
&nbsp; &nbsp; &nbsp; &nbsp;size++;
&nbsp; &nbsp; &nbsp; &nbsp;// trying to increase the size and then initialize the 11th element present at 10th index
&nbsp; &nbsp; &nbsp; &nbsp;arr[size-1]=2;
&nbsp; &nbsp;}
}</pre></div></div><p><strong>The output is as follows:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-qh2fdndi4" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">$javac Example.java
$java &nbsp;Example
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 10
at Example.main(Example.java:14)</pre></div></div><p>The code generates an java.lang.ArrayIndexOutOfBoundsException exception.</p><p>To increase the size of an array, we need to copy it and increase its size dynamically. The java.util.Arrays class provides Arrays.copyOf() method which helps us to create a new array with an increased size and copy the values of the elements of the original array simultaneously.</p><p><strong>The syntax:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-b6awp3pvh" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">Arrays.copyOf(original_array,new_size);</pre></div></div><p>Let us see an example where we copy an array and increase its size:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-43dp0kzuz" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">import java.util.Arrays;
public class Example
{
&nbsp; &nbsp;public static void main(String[] args)
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;int[] arr = {1,2,3,4,5,6,7,8}; // array arr has 8 elements
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println("Inital array size: "+arr.length);
&nbsp; &nbsp; &nbsp; &nbsp;// copying the array arr and increasing its size to 10
&nbsp; &nbsp; &nbsp; &nbsp; int[] crr = Arrays.copyOf(arr, 10);
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println("Final array size: "+crr.length);
&nbsp; &nbsp;}
}</pre></div></div><p><strong>The output is as follows:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-nrifmncwi" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">$javac Example.java
$java Example
Inital array size: 8
Final array size: 10</pre></div></div><p>We can use the ArrayList class to create a dynamic array list but that would occupy a lot more memory. Thus we use the Arrays.copyOf() method.</p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">50. How to compare two strings in Java</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p><strong>Using compare methods</strong></p><p>Compare two strings in Java using the compareTo() and compareToIgnoreCase() methods. The compareTo() method is used to compare two strings lexicographically or in dictionary order. Each character is translated into a Unicode value for comparison. If both the strings are equal, it returns 0 otherwise it returns positive or negative values.</p><p>The compareTo() method returns a positive value if the first string is lexicographically greater than the second string and it returns a negative value if the first string is lexicographically lesser than the second string. The compareToIgnoreCase() method compares two strings lexicographically irrespective of their cases.</p><p>Let us see an example where compareTo() and compareToIgnoreCase() methods are used to compare two strings:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-hk6v9o13x" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">public class Example
{
&nbsp; public static void main(String args[])
&nbsp; {
&nbsp; &nbsp; &nbsp;String s1 = "Same string";
&nbsp; &nbsp; &nbsp;String s2 = "same string";
&nbsp; &nbsp; &nbsp;int a1= s1.compareTo(s2);
&nbsp; &nbsp; &nbsp;int a2=s1.compareToIgnoreCase(s2);
&nbsp; &nbsp; &nbsp;if(a1&lt;0)
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println("String s2 is greater");
&nbsp; &nbsp; &nbsp;else if(a1&gt;0)
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println("String s1 is greater");
&nbsp; &nbsp; &nbsp;else
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println("String s1 is equal to String s2");
&nbsp; &nbsp; if(a2==0)
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println("After Ignoring the case, s1 and s2 are equal");
&nbsp; &nbsp; &nbsp;else
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println("Even after ignoring the case, s1 and s2 are not equal");
&nbsp; }
}</pre></div></div><p><strong>The output is as follows:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-70l7e9iz2" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">$javac Example.java
$java Example
String s2 is greater
After Ignoring the case, s1 and s2 are equal</pre></div></div><p>Using equals() and equalsIgnoreCase()</p><p>The equals() method compares the string to a specific object. It returns a boolean value either true or false. It returns true when argument is not null and the string matches the characters of the object. The equalsIgnoreCase() does the same operation but does not take into account the case of the string and the sequence of characters of the object.</p><p>Let us see an example where equals() and equalsIgnoreCase() are used to compare two strings.</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-e3h78631z" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">public class Example
{
&nbsp; public static void main(String []args)
&nbsp; {
&nbsp; &nbsp; &nbsp;String s1 = "Same String";
&nbsp; &nbsp; &nbsp;String s2 = "same string";
&nbsp; &nbsp; &nbsp;System.out.println(s1.equals(s2));
&nbsp; &nbsp; &nbsp;System.out.println(s1.equalsIgnoreCase(s2));
&nbsp; }
}</pre></div></div><p><strong>The output is as follows:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-vhh8y2tx9" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">$javac Example.java
$java Example
false
true</pre></div></div><p><strong>Using the == operator</strong></p><p>We can use the == operator to compare two strings. This operator acts like the equals() method and returns a boolean value as the result.</p><p>Let us see the application of == operator for comparison of two strings:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-ow6ldusmh" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">public class Example
{
&nbsp; public static void main(String []args)
&nbsp; {
&nbsp; &nbsp; &nbsp;String s1 = "Same String";
&nbsp; &nbsp; &nbsp;String s2 = "same string";
&nbsp; &nbsp; &nbsp;String s3 = "Same String";
&nbsp; &nbsp; &nbsp;System.out.println(s1==s2);
&nbsp; &nbsp; &nbsp;System.out.println(s1==s3);
&nbsp; }
}</pre></div></div><p><strong>The output is as follows:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-2fwpebz8c" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">$javac Example.java
$java Example
false
true</pre></div></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">51. Overload main() method in Java</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>It is quite possible to overload the main() method in Java as it is not an extra-terrestrial method. The main() method is like any other method and can be overloaded too like other methods.</p><p>As public static void main(String [] args) serves as the method signature of the main method, JVM calls its first. public static void main(String [] args) acts as the entry point for the Java program.</p><p>We can overload the main method in Java. Since the program doesn’t execute the overloaded main method when the program executes, we need to call the overloaded main method from the actual main method which has the method signature.</p><p>Let us see an example of overloading of the main method in Java</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-7xom3zrjk" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">public class Example
{ &nbsp;&nbsp;
&nbsp; public static void main(String x)
&nbsp; {
&nbsp; &nbsp; &nbsp; System.out.println(x+" World");
&nbsp; }
&nbsp; public static void main(String a, int b)
&nbsp; {
&nbsp; &nbsp; &nbsp; System.out.println(a+","+b);
&nbsp; }
&nbsp; public static void main(String []args)
&nbsp; {
&nbsp; &nbsp; System.out.println("Hello from public static void main(String []args)!");
&nbsp; &nbsp; &nbsp;main("Hello");
&nbsp; &nbsp; &nbsp;main("Hello",2);
&nbsp; }
}</pre></div></div><p><strong>The output is as follows:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-xfyaelb73" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">$javac Example.java
$java -Xmx128M -Xms16M Example
Hello from public static void main(String []args)!
Hello World
Hello,2</pre></div></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">52. Compare Characters in Java</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p class="CertTheme__paragraph" data-mode="standard"><br></p><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><span>The Java provides compareTo() method to compare two characters.</span><br><span>Create characters:</span></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-cyfhi290m" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm"><span>Character c1 </span><span class="CertTheme__tokenOperator">=</span><span> </span><span class="CertTheme__tokenAttr">new</span><span> </span><span class="CertTheme__tokenFunction">Character</span><span class="CertTheme__tokenPunctuation">(</span><span class="CertTheme__tokenSelector">'s'</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">;</span><br><span>Character c2 </span><span class="CertTheme__tokenOperator">=</span><span> </span><span class="CertTheme__tokenAttr">new</span><span> </span><span class="CertTheme__tokenFunction">Character</span><span class="CertTheme__tokenPunctuation">(</span><span class="CertTheme__tokenSelector">'p'</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">;</span></pre></div></div><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><span>Now let us compare them:</span></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-m7ihb0d9d" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm"><span class="CertTheme__tokenAttr">public</span><span> </span><span class="CertTheme__tokenAttr">class</span><span> </span><span class="CertTheme__tokenFunction">Example</span><span> </span><span class="CertTheme__tokenPunctuation">{</span><br><span>&nbsp; &nbsp; </span><span class="CertTheme__tokenAttr">public</span><span> </span><span class="CertTheme__tokenAttr">static</span><span> </span><span class="CertTheme__tokenAttr">void</span><span> </span><span class="CertTheme__tokenFunction">main</span><span class="CertTheme__tokenPunctuation">(</span><span>String </span><span class="CertTheme__tokenPunctuation">[</span><span class="CertTheme__tokenPunctuation">]</span><span>args</span><span class="CertTheme__tokenPunctuation">)</span><span> </span><span class="CertTheme__tokenPunctuation">{</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp;Character c1 </span><span class="CertTheme__tokenOperator">=</span><span> </span><span class="CertTheme__tokenAttr">new</span><span> </span><span class="CertTheme__tokenFunction">Character</span><span class="CertTheme__tokenPunctuation">(</span><span class="CertTheme__tokenSelector">'s'</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">;</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp;Character c2 </span><span class="CertTheme__tokenOperator">=</span><span> </span><span class="CertTheme__tokenAttr">new</span><span> </span><span class="CertTheme__tokenFunction">Character</span><span class="CertTheme__tokenPunctuation">(</span><span class="CertTheme__tokenSelector">'p'</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">;</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp;</span><span class="CertTheme__tokenAttr">if</span><span> </span><span class="CertTheme__tokenPunctuation">(</span><span class="CertTheme__tokenPunctuation">(</span><span>c1</span><span class="CertTheme__tokenPunctuation">.</span><span class="CertTheme__tokenFunction">compareTo</span><span class="CertTheme__tokenPunctuation">(</span><span>c2</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">)</span><span> </span><span class="CertTheme__tokenOperator">==</span><span> </span><span class="CertTheme__tokenProperty">0</span><span class="CertTheme__tokenPunctuation">)</span><span> </span><span class="CertTheme__tokenPunctuation">{</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;System</span><span class="CertTheme__tokenPunctuation">.</span><span>out</span><span class="CertTheme__tokenPunctuation">.</span><span class="CertTheme__tokenFunction">println</span><span class="CertTheme__tokenPunctuation">(</span><span class="CertTheme__tokenSelector">"Equal!"</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">;</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp;</span><span class="CertTheme__tokenPunctuation">}</span><span> </span><span class="CertTheme__tokenAttr">else</span><span> </span><span class="CertTheme__tokenAttr">if</span><span> </span><span class="CertTheme__tokenPunctuation">(</span><span class="CertTheme__tokenPunctuation">(</span><span>c1</span><span class="CertTheme__tokenPunctuation">.</span><span class="CertTheme__tokenFunction">compareTo</span><span class="CertTheme__tokenPunctuation">(</span><span>c2</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">)</span><span> </span><span class="CertTheme__tokenOperator">&lt;</span><span> </span><span class="CertTheme__tokenProperty">0</span><span class="CertTheme__tokenPunctuation">)</span><span> </span><span class="CertTheme__tokenPunctuation">{</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;System</span><span class="CertTheme__tokenPunctuation">.</span><span>out</span><span class="CertTheme__tokenPunctuation">.</span><span class="CertTheme__tokenFunction">println</span><span class="CertTheme__tokenPunctuation">(</span><span class="CertTheme__tokenSelector">"c1 is less than c2"</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">;</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp;</span><span class="CertTheme__tokenPunctuation">}</span><span> </span><span class="CertTheme__tokenAttr">else</span><span> </span><span class="CertTheme__tokenAttr">if</span><span> </span><span class="CertTheme__tokenPunctuation">(</span><span class="CertTheme__tokenPunctuation">(</span><span>c1</span><span class="CertTheme__tokenPunctuation">.</span><span class="CertTheme__tokenFunction">compareTo</span><span class="CertTheme__tokenPunctuation">(</span><span>c2</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">)</span><span> </span><span class="CertTheme__tokenOperator">&gt;</span><span> </span><span class="CertTheme__tokenProperty">0</span><span class="CertTheme__tokenPunctuation">)</span><span> </span><span class="CertTheme__tokenPunctuation">{</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;System</span><span class="CertTheme__tokenPunctuation">.</span><span>out</span><span class="CertTheme__tokenPunctuation">.</span><span class="CertTheme__tokenFunction">println</span><span class="CertTheme__tokenPunctuation">(</span><span class="CertTheme__tokenSelector">"c1 is less than c2"</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">;</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp;</span><span class="CertTheme__tokenPunctuation">}</span><br><span>&nbsp; &nbsp; </span><span class="CertTheme__tokenPunctuation">}</span><br><span class="CertTheme__tokenPunctuation">}</span></pre></div></div><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><b><strong class="CertTheme__textBold">The output:</strong></b></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-n33h47nns" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm"><span>c1 is less than c2</span></pre></div></div><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><br></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">53. How to set JDK path in Java</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p>Go to “Start” and type “Environment Variables”. Then you will reach a window “”.</p><p><img alt="System Properties" loading="lazy" width="100" height="100" decoding="async"  class="fr-fic fr-dib" style="color:transparent;width:100%;height:auto;background-size:cover;background-position:50% 50%;background-repeat:no-repeat;background-image:url(&quot;data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http%3A//www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cfilter id='b' color-interpolation-filters='sRGB'%3E%3CfeGaussianBlur stdDeviation='20'/%3E%3C/filter%3E%3Cimage preserveAspectRatio='none' filter='url(%23b)' x='0' y='0' height='100%25' width='100%25' href='data:image/svg+xml;base64,CiAgPHN2ZyB3aWR0aD0iMTAwIiBoZWlnaHQ9IjEwMCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIj4KICAgIDxkZWZzPgogICAgICA8bGluZWFyR3JhZGllbnQgaWQ9ImciPgogICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNjY2MiIG9mZnNldD0iMjAlIiAvPgogICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNkZGQiIG9mZnNldD0iNTAlIiAvPgogICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNlZWUiIG9mZnNldD0iNzAlIiAvPgogICAgICA8L2xpbmVhckdyYWRpZW50PgogICAgPC9kZWZzPgogICAgPHJlY3Qgd2lkdGg9IjEwMCIgaGVpZ2h0PSIxMDAiIGZpbGw9IiNlZWUiIC8+CiAgICA8cmVjdCBpZD0iciIgd2lkdGg9IjEwMCIgaGVpZ2h0PSIxMDAiIGZpbGw9InVybCgjZykiIC8+CiAgICA8YW5pbWF0ZSB4bGluazpocmVmPSIjciIgYXR0cmlidXRlTmFtZT0ieCIgZnJvbT0iLTEwMCIgdG89IjEwMCIgZHVyPSIxcyIgcmVwZWF0Q291bnQ9ImluZGVmaW5pdGUiICAvPgogIDwvc3ZnPg=='/%3E%3C/svg%3E&quot;)" sizes="(min-width: 767px) 50vw, 100vw" srcSet="" src="https://images.unsplash.com/photo-1478104724775-8bd31ff3e44b?ixlib=rb-4.0.3&auto=format&fit=crop&w=1000&q=80">System Properties</p><p>Now, click on “Environment Variables”:</p><p><img alt="Environment Variables" loading="lazy" width="100" height="100" decoding="async"  class="fr-fic fr-dib" style="color:transparent;width:100%;height:auto;background-size:cover;background-position:50% 50%;background-repeat:no-repeat;background-image:url(&quot;data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http%3A//www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cfilter id='b' color-interpolation-filters='sRGB'%3E%3CfeGaussianBlur stdDeviation='20'/%3E%3C/filter%3E%3Cimage preserveAspectRatio='none' filter='url(%23b)' x='0' y='0' height='100%25' width='100%25' href='data:image/svg+xml;base64,CiAgPHN2ZyB3aWR0aD0iMTAwIiBoZWlnaHQ9IjEwMCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIj4KICAgIDxkZWZzPgogICAgICA8bGluZWFyR3JhZGllbnQgaWQ9ImciPgogICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNjY2MiIG9mZnNldD0iMjAlIiAvPgogICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNkZGQiIG9mZnNldD0iNTAlIiAvPgogICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNlZWUiIG9mZnNldD0iNzAlIiAvPgogICAgICA8L2xpbmVhckdyYWRpZW50PgogICAgPC9kZWZzPgogICAgPHJlY3Qgd2lkdGg9IjEwMCIgaGVpZ2h0PSIxMDAiIGZpbGw9IiNlZWUiIC8+CiAgICA8cmVjdCBpZD0iciIgd2lkdGg9IjEwMCIgaGVpZ2h0PSIxMDAiIGZpbGw9InVybCgjZykiIC8+CiAgICA8YW5pbWF0ZSB4bGluazpocmVmPSIjciIgYXR0cmlidXRlTmFtZT0ieCIgZnJvbT0iLTEwMCIgdG89IjEwMCIgZHVyPSIxcyIgcmVwZWF0Q291bnQ9ImluZGVmaW5pdGUiICAvPgogIDwvc3ZnPg=='/%3E%3C/svg%3E&quot;)" sizes="(min-width: 767px) 50vw, 100vw" srcSet="" src="https://images.unsplash.com/photo-1515169061895-37fbb16acd37?ixlib=rb-4.0.3&auto=format&fit=crop&w=1000&q=80"></p><p>Now click on “Path” in the user variables drop down list.</p><p><img alt="Environment Variable" loading="lazy" width="100" height="100" decoding="async"  class="fr-fic fr-dib" style="color:transparent;width:100%;height:auto;background-size:cover;background-position:50% 50%;background-repeat:no-repeat;background-image:url(&quot;data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http%3A//www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cfilter id='b' color-interpolation-filters='sRGB'%3E%3CfeGaussianBlur stdDeviation='20'/%3E%3C/filter%3E%3Cimage preserveAspectRatio='none' filter='url(%23b)' x='0' y='0' height='100%25' width='100%25' href='data:image/svg+xml;base64,CiAgPHN2ZyB3aWR0aD0iMTAwIiBoZWlnaHQ9IjEwMCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIj4KICAgIDxkZWZzPgogICAgICA8bGluZWFyR3JhZGllbnQgaWQ9ImciPgogICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNjY2MiIG9mZnNldD0iMjAlIiAvPgogICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNkZGQiIG9mZnNldD0iNTAlIiAvPgogICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNlZWUiIG9mZnNldD0iNzAlIiAvPgogICAgICA8L2xpbmVhckdyYWRpZW50PgogICAgPC9kZWZzPgogICAgPHJlY3Qgd2lkdGg9IjEwMCIgaGVpZ2h0PSIxMDAiIGZpbGw9IiNlZWUiIC8+CiAgICA8cmVjdCBpZD0iciIgd2lkdGg9IjEwMCIgaGVpZ2h0PSIxMDAiIGZpbGw9InVybCgjZykiIC8+CiAgICA8YW5pbWF0ZSB4bGluazpocmVmPSIjciIgYXR0cmlidXRlTmFtZT0ieCIgZnJvbT0iLTEwMCIgdG89IjEwMCIgZHVyPSIxcyIgcmVwZWF0Q291bnQ9ImluZGVmaW5pdGUiICAvPgogIDwvc3ZnPg=='/%3E%3C/svg%3E&quot;)" sizes="(min-width: 767px) 50vw, 100vw" srcSet="" src="https://images.unsplash.com/photo-1523961131990-521072f1616c?ixlib=rb-4.0.3&auto=format&fit=crop&w=1000&q=80"></p><p>Click on “New” and enter the following path. We are setting path here for Java 11:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-edaz18508" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">C:\Program Files\Java\jdk-11.0.1\bin</pre></div></div><p><img alt="Environment Variable" loading="lazy" width="100" height="100" decoding="async"  class="fr-fic fr-dib" style="color:transparent;width:100%;height:auto;background-size:cover;background-position:50% 50%;background-repeat:no-repeat;background-image:url(&quot;data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http%3A//www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cfilter id='b' color-interpolation-filters='sRGB'%3E%3CfeGaussianBlur stdDeviation='20'/%3E%3C/filter%3E%3Cimage preserveAspectRatio='none' filter='url(%23b)' x='0' y='0' height='100%25' width='100%25' href='data:image/svg+xml;base64,CiAgPHN2ZyB3aWR0aD0iMTAwIiBoZWlnaHQ9IjEwMCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIj4KICAgIDxkZWZzPgogICAgICA8bGluZWFyR3JhZGllbnQgaWQ9ImciPgogICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNjY2MiIG9mZnNldD0iMjAlIiAvPgogICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNkZGQiIG9mZnNldD0iNTAlIiAvPgogICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNlZWUiIG9mZnNldD0iNzAlIiAvPgogICAgICA8L2xpbmVhckdyYWRpZW50PgogICAgPC9kZWZzPgogICAgPHJlY3Qgd2lkdGg9IjEwMCIgaGVpZ2h0PSIxMDAiIGZpbGw9IiNlZWUiIC8+CiAgICA8cmVjdCBpZD0iciIgd2lkdGg9IjEwMCIgaGVpZ2h0PSIxMDAiIGZpbGw9InVybCgjZykiIC8+CiAgICA8YW5pbWF0ZSB4bGluazpocmVmPSIjciIgYXR0cmlidXRlTmFtZT0ieCIgZnJvbT0iLTEwMCIgdG89IjEwMCIgZHVyPSIxcyIgcmVwZWF0Q291bnQ9ImluZGVmaW5pdGUiICAvPgogIDwvc3ZnPg=='/%3E%3C/svg%3E&quot;)" sizes="(min-width: 767px) 50vw, 100vw" srcSet="" src="https://images.unsplash.com/photo-1523961131990-521072f1616c?ixlib=rb-4.0.3&auto=format&fit=crop&w=1000&q=80"></p><p>After adding the path above, click “OK”.</p><p><img alt="Environment Variable" loading="lazy" width="100" height="100" decoding="async"  class="fr-fic fr-dib" style="color:transparent;width:100%;height:auto;background-size:cover;background-position:50% 50%;background-repeat:no-repeat;background-image:url(&quot;data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http%3A//www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cfilter id='b' color-interpolation-filters='sRGB'%3E%3CfeGaussianBlur stdDeviation='20'/%3E%3C/filter%3E%3Cimage preserveAspectRatio='none' filter='url(%23b)' x='0' y='0' height='100%25' width='100%25' href='data:image/svg+xml;base64,CiAgPHN2ZyB3aWR0aD0iMTAwIiBoZWlnaHQ9IjEwMCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIj4KICAgIDxkZWZzPgogICAgICA8bGluZWFyR3JhZGllbnQgaWQ9ImciPgogICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNjY2MiIG9mZnNldD0iMjAlIiAvPgogICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNkZGQiIG9mZnNldD0iNTAlIiAvPgogICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNlZWUiIG9mZnNldD0iNzAlIiAvPgogICAgICA8L2xpbmVhckdyYWRpZW50PgogICAgPC9kZWZzPgogICAgPHJlY3Qgd2lkdGg9IjEwMCIgaGVpZ2h0PSIxMDAiIGZpbGw9IiNlZWUiIC8+CiAgICA8cmVjdCBpZD0iciIgd2lkdGg9IjEwMCIgaGVpZ2h0PSIxMDAiIGZpbGw9InVybCgjZykiIC8+CiAgICA8YW5pbWF0ZSB4bGluazpocmVmPSIjciIgYXR0cmlidXRlTmFtZT0ieCIgZnJvbT0iLTEwMCIgdG89IjEwMCIgZHVyPSIxcyIgcmVwZWF0Q291bnQ9ImluZGVmaW5pdGUiICAvPgogIDwvc3ZnPg=='/%3E%3C/svg%3E&quot;)" sizes="(min-width: 767px) 50vw, 100vw" srcSet="" src="https://images.unsplash.com/photo-1523961131990-521072f1616c?ixlib=rb-4.0.3&auto=format&fit=crop&w=1000&q=80"></p><p>Click “OK” again.</p><p><img alt="System Properties" loading="lazy" width="100" height="100" decoding="async"  class="fr-fic fr-dib" style="color:transparent;width:100%;height:auto;background-size:cover;background-position:50% 50%;background-repeat:no-repeat;background-image:url(&quot;data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http%3A//www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cfilter id='b' color-interpolation-filters='sRGB'%3E%3CfeGaussianBlur stdDeviation='20'/%3E%3C/filter%3E%3Cimage preserveAspectRatio='none' filter='url(%23b)' x='0' y='0' height='100%25' width='100%25' href='data:image/svg+xml;base64,CiAgPHN2ZyB3aWR0aD0iMTAwIiBoZWlnaHQ9IjEwMCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIj4KICAgIDxkZWZzPgogICAgICA8bGluZWFyR3JhZGllbnQgaWQ9ImciPgogICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNjY2MiIG9mZnNldD0iMjAlIiAvPgogICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNkZGQiIG9mZnNldD0iNTAlIiAvPgogICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNlZWUiIG9mZnNldD0iNzAlIiAvPgogICAgICA8L2xpbmVhckdyYWRpZW50PgogICAgPC9kZWZzPgogICAgPHJlY3Qgd2lkdGg9IjEwMCIgaGVpZ2h0PSIxMDAiIGZpbGw9IiNlZWUiIC8+CiAgICA8cmVjdCBpZD0iciIgd2lkdGg9IjEwMCIgaGVpZ2h0PSIxMDAiIGZpbGw9InVybCgjZykiIC8+CiAgICA8YW5pbWF0ZSB4bGluazpocmVmPSIjciIgYXR0cmlidXRlTmFtZT0ieCIgZnJvbT0iLTEwMCIgdG89IjEwMCIgZHVyPSIxcyIgcmVwZWF0Q291bnQ9ImluZGVmaW5pdGUiICAvPgogIDwvc3ZnPg=='/%3E%3C/svg%3E&quot;)" sizes="(min-width: 767px) 50vw, 100vw" srcSet="" src="https://images.unsplash.com/photo-1478104724775-8bd31ff3e44b?ixlib=rb-4.0.3&auto=format&fit=crop&w=1000&q=80"></p><p>Click “OK”.<br>You have successfully set the JDK Path.</p><p>For verification, go to command prompt (cmd) and type:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-0sp7b2teg" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">java -version</pre></div></div><p><img alt="Command prompt" loading="lazy" width="100" height="100" decoding="async"  class="fr-fic fr-dib" style="color:transparent;width:100%;height:auto;background-size:cover;background-position:50% 50%;background-repeat:no-repeat;background-image:url(&quot;data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http%3A//www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cfilter id='b' color-interpolation-filters='sRGB'%3E%3CfeGaussianBlur stdDeviation='20'/%3E%3C/filter%3E%3Cimage preserveAspectRatio='none' filter='url(%23b)' x='0' y='0' height='100%25' width='100%25' href='data:image/svg+xml;base64,CiAgPHN2ZyB3aWR0aD0iMTAwIiBoZWlnaHQ9IjEwMCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIj4KICAgIDxkZWZzPgogICAgICA8bGluZWFyR3JhZGllbnQgaWQ9ImciPgogICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNjY2MiIG9mZnNldD0iMjAlIiAvPgogICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNkZGQiIG9mZnNldD0iNTAlIiAvPgogICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNlZWUiIG9mZnNldD0iNzAlIiAvPgogICAgICA8L2xpbmVhckdyYWRpZW50PgogICAgPC9kZWZzPgogICAgPHJlY3Qgd2lkdGg9IjEwMCIgaGVpZ2h0PSIxMDAiIGZpbGw9IiNlZWUiIC8+CiAgICA8cmVjdCBpZD0iciIgd2lkdGg9IjEwMCIgaGVpZ2h0PSIxMDAiIGZpbGw9InVybCgjZykiIC8+CiAgICA8YW5pbWF0ZSB4bGluazpocmVmPSIjciIgYXR0cmlidXRlTmFtZT0ieCIgZnJvbT0iLTEwMCIgdG89IjEwMCIgZHVyPSIxcyIgcmVwZWF0Q291bnQ9ImluZGVmaW5pdGUiICAvPgogIDwvc3ZnPg=='/%3E%3C/svg%3E&quot;)" sizes="(min-width: 767px) 50vw, 100vw" srcSet="" src="https://images.unsplash.com/photo-1614064000300-47b2c5dc44bd?ixlib=rb-4.0.3&auto=format&fit=crop&w=1000&q=80"></p><p>The above shows that we have successfully set the path.</p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">54. Benefit of Generics in Collections Framework?</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p>Generics were introduced to deal with type-safe objects in J2SE 5. Only specific types of objects can be stored in Collections as forced by Generics.</p><p>Some of the benefits of Generics in Java are given as follows:</p><p><strong>Elimination of type casting</strong><strong><br></strong></p><p>Type casting is not required after the advent of generics. An example that demonstrates this is as follows:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-q90w50h9h" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">Before generics type casting was required.
List l = new ArrayList(); &nbsp;
l.add("apple"); &nbsp;
String str = (String) list.get(0); &nbsp; &nbsp; // type casting &nbsp;
After generics type casting was no longer needed.
List&lt;String&gt; l = new ArrayList&lt;String&gt;(); &nbsp;
list.add("apple"); &nbsp;
String str = list.get(0); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// no type casting</pre></div></div><p><strong>Checking at compile time</strong><strong><br></strong></p><p>Compile time checking is provided so that there is no problem at run time as it is much better to handle a problem at compile time than at run time. An example that demonstrates this is as follows:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-ekhz8tem7" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">List&lt;String&gt; l = new ArrayList&lt;String&gt;(); &nbsp;
l.add("apple"); &nbsp;
l.add("mango"); &nbsp;
l.add(98); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// This will lead to a Compile Time Error</pre></div></div><p><strong>Type-Safety</strong><strong><br></strong></p><p>Generics result in type safety as only a single type of object can be held in them. This means that other types of objects are not allowed.</p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">55. What is a Nested Top-level class in Java</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>Nested classes in Java is declared inside a class or interface. Non-static nested classes are known as inner class in Java as there are two types of nested classes i.e. static and non-static.</p><p>A program that demonstrates an inner class in Java is given as follows:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-72582sx0p" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">class Outer
{
&nbsp; class Inner
&nbsp; {
&nbsp; &nbsp; &nbsp;public void display()
&nbsp; &nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; System.out.println("Inside the inner class method");
&nbsp; &nbsp; &nbsp;}
&nbsp; }
}
public class Main
{
&nbsp; public static void main(String[] args)
&nbsp; {
&nbsp; &nbsp; &nbsp; Outer.Inner obj = new Outer().new Inner();
&nbsp; &nbsp; &nbsp; obj.display();
&nbsp; }
}</pre></div></div><p>The output of the above program is as follows:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-1wzrpvflo" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">Inside the inner class method</pre></div></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">56. Role of ClassLoader in Java</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>The Java Class is stored in the form of byte code in a .class file after it is compiled. The ClassLoader loads the Class of the Java program into memory when it is required.</p><p>The ClassLoader is hierarchical and so if there is a request to load a class, it is delegated to the parent class loader. The uniqueness in the Java Runtime Environment is maintained using this method. &nbsp;&nbsp;</p><p>The types of build-in ClassLoader in Java are given as follows:</p><ol class="CertTheme__ol1 pt-spacing10"><li class="CertTheme__listItem pt-spacing10">Bootstrap Class Loader</li><li class="CertTheme__listItem pt-spacing10">Extensions Class Loader</li><li class="CertTheme__listItem pt-spacing10">System Class Loader</li></ol><p>A program that demonstrates ClassLoader in Java is given as follows:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-kia4pb5cp" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">public class Demo {
public static void main(String[] args) {
&nbsp; &nbsp;System.out.println("class loader for this class: " + Demo.class.getClassLoader());
&nbsp; &nbsp;System.out.println("class loader for DNSNameService: " + sun.net.spi.nameservice.dns.DNSNameService.class.getClassLoader());
&nbsp; System.out.println("class loader for HashMap: " +
&nbsp; java.util.HashMap.class.getClassLoader());
}
}</pre></div></div><p>The output of the above program is as follows:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-ogvs1ts53" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">class loader for this class: sun.misc.Launcher$AppClassLoader@4e0e2f2a
class loader for DNSNameService: sun.misc.Launcher$ExtClassLoader@5c647e05
class loader for HashMap: null</pre></div></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">57. When a class file gets created in Java?</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p>The Java class file has a .class extension and contains the Java bytecode. This class file can be executed by the Java Virtual Machine.</p><p>The Java class file is created as a result of successful compilation by the Java compiler from the .java file. Each class in the .java file is compiled into a separate class file if the .java file has more than one class.</p><p>A program that demonstrates the creation of a class file in Java is given as follows:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-3zjlnfh3u" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">class A
{
&nbsp;A()
&nbsp;{
&nbsp; &nbsp;System.out.println("This is class A");
&nbsp;}
}
class B
{
&nbsp;B()
&nbsp;{
&nbsp; &nbsp;System.out.println("This is class B");
&nbsp;}
}
public class Demo
{
&nbsp;public static void main(String[] args)
&nbsp;{
&nbsp; &nbsp;A obj1 = new A();
&nbsp; &nbsp;B obj2 = new B();
&nbsp;}
}</pre></div></div><p>The output of the above program is as follows:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-g5clixwc3" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">This is class A
This is class B</pre></div></div><p>After the above program is compiled successfully, there are 3 class files created in the corresponding folder as there are 3 classes in the .java file. These class files are A.class, B.class and Demo.class.</p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">58. Determine day of week for a given date in Java</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>The Calendar.DAY_OF_WEEK constant is used in Java to get the day number of week.</p><p>The example displays the same:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-s0dli8vgn" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">import java.util.Calendar;
public class Example {
&nbsp;public static void main(String[] args) {
&nbsp; &nbsp;Calendar c = Calendar.getInstance();
&nbsp; &nbsp;System.out.println(c.getTime().toString());
&nbsp; &nbsp;System.out.println("Day = " + c.get(Calendar.DAY_OF_WEEK));
&nbsp;}
}</pre></div></div><p>The example displays the day number of the week:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-h1femi39h" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">Sun Dec 16 21:32:34 UTC 2018
Day = 1</pre></div></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">59. Reverse an Integer in Java</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p>Reversing an integer involves reversing all of its digits. An example of this is given as follows:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-lydgc6i6x" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">Integer = 123
Reverse of the integer = 321</pre></div></div><p>A program that demonstrates reversing an integer in Java is given as follows:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-wxtjrcjq3" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">public class Demo
{
&nbsp; public static void main(String args[])
&nbsp; {
&nbsp; &nbsp; &nbsp;int num = 2413, rev = 0;
&nbsp; &nbsp; &nbsp;System.out.println("The number is " + num);
&nbsp; &nbsp; &nbsp;while(num != 0)
&nbsp; &nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;rev = rev * 10;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;rev = rev + num % 10;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;num = num / 10;
&nbsp; &nbsp; &nbsp;}
&nbsp; &nbsp; &nbsp;System.out.println("Reverse of the above number is " + rev);
&nbsp; }
}</pre></div></div><p><strong>The output of the above program is as follows:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-2dhfu2k9y" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">The number is 2413
Reverse of the above number is 3142</pre></div></div><p>In the above program, the number 2413 is reversed using a while loop and the result is stored in rev which is then displayed.</p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">60. Heap vs Stack Memory in Java</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>Details about the heap space and stack memory in Java as well as their differences is given as follows:</p><h4><span style="color:rgb(0, 0, 0)">Heap Space in Java</span></h4><p>The heap space in Java is allocated the memory to the Objects and the JRE classes by the Java runtime. All the objects in the application are created in the heap space. The objects in the heap space are globally accessible from any place in the application and so they have a lifetime for the whole application execution.</p><p>The memory model of the heap space is divided into parts known as generations. The three generations are young generation, old generation and permanent generation.</p><h4><span style="color:rgb(0, 0, 0)">Stack Memory in Java</span></h4><p>The Stack memory in Java is used for thread execution. Specific values are stored in the stack memory that are available for a short time. Also, stack memory may contain data references to objects getting referred from the method that are in the heap memory.</p><p>The order in Stack memory is Last In First Out (LIFO). A block is created in the stack memory for all the primitive values and references to other objects in a method when that method is invoked. After the end of the method, the memory block in the stack memory is free and can be used by another method.</p><h4><span style="color:rgb(0, 0, 0)">Differences between Heap Space and Stack Memory</span></h4><p>Some of the differences between stack memory and heap memory are given as follows:</p><ol class="CertTheme__ol1 pt-spacing10"><li class="CertTheme__listItem pt-spacing10">The stack memory management is done using LIFO but it is more complicated for heap memory as that is used by the whole application.</li><li class="CertTheme__listItem pt-spacing10">Stack memory is faster than heap memory as its memory allocation procedure is much more simple.</li><li class="CertTheme__listItem pt-spacing10">The stack memory is only used by a thread whereas the heap memory is required by all the application parts.</li><li class="CertTheme__listItem pt-spacing10">The stack memory is only accessible by the individual thread but the heap memory objects can be accessed globally.</li><li class="CertTheme__listItem pt-spacing10">The stack memory is comparatively short lived while the heap memory exists for the whole execution of the application.</li></ol><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">61. Check for Overflow in Java</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>When a value is assigned to a variable that is more than the maximum allowed value for that variable, then overflow occurs. There is no exception thrown by the JVM if an overflow occurs and it is the responsibility of the programmer to handle the overflow condition.</p><p>A program that checks for overflow in Java is given as follows:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-2jk57tdgy" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">public class Demo
{
&nbsp; public static void main(String[] args)
&nbsp; {
&nbsp; &nbsp; &nbsp;int num1 = 2147483647;
&nbsp; &nbsp; &nbsp;int num2 = 1;
&nbsp; &nbsp; &nbsp;System.out.println("Number 1: " + num1);
&nbsp; &nbsp; &nbsp;System.out.println("Number 2: " + num2);
&nbsp; &nbsp; &nbsp;long sum = (long)num1 + (long)num2;
&nbsp; &nbsp; &nbsp;if (sum &gt; Integer.MAX_VALUE)
&nbsp; &nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp; throw new ArithmeticException("Overflow occurred!");
&nbsp; &nbsp; &nbsp;}
&nbsp; &nbsp; &nbsp;System.out.println("The sum of two numbers is: " + (int)sum);
&nbsp; }
}</pre></div></div><p><strong>The output of the above program is as follows:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-58nsegtm6" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">Number 1: 2147483647
Number 2: 1
Exception in thread "main" java.lang.ArithmeticException: Overflow occurred!
at Demo.main(Demo.java:14)</pre></div></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">62. Can the overloaded method be overridden in Java?</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p>Yes, we can override the overloaded method in Java.</p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">63. Compare two Java arrays</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>Two arrays in Java are said to be equal if they have the same number of elements and all the corresponding elements are also the same. So, the two arrays can be compared in Java by using the Arrays.equals() method.</p><p>A program that demonstrates this method is given as follows:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-0wq5vjc13" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">import java.util.Arrays;
public class Demo
{
&nbsp; &nbsp;public static void main (String[] args) &nbsp;
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;int arr1[] = {5, 2, 9, 7, 1};
&nbsp; &nbsp; &nbsp; &nbsp;int arr2[] = {5, 2, 9, 7, 1};
&nbsp; &nbsp; &nbsp; &nbsp;int i;
&nbsp; &nbsp; &nbsp; &nbsp;System.out.print("Array 1: ");
&nbsp; &nbsp; &nbsp; &nbsp;for (i=0; i&lt;5; i++)
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;System.out.print(arr1[i] + " ");
&nbsp; &nbsp; &nbsp; &nbsp;System.out.print("\nArray 2: ");
&nbsp; &nbsp; &nbsp; &nbsp;for (i=0; i&lt;5; i++)
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;System.out.print(arr2[i] + " ");
&nbsp; &nbsp; &nbsp; &nbsp;if (Arrays.equals(arr1, arr2))
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;System.out.println("\nThe above two arrays are the same");
&nbsp; &nbsp; &nbsp; &nbsp;else
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;System.out.println("\nThe above two arrays are not the same");
&nbsp; &nbsp;}
}</pre></div></div><p><strong>The output of the above program is as follows:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-qjpsbm4s6" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">Array 1: 5 2 9 7 1
Array 2: 5 2 9 7 1
The above two arrays are the same</pre></div></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">64. Compare two dates in Java</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p class="CertTheme__paragraph" data-mode="standard"><br></p><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><span>Two dates in Java can be compared using the compareTo() method. The syntax for this is given as follows:</span></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-ehhynvcub" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm"><span>date1</span><span class="CertTheme__tokenPunctuation">.</span><span class="CertTheme__tokenFunction">compareTo</span><span class="CertTheme__tokenPunctuation">(</span><span>date2</span><span class="CertTheme__tokenPunctuation">)</span></pre></div></div><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><span>This method returns 0 if both the dates are equal, it returns a value greater than 0 if date1 is after date2 and it returns a value less than 0 if date1 is before date2.</span></p><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><span>A program that compares two dates in Java is given as follows:</span></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-9u6u1woh8" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm"><span class="CertTheme__tokenAttr">import</span><span> java</span><span class="CertTheme__tokenPunctuation">.</span><span>text</span><span class="CertTheme__tokenPunctuation">.</span><span>ParseException</span><span class="CertTheme__tokenPunctuation">;</span><br><span class="CertTheme__tokenAttr">import</span><span> java</span><span class="CertTheme__tokenPunctuation">.</span><span>text</span><span class="CertTheme__tokenPunctuation">.</span><span>SimpleDateFormat</span><span class="CertTheme__tokenPunctuation">;</span><br><span class="CertTheme__tokenAttr">import</span><span> java</span><span class="CertTheme__tokenPunctuation">.</span><span>util</span><span class="CertTheme__tokenPunctuation">.</span><span>Date</span><span class="CertTheme__tokenPunctuation">;</span><br><span class="CertTheme__tokenAttr">public</span><span> </span><span class="CertTheme__tokenAttr">class</span><span> </span><span class="CertTheme__tokenFunction">Demo</span><br><span class="CertTheme__tokenPunctuation">{</span><br><span>&nbsp; &nbsp;</span><span class="CertTheme__tokenAttr">public</span><span> </span><span class="CertTheme__tokenAttr">static</span><span> </span><span class="CertTheme__tokenAttr">void</span><span> </span><span class="CertTheme__tokenFunction">main</span><span class="CertTheme__tokenPunctuation">(</span><span>String</span><span class="CertTheme__tokenPunctuation">[</span><span class="CertTheme__tokenPunctuation">]</span><span> args</span><span class="CertTheme__tokenPunctuation">)</span><span> throws ParseException</span><br><span>&nbsp; &nbsp;</span><span class="CertTheme__tokenPunctuation">{</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp;SimpleDateFormat dformat </span><span class="CertTheme__tokenOperator">=</span><span> </span><span class="CertTheme__tokenAttr">new</span><span> </span><span class="CertTheme__tokenFunction">SimpleDateFormat</span><span class="CertTheme__tokenPunctuation">(</span><span class="CertTheme__tokenSelector">"yyyy-MM-dd"</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">;</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp;Date d1 </span><span class="CertTheme__tokenOperator">=</span><span> dformat</span><span class="CertTheme__tokenPunctuation">.</span><span class="CertTheme__tokenFunction">parse</span><span class="CertTheme__tokenPunctuation">(</span><span class="CertTheme__tokenSelector">"2018-12-05"</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">;</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp;Date d2 </span><span class="CertTheme__tokenOperator">=</span><span> dformat</span><span class="CertTheme__tokenPunctuation">.</span><span class="CertTheme__tokenFunction">parse</span><span class="CertTheme__tokenPunctuation">(</span><span class="CertTheme__tokenSelector">"2018-08-07"</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">;</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp;System</span><span class="CertTheme__tokenPunctuation">.</span><span>out</span><span class="CertTheme__tokenPunctuation">.</span><span class="CertTheme__tokenFunction">println</span><span class="CertTheme__tokenPunctuation">(</span><span class="CertTheme__tokenSelector">"The date 1 is: "</span><span> </span><span class="CertTheme__tokenOperator">+</span><span> dformat</span><span class="CertTheme__tokenPunctuation">.</span><span class="CertTheme__tokenFunction">format</span><span class="CertTheme__tokenPunctuation">(</span><span>d1</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">;</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp;System</span><span class="CertTheme__tokenPunctuation">.</span><span>out</span><span class="CertTheme__tokenPunctuation">.</span><span class="CertTheme__tokenFunction">println</span><span class="CertTheme__tokenPunctuation">(</span><span class="CertTheme__tokenSelector">"The date 2 is: "</span><span> </span><span class="CertTheme__tokenOperator">+</span><span> dformat</span><span class="CertTheme__tokenPunctuation">.</span><span class="CertTheme__tokenFunction">format</span><span class="CertTheme__tokenPunctuation">(</span><span>d2</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">;</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp;</span><span class="CertTheme__tokenAttr">if</span><span> </span><span class="CertTheme__tokenPunctuation">(</span><span>d1</span><span class="CertTheme__tokenPunctuation">.</span><span class="CertTheme__tokenFunction">compareTo</span><span class="CertTheme__tokenPunctuation">(</span><span>d2</span><span class="CertTheme__tokenPunctuation">)</span><span> </span><span class="CertTheme__tokenOperator">&gt;</span><span> </span><span class="CertTheme__tokenProperty">0</span><span class="CertTheme__tokenPunctuation">)</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp;</span><span class="CertTheme__tokenPunctuation">{</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;System</span><span class="CertTheme__tokenPunctuation">.</span><span>out</span><span class="CertTheme__tokenPunctuation">.</span><span class="CertTheme__tokenFunction">println</span><span class="CertTheme__tokenPunctuation">(</span><span class="CertTheme__tokenSelector">"Date 1 occurs after Date 2"</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">;</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp;</span><span class="CertTheme__tokenPunctuation">}</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp;</span><span class="CertTheme__tokenAttr">else</span><span> </span><span class="CertTheme__tokenAttr">if</span><span> </span><span class="CertTheme__tokenPunctuation">(</span><span>d1</span><span class="CertTheme__tokenPunctuation">.</span><span class="CertTheme__tokenFunction">compareTo</span><span class="CertTheme__tokenPunctuation">(</span><span>d2</span><span class="CertTheme__tokenPunctuation">)</span><span> </span><span class="CertTheme__tokenOperator">&lt;</span><span> </span><span class="CertTheme__tokenProperty">0</span><span class="CertTheme__tokenPunctuation">)</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp;</span><span class="CertTheme__tokenPunctuation">{</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;System</span><span class="CertTheme__tokenPunctuation">.</span><span>out</span><span class="CertTheme__tokenPunctuation">.</span><span class="CertTheme__tokenFunction">println</span><span class="CertTheme__tokenPunctuation">(</span><span class="CertTheme__tokenSelector">"Date 1 occurs before Date 2"</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">;</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp;</span><span class="CertTheme__tokenPunctuation">}</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp;</span><span class="CertTheme__tokenAttr">else</span><span> </span><span class="CertTheme__tokenAttr">if</span><span> </span><span class="CertTheme__tokenPunctuation">(</span><span>d1</span><span class="CertTheme__tokenPunctuation">.</span><span class="CertTheme__tokenFunction">compareTo</span><span class="CertTheme__tokenPunctuation">(</span><span>d2</span><span class="CertTheme__tokenPunctuation">)</span><span> </span><span class="CertTheme__tokenOperator">==</span><span> </span><span class="CertTheme__tokenProperty">0</span><span class="CertTheme__tokenPunctuation">)</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp;</span><span class="CertTheme__tokenPunctuation">{</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;System</span><span class="CertTheme__tokenPunctuation">.</span><span>out</span><span class="CertTheme__tokenPunctuation">.</span><span class="CertTheme__tokenFunction">println</span><span class="CertTheme__tokenPunctuation">(</span><span class="CertTheme__tokenSelector">"Both the dates are equal"</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">;</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp;</span><span class="CertTheme__tokenPunctuation">}</span><br><span>&nbsp; &nbsp;</span><span class="CertTheme__tokenPunctuation">}</span><br><span class="CertTheme__tokenPunctuation">}</span></pre></div></div><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><b><strong class="CertTheme__textBold">The output of the above program is as follows:</strong></b></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-ltyh021d1" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm"><span>The date </span><span class="CertTheme__tokenProperty">1</span><span> </span><span>is</span><span class="CertTheme__tokenOperator">:</span><span> </span><span class="CertTheme__tokenProperty">2018</span><span class="CertTheme__tokenOperator">-</span><span class="CertTheme__tokenProperty">12</span><span class="CertTheme__tokenOperator">-</span><span class="CertTheme__tokenProperty">05</span><br><span>The date </span><span class="CertTheme__tokenProperty">2</span><span> </span><span>is</span><span class="CertTheme__tokenOperator">:</span><span> </span><span class="CertTheme__tokenProperty">2018</span><span class="CertTheme__tokenOperator">-</span><span class="CertTheme__tokenProperty">08</span><span class="CertTheme__tokenOperator">-</span><span class="CertTheme__tokenProperty">07</span><br><span>Date </span><span class="CertTheme__tokenProperty">1</span><span> occurs after Date </span><span class="CertTheme__tokenProperty">2</span></pre></div></div><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><br></p></div></div></div></div><div class="relative"><div class="mt-spacing20 z-10 relative text-center flex justify-center mt-0"><button class="flex items-center gap-x-spacing8 py-spacing4"><span class="text-sm underline font-semibold text-mono-black">View all questions</span><i class="icon-chevron-down-double text-xl leading-5 text-neutral-800"></i></button></div><div class="absolute bottom-0 block h-32 w-full bg-gradient-to-t from-subdued/100 from-30% md:from-40%"></div></div></div></div></div><div class="hidden"><div><div class="text-xl text-neutral-800 mb-spacing20 font-bold">Advanced</div><div class="relative w-full"><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-primary-main outline-2 shadow-card hover:shadow-card visible"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-t-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden">1. May I override a public method with a protected method? Why is it so?</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-0 text-neutral-800"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p>We cannot override a public method by a protected method. The access modifiers of the method in the child class cannot limit the scope of the method of the parent class while overriding. This is because we call the method through a superclass reference which overrides the parent implementation by the child implementation. As the type of reference is of Parent class, the client code knows the API with the broader scope (public) and is prepared based on the parent API. So, it doesn’t make any sense to limit the scope in the overriding (child) method, but the opposite is possible, of course.</p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow visible"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">2. What is the String pool in java?</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p>Strings are immutable in Java. When we make changes in a String, it creates a new String object. Our programs create a lot of String objects in the runtime. To offer optimum performance, JVM minimizes the String object creation maintaining a pool of String literals in the heap memory (Java 7 onwards). So, when it is required to create a String literal, it first checks in the pool, whether it exists there. If found, it returns the reference of that object. Otherwise, it creates the object and reserves it in the pool for reusing it in a later phase.&nbsp;</p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow visible"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">3. What do you mean by an immutable class? How can we make a class immutable?</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>An immutable class doesn’t allow to change the state of its objects after creation. If we need to change that state of an object it will create a new object. One of the most popular examples of an immutable class is String. We need to take care of several things to make a type immutable.&nbsp;</p><ol class="CertTheme__ol1 pt-spacing10"><li class="CertTheme__listItem pt-spacing10">&nbsp;The class needs to be final. The reason for not allowing to extend it is that a subclass may get access the sensitive fields or methods which may change the state of the object.&nbsp;</li><li class="CertTheme__listItem pt-spacing10">&nbsp;The class should declare all its members as private.&nbsp;</li><li class="CertTheme__listItem pt-spacing10">&nbsp;It should not offer APIs or public methods to change its state. For example setter methods. Even if it does, it should create a clone of its own, make the changes there and return the object.&nbsp;</li><li class="CertTheme__listItem pt-spacing10">&nbsp;If any member of the class is mutable, we should declare it as final.&nbsp;</li><li class="CertTheme__listItem pt-spacing10">We should initialize the object through a constructor making a deep clone of the mutable objects passed as the constructor arguments.&nbsp;</li><li class="CertTheme__listItem pt-spacing10">we should not expose the references of the mutable members outside the class. If we need to do this, we need to clone the member properly and return it. This ensures even if the object is changed via its reference, it is not the same object.&nbsp;</li></ol><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow visible"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">4. What is a default method? Why this design change has been done?</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>In the earlier versions of Java (up to 1.7), the interface was designed to have only method signatures. From Java 8 the interface is now able to contain method implementation as well. These methods should be marked with default keyword and are called default methods of an interface. This means it is not mandatory to override the default methods in the implementing classes. When an interface is widely used by many applications, it was very difficult to add a new method in the same, because, it can break the code. The implementers need to change their code in many places. To overcome this complexity and make interfaces backward compatible this change has been introduced. public interface Shape {&nbsp;</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-wxr0opey6" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">default double area() {&nbsp;
return 0.0; }&nbsp;default double volume() {&nbsp;
return 0.0; } } </pre></div></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow visible"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">5. What is the difference between the stack and heap memory? Why a stack is used   for the purpose of storing the local variables?</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p>Stack memory is used to create the local variables and object references while executing a method by a thread. This means each thread has a separate stack and set of local variables. Stack doesn’t contain the actual objects - it only contains the references. The memory space for the actual objects is allocated in the heap memory. Heap memory is composed of a number of parts - young generation (Eden and Survivor space) and old generation. For each method call JVM creates a new stack frame containing the local variables. Maintaining them as a stack helps to retrieve the most recent stack frame i.e., the set of variables of the caller method easily when a method returns.&nbsp;</p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">6. What is a HashSet? How is it implemented?</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p>A set is a collection of unordered and unique elements. While adding an element a HashSet uses the hashCode() and equals() method to determine if the element already exists in the Set. If it doesn’t exist, it adds the element into the set. A HashSet uses a HashMap internally which uses the element as the key and keeps a fixed item as the value. If the element exists in the HashMap as a key, it simply returns with a boolean value false denoting it already exists in the set, otherwise puts the element in the map and returns true.&nbsp;</p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">7. Is String an immutable class? Why String has been defined as immutable?</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p>Yes, String is an immutable class. String is widely used in different situations like sharing as a parameter of a method, loading a class by its name, returning as a value. So, there would be a huge possibility that a String object could be changed without any knowledge of its other users and result in creating difficult to catch bugs in the system. String has been a popular choice as a key in the HashMap or HashTable. A good candidate for a key in the HashMap should be immutable. If String had been mutable and changes its state, it might result in retrieving the wrong value for the same key or not finding it at all. String literals are fetched from the String pool instead of creating it every time. Had the String been mutable, this would not be possible as it could not identify whether the value exists in the pool after any change in its state. &nbsp;</p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">8. What is cloning? What is the difference between shallow cloning and deep   cloning?</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><span>Cloning means creating a copy of an object or creating a duplicate object - the state of them should be the same. An object may be composed of several other objects. Shallow cloning creates a new object and assigns its field values to the corresponding fields of the new object. As the fields contain only the references of the objects which reside in the heap, fields of the new object also point to the same component instances. Shallow cloning is fast but has a serious downside in that if any of the component objects is changed, it reflects in the cloned object as well, because both of them holds the references of the same objects.</span></p><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><span>Deep Cloning, on the other side, doesn’t copy the references from the fields, it creates a duplicate of the component objects as well. As in Deep cloning, all the component objects are cloned it’s comparatively slow but creates a true duplicate of the actual object.</span></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">9. Java Memory Model</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><span>The Java Memory Model helps to understand the way the Java Virtual Machine works with the computer memory. The internal Java memory model divides the memory into thread stacks that are used by individual threads and the heap that is used by the entire application.</span></p><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><span>A diagram that demonstrates the internal Java memory model is given as follows:</span></p><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><img alt="Java Memory Model" loading="lazy" width="100" height="100" decoding="async"  class="" style="color:transparent;width:100%;height:auto;background-size:cover;background-position:50% 50%;background-repeat:no-repeat;background-image:url(&quot;data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http%3A//www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cfilter id='b' color-interpolation-filters='sRGB'%3E%3CfeGaussianBlur stdDeviation='20'/%3E%3C/filter%3E%3Cimage preserveAspectRatio='none' filter='url(%23b)' x='0' y='0' height='100%25' width='100%25' href='data:image/svg+xml;base64,CiAgPHN2ZyB3aWR0aD0iMTAwIiBoZWlnaHQ9IjEwMCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIj4KICAgIDxkZWZzPgogICAgICA8bGluZWFyR3JhZGllbnQgaWQ9ImciPgogICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNjY2MiIG9mZnNldD0iMjAlIiAvPgogICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNkZGQiIG9mZnNldD0iNTAlIiAvPgogICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNlZWUiIG9mZnNldD0iNzAlIiAvPgogICAgICA8L2xpbmVhckdyYWRpZW50PgogICAgPC9kZWZzPgogICAgPHJlY3Qgd2lkdGg9IjEwMCIgaGVpZ2h0PSIxMDAiIGZpbGw9IiNlZWUiIC8+CiAgICA8cmVjdCBpZD0iciIgd2lkdGg9IjEwMCIgaGVpZ2h0PSIxMDAiIGZpbGw9InVybCgjZykiIC8+CiAgICA8YW5pbWF0ZSB4bGluazpocmVmPSIjciIgYXR0cmlidXRlTmFtZT0ieCIgZnJvbT0iLTEwMCIgdG89IjEwMCIgZHVyPSIxcyIgcmVwZWF0Q291bnQ9ImluZGVmaW5pdGUiICAvPgogIDwvc3ZnPg=='/%3E%3C/svg%3E&quot;)" sizes="(min-width: 767px) 50vw, 100vw" srcSet="" src="https://images.unsplash.com/photo-1523240795612-9a054b0db644?ixlib=rb-4.0.3&auto=format&fit=crop&w=1000&q=80"></p><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><span>Details about the thread stack and Heap in the internal Java memory model are given as follows:</span></p><h3 class="CertTheme__h3" dir="ltr"><span>Thread Stack</span></h3><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><span>The Thread Stack memory in Java is used for thread execution. Specific values are stored in the thread stack that are available for a short time. Also, stack memory may contain data references to objects getting referred from the method that are in the heap memory.</span></p><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><span>The order in Thread Stack memory is Last In First Out (LIFO). A block is created in the stack memory for all the primitive values and references to other objects in a method when that method is invoked. After the end of the method, the memory block in the stack memory is free and can be used by another method.</span></p><h3 class="CertTheme__h3" dir="ltr"><span>Heap</span></h3><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><span>The heap space in Java is used to allocate memory to the Objects and the JRE classes by the Java runtime. All the objects in the application are created in the heap space. The objects in the heap space are globally accessible from any place in the application and so they have a lifetime for the whole application execution.</span></p><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><span>The memory model of the heap space is divided into parts known as generations. Details about these are given as follows:</span></p><ul class="CertTheme__ul"><li value="1" class="CertTheme__listItem pt-spacing10"><b><strong class="CertTheme__textBold">Young Generation</strong></b></li></ul><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><span>All the new objects are allocated in the young generation and they age here. When this place fills up, then minor garbage collection occurs.</span></p><ul class="CertTheme__ul"><li value="1" class="CertTheme__listItem pt-spacing10"><b><strong class="CertTheme__textBold">Old Generation</strong></b></li></ul><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><span>All the longer existing objects are stored in the old generation. When objects in the young generation reach a certain age threshold, they are moved to the old generation.</span></p><ul class="CertTheme__ul"><li value="1" class="CertTheme__listItem pt-spacing10"><b><strong class="CertTheme__textBold">Permanent Generation</strong></b></li></ul><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><span>The Java metadata for runtime classes is stored in the permanent generation.</span></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">10. JShell in Java 9</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><span>JShell is a feature introduced in Java 9. JShell provides Java with REPL ability. REPL stands for Read-Eval-Print-Loop. With REPL, we can test java based logic and expressions without any requirement of compiling.</span></p><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><span>REPl is acts as an immediate feedback loop and can have a great effect on productivity in that particular language.</span></p><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><span>Now let us play around with JShell for a bit.</span></p><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><span>Running JShell on Windows</span></p><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><b><strong class="CertTheme__textBold">Step 1</strong></b><span>: Setup the JDK path</span></p><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><span>Go to Control Panel &gt; System &gt; Advanced System Settings &gt; Advanced tab &gt; Environment Variables.</span></p><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><span>Under System Variable, click Path, then New and add the following JDK path,</span></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-ewn48vj4m" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm"><span class="CertTheme__tokenProperty">C</span><span class="CertTheme__tokenOperator">:</span><span>\Program Files\Java\jdk</span><span class="CertTheme__tokenOperator">-</span><span class="CertTheme__tokenProperty">11.0</span><span class="CertTheme__tokenProperty">.1</span><span>\bin</span></pre></div></div><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><b><strong class="CertTheme__textBold">Step 2:</strong></b><span> Now open Command Prompt and type </span><b><strong class="CertTheme__textBold">jshell</strong></b><span>.</span></p><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><img alt="Command Prompt" loading="lazy" width="100" height="100" decoding="async"  class="" style="color:transparent;width:100%;height:auto;background-size:cover;background-position:50% 50%;background-repeat:no-repeat;background-image:url(&quot;data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http%3A//www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cfilter id='b' color-interpolation-filters='sRGB'%3E%3CfeGaussianBlur stdDeviation='20'/%3E%3C/filter%3E%3Cimage preserveAspectRatio='none' filter='url(%23b)' x='0' y='0' height='100%25' width='100%25' href='data:image/svg+xml;base64,CiAgPHN2ZyB3aWR0aD0iMTAwIiBoZWlnaHQ9IjEwMCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIj4KICAgIDxkZWZzPgogICAgICA8bGluZWFyR3JhZGllbnQgaWQ9ImciPgogICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNjY2MiIG9mZnNldD0iMjAlIiAvPgogICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNkZGQiIG9mZnNldD0iNTAlIiAvPgogICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNlZWUiIG9mZnNldD0iNzAlIiAvPgogICAgICA8L2xpbmVhckdyYWRpZW50PgogICAgPC9kZWZzPgogICAgPHJlY3Qgd2lkdGg9IjEwMCIgaGVpZ2h0PSIxMDAiIGZpbGw9IiNlZWUiIC8+CiAgICA8cmVjdCBpZD0iciIgd2lkdGg9IjEwMCIgaGVpZ2h0PSIxMDAiIGZpbGw9InVybCgjZykiIC8+CiAgICA8YW5pbWF0ZSB4bGluazpocmVmPSIjciIgYXR0cmlidXRlTmFtZT0ieCIgZnJvbT0iLTEwMCIgdG89IjEwMCIgZHVyPSIxcyIgcmVwZWF0Q291bnQ9ImluZGVmaW5pdGUiICAvPgogIDwvc3ZnPg=='/%3E%3C/svg%3E&quot;)" sizes="(min-width: 767px) 50vw, 100vw" srcSet="" src="https://images.unsplash.com/photo-1522202176988-66273c2fd55f?ixlib=rb-4.0.3&auto=format&fit=crop&w=1000&q=80"></p><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><b><strong class="CertTheme__textBold">Step 3: </strong></b><span>Viewing the JShell commands</span><br><span>Type </span><b><strong class="CertTheme__textBold">/help </strong></b><span>in the command window once JShell start running:</span></p><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><img alt="Command Prompt" loading="lazy" width="100" height="100" decoding="async"  class="" style="color:transparent;width:100%;height:auto;background-size:cover;background-position:50% 50%;background-repeat:no-repeat;background-image:url(&quot;data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http%3A//www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cfilter id='b' color-interpolation-filters='sRGB'%3E%3CfeGaussianBlur stdDeviation='20'/%3E%3C/filter%3E%3Cimage preserveAspectRatio='none' filter='url(%23b)' x='0' y='0' height='100%25' width='100%25' href='data:image/svg+xml;base64,CiAgPHN2ZyB3aWR0aD0iMTAwIiBoZWlnaHQ9IjEwMCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIj4KICAgIDxkZWZzPgogICAgICA8bGluZWFyR3JhZGllbnQgaWQ9ImciPgogICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNjY2MiIG9mZnNldD0iMjAlIiAvPgogICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNkZGQiIG9mZnNldD0iNTAlIiAvPgogICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNlZWUiIG9mZnNldD0iNzAlIiAvPgogICAgICA8L2xpbmVhckdyYWRpZW50PgogICAgPC9kZWZzPgogICAgPHJlY3Qgd2lkdGg9IjEwMCIgaGVpZ2h0PSIxMDAiIGZpbGw9IiNlZWUiIC8+CiAgICA8cmVjdCBpZD0iciIgd2lkdGg9IjEwMCIgaGVpZ2h0PSIxMDAiIGZpbGw9InVybCgjZykiIC8+CiAgICA8YW5pbWF0ZSB4bGluazpocmVmPSIjciIgYXR0cmlidXRlTmFtZT0ieCIgZnJvbT0iLTEwMCIgdG89IjEwMCIgZHVyPSIxcyIgcmVwZWF0Q291bnQ9ImluZGVmaW5pdGUiICAvPgogIDwvc3ZnPg=='/%3E%3C/svg%3E&quot;)" sizes="(min-width: 767px) 50vw, 100vw" srcSet="" src="https://images.unsplash.com/photo-1522202176988-66273c2fd55f?ixlib=rb-4.0.3&auto=format&fit=crop&w=1000&q=80"></p><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><b><strong class="CertTheme__textBold">Step 4: </strong></b><span>Running jshell commands</span></p><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><span>Type </span><b><strong class="CertTheme__textBold">/imports </strong></b><span>in the jshell command window for obtaining the packages imported by jshell</span></p><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><img alt="Command Prompt" loading="lazy" width="100" height="100" decoding="async"  class="" style="color:transparent;width:100%;height:auto;background-size:cover;background-position:50% 50%;background-repeat:no-repeat;background-image:url(&quot;data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http%3A//www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cfilter id='b' color-interpolation-filters='sRGB'%3E%3CfeGaussianBlur stdDeviation='20'/%3E%3C/filter%3E%3Cimage preserveAspectRatio='none' filter='url(%23b)' x='0' y='0' height='100%25' width='100%25' href='data:image/svg+xml;base64,CiAgPHN2ZyB3aWR0aD0iMTAwIiBoZWlnaHQ9IjEwMCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIj4KICAgIDxkZWZzPgogICAgICA8bGluZWFyR3JhZGllbnQgaWQ9ImciPgogICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNjY2MiIG9mZnNldD0iMjAlIiAvPgogICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNkZGQiIG9mZnNldD0iNTAlIiAvPgogICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNlZWUiIG9mZnNldD0iNzAlIiAvPgogICAgICA8L2xpbmVhckdyYWRpZW50PgogICAgPC9kZWZzPgogICAgPHJlY3Qgd2lkdGg9IjEwMCIgaGVpZ2h0PSIxMDAiIGZpbGw9IiNlZWUiIC8+CiAgICA8cmVjdCBpZD0iciIgd2lkdGg9IjEwMCIgaGVpZ2h0PSIxMDAiIGZpbGw9InVybCgjZykiIC8+CiAgICA8YW5pbWF0ZSB4bGluazpocmVmPSIjciIgYXR0cmlidXRlTmFtZT0ieCIgZnJvbT0iLTEwMCIgdG89IjEwMCIgZHVyPSIxcyIgcmVwZWF0Q291bnQ9ImluZGVmaW5pdGUiICAvPgogIDwvc3ZnPg=='/%3E%3C/svg%3E&quot;)" sizes="(min-width: 767px) 50vw, 100vw" srcSet="" src="https://images.unsplash.com/photo-1522202176988-66273c2fd55f?ixlib=rb-4.0.3&auto=format&fit=crop&w=1000&q=80"></p><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><b><strong class="CertTheme__textBold">Step 5: </strong></b><span>Performing calculations in jshell</span></p><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><span>Try simple arithmetic calculations with jshell</span></p><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><img alt="Command Prompt" loading="lazy" width="100" height="100" decoding="async"  class="" style="color:transparent;width:100%;height:auto;background-size:cover;background-position:50% 50%;background-repeat:no-repeat;background-image:url(&quot;data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http%3A//www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cfilter id='b' color-interpolation-filters='sRGB'%3E%3CfeGaussianBlur stdDeviation='20'/%3E%3C/filter%3E%3Cimage preserveAspectRatio='none' filter='url(%23b)' x='0' y='0' height='100%25' width='100%25' href='data:image/svg+xml;base64,CiAgPHN2ZyB3aWR0aD0iMTAwIiBoZWlnaHQ9IjEwMCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIj4KICAgIDxkZWZzPgogICAgICA8bGluZWFyR3JhZGllbnQgaWQ9ImciPgogICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNjY2MiIG9mZnNldD0iMjAlIiAvPgogICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNkZGQiIG9mZnNldD0iNTAlIiAvPgogICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNlZWUiIG9mZnNldD0iNzAlIiAvPgogICAgICA8L2xpbmVhckdyYWRpZW50PgogICAgPC9kZWZzPgogICAgPHJlY3Qgd2lkdGg9IjEwMCIgaGVpZ2h0PSIxMDAiIGZpbGw9IiNlZWUiIC8+CiAgICA8cmVjdCBpZD0iciIgd2lkdGg9IjEwMCIgaGVpZ2h0PSIxMDAiIGZpbGw9InVybCgjZykiIC8+CiAgICA8YW5pbWF0ZSB4bGluazpocmVmPSIjciIgYXR0cmlidXRlTmFtZT0ieCIgZnJvbT0iLTEwMCIgdG89IjEwMCIgZHVyPSIxcyIgcmVwZWF0Q291bnQ9ImluZGVmaW5pdGUiICAvPgogIDwvc3ZnPg=='/%3E%3C/svg%3E&quot;)" sizes="(min-width: 767px) 50vw, 100vw" srcSet="" src="https://images.unsplash.com/photo-1522202176988-66273c2fd55f?ixlib=rb-4.0.3&auto=format&fit=crop&w=1000&q=80"></p><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><b><strong class="CertTheme__textBold">Step 6: </strong></b><span>Creating functions in jshell</span></p><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><span>You can create functions and use them in jshell</span></p><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><img alt="Command Prompt" loading="lazy" width="100" height="100" decoding="async"  class="" style="color:transparent;width:100%;height:auto;background-size:cover;background-position:50% 50%;background-repeat:no-repeat;background-image:url(&quot;data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http%3A//www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cfilter id='b' color-interpolation-filters='sRGB'%3E%3CfeGaussianBlur stdDeviation='20'/%3E%3C/filter%3E%3Cimage preserveAspectRatio='none' filter='url(%23b)' x='0' y='0' height='100%25' width='100%25' href='data:image/svg+xml;base64,CiAgPHN2ZyB3aWR0aD0iMTAwIiBoZWlnaHQ9IjEwMCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIj4KICAgIDxkZWZzPgogICAgICA8bGluZWFyR3JhZGllbnQgaWQ9ImciPgogICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNjY2MiIG9mZnNldD0iMjAlIiAvPgogICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNkZGQiIG9mZnNldD0iNTAlIiAvPgogICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNlZWUiIG9mZnNldD0iNzAlIiAvPgogICAgICA8L2xpbmVhckdyYWRpZW50PgogICAgPC9kZWZzPgogICAgPHJlY3Qgd2lkdGg9IjEwMCIgaGVpZ2h0PSIxMDAiIGZpbGw9IiNlZWUiIC8+CiAgICA8cmVjdCBpZD0iciIgd2lkdGg9IjEwMCIgaGVpZ2h0PSIxMDAiIGZpbGw9InVybCgjZykiIC8+CiAgICA8YW5pbWF0ZSB4bGluazpocmVmPSIjciIgYXR0cmlidXRlTmFtZT0ieCIgZnJvbT0iLTEwMCIgdG89IjEwMCIgZHVyPSIxcyIgcmVwZWF0Q291bnQ9ImluZGVmaW5pdGUiICAvPgogIDwvc3ZnPg=='/%3E%3C/svg%3E&quot;)" sizes="(min-width: 767px) 50vw, 100vw" srcSet="" src="https://images.unsplash.com/photo-1522202176988-66273c2fd55f?ixlib=rb-4.0.3&auto=format&fit=crop&w=1000&q=80"></p><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><b><strong class="CertTheme__textBold">Step 7: </strong></b><span>Exiting jshell</span></p><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><span>To exit jshell, type </span><b><strong class="CertTheme__textBold">/exit</strong></b></p><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><img alt="Command Prompt" loading="lazy" width="100" height="100" decoding="async"  class="" style="color:transparent;width:100%;height:auto;background-size:cover;background-position:50% 50%;background-repeat:no-repeat;background-image:url(&quot;data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http%3A//www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cfilter id='b' color-interpolation-filters='sRGB'%3E%3CfeGaussianBlur stdDeviation='20'/%3E%3C/filter%3E%3Cimage preserveAspectRatio='none' filter='url(%23b)' x='0' y='0' height='100%25' width='100%25' href='data:image/svg+xml;base64,CiAgPHN2ZyB3aWR0aD0iMTAwIiBoZWlnaHQ9IjEwMCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIj4KICAgIDxkZWZzPgogICAgICA8bGluZWFyR3JhZGllbnQgaWQ9ImciPgogICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNjY2MiIG9mZnNldD0iMjAlIiAvPgogICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNkZGQiIG9mZnNldD0iNTAlIiAvPgogICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNlZWUiIG9mZnNldD0iNzAlIiAvPgogICAgICA8L2xpbmVhckdyYWRpZW50PgogICAgPC9kZWZzPgogICAgPHJlY3Qgd2lkdGg9IjEwMCIgaGVpZ2h0PSIxMDAiIGZpbGw9IiNlZWUiIC8+CiAgICA8cmVjdCBpZD0iciIgd2lkdGg9IjEwMCIgaGVpZ2h0PSIxMDAiIGZpbGw9InVybCgjZykiIC8+CiAgICA8YW5pbWF0ZSB4bGluazpocmVmPSIjciIgYXR0cmlidXRlTmFtZT0ieCIgZnJvbT0iLTEwMCIgdG89IjEwMCIgZHVyPSIxcyIgcmVwZWF0Q291bnQ9ImluZGVmaW5pdGUiICAvPgogIDwvc3ZnPg=='/%3E%3C/svg%3E&quot;)" sizes="(min-width: 767px) 50vw, 100vw" srcSet="" src="https://images.unsplash.com/photo-1522202176988-66273c2fd55f?ixlib=rb-4.0.3&auto=format&fit=crop&w=1000&q=80"></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">11. Nashorn in Java 8</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><span>The JavaScript engine in Java SE 8 which replaces the erstwhile Rhino engine is called </span><b><strong class="CertTheme__textBold">Nashorn</strong></b><span>. It is 2-10 times better in performance than Rhino, as it compiles the source code in the system memory directly and sends it in the form of bytecode to the JVM.</span></p><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><span>JAVA 8 provides a new command for Nashorn namely,</span><b><strong class="CertTheme__textBold"> jjs</strong></b><span> which runs JavaScripts codes at command window (Command Prompt for Windows and Terminal for Linux operating systems).</span></p><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><span>Running js file using jjs</span></p><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><span>Create and save JavaScript file example.js in the </span><b><strong class="CertTheme__textBold">C:\Java</strong></b><span> Folder</span></p><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><span>The example.js has the following command:</span></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-47396cq93" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm"><span class="CertTheme__tokenFunction">print</span><span class="CertTheme__tokenPunctuation">(</span><span>‘Welcome to </span><span class="CertTheme__tokenProperty">NASHORN</span><span>’</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">;</span></pre></div></div><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><span>The screenshot showing the location of the example.js file:</span></p><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><img alt="js file" loading="lazy" width="100" height="100" decoding="async"  class="" style="color:transparent;width:100%;height:auto;background-size:cover;background-position:50% 50%;background-repeat:no-repeat;background-image:url(&quot;data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http%3A//www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cfilter id='b' color-interpolation-filters='sRGB'%3E%3CfeGaussianBlur stdDeviation='20'/%3E%3C/filter%3E%3Cimage preserveAspectRatio='none' filter='url(%23b)' x='0' y='0' height='100%25' width='100%25' href='data:image/svg+xml;base64,CiAgPHN2ZyB3aWR0aD0iMTAwIiBoZWlnaHQ9IjEwMCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIj4KICAgIDxkZWZzPgogICAgICA8bGluZWFyR3JhZGllbnQgaWQ9ImciPgogICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNjY2MiIG9mZnNldD0iMjAlIiAvPgogICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNkZGQiIG9mZnNldD0iNTAlIiAvPgogICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNlZWUiIG9mZnNldD0iNzAlIiAvPgogICAgICA8L2xpbmVhckdyYWRpZW50PgogICAgPC9kZWZzPgogICAgPHJlY3Qgd2lkdGg9IjEwMCIgaGVpZ2h0PSIxMDAiIGZpbGw9IiNlZWUiIC8+CiAgICA8cmVjdCBpZD0iciIgd2lkdGg9IjEwMCIgaGVpZ2h0PSIxMDAiIGZpbGw9InVybCgjZykiIC8+CiAgICA8YW5pbWF0ZSB4bGluazpocmVmPSIjciIgYXR0cmlidXRlTmFtZT0ieCIgZnJvbT0iLTEwMCIgdG89IjEwMCIgZHVyPSIxcyIgcmVwZWF0Q291bnQ9ImluZGVmaW5pdGUiICAvPgogIDwvc3ZnPg=='/%3E%3C/svg%3E&quot;)" sizes="(min-width: 767px) 50vw, 100vw" srcSet="" src="https://images.unsplash.com/photo-1517048676732-dce42f022dc7?ixlib=rb-4.0.3&auto=format&fit=crop&w=1000&q=80"></p><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><span>Open Command Prompt in Windows and type C:\Java&gt;jjs example.js</span></p><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><img alt="Command Prompt" loading="lazy" width="100" height="100" decoding="async"  class="" style="color:transparent;width:100%;height:auto;background-size:cover;background-position:50% 50%;background-repeat:no-repeat;background-image:url(&quot;data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http%3A//www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cfilter id='b' color-interpolation-filters='sRGB'%3E%3CfeGaussianBlur stdDeviation='20'/%3E%3C/filter%3E%3Cimage preserveAspectRatio='none' filter='url(%23b)' x='0' y='0' height='100%25' width='100%25' href='data:image/svg+xml;base64,CiAgPHN2ZyB3aWR0aD0iMTAwIiBoZWlnaHQ9IjEwMCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIj4KICAgIDxkZWZzPgogICAgICA8bGluZWFyR3JhZGllbnQgaWQ9ImciPgogICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNjY2MiIG9mZnNldD0iMjAlIiAvPgogICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNkZGQiIG9mZnNldD0iNTAlIiAvPgogICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNlZWUiIG9mZnNldD0iNzAlIiAvPgogICAgICA8L2xpbmVhckdyYWRpZW50PgogICAgPC9kZWZzPgogICAgPHJlY3Qgd2lkdGg9IjEwMCIgaGVpZ2h0PSIxMDAiIGZpbGw9IiNlZWUiIC8+CiAgICA8cmVjdCBpZD0iciIgd2lkdGg9IjEwMCIgaGVpZ2h0PSIxMDAiIGZpbGw9InVybCgjZykiIC8+CiAgICA8YW5pbWF0ZSB4bGluazpocmVmPSIjciIgYXR0cmlidXRlTmFtZT0ieCIgZnJvbT0iLTEwMCIgdG89IjEwMCIgZHVyPSIxcyIgcmVwZWF0Q291bnQ9ImluZGVmaW5pdGUiICAvPgogIDwvc3ZnPg=='/%3E%3C/svg%3E&quot;)" sizes="(min-width: 767px) 50vw, 100vw" srcSet="" src="https://images.unsplash.com/photo-1522202176988-66273c2fd55f?ixlib=rb-4.0.3&auto=format&fit=crop&w=1000&q=80"></p><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><span>Running jjs in Interactive mode</span></p><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><span>Type jjs in the console window and type a print command.</span></p><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><span>For exiting, type quit():</span></p><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><img alt="Command Prompt" loading="lazy" width="100" height="100" decoding="async"  class="" style="color:transparent;width:100%;height:auto;background-size:cover;background-position:50% 50%;background-repeat:no-repeat;background-image:url(&quot;data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http%3A//www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cfilter id='b' color-interpolation-filters='sRGB'%3E%3CfeGaussianBlur stdDeviation='20'/%3E%3C/filter%3E%3Cimage preserveAspectRatio='none' filter='url(%23b)' x='0' y='0' height='100%25' width='100%25' href='data:image/svg+xml;base64,CiAgPHN2ZyB3aWR0aD0iMTAwIiBoZWlnaHQ9IjEwMCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIj4KICAgIDxkZWZzPgogICAgICA8bGluZWFyR3JhZGllbnQgaWQ9ImciPgogICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNjY2MiIG9mZnNldD0iMjAlIiAvPgogICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNkZGQiIG9mZnNldD0iNTAlIiAvPgogICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNlZWUiIG9mZnNldD0iNzAlIiAvPgogICAgICA8L2xpbmVhckdyYWRpZW50PgogICAgPC9kZWZzPgogICAgPHJlY3Qgd2lkdGg9IjEwMCIgaGVpZ2h0PSIxMDAiIGZpbGw9IiNlZWUiIC8+CiAgICA8cmVjdCBpZD0iciIgd2lkdGg9IjEwMCIgaGVpZ2h0PSIxMDAiIGZpbGw9InVybCgjZykiIC8+CiAgICA8YW5pbWF0ZSB4bGluazpocmVmPSIjciIgYXR0cmlidXRlTmFtZT0ieCIgZnJvbT0iLTEwMCIgdG89IjEwMCIgZHVyPSIxcyIgcmVwZWF0Q291bnQ9ImluZGVmaW5pdGUiICAvPgogIDwvc3ZnPg=='/%3E%3C/svg%3E&quot;)" sizes="(min-width: 767px) 50vw, 100vw" srcSet="" src="https://images.unsplash.com/photo-1522202176988-66273c2fd55f?ixlib=rb-4.0.3&auto=format&fit=crop&w=1000&q=80"></p><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><span>Now, quit:</span></p><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><img alt="Command Prompt" loading="lazy" width="100" height="100" decoding="async"  class="" style="color:transparent;width:100%;height:auto;background-size:cover;background-position:50% 50%;background-repeat:no-repeat;background-image:url(&quot;data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http%3A//www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cfilter id='b' color-interpolation-filters='sRGB'%3E%3CfeGaussianBlur stdDeviation='20'/%3E%3C/filter%3E%3Cimage preserveAspectRatio='none' filter='url(%23b)' x='0' y='0' height='100%25' width='100%25' href='data:image/svg+xml;base64,CiAgPHN2ZyB3aWR0aD0iMTAwIiBoZWlnaHQ9IjEwMCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIj4KICAgIDxkZWZzPgogICAgICA8bGluZWFyR3JhZGllbnQgaWQ9ImciPgogICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNjY2MiIG9mZnNldD0iMjAlIiAvPgogICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNkZGQiIG9mZnNldD0iNTAlIiAvPgogICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNlZWUiIG9mZnNldD0iNzAlIiAvPgogICAgICA8L2xpbmVhckdyYWRpZW50PgogICAgPC9kZWZzPgogICAgPHJlY3Qgd2lkdGg9IjEwMCIgaGVpZ2h0PSIxMDAiIGZpbGw9IiNlZWUiIC8+CiAgICA8cmVjdCBpZD0iciIgd2lkdGg9IjEwMCIgaGVpZ2h0PSIxMDAiIGZpbGw9InVybCgjZykiIC8+CiAgICA8YW5pbWF0ZSB4bGluazpocmVmPSIjciIgYXR0cmlidXRlTmFtZT0ieCIgZnJvbT0iLTEwMCIgdG89IjEwMCIgZHVyPSIxcyIgcmVwZWF0Q291bnQ9ImluZGVmaW5pdGUiICAvPgogIDwvc3ZnPg=='/%3E%3C/svg%3E&quot;)" sizes="(min-width: 767px) 50vw, 100vw" srcSet="" src="https://images.unsplash.com/photo-1522202176988-66273c2fd55f?ixlib=rb-4.0.3&auto=format&fit=crop&w=1000&q=80"></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">12. Does Java support Remote Method Invocation (RMI)?</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>The Remote Method Invocation is an API in Java which manages the creation of a distributed application by allowing an object to invoke a method on another object that may be on the same machine or another remote machine but is on another address space.</p><p>The communication between the client and server in RMI is done by using the stub object and the skeleton object that are on the client side and server side respectively.</p><p>Details about the stub object and the skeleton object are provided along with the following diagram:</p><p><img alt="communication between the client and server " loading="lazy" width="100" height="100" decoding="async"  class="fr-fic fr-dib" style="color:transparent;width:100%;height:auto;background-size:cover;background-position:50% 50%;background-repeat:no-repeat;background-image:url(&quot;data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http%3A//www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cfilter id='b' color-interpolation-filters='sRGB'%3E%3CfeGaussianBlur stdDeviation='20'/%3E%3C/filter%3E%3Cimage preserveAspectRatio='none' filter='url(%23b)' x='0' y='0' height='100%25' width='100%25' href='data:image/svg+xml;base64,CiAgPHN2ZyB3aWR0aD0iMTAwIiBoZWlnaHQ9IjEwMCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIj4KICAgIDxkZWZzPgogICAgICA8bGluZWFyR3JhZGllbnQgaWQ9ImciPgogICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNjY2MiIG9mZnNldD0iMjAlIiAvPgogICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNkZGQiIG9mZnNldD0iNTAlIiAvPgogICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNlZWUiIG9mZnNldD0iNzAlIiAvPgogICAgICA8L2xpbmVhckdyYWRpZW50PgogICAgPC9kZWZzPgogICAgPHJlY3Qgd2lkdGg9IjEwMCIgaGVpZ2h0PSIxMDAiIGZpbGw9IiNlZWUiIC8+CiAgICA8cmVjdCBpZD0iciIgd2lkdGg9IjEwMCIgaGVpZ2h0PSIxMDAiIGZpbGw9InVybCgjZykiIC8+CiAgICA8YW5pbWF0ZSB4bGluazpocmVmPSIjciIgYXR0cmlidXRlTmFtZT0ieCIgZnJvbT0iLTEwMCIgdG89IjEwMCIgZHVyPSIxcyIgcmVwZWF0Q291bnQ9ImluZGVmaW5pdGUiICAvPgogIDwvc3ZnPg=='/%3E%3C/svg%3E&quot;)" sizes="(min-width: 767px) 50vw, 100vw" srcSet="" src="https://images.unsplash.com/photo-1535905557-58cb6c7a44aa?ixlib=rb-4.0.3&auto=format&fit=crop&w=1000&q=80"></p><ul><li class="CertTheme__listItem pt-spacing10"><strong>Stub object:&nbsp;</strong>All the outgoing requests for the client side are routed through the stub object and so it is also known as the gateway for the client-side object.</li><li class="CertTheme__listItem pt-spacing10"><strong>Skeleton Object:&nbsp;</strong>All the incoming requests for the server side are routed through the skeleton object and so it is also known as the gateway for the server-side object.</li></ul><p>The steps to create a Remote Method Invocation program are given as follows:</p><ol class="CertTheme__ol1 pt-spacing10"><li class="CertTheme__listItem pt-spacing10">First the remote interface is created.</li><li class="CertTheme__listItem pt-spacing10">The implementation of the remote interface is provided.</li><li class="CertTheme__listItem pt-spacing10">The implementation class is compiled and the stub and skeleton objects are created.</li><li class="CertTheme__listItem pt-spacing10">The registry service is started using the rmiregistry tool.</li><li class="CertTheme__listItem pt-spacing10">The remote application is created and started.</li><li class="CertTheme__listItem pt-spacing10">The client application is created and started.</li></ol><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">13. Daemon Threads in Java</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p>Daemon Thread are a specific kind of thread in Java that has the lowest priority while multithreading. All the User Threads have higher priority than the Daemon Thread. It cannot stop the JVM from exiting while rest of the threads have finished executing.</p><p>JVM doesn’t depend on the execution of the daemon threads. The Daemon thread performs background tasks like Garbage collection but is terminated as soon as the User Threads complete their execution. JVM doesn’t take into consideration whether the Daemon Thread is still running or not. It terminates the threads and then shuts itself down.</p><p>Daemon thread in java is a service provider thread that provides services to the user thread. There are many automatic daemon threads like gc and finalizer.</p><p>Methods for the Daemon thread include:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-kcmch1g7v" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">public void setDaemon(boolean status) </pre></div></div><p>The void setDaemon(boolean status) labels the current thread as a Daemon thread or an User Thread</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-6yvp2edd9" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">public boolean isDaemon()</pre></div></div><p>The boolean isDaemon() checks whether the thread is a Daemon thread or not.</p><p>Let us see the execution of Daemon Threads along with User Threads</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-mw542p291" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">public class Example extends Thread
{
&nbsp; &nbsp;public Example(String thread_name)
&nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;super(thread_name);
&nbsp; &nbsp;}
&nbsp; &nbsp;public void run()
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;if(Thread.currentThread().isDaemon())
&nbsp; &nbsp; &nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;System.out.println(getName() + " is just a Daemon thread "); &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp;}
&nbsp; &nbsp; &nbsp; &nbsp;else
&nbsp; &nbsp; &nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;System.out.println(getName() + " is an User thread!!!!"); &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp;}
&nbsp; &nbsp;}
&nbsp; &nbsp;public static void main(String[] args)
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;Example t1 = new Example("t1");
&nbsp; &nbsp; &nbsp; &nbsp;Example t2 = new Example("t2");
&nbsp; &nbsp; &nbsp; &nbsp;Example t3 = new Example("t3");
&nbsp; &nbsp; &nbsp; &nbsp;Example t4 = new Example("t4");
&nbsp; &nbsp; &nbsp; &nbsp;t1.setDaemon(true); // making t1 as Daemon
&nbsp; &nbsp; &nbsp; &nbsp;t1.start(); &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp;t2.setDaemon(true); &nbsp;// making t2 as Daemon
&nbsp; &nbsp; &nbsp; &nbsp;t2.start();
&nbsp; &nbsp; &nbsp; &nbsp;t3.start(); // t3 is a user thread
&nbsp; &nbsp; &nbsp; &nbsp;t4.setDaemon(true); // making t4 as Daemon
&nbsp; &nbsp;}
}</pre></div></div><p><strong>The output is as follows:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-tzl3x036t" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">$javac Example.java
$java Example
t1 is just a Daemon thread
t2 is just a Daemon thread
t3 is an User thread!!!!</pre></div></div><p>We can notice that after the execution of the User Thread t3 has completed, the Daemon Thread t4 terminates and is not checked for being a Daemon Thread.</p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">14. Predicate in Java 8</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>Predicate is a functional interface defined in java.util.Function package. It helps in improving the control of the code. It can be used as an assignment target in lambda expressions and functional interfaces. Functional interfaces are those interfaces that have only one abstract method.</p><p>Here is the declaration</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-6hrdd3ws3" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">@FunctionalInterface
public interface Predicate &lt;T&gt;</pre></div></div><p>Methods:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-zossmt7f7" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">boolean test(T t)</pre></div></div><p>The test() method evaluates the predicate based on the given argument.</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-38rrn3tsi" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">default Predicate&lt;T&gt; and(Predicate&lt;? super T&gt; other)</pre></div></div><p>The and() method returns a formulated predicate by short circuited logical AND of this predicate and the other. If the other is null, it throws a NullPointerException. If this predicate is false, the other is not evaluated.</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-i7v0z4l5q" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">default Predicate&lt;T&gt; negate()</pre></div></div><p>The negate() method returns a predicate that represents the logical NOT of this predicate.</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-7l43y2jcq" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">default Predicate&lt;T&gt; or(Predicate&lt;? super T&gt; other)</pre></div></div><p>The or() method returns a formulated predicated by short circuited OR of this predicate and the other. If this predicate is true, the other is not evaluated.</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-el01z3q7f" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">static &lt;T&gt; Predicate&lt;T&gt; isEqual(Object targetRef)</pre></div></div><p>The isEqual() method returns a predicate that tests if two arguments are equal according to Objects.equals(Object, Object).</p><p>Here is a sample program for Predicates in Java :</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-wa24yil64" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">import java.util.function.Predicate; &nbsp;
public class Example
{ &nbsp;
&nbsp; &nbsp;public static void main(String[] args)
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; Predicate&lt;Integer&gt; a = n-&gt; (n%3==0); &nbsp;// Creating predicate with lambda expression
&nbsp; &nbsp; &nbsp; System.out.println(a.test(36)); &nbsp;// Calling Predicate method test(Object)
&nbsp; &nbsp;}
}</pre></div></div><p><strong>The output is as follows:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-mdfac1yc5" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">$javac Example.java
$java Example
true</pre></div></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">15. New Date/Time API in Java 8</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>Java 8 introduced a new Date/Time Application Program Interface(API) as the previous Date/Time API w drawbacks.</p><ul><li class="CertTheme__listItem pt-spacing10"><strong>Not thread safe</strong>: The java.util.Date class was not thread safe. This forced developers to cope with the concurrency issue when the threads of the Date class were not in complete order with each other. The new date-time API is immutable and does not have setter methods.</li><li class="CertTheme__listItem pt-spacing10"><strong>Poor design</strong>: Default Date had become obsolete since it started from the year 1900, month started from 1, and day started from 0. Thus uniformity couldn’t be achieved. &nbsp;The old API had less immediate methods for the functions to be performed on date. The new API provides numerous useful methods for such operations.</li><li class="CertTheme__listItem pt-spacing10"><strong>Inconvenient handling of time zone</strong>: &nbsp;The problems faced due the timezone needed huge amount of code written by a developer. The new API has been developed bearing &nbsp;the domain-specific blueprint in mind.</li><li class="CertTheme__listItem pt-spacing10">The new API has been listed under the java.time package. Some of the significant classes under the java.time package are:</li><li class="CertTheme__listItem pt-spacing10"><strong>Local</strong>: The Local class is a streamlined Data/Time API &nbsp;without the hodoo of timezone handling</li><li class="CertTheme__listItem pt-spacing10"><strong>Zoned</strong>: The Zoned class is a streamlined Data/Time API with consideration of timezones</li></ul><p>Let us see an example of the Local class with the new Date/Time API:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-kgfyv4rci" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">import java.time.LocalDate;
import java.time.LocalTime;
import java.time.LocalDateTime;
import java.time.Month;
public class Example
{
&nbsp; public void checkDate()
&nbsp; &nbsp; {
&nbsp; &nbsp; &nbsp; &nbsp;LocalDateTime currentTime = LocalDateTime.now(); // computing local Date/Time
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println("Present DateTime: " + currentTime);
&nbsp; &nbsp; &nbsp; &nbsp;LocalDate date = currentTime.toLocalDate(); &nbsp;// computing local Data
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println("Present Local Date : " + date);
&nbsp; &nbsp; // computing current local time in hours, minutes and seconds
&nbsp; &nbsp; &nbsp; &nbsp;int second = currentTime.getSecond(); &nbsp;&nbsp;
&nbsp; &nbsp; &nbsp; &nbsp;int minute =currentTime.getMinute();
&nbsp; &nbsp; &nbsp; &nbsp;int hour=currentTime.getHour();
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println("Hour: " + hour +"|Minute: " + minute +"|seconds: " + second);
&nbsp; &nbsp; &nbsp; }
&nbsp; public static void main(String args[])
&nbsp; {
&nbsp; &nbsp; &nbsp;Example obj = new Example();
&nbsp; &nbsp; &nbsp;obj.checkDate();
&nbsp; }
}</pre></div></div><p><strong>The output is as follows:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-5jci0uixm" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">$javac Example.java
$java Example
Present DateTime: 2018-12-13T18:39:24.730
Present Local Date : 2018-12-13
Hour: 18|Minute: 39|seconds: 24</pre></div></div><p>Now, let us see an example of the Zoned class with the new Date/Time API:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-hekvg7nfi" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
public class Example
{
&nbsp; &nbsp;public static void Zone()
&nbsp; &nbsp;{
&nbsp; &nbsp; LocalDateTime dt = LocalDateTime.now();
&nbsp; &nbsp; DateTimeFormatter format = DateTimeFormatter.ofPattern(" HH:mm:ss dd-MM-YYYY"); &nbsp;
&nbsp; &nbsp; String fcd = dt.format(format); // stores the formatted current date
&nbsp; &nbsp; System.out.println("Present formatted Time and Date: "+fcd); &nbsp;
&nbsp; &nbsp; ZonedDateTime zone = ZonedDateTime.now(); &nbsp;
&nbsp; &nbsp; System.out.println("The Present zone is "+zone.getZone()); &nbsp;
&nbsp; &nbsp;}
&nbsp; &nbsp;public static void main(String[] args) &nbsp;
&nbsp; &nbsp;{
&nbsp; &nbsp; Zone();
&nbsp; &nbsp;}
}</pre></div></div><p><strong>The output is as follows:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-taq9u6vcb" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">$javac Example.java
$java Example
Present formatted Time and Date: &nbsp;19:24:52 13-12-2018
The Present zone is Etc/UTC</pre></div></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">16. Optional Class in Java 8</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>Optional is a container object which might not contain a non-null value. If a value is available, isPresent() will return true and get() will return the value. Supplementary methods that rely on the availability of a contained value are provided, like orElse() methods (return a default value if value not present) and ifPresent()(execute a block of code if the value is present).</p><p>Syntax for optional class</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-ow01bxq1g" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">public final class Optional&lt;T&gt; extends Object</pre></div></div><p>Optional class is a value based class. Operations pertaining to identity including reference equality (==), identity hash code, or synchronization on objects of the class may have unprecedented outcomes and should be avoided.</p><p>Let us see an example where the isPresent() method of the optional class is used:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-pxj34xiny" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">import java.util.Optional; &nbsp;&nbsp;
public class Example
{ &nbsp;&nbsp;
&nbsp; &nbsp;public static void main(String[] args)
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;String s1 = new String("Hello");
&nbsp; &nbsp; &nbsp; &nbsp;String s2 = null;
&nbsp; &nbsp; &nbsp; &nbsp;Optional&lt;String&gt; obj1 = Optional.ofNullable(s1);
&nbsp; &nbsp; &nbsp; &nbsp;Optional&lt;String&gt; obj2 = Optional.ofNullable(s2);
&nbsp; &nbsp; &nbsp; &nbsp;if (obj1.isPresent()) &nbsp; &nbsp;// checks if String object is present
&nbsp; &nbsp; &nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; System.out.println(s1.toUpperCase()); &nbsp;&nbsp;
&nbsp; &nbsp; &nbsp; &nbsp;}
&nbsp; &nbsp; &nbsp; &nbsp;else
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println("s1 is a Null string");
&nbsp; &nbsp; &nbsp; &nbsp;if(obj2.isPresent()) &nbsp; // checks if String object is present
&nbsp; &nbsp; &nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; System.out.println(s1.toUpperCase());
&nbsp; &nbsp; &nbsp; &nbsp;}
&nbsp; &nbsp; &nbsp; &nbsp;else
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println("s2 is a Null string");
&nbsp; &nbsp;}
}</pre></div></div><p><strong>The output is as follows:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-835o8c8sq" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">$javac Example.java
$java Example
HELLO
s2 is a Null string</pre></div></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">17. Are functions in Java &nbsp;virtual by default?</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p>Yes, all the functions in Java are virtual by default.</p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">18. Inbuilt encoder and decoder for Base64 encoding in Java 8</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p class="CertTheme__paragraph" data-mode="standard"><br></p><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><span>The Base64 class consist of static methods for obtaining encoders and decoders for Base64 encoding. Java 8 allows us to use three types of encoding:</span></p><ul class="CertTheme__ul"><li value="1" class="CertTheme__listItem pt-spacing10"><b><strong class="CertTheme__textBold">Basic</strong></b><span> − The output is plotted to a set of characters lying in Base64 alphabet. The encoder does not add any line feed in output, and the decoder rejects any character other than Base64 alphabet.</span></li><li value="2" class="CertTheme__listItem pt-spacing10"><b><strong class="CertTheme__textBold">Uniform Resource Locator(URL) and filename safe </strong></b><span>− The output is plotted to set of characters lying in Base64 alphabet. The decoder rejects data that contains characters outside the Base64 alphabet.</span></li><li value="3" class="CertTheme__listItem pt-spacing10"><b><strong class="CertTheme__textBold">Multipurpose Internet Mail Extensions (MIME)</strong></b><span> − The output is plotted to MIME compatible format. The encoded output must have lines with a maximum of 76 characters each and applies a carriage return '\r' followed instantly by a linefeed '\n' as the line separator. There is no linefeed separator at the end of the encoded output. All the characters apart from the Base64 alphabet are ignored by the decoder.</span></li></ul><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><span>The declaration of the Base64 class is as follows:</span></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-w6p0z5nyu" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm"><span class="CertTheme__tokenAttr">public</span><span> </span><span class="CertTheme__tokenAttr">class</span><span> </span><span class="CertTheme__tokenFunction">Base64</span><br><span class="CertTheme__tokenAttr">extends</span><span> </span><span class="CertTheme__tokenFunction">Object</span></pre></div></div><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><span>Let us see an example of basic Base64 encoding and decoding:</span></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-evk5s8mcs" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm"><span class="CertTheme__tokenAttr">import</span><span> java</span><span class="CertTheme__tokenPunctuation">.</span><span>util</span><span class="CertTheme__tokenPunctuation">.</span><span>Base64</span><span class="CertTheme__tokenPunctuation">;</span><br><span class="CertTheme__tokenAttr">public</span><span> </span><span class="CertTheme__tokenAttr">class</span><span> </span><span class="CertTheme__tokenFunction">Example</span><br><span class="CertTheme__tokenPunctuation">{</span><br><span>&nbsp; &nbsp;</span><span class="CertTheme__tokenAttr">public</span><span> </span><span class="CertTheme__tokenAttr">static</span><span> </span><span class="CertTheme__tokenAttr">void</span><span> </span><span class="CertTheme__tokenFunction">main</span><span class="CertTheme__tokenPunctuation">(</span><span>String</span><span class="CertTheme__tokenPunctuation">[</span><span class="CertTheme__tokenPunctuation">]</span><span> args</span><span class="CertTheme__tokenPunctuation">)</span><br><span>&nbsp; &nbsp;</span><span class="CertTheme__tokenPunctuation">{</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp;String enc </span><span class="CertTheme__tokenOperator">=</span><span> Base64</span><span class="CertTheme__tokenPunctuation">.</span><span class="CertTheme__tokenFunction">getEncoder</span><span class="CertTheme__tokenPunctuation">(</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">.</span><span class="CertTheme__tokenFunction">encodeToString</span><span class="CertTheme__tokenPunctuation">(</span><span class="CertTheme__tokenSelector">"Encoding in Base64"</span><span class="CertTheme__tokenPunctuation">.</span><span class="CertTheme__tokenFunction">getBytes</span><span class="CertTheme__tokenPunctuation">(</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">;</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp;System</span><span class="CertTheme__tokenPunctuation">.</span><span>out</span><span class="CertTheme__tokenPunctuation">.</span><span class="CertTheme__tokenFunction">println</span><span class="CertTheme__tokenPunctuation">(</span><span class="CertTheme__tokenSelector">"Encoder Output : "</span><span> </span><span class="CertTheme__tokenOperator">+</span><span> enc</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">;</span><br><span>&nbsp; &nbsp; &nbsp; &nbsp;byte</span><span class="CertTheme__tokenPunctuation">[</span><span class="CertTheme__tokenPunctuation">]</span><span> dec </span><span class="CertTheme__tokenOperator">=</span><span> Base64</span><span class="CertTheme__tokenPunctuation">.</span><span class="CertTheme__tokenFunction">getDecoder</span><span class="CertTheme__tokenPunctuation">(</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">.</span><span class="CertTheme__tokenFunction">decode</span><span class="CertTheme__tokenPunctuation">(</span><span>enc</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">;</span><br><span>&nbsp; &nbsp; &nbsp; System</span><span class="CertTheme__tokenPunctuation">.</span><span>out</span><span class="CertTheme__tokenPunctuation">.</span><span class="CertTheme__tokenFunction">println</span><span class="CertTheme__tokenPunctuation">(</span><span class="CertTheme__tokenSelector">"Decoder Output : "</span><span> </span><span class="CertTheme__tokenOperator">+</span><span> </span><span class="CertTheme__tokenAttr">new</span><span> </span><span class="CertTheme__tokenFunction">String</span><span class="CertTheme__tokenPunctuation">(</span><span>dec</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">)</span><span class="CertTheme__tokenPunctuation">;</span><br><span>&nbsp; &nbsp;</span><span class="CertTheme__tokenPunctuation">}</span><br><span class="CertTheme__tokenPunctuation">}</span></pre></div></div><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><b><strong class="CertTheme__textBold">The output is as follows:</strong></b></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-ktkxwkci4" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm"><span>$javac Example</span><span class="CertTheme__tokenPunctuation">.</span><span>java</span><br><span>$java </span><span class="CertTheme__tokenOperator">-</span><span>Xmx128M </span><span class="CertTheme__tokenOperator">-</span><span>Xms16M Example</span><br><span>Encoder Output </span><span class="CertTheme__tokenOperator">:</span><span> RW5jb2RpbmcgaW4gQmFzZTY0</span><br><span>Decoder Output </span><span class="CertTheme__tokenOperator">:</span><span> Encoding </span><span class="CertTheme__tokenAttr">in</span><span> Base64</span></pre></div></div><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><br></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">19. Create a module in Java 9</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p>A self-explanatory collection of code and resources is called a Module. It adds a higher level of hierarchy above packages. A module is basically a uniquely named, reclaimable group of related packages, as well as resources (such as images and XML files) and a module descriptor.</p><p>Without further ado, let us go on and see the Steps to create a module in Java 9.</p><p>Let the name of our module be examplemodule.<br><strong>Step 1:&nbsp;</strong>Create a folder:</p><p>C:\&gt;Java\src&nbsp;</p><p>The same folder is visible here:</p><p><img alt="js file" loading="lazy" width="100" height="100" decoding="async"  class="fr-fic fr-dib" style="color:transparent;width:100%;height:auto;background-size:cover;background-position:50% 50%;background-repeat:no-repeat;background-image:url(&quot;data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http%3A//www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cfilter id='b' color-interpolation-filters='sRGB'%3E%3CfeGaussianBlur stdDeviation='20'/%3E%3C/filter%3E%3Cimage preserveAspectRatio='none' filter='url(%23b)' x='0' y='0' height='100%25' width='100%25' href='data:image/svg+xml;base64,CiAgPHN2ZyB3aWR0aD0iMTAwIiBoZWlnaHQ9IjEwMCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIj4KICAgIDxkZWZzPgogICAgICA8bGluZWFyR3JhZGllbnQgaWQ9ImciPgogICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNjY2MiIG9mZnNldD0iMjAlIiAvPgogICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNkZGQiIG9mZnNldD0iNTAlIiAvPgogICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNlZWUiIG9mZnNldD0iNzAlIiAvPgogICAgICA8L2xpbmVhckdyYWRpZW50PgogICAgPC9kZWZzPgogICAgPHJlY3Qgd2lkdGg9IjEwMCIgaGVpZ2h0PSIxMDAiIGZpbGw9IiNlZWUiIC8+CiAgICA8cmVjdCBpZD0iciIgd2lkdGg9IjEwMCIgaGVpZ2h0PSIxMDAiIGZpbGw9InVybCgjZykiIC8+CiAgICA8YW5pbWF0ZSB4bGluazpocmVmPSIjciIgYXR0cmlidXRlTmFtZT0ieCIgZnJvbT0iLTEwMCIgdG89IjEwMCIgZHVyPSIxcyIgcmVwZWF0Q291bnQ9ImluZGVmaW5pdGUiICAvPgogIDwvc3ZnPg=='/%3E%3C/svg%3E&quot;)" sizes="(min-width: 767px) 50vw, 100vw" srcSet="" src="https://images.unsplash.com/photo-1517048676732-dce42f022dc7?ixlib=rb-4.0.3&auto=format&fit=crop&w=1000&q=80"></p><p>Create a folder named <strong>examplemodule</strong> inside the <strong>src</strong> folder:&nbsp;</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-2ewu0ywih" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">C:\Java\src\examplemodule</pre></div></div><p>The screenshot displays the same path:</p><p><img alt="js file" loading="lazy" width="100" height="100" decoding="async"  class="fr-fic fr-dib" style="color:transparent;width:100%;height:auto;background-size:cover;background-position:50% 50%;background-repeat:no-repeat;background-image:url(&quot;data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http%3A//www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cfilter id='b' color-interpolation-filters='sRGB'%3E%3CfeGaussianBlur stdDeviation='20'/%3E%3C/filter%3E%3Cimage preserveAspectRatio='none' filter='url(%23b)' x='0' y='0' height='100%25' width='100%25' href='data:image/svg+xml;base64,CiAgPHN2ZyB3aWR0aD0iMTAwIiBoZWlnaHQ9IjEwMCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIj4KICAgIDxkZWZzPgogICAgICA8bGluZWFyR3JhZGllbnQgaWQ9ImciPgogICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNjY2MiIG9mZnNldD0iMjAlIiAvPgogICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNkZGQiIG9mZnNldD0iNTAlIiAvPgogICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNlZWUiIG9mZnNldD0iNzAlIiAvPgogICAgICA8L2xpbmVhckdyYWRpZW50PgogICAgPC9kZWZzPgogICAgPHJlY3Qgd2lkdGg9IjEwMCIgaGVpZ2h0PSIxMDAiIGZpbGw9IiNlZWUiIC8+CiAgICA8cmVjdCBpZD0iciIgd2lkdGg9IjEwMCIgaGVpZ2h0PSIxMDAiIGZpbGw9InVybCgjZykiIC8+CiAgICA8YW5pbWF0ZSB4bGluazpocmVmPSIjciIgYXR0cmlidXRlTmFtZT0ieCIgZnJvbT0iLTEwMCIgdG89IjEwMCIgZHVyPSIxcyIgcmVwZWF0Q291bnQ9ImluZGVmaW5pdGUiICAvPgogIDwvc3ZnPg=='/%3E%3C/svg%3E&quot;)" sizes="(min-width: 767px) 50vw, 100vw" srcSet="" src="https://images.unsplash.com/photo-1517048676732-dce42f022dc7?ixlib=rb-4.0.3&auto=format&fit=crop&w=1000&q=80"></p><p><strong>Step 2:&nbsp;</strong>Create a module-info.java file in the <strong>C:\&gt;Java\src\examplemodule</strong> folder with following code:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-la4evlau0" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">module examplemodule{ &nbsp;}</pre></div></div><p>The screenshot:</p><p><img alt="js file" loading="lazy" width="100" height="100" decoding="async"  class="fr-fic fr-dib" style="color:transparent;width:100%;height:auto;background-size:cover;background-position:50% 50%;background-repeat:no-repeat;background-image:url(&quot;data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http%3A//www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cfilter id='b' color-interpolation-filters='sRGB'%3E%3CfeGaussianBlur stdDeviation='20'/%3E%3C/filter%3E%3Cimage preserveAspectRatio='none' filter='url(%23b)' x='0' y='0' height='100%25' width='100%25' href='data:image/svg+xml;base64,CiAgPHN2ZyB3aWR0aD0iMTAwIiBoZWlnaHQ9IjEwMCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIj4KICAgIDxkZWZzPgogICAgICA8bGluZWFyR3JhZGllbnQgaWQ9ImciPgogICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNjY2MiIG9mZnNldD0iMjAlIiAvPgogICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNkZGQiIG9mZnNldD0iNTAlIiAvPgogICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNlZWUiIG9mZnNldD0iNzAlIiAvPgogICAgICA8L2xpbmVhckdyYWRpZW50PgogICAgPC9kZWZzPgogICAgPHJlY3Qgd2lkdGg9IjEwMCIgaGVpZ2h0PSIxMDAiIGZpbGw9IiNlZWUiIC8+CiAgICA8cmVjdCBpZD0iciIgd2lkdGg9IjEwMCIgaGVpZ2h0PSIxMDAiIGZpbGw9InVybCgjZykiIC8+CiAgICA8YW5pbWF0ZSB4bGluazpocmVmPSIjciIgYXR0cmlidXRlTmFtZT0ieCIgZnJvbT0iLTEwMCIgdG89IjEwMCIgZHVyPSIxcyIgcmVwZWF0Q291bnQ9ImluZGVmaW5pdGUiICAvPgogIDwvc3ZnPg=='/%3E%3C/svg%3E&quot;)" sizes="(min-width: 767px) 50vw, 100vw" srcSet="" src="https://images.unsplash.com/photo-1517048676732-dce42f022dc7?ixlib=rb-4.0.3&auto=format&fit=crop&w=1000&q=80"></p><p><strong>Step 3:&nbsp;</strong>Create a file Example.java in the <strong>C:\Java\src\examplemodule&nbsp;</strong>folder.</p><p>The file has the following source code:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-zimji09gq" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">package examplemodule;
public class Example
{
&nbsp;public static void main(String[] args)
&nbsp;{
&nbsp; System.out.println("Welcome to Java 9");
&nbsp; }
}</pre></div></div><p><strong>Step 4:&nbsp;</strong>Create a folder <strong>C:\Java\mods</strong>.</p><p><img alt="js file" loading="lazy" width="100" height="100" decoding="async"  class="fr-fic fr-dib" style="color:transparent;width:100%;height:auto;background-size:cover;background-position:50% 50%;background-repeat:no-repeat;background-image:url(&quot;data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http%3A//www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cfilter id='b' color-interpolation-filters='sRGB'%3E%3CfeGaussianBlur stdDeviation='20'/%3E%3C/filter%3E%3Cimage preserveAspectRatio='none' filter='url(%23b)' x='0' y='0' height='100%25' width='100%25' href='data:image/svg+xml;base64,CiAgPHN2ZyB3aWR0aD0iMTAwIiBoZWlnaHQ9IjEwMCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIj4KICAgIDxkZWZzPgogICAgICA8bGluZWFyR3JhZGllbnQgaWQ9ImciPgogICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNjY2MiIG9mZnNldD0iMjAlIiAvPgogICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNkZGQiIG9mZnNldD0iNTAlIiAvPgogICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNlZWUiIG9mZnNldD0iNzAlIiAvPgogICAgICA8L2xpbmVhckdyYWRpZW50PgogICAgPC9kZWZzPgogICAgPHJlY3Qgd2lkdGg9IjEwMCIgaGVpZ2h0PSIxMDAiIGZpbGw9IiNlZWUiIC8+CiAgICA8cmVjdCBpZD0iciIgd2lkdGg9IjEwMCIgaGVpZ2h0PSIxMDAiIGZpbGw9InVybCgjZykiIC8+CiAgICA8YW5pbWF0ZSB4bGluazpocmVmPSIjciIgYXR0cmlidXRlTmFtZT0ieCIgZnJvbT0iLTEwMCIgdG89IjEwMCIgZHVyPSIxcyIgcmVwZWF0Q291bnQ9ImluZGVmaW5pdGUiICAvPgogIDwvc3ZnPg=='/%3E%3C/svg%3E&quot;)" sizes="(min-width: 767px) 50vw, 100vw" srcSet="" src="https://images.unsplash.com/photo-1517048676732-dce42f022dc7?ixlib=rb-4.0.3&auto=format&fit=crop&w=1000&q=80"></p><p>Create a folder name <strong>examplemodule&nbsp;</strong>in the mods folder. This is the same as the name of the module we have created.</p><p><img alt="js file" loading="lazy" width="100" height="100" decoding="async"  class="fr-fic fr-dib" style="color:transparent;width:100%;height:auto;background-size:cover;background-position:50% 50%;background-repeat:no-repeat;background-image:url(&quot;data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http%3A//www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cfilter id='b' color-interpolation-filters='sRGB'%3E%3CfeGaussianBlur stdDeviation='20'/%3E%3C/filter%3E%3Cimage preserveAspectRatio='none' filter='url(%23b)' x='0' y='0' height='100%25' width='100%25' href='data:image/svg+xml;base64,CiAgPHN2ZyB3aWR0aD0iMTAwIiBoZWlnaHQ9IjEwMCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIj4KICAgIDxkZWZzPgogICAgICA8bGluZWFyR3JhZGllbnQgaWQ9ImciPgogICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNjY2MiIG9mZnNldD0iMjAlIiAvPgogICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNkZGQiIG9mZnNldD0iNTAlIiAvPgogICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNlZWUiIG9mZnNldD0iNzAlIiAvPgogICAgICA8L2xpbmVhckdyYWRpZW50PgogICAgPC9kZWZzPgogICAgPHJlY3Qgd2lkdGg9IjEwMCIgaGVpZ2h0PSIxMDAiIGZpbGw9IiNlZWUiIC8+CiAgICA8cmVjdCBpZD0iciIgd2lkdGg9IjEwMCIgaGVpZ2h0PSIxMDAiIGZpbGw9InVybCgjZykiIC8+CiAgICA8YW5pbWF0ZSB4bGluazpocmVmPSIjciIgYXR0cmlidXRlTmFtZT0ieCIgZnJvbT0iLTEwMCIgdG89IjEwMCIgZHVyPSIxcyIgcmVwZWF0Q291bnQ9ImluZGVmaW5pdGUiICAvPgogIDwvc3ZnPg=='/%3E%3C/svg%3E&quot;)" sizes="(min-width: 767px) 50vw, 100vw" srcSet="" src="https://images.unsplash.com/photo-1517048676732-dce42f022dc7?ixlib=rb-4.0.3&auto=format&fit=crop&w=1000&q=80"></p><p>Now compile the module to mods directory</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-rfyt2k8xb" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">C:\Java&gt; javac -d mods/examplemodule src/examplemodule/module-info.java src/examplemodule/Example.java</pre></div></div><p><img alt="Image" loading="lazy" width="100" height="100" decoding="async"  class="fr-fic fr-dib" style="color:transparent;width:100%;height:auto;background-size:cover;background-position:50% 50%;background-repeat:no-repeat;background-image:url(&quot;data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http%3A//www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cfilter id='b' color-interpolation-filters='sRGB'%3E%3CfeGaussianBlur stdDeviation='20'/%3E%3C/filter%3E%3Cimage preserveAspectRatio='none' filter='url(%23b)' x='0' y='0' height='100%25' width='100%25' href='data:image/svg+xml;base64,CiAgPHN2ZyB3aWR0aD0iMTAwIiBoZWlnaHQ9IjEwMCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIj4KICAgIDxkZWZzPgogICAgICA8bGluZWFyR3JhZGllbnQgaWQ9ImciPgogICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNjY2MiIG9mZnNldD0iMjAlIiAvPgogICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNkZGQiIG9mZnNldD0iNTAlIiAvPgogICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNlZWUiIG9mZnNldD0iNzAlIiAvPgogICAgICA8L2xpbmVhckdyYWRpZW50PgogICAgPC9kZWZzPgogICAgPHJlY3Qgd2lkdGg9IjEwMCIgaGVpZ2h0PSIxMDAiIGZpbGw9IiNlZWUiIC8+CiAgICA8cmVjdCBpZD0iciIgd2lkdGg9IjEwMCIgaGVpZ2h0PSIxMDAiIGZpbGw9InVybCgjZykiIC8+CiAgICA8YW5pbWF0ZSB4bGluazpocmVmPSIjciIgYXR0cmlidXRlTmFtZT0ieCIgZnJvbT0iLTEwMCIgdG89IjEwMCIgZHVyPSIxcyIgcmVwZWF0Q291bnQ9ImluZGVmaW5pdGUiICAvPgogIDwvc3ZnPg=='/%3E%3C/svg%3E&quot;)" sizes="(min-width: 767px) 50vw, 100vw" srcSet="" src="https://images.unsplash.com/photo-1581091226825-a6a2a5aee158?ixlib=rb-4.0.3&auto=format&fit=crop&w=1000&q=80"></p><p><strong>Step 5:&nbsp;</strong>Let us run the module by running the following command</p><p><strong>C:\Java&gt;java --module-path mods -m examplemodule/examplemodule.Example</strong></p><p>The <em>module-path</em> provides the module location as mods and -m signifies the main module.</p><p>The following is the output:</p><p><img alt="command box" loading="lazy" width="100" height="100" decoding="async"  class="fr-fic fr-dib" style="color:transparent;width:100%;height:auto;background-size:cover;background-position:50% 50%;background-repeat:no-repeat;background-image:url(&quot;data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http%3A//www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cfilter id='b' color-interpolation-filters='sRGB'%3E%3CfeGaussianBlur stdDeviation='20'/%3E%3C/filter%3E%3Cimage preserveAspectRatio='none' filter='url(%23b)' x='0' y='0' height='100%25' width='100%25' href='data:image/svg+xml;base64,CiAgPHN2ZyB3aWR0aD0iMTAwIiBoZWlnaHQ9IjEwMCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIj4KICAgIDxkZWZzPgogICAgICA8bGluZWFyR3JhZGllbnQgaWQ9ImciPgogICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNjY2MiIG9mZnNldD0iMjAlIiAvPgogICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNkZGQiIG9mZnNldD0iNTAlIiAvPgogICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNlZWUiIG9mZnNldD0iNzAlIiAvPgogICAgICA8L2xpbmVhckdyYWRpZW50PgogICAgPC9kZWZzPgogICAgPHJlY3Qgd2lkdGg9IjEwMCIgaGVpZ2h0PSIxMDAiIGZpbGw9IiNlZWUiIC8+CiAgICA8cmVjdCBpZD0iciIgd2lkdGg9IjEwMCIgaGVpZ2h0PSIxMDAiIGZpbGw9InVybCgjZykiIC8+CiAgICA8YW5pbWF0ZSB4bGluazpocmVmPSIjciIgYXR0cmlidXRlTmFtZT0ieCIgZnJvbT0iLTEwMCIgdG89IjEwMCIgZHVyPSIxcyIgcmVwZWF0Q291bnQ9ImluZGVmaW5pdGUiICAvPgogIDwvc3ZnPg=='/%3E%3C/svg%3E&quot;)" sizes="(min-width: 767px) 50vw, 100vw" srcSet="" src="https://images.unsplash.com/photo-1517694712202-14dd9538aa97?ixlib=rb-4.0.3&auto=format&fit=crop&w=1000&q=80"></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">20. Private Interface Methods in Java 9</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>Java 9 introduced private methods and private static methods. An interface can now have six features. The features are as follows:</p><ul><li class="CertTheme__listItem pt-spacing10">Constant variables</li><li class="CertTheme__listItem pt-spacing10">Default methods</li><li class="CertTheme__listItem pt-spacing10">Static methods</li><li class="CertTheme__listItem pt-spacing10">Abstract methods</li><li class="CertTheme__listItem pt-spacing10">Private methods</li><li class="CertTheme__listItem pt-spacing10">Private Static methods</li></ul><p>The private methods increase reusability of code within interfaces. Their scope is limited to the interface itself and cannot be called or accessed outside the interface.</p><p>An example to show private methods in interfaces is as follows:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-bdrg1qixg" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">public interface MethodInterface
{
&nbsp; &nbsp;public abstract void m1();
&nbsp; &nbsp;public default void m2()
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;m4(); //private method inside default method
&nbsp; &nbsp; &nbsp; &nbsp;m5(); //static method inside other non-static method
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println("This is a default method");
&nbsp; &nbsp;}
&nbsp; &nbsp;public static void m3()
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println("This is a static method");
&nbsp; &nbsp;}
&nbsp; &nbsp;private void m4()
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println("This is a private method");
&nbsp; &nbsp;}
&nbsp; &nbsp;private static void m5()
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println("This is a private static method");
&nbsp; &nbsp;}
}
public class Example implements MethodInterface
{
&nbsp; &nbsp;@Override
&nbsp; &nbsp;public void m1()
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println("This is an abstract method");
&nbsp; &nbsp;}
&nbsp; &nbsp;public static void main(String[] args)
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;MethodInterface obj = new Example();
&nbsp; &nbsp; &nbsp; &nbsp;obj.m1();
&nbsp; &nbsp; &nbsp; &nbsp;obj.m2();
&nbsp; &nbsp; &nbsp; &nbsp;MethodInterface.m3();
&nbsp; &nbsp;}</pre></div></div><p><strong>The output is as follows:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-t1a5op5if" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">This is an abstract method
This is a private method
This is a private static method
This is a default method
This is a static method</pre></div></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">21. Stream API improvements in Java 9</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>When Java 9 burst onto the scene, it brought with it some improvements in Stream API. Quite a few methods were added to the Stream Interface. Let us have a look at some of them.</p><ul><li class="CertTheme__listItem pt-spacing10"><strong>takewhile(Predicate)</strong></li></ul><p>takewhile() method accepts all values until the predicate returns false. If a stream is ordered, takewhile() returns a stream consisting the longest prefix of elements taken from this stream that match the predicate. If the stream is unordered, the method returns a stream consisting of a subset of elements extracted from this stream that match the given predicate.</p><p><strong>The syntax:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-741nitzhg" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">default Stream&lt;T&gt; takeWhile(Predicate&lt;? super T&gt; predicate)</pre></div></div><p>Let us see an example of the takeWhile() method:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-9re0dp3l3" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">import java.util.stream.Stream;
public class Example
{
&nbsp; public static void main(String[] args)
&nbsp; {
&nbsp; &nbsp; &nbsp;Stream.of("y","a","m","","u","f").takeWhile(o-&gt;!o.isEmpty()).forEach(System.out::print);
&nbsp; }
}</pre></div></div><p>The takeWhile() method accepts all y, a, and m and then once it finds the String to be empty, it stops its execution.</p><p><strong>The output is as follows:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-pzup4h4qq" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">$javac Example.java
$java Example
yam</pre></div></div><ul><li class="CertTheme__listItem pt-spacing10"><strong>dropWhile(Predicate)</strong></li></ul><p>The dropWhile() method drops all the value until it matches with the predicate. After that, it starts to accept values. The dropWhile() method returns the remaining stream after matching the predicate if the stream is ordered. When the stream is unordered , it returns a stream consisting of the remaining elements of this stream after dropping a subset of elements that match the given predicate.</p><p><strong>The syntax:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-mx6l2ft7i" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">default Stream &lt;T&gt; dropWhile(Predicate&lt;? super T&gt; predicate)</pre></div></div><p>Let us see a program showing the use of the dropWhile() method:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-zcihug038" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">import java.util.stream.Stream;
public class Example
{
&nbsp; public static void main(String[] args)
&nbsp; {
&nbsp; &nbsp; &nbsp;Stream.of("y","a","m","","u","f").dropWhile(o-&gt;!o.isEmpty()).forEach(System.out::print);
&nbsp; &nbsp; &nbsp;Stream.of("y","","m","","u","f").dropWhile(o-&gt;!o.isEmpty()).forEach(System.out::print);
&nbsp; }
}</pre></div></div><p>dropWhile() method for the first sequence drops y,a,m values, then once string is empty, it takes all the values. dropWhile() method for the first sequence drops y values, then once string is empty, it takes all the values.</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-vaxn6eixv" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">$javac Example.java
$java Example
uf
muf</pre></div></div><ul><li class="CertTheme__listItem pt-spacing10"><strong>iterate()&nbsp;</strong></li></ul><p>The iterate() method has hasNext predicate as argument which terminates the loop once hasNext predicate returns false. It takes three arguments, seed, hasNext and next.</p><p><strong>The syntax:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-xtu2pls7c" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">static &lt;T&gt; Stream&lt;T&gt; iterate(T seed, Predicate&lt;? super T&gt; hasNext,UnaryOperator&lt;T&gt;next)</pre></div></div><p>Let us see an example of the iterator method:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-6gwm8u3wd" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">import java.util.stream.Stream; &nbsp; &nbsp;
public class Example
{ &nbsp;
&nbsp; &nbsp;public static void main(String[] args)
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;Stream.iterate(1, i -&gt; i &lt;= 10, i -&gt; i*2).forEach(System.out::println); &nbsp;
&nbsp; &nbsp;}
}</pre></div></div><p><strong>The output is as follows:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-bq48bydj9" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">$javac Example.java
$java Example
1
2
4
8
10</pre></div></div><ul><li class="CertTheme__listItem pt-spacing10"><strong>ofNullable()</strong></li></ul><p>The ofNullable prevents Null pointer exceptions and prevents null checks for streams. It returns a sequential stream that contains a single element, if non-null. Otherwise, it returns an empty stream.</p><p>The syntax:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-vsk5rdinb" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">static &lt;T&gt; Stream&lt;T&gt; ofNullable(T t)</pre></div></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">22. Can Java static methods be overridden?</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p>Java static methods cannot be overridden.</p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">23. Java 9 Inner Class Diamond Operator</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>The purpose of the diamond operator was to increase reusability of code, avoid redundant code which was achieved by leaving the generic type on the right side of the expression.</p><p>There was a certain problem with the diamond operator as it couldn’t be used with anonymous inner classes. Java 9 enhanced the diamond operator so that it could be used with anonymous inner classes.</p><p>Let us look at an example of diamond operator with anonymous inner class</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-cq6g48lll" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">abstract class ABC&lt;T&gt;
{ &nbsp;
&nbsp; &nbsp;abstract T dif(T t1, T t2); &nbsp;
} &nbsp;
public class Example
{ &nbsp;
&nbsp; &nbsp;public static void main(String[] args)
&nbsp; {
&nbsp; &nbsp; &nbsp; &nbsp;MyClass&lt;Integer&gt; obj = new MyClass&lt;&gt;()
&nbsp; &nbsp; &nbsp; {
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Integer dif(Integer a, Integer b)
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return a-b;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}
&nbsp; &nbsp; &nbsp; &nbsp;};
&nbsp; &nbsp; &nbsp; &nbsp;Integer dif = obj.dif(10,90); &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println(dif); &nbsp;
&nbsp; &nbsp;}
}</pre></div></div><p><strong>The output is as follows:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-uvux42prk" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">$javac Example.java
$java Example
-80</pre></div></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">24. Java 9 collection Factory Methods</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>Before Java 9, we had to add data to Set and List separately and then Map them. Java 9 added methods to List, Set and Map along with their overloaded counterparts.</p><p>Some of the Collection Objects have the following factory methods:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-sd3emb4cc" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">static &lt;E&gt; List&lt;T&gt; of(T l1, T l2, T l3); &nbsp;
static &lt;E&gt; Set&lt;T&gt; &nbsp;of(T s1, T s2, T s3);
static &lt;K,V&gt; Map&lt;K,V&gt; of(K k1, V v1, K k2, V v2, K k3, V v3);
static &lt;K,V&gt; Map&lt;K,V&gt; ofEntries(Map.Entry&lt;? extends K,? extends V&gt;... entries)</pre></div></div><p>The of(...) method is overloaded to have 0-10 parameters and one with variable var args parameter for Set and Map interfaces and is overloaded to have 0-10 parameters for Map interface. When there are more than 10 parameters for a Map Interface, ofEntries() method is used to accept var args parameter.</p><p>Let us see an example showing the use of Collection Factory Methods:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-b6857v5ja" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
public class Example
{
&nbsp; public static void main(String []args)
&nbsp; {
&nbsp; &nbsp; &nbsp;Set&lt;String&gt; set = Set.of("S", "E", "T"); &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp;System.out.println(set);
&nbsp; &nbsp; &nbsp;List&lt;String&gt; list = List.of("L", "I", "S","T");
&nbsp; &nbsp; &nbsp;System.out.println(list);
&nbsp; &nbsp; &nbsp;Map&lt;String, String&gt; map = Map.of("M","m","A","a","P","p");
&nbsp; &nbsp; &nbsp;System.out.println(map);
&nbsp; }
}</pre></div></div><p><strong>The output is as follows</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-j54ailpr3" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">[S, E , T]
[L, I, S, T]
{M=m, A=a, P=p</pre></div></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">25. CompletableFuture API enhancements in Java 9</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p>In Java 9, the CompletableFuture API has been further developed. Some of the changes done to the API are:</p><ul><li class="CertTheme__listItem pt-spacing10">Support for timeouts and delays</li><li class="CertTheme__listItem pt-spacing10">Improved support for subclassing</li><li class="CertTheme__listItem pt-spacing10">Addition of new factory methods</li></ul><p><strong>Support for timeouts and delays</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-fwv13zuyy" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">public CompletableFuture&lt;T&gt; completeOnTimeout(T value, long timeout, TimeUnit unit)</pre></div></div><p>This method completes the CompletableFuture with the provided value. If not, it completes it before the given timeout.</p><p><strong>Improved support for subclassing</strong></p><p>public Executor defaultExecutor()</p><p>It returns the default Executor used for async methods that do not show an Executor. This method may be overridden in subclasses to return an Executor to give at least one independent thread</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-ib9pdah7s" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">public &lt;U&gt; CompletableFuture&lt;U&gt; newIncompleteFuture()</pre></div></div><p>It returns a new incomplete CompletableFuture of the specification to be returned by a CompletionStage method.</p><p><strong>New factory Methods</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-36np6fpel" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">public static &lt;U&gt; CompletableFuture&lt;U&gt; completedFuture(U value)</pre></div></div><p>This factory method returns a new CompletableFuture which is already accomplished with the provided value.</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-t2kjo7o87" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">public static &lt;U&gt; CompletionStage&lt;U&gt; completedStage(U value)</pre></div></div><p>This factory method returns a new CompletionStage which is accomplished beforehand with the provided value and is compatible with only those methods available in interface CompletionStage.</p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">26. Convert an UNSIGNED byte to Java type</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>When a byte is converted to another data type, it is always considered to be signed. In order for unsigned byte conversion, we must mask it to Java and cast it to an integer.</p><p>Firstly, we declare three byte values b1, b2 and b3 and assign them values in the range of -128 to 127. Then we cast the value to an integer and use a logical &amp; operator with 0xFF which represents the hexadecimal number having integer value 255 or has binary representation as 00000000000000000000000011111111 (under the 32-bit integer) and it along with the bitwise effectively masks the variable leaving its values in the last 8 bits and ignores the other values as the other bits become 0.Thus &amp; 0xff is used for masking variables.</p><p>Let us see how an unsigned byte is converted to a Java type:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-370ao792m" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">import java.util.*;
public class Example
{
&nbsp; public static void main(String[] args)
&nbsp; {
&nbsp; &nbsp; &nbsp;byte b1 = 127;
&nbsp; &nbsp; &nbsp;byte b2 = -128;
&nbsp; &nbsp; &nbsp;byte b3 = -1;
&nbsp; &nbsp; &nbsp;System.out.print(b1+" : ");
&nbsp; &nbsp; &nbsp;System.out.println((int) b1 &amp; 0xFF);
&nbsp; &nbsp; &nbsp;System.out.print(b2+" : ");
&nbsp; &nbsp; &nbsp;System.out.println((int) b2 &amp; 0xFF);
&nbsp; &nbsp; &nbsp;System.out.print(b3+" : ");
&nbsp; &nbsp; &nbsp;System.out.println((int) b3 &amp; 0xFF);
&nbsp; }
}</pre></div></div><p><strong>The output is as follows:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-4hqjde6xi" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">$javac Example.java
$java &nbsp;Example
127 : 127
-128 : 128
-1 : 255</pre></div></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">27. Execute a Java Program without main() method</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p>A Java program can be compiled and executed without main method if we use the static block having System.exit(0); statement at the end which terminates the program before JVM starts looking for main method. However, this is only possible upto Java 6 .</p><p>Let us see how to execute a Java program without the main() method</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-sv736d276" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">public class Example
{
static
{
&nbsp;System.out.println("Hello World");
&nbsp;System.exit(0);
}
}</pre></div></div><p>Upto Java 6, the output would be as follows:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-epebzcaux" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">$javac Example.java
$java Example
Hello World</pre></div></div><p>Java 7 onwards, the program gets compiled but will not get executed and will show an error message as.</p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">28. Constructor chaining with this keyword</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>Constructor chaining in Java is the process of calling one constructor with the help of another while considering the current object.</p><p>It can be done in 2 ways –</p><ul><li class="CertTheme__listItem pt-spacing10"><strong>Within same class</strong>: It can be done using this() keyword for constructors in the same class.</li><li class="CertTheme__listItem pt-spacing10"><strong>From base class</strong>: By using super() keyword to call a constructor from the base class.</li></ul><p>Here we will take a look at how constructor chaining is done with this keyword</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-ecy0zifca" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">public class Example
{
Example()
{
&nbsp; this(10);
&nbsp;System.out.println("Default constructor");
}
Example(int x)
{
&nbsp;this(7, 9);
&nbsp;System.out.println("Parameterized Constructor having parameter :"+x);
}
Example(int a, int b)
{
&nbsp; &nbsp; this(10,3,4);
&nbsp;System.out.println("Parameterized Constructor having parameters :"+a+","+b);
}
Example(int a, int b, int c)
{
&nbsp;System.out.println("Parameterized Constructor having parameters :"+a+","+b+","+c);
}
public static void main(String args[])
{
&nbsp;new Example();
}
}</pre></div></div><p><strong>The output is as follows:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-wdubxddl9" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">$javac Example.java
$java Example
Parameterized Constructor having parameters :10,3,4
Parameterized Constructor having parameters :7,9
Parameterized Constructor having parameter :10
Default constructor</pre></div></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">29. When to use ArrayList and LinkedList in Java?</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>The List interface is implemented using the ArrayList and the LinkedList. The ArrayList implements a dynamically resized array while the LinkedList implements a doubly linked list. So ArrayList or LinkedList in Java should be selected according to the implementations required. Also the differences between both of these are provided to make the selection easily.</p><p><strong>Some of the differences between Arraylist and LinkedList are given as follows:</strong></p><ol class="CertTheme__ol1 pt-spacing10"><li class="CertTheme__listItem pt-spacing10">The time required to find if an element is available in both ArrayList and LinkedList is O(n) in the worst case. But binary search can be used on a sorted ArrayList to reduce this time to O(log n).</li><li class="CertTheme__listItem pt-spacing10">It is easier and much faster to insert elements in LinkedList as compared to ArrayList. The time complexity for insertion in ArrayList is O(n) in worst case while it is O(1) in LinkedList.</li><li class="CertTheme__listItem pt-spacing10">Deletion of elements is also easier in LinkedList as compared to ArrayList. However the time complexity for deletion in ArrayList and LinkedList is O(n) in worst case.</li><li class="CertTheme__listItem pt-spacing10">There is more memory overhead in LinkedList as compared to ArrayList. This is because in LinkedList each node contains the data and address of the previous and next nodes while in ArrayList each index contains the data only.</li></ol><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">30. New features in Java 10</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p>Java 10 is the fastest release of a Java version till date. It has many important features with multiple changes that have a far-reaching impact. Some of the new features of Java 10 are given as follows:</p><p><strong>1. Experimental Java Based JIT Compiler (JEP 317)</strong></p><p>A new Java based JIT compiler is introduced by this JEP that is the basis of an experimental AOT(Ahead of Time) compiler.</p><p><strong>2. Time-Based Release Versioning (JEP 322)</strong></p><p>The version string scheme of the JDK and the Java SE platform can be revised using this JEP.</p><p><strong>3. Remove the Native Header Generation Tool (JEP 313)</strong></p><p>There is no separate tool in Java 10 to generate header files when compiling the JNI code. This was done as the above process can already be performed using javac.</p><p><strong>4. Garbage Collector Interface (JEP 304)</strong></p><p>The code isolation of different garbage collectors is increased and a clean interface is introduced by this JEP.</p><p><strong>5. Parallel Full GC for G1 (JEP 307)</strong></p><p>The full GC algorithm is parallelized with the JEP 307. This is done so that the same number of threads can be used in the event of a G1 full GC as are used in the concurrent collections.</p><p><strong>6. Heap Allocation on Alternative Memory Devices (JEP 316)</strong></p><p>The Java object heap is allocated by the HotSpot VM on an alternate memory device that is specified by the user.</p><p><strong>7. Consolidate the JDK Forest into a Single Repository (JEP 296)</strong></p><p>The multiple repositories of the JDK forest are combined into a single repository using this JEP.</p><p><strong>8. Root Certificates (JEP 319)</strong></p><p>A default set of root certification authority is provided by the JEP 319 that makes openJDK builds more attractive for developers.</p><p><strong>9. Local Variable Type Inference (JEP 286)</strong></p><p>Some of the strict type declaration is removed to improve the developer experience. This means that the compiler can infer the type using only var.</p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">31. Check if two strings are anagrams of each other in Java</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>An anagram of a string is a string that has the same characters with the same frequency. Only the character order can be different. An example of a anagram is given as follows:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-mh7rh7o9l" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">String = silent
Anagram = listen</pre></div></div><p>A program that checks if two strings are anagrams of each other in Java is given as follows:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-kajdmq56z" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">import java.io.*;
import java.util.*;
public class Demo
{
&nbsp; &nbsp;static boolean checkAnagram(char s1[], char s2[])
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;int alphaCount1[] = new int [256];
&nbsp; &nbsp; &nbsp; &nbsp;Arrays.fill(alphaCount1, 0);
&nbsp; &nbsp; &nbsp; &nbsp;int alphaCount2[] = new int [256];
&nbsp; &nbsp; &nbsp; &nbsp;Arrays.fill(alphaCount2, 0);
&nbsp; &nbsp; &nbsp; &nbsp;int i;
&nbsp; &nbsp; &nbsp; &nbsp;for (i = 0; i &lt;s1.length &amp;&amp; i &lt; s2.length ; i++)
&nbsp; &nbsp; &nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;alphaCount1[s1[i]]++;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;alphaCount2[s2[i]]++;
&nbsp; &nbsp; &nbsp; &nbsp;}
&nbsp; &nbsp; &nbsp; &nbsp;if (s1.length != s2.length)
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return false;
&nbsp; &nbsp; &nbsp; &nbsp;for (i = 0; i &lt; 256; i++)
&nbsp; &nbsp; &nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (alphaCount1[i] != alphaCount2[i])
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return false;
&nbsp; &nbsp; &nbsp; &nbsp;}
&nbsp; &nbsp; &nbsp; &nbsp;return true;
&nbsp; &nbsp;}
&nbsp; &nbsp;public static void main(String args[])
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;String str1 = "triangle";
&nbsp; &nbsp; &nbsp; &nbsp;String str2 = "integral";
&nbsp; &nbsp; &nbsp; &nbsp;char s1[] = str1.toCharArray();
&nbsp; &nbsp; &nbsp; &nbsp;char s2[] = str2.toCharArray();
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println("String 1: " + str1 );
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println("String 2: " + str2 );
&nbsp; &nbsp; &nbsp; &nbsp;if ( checkAnagram(s1, s2) )
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;System.out.println("The two strings are anagram of each other");
&nbsp; &nbsp; &nbsp; &nbsp;else
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;System.out.println("The two strings are not anagram of each other");
&nbsp; &nbsp;}
}</pre></div></div><p><strong>The output of the above program is as follows:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-j5p928k4s" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">String 1: triangle
String 2: integral
The two strings are anagram of each other</pre></div></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">32. Check for underflow in Java</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>When a value is assigned to a variable that is less than the minimum allowed value for that variable, then underflow occurs. There is no exception thrown by the JVM if an underflow occurs and it is the responsibility of the programmer to handle the underflow condition.</p><p>A program that checks for underflow in Java is given as follows:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-a8d9x1w5f" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">public class Demo
{
&nbsp; public static void main(String[] args)
&nbsp; {
&nbsp; &nbsp; &nbsp;int num1 = -2147483648;
&nbsp; &nbsp; &nbsp;int num2 = -1;
&nbsp; &nbsp; &nbsp;System.out.println("Number 1: " + num1);
&nbsp; &nbsp; &nbsp;System.out.println("Number 2: " + num2);
&nbsp; &nbsp; &nbsp;long sum = (long)num1 + (long)num2;
&nbsp; &nbsp; &nbsp;if (sum &lt; Integer.MIN_VALUE)
&nbsp; &nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp; throw new ArithmeticException("Underflow occurred!");
&nbsp; &nbsp; &nbsp;}
&nbsp; &nbsp; &nbsp;System.out.println("The sum of two numbers is: " + (int)sum);
&nbsp; }
}</pre></div></div><p><strong>The output of the above program is as follows:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-t3c6xop8z" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">Number 1: -2147483648
Number 2: -1
Exception in thread "main" java.lang.ArithmeticException: Underflow occurred!
at Demo.main(Demo.java:15)</pre></div></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">33. Compare sleep() and wait() methods in Java</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>The execution of a thread can be paused in a multithreading environment in Java using the sleep() or wait() methods. The thread is paused for the required time using sleep() while the thread goes into a wait state using wait() and can only be revived by calling notify() or notifyAll().</p><p>Some of the differences between sleep() and wait() are given as follows:</p><div class="overflow-x-auto mt-spacing10 mb-[16.8px] md:mb-6 max-w-full"><table class="min-w-full divide-y divide-gray-200 border"><thead><tr><th class="CertTheme__tableCell CertTheme__tableCellHeader" style="border:1px solid black;width:175px;vertical-align:top;text-align:start;background-color:rgb(242, 243, 245)">The sleep() method</th><th class="CertTheme__tableCell CertTheme__tableCellHeader" style="border:1px solid black;width:175px;vertical-align:top;text-align:start;background-color:rgb(242, 243, 245)">The wait() method</th></tr></thead><tbody><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">The sleep() method is always called on the thread that is currently executing.</td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">The wait() method is called on an object. The lock object must be synchronized with the current thread.</td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">The sleep() method does not release the monitor or the lock.</td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">The wait() method releases the monitor or the lock.</td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">The sleep() method is used to pause the execution for a given amount of time.</td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">The wait() method can be used for inter thread communication.</td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">The thread is woken up after the required time using sleep() or interrupt() is called.</td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">The thread is woken up after the notify() or notifyAll() methods are called by the object.</td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">The sleep() method can be used for multi thread synchronization.</td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">The wait() method can be used for time synchronization.</td></tr></tbody></table></div><p>An example of sleep() is given as follows:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-xfu6khj4a" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">synchronized(LOCK)
{ &nbsp;
&nbsp; &nbsp;Thread.sleep(1000);
}</pre></div></div><p>An example of wait() is given as follows:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-5htjka48h" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">synchronized(LOCK)
{ &nbsp;
&nbsp; &nbsp;LOCK.wait();
}</pre></div></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">34. Synchronization with respect to Java multi-threading</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>Multiple threads can manage their access to a shared resource using synchronization where only one thread accesses the resource at a time.</p><p>There are two types of thread synchronization in Java. These are given as follows:</p><ol class="CertTheme__ol1 pt-spacing10"><li class="CertTheme__listItem pt-spacing10">Mutual Exclusion</li><li class="CertTheme__listItem pt-spacing10">Inter thread Communication</li></ol><p>A program of thread synchronization is given as follows:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-90iinrrr1" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">class Demo
{ &nbsp;
synchronized void display(int n)
{
&nbsp; for(int i=1;i&lt;=5;i++)
&nbsp; {
&nbsp; &nbsp; System.out.println(n); &nbsp;
&nbsp; &nbsp; try
&nbsp; &nbsp; {
&nbsp; &nbsp; &nbsp; Thread.sleep(400);
&nbsp; &nbsp; }catch(Exception e){System.out.println(e);} &nbsp;
&nbsp; }
} &nbsp;
} &nbsp;
class Thread1 extends Thread
{ &nbsp;
&nbsp; Demo obj; &nbsp;
&nbsp; Thread1(Demo obj)
&nbsp; {
&nbsp; &nbsp; &nbsp; &nbsp;this.obj=obj; &nbsp;
&nbsp; }
&nbsp; public void run()
&nbsp; {
&nbsp; &nbsp; &nbsp; &nbsp;obj.display(8); &nbsp;
&nbsp; }
}
class Thread2 extends Thread
{ &nbsp;
&nbsp; Demo obj; &nbsp;&nbsp;
&nbsp; Thread2(Demo obj) &nbsp;
&nbsp; {
&nbsp; &nbsp; &nbsp; &nbsp;this.obj=obj;
&nbsp; }
&nbsp; public void run()
&nbsp; {
&nbsp; &nbsp; &nbsp; &nbsp;obj.display(3); &nbsp;
&nbsp; }
} &nbsp;
public class SynchronizationDemo
{
&nbsp; &nbsp;public static void main(String args[])
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;Demo obj1 = new Demo();
&nbsp; &nbsp; &nbsp; &nbsp;Thread1 thr1 = new Thread1(obj1); &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp;Thread2 thr2 = new Thread2(obj1); &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp;thr1.start(); &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp;thr2.start(); &nbsp;
&nbsp; &nbsp;}
} &nbsp;</pre></div></div><p><strong>The output of the above program is as follows:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-uigols9tn" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">8
8
8
8
8
3
3
3
3
3</pre></div></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">35. Shallow and Deep copy in Java</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p>Shallow copy and deep copy are related to the cloning process i.e. creating a copy of an object in Java. Details about the shallow and deep copy are given as follows:</p><p><strong>Shallow Copy in Java</strong></p><p>A shallow copy of an object is able to copy the main object but not the inner objects. This means that the original object the created copy shares the inner objects.</p><p>An example of this is given as follows:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-gh7w402gj" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">public class Employee
{
&nbsp; private Name name;
&nbsp; private DepartmentDetails dept;
&nbsp; public Employee(Employee emp)
&nbsp; {
&nbsp; &nbsp; &nbsp; &nbsp;this.name = emp.name;
&nbsp; &nbsp; &nbsp; &nbsp;this.dept = emp.dept;
&nbsp; }
.
.
.
}</pre></div></div><p>In the above example, if a shallow copy is created of an object of class Employee, then a second Employee is created but the Name and DepartmentDetails objects are shared by both the objects. So if changes are made to one of the objects, then they be reflected in the object created using a shallow copy.</p><p><strong>Deep Copy in Java</strong></p><p>The deep copy of an object is a fully independent copy and the whole object structure is copied when a new deep copy is created.</p><p>An example of this is given as follows:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-a5ub52lob" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">public class Employee
{
&nbsp; private Name name;
&nbsp; private DepartmentDetails dept;
&nbsp; public Employee(Employee emp)
&nbsp; {
&nbsp; &nbsp; &nbsp; &nbsp;this.name = emp.name;
&nbsp; &nbsp; &nbsp; &nbsp;this.dept = emp.dept;
&nbsp; }
.
.
.
}</pre></div></div><p>In the above example, if a deep copy is created of an object of class Employee then the whole object structure is copied and if changes are made to one of the objects, then they would not be reflected in the object created using a deep copy.</p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">36. Why do we need Wrapper classes in Java?</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>A wrapper class is a specific class whose object contains or wraps primitive data types. It can also be said that primitive data types are wrapped into an object of a wrapper class.</p><p>Some of the reasons the wrapper classes are required in Java are given as follows:</p><ol class="CertTheme__ol1 pt-spacing10"><li class="CertTheme__listItem pt-spacing10">The wrapper classes convert the primitive data types into objects. This is required if the arguments passed to the methods need to be modified as the primitive data types are passed by value.</li><li class="CertTheme__listItem pt-spacing10">Synchronization in multithreading is supported by objects and so wrapper classes may be required.</li><li class="CertTheme__listItem pt-spacing10">Only objects and not primitive types are stored in data structures such as ArrayList and Vector in the Collection framework.</li><li class="CertTheme__listItem pt-spacing10">Another use of wrapper classes is because the classes in the java.util package handle only objects.</li></ol><p>A list of all the primitive data types and the corresponding wrapper classes is given as follows:</p><div class="overflow-x-auto mt-spacing10 mb-[16.8px] md:mb-6 max-w-full"><table class="min-w-full divide-y divide-gray-200 border"><thead><tr><th class="CertTheme__tableCell CertTheme__tableCellHeader" style="border:1px solid black;width:175px;vertical-align:top;text-align:start;background-color:rgb(242, 243, 245)">Primitive Data Type<br></th><th class="CertTheme__tableCell CertTheme__tableCellHeader" style="border:1px solid black;width:175px;vertical-align:top;text-align:start;background-color:rgb(242, 243, 245)">Wrapper Class<br></th></tr></thead><tbody><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Char<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Character<br></td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Byte<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Byte<br></td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Long<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Integer<br></td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Short<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Short<br></td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">float<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Float<br></td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Double<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Double<br></td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Boolean<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Boolean<br></td></tr></tbody></table></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">37. When double-type is preferred over float-type in Java?</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>The double-type and the float-type are both used to represent floating point numbers in Java. However, for some situations double-type is better and in some cases float-type is better.</p><p>Double-type is preferred over float-type if more precise and accurate result is required. The precision of double-type is up to 15 to 16 decimal points while the precision of float type is only around 6 to 7 decimal digits.</p><p>Another reason that double-type may be preferred over float-type is that it has a larger range. It uses 1 bit for sign, 11 bits for exponent and 52 bits for mantissa while float-type only uses 1 bit for sign, 8 bits for exponent and 23 bits for mantissa.</p><p>A program that demonstrates double-type and float-type in Java is given as follows:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-cm48obp4a" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">public class Demo
{
&nbsp; &nbsp;public static void main(String []args)
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;double d = 55.637848675695785;
&nbsp; &nbsp; &nbsp; &nbsp;float f = 25.657933f;
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println("Value of double = " + d);
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println("Value of float = " + f);
&nbsp; &nbsp;}
}</pre></div></div><p><strong>The output of the above program is as follows:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-13129nadk" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">Value of double = 55.637848675695786
Value of float = 25.657932</pre></div></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">38. Best Practices while working with multi-threading in Java</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p>The most important usage of threads can be achieved using Multithreading. This means that multiple tasks can run in parallel. Some of the best practices of multi-threading in Java are given as follows:</p><p><strong>1. Minimize the locking scope</strong></p><p>The locking scope should be minimized as any code inside a lock cannot be executed concurrently and this reduces the application performance.</p><p><strong>2. Concurrent Collections should be preferred over synchronized Collection</strong></p><p>Concurrent Collections should be preferred over synchronized Collections as they provide more scalability and performance.</p><p><strong>3. Prefer Immutable Classes</strong></p><p>Immutable classes like String, Integer etc. as well as other wrapper classes should be used as they simplify the concurrent code writing. This is because there is no need to worry about the state.</p><p><strong>4. Thread Pool Executors should be preferred instead of Threads</strong></p><p>A thread pool is a better option for a scalable Java application as thread creation is quite expensive.</p><p><strong>5. Use Local Variables</strong></p><p>Instead of using class or instance variables, local variables should be used as much as possible.</p><p><strong>6. BlockingQueue should be preferred for producer-consumer design</strong></p><p>The best way to implement the producer consumer design pattern is using BlockingQueue. This is quite important as many concurrency problems are based on &nbsp;the producer consumer design.</p><p><strong>7. Synchronization utility should be preferred over wait notify</strong></p><p>There are a lot of synchronization utilities like CyclicBarrier, CountDownLatch and Semaphore which should be used instead of wait and notify.</p><p><strong>8. Use Semaphore to create bounds</strong></p><p>There should be bounds on different resources such as the file system ,database, sockets etc. to build a stable system. These bounds can be created using semaphores.</p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">39. Best Practices while working with Collections in Java</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p>A group of objects can be stored and manipulated using an architecture that is provided by the Collections API in Java. All the possible operations in Java such as searching, sorting, deletion, insertion etc. can be performed using the Java Collections.</p><p>Some of the best practices of while working with Collections in Java are given as follows:</p><p><strong>1. Choosing the right collections</strong></p><p>Before using collections, the right collection needs to be chosen according to the problem that needs to be solved.</p><p><strong>2. Using Arrays and Collections utility classes</strong></p><p>The Arrays and Collections utility classes provided by the Java Collections Framework should be used as required as they provide many useful methods to search, sort and modify elements in a collection</p><p><strong>3. Specify initial capacity of a collection if possible</strong></p><p>The initial capacity of a collection is always specified by an overloaded constructor that is contained in almost all concrete collection classes.</p><p><strong>4. Prefer isEmpty() over size()</strong></p><p>The isEmpty() method should be preferred over the size() method to check the emptiness of a collection. Even though there is a performance difference between these two methods, this is done to enhance the readability of this code.</p><p><strong>5. Do not return null in a method that returns a collection</strong></p><p>If a method returns a collection, then it should not return null if there is no element in the collection. Instead, it should return an empty collection.</p><p><strong>6. Using the Stream API on collections</strong></p><p>There is a stream method in every collection in Java 8 that returns a stream of elements. This means that the aggregate functions can be easily performed using the Stream API.</p><p><strong>7. Do not use the classic for loop</strong></p><p>Instead of using a classic for loop to iterate a list collection, use an iterator. This is because if the for loop variable is altered inside the loop, it can lead to bugs.</p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">40. Can Diamond operator be used with anonymous class in Java 9?</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p>Yes, Diamond operator can be used with anonymous class in Java 9. It was introduced in Java 7 to make code more readable. Till Java 7, enhancements weren’t introduced for Diamond operator to use with Anonymous inner classes.</p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">41. Why were Streams introduced in Java 8?</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>It's no surprise that this one pops up often in Java coding interview questions.</p><p>Streams support aggregate operations and introduced in Java 8. It is a sequence of objects with operations like Sorted, Map, Filter, etc.</p><p>For Streams, the following package is used:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-t1ovfg0g7" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">import java.util.stream.*;</pre></div></div><p>Here is an example of Stream operations in Java 8 to work with map and collect:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-pfkmf0nym" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">import java.util.*;
import java.util.stream.*;
public class Demo
{
&nbsp;public static void main(String args[])
&nbsp;{
&nbsp; &nbsp;List&lt;Integer&gt; l = Arrays.asList(29, 35, 67);
&nbsp; &nbsp;List&lt;Integer&gt; res = l.stream().map(a -&gt; a*a).collect(Collectors.toList());
&nbsp; &nbsp;System.out.println(res);
&nbsp;}
}</pre></div></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">42. Can we declare main method final in Java?</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>The final keyword is a non-access modifier in Java that is only applicable for variables, methods or classes.</p><p>The main method can be declared as final in Java and the JVM has no problem with that. However, it is not possible to override the main method in Java unlike any final method.</p><p>A program that declares the main method as final in Java is given as follows:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-w6ieyb5is" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">public class Demo
{
&nbsp; &nbsp;public final static void main(String[] args)
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println("The Main Method is declared final");
&nbsp; &nbsp;}
}</pre></div></div><p><strong>The output of the above program is as follows:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-4rms63t15" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">The Main Method is declared final</pre></div></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">43. Is try without a catch allowed in Java?</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>The try, catch and finally blocks are used for exception handling. The try block is allowed without a catch block in Java but the finally block should be provided. The finally block always executes whether there is an exception or not in the try block. The only time it does not execute is if System.exit() is called.</p><p>A program that demonstrates the try without a catch block is Java is given as follows:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-0kjrdypuj" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">public class Demo
{
&nbsp; &nbsp;public static void main(String args[])
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp; try
&nbsp; &nbsp; &nbsp; &nbsp; {
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; System.out.println("The try block");
&nbsp; &nbsp; &nbsp; &nbsp; }
&nbsp; &nbsp; &nbsp; &nbsp; finally
&nbsp; &nbsp; &nbsp; &nbsp; {
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; System.out.println("The finally block");
&nbsp; &nbsp; &nbsp; &nbsp; }
&nbsp; &nbsp;}
}</pre></div></div><p><strong>The output of the above program is as follows:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-a7ssb3viy" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">The try block
The finally block</pre></div></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">44. How to format a date in Java?</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>The methods to format the data in Java are provided in the class java.text.SimpleDateFormat. This class is a concrete class that is used for formatting and parsing the date and it inherits from the java.text.DateFormat class.</p><p>A program to format the date in Java using the java.text.SimpleDateFormat is given as follows:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-enoncywnu" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">import java.text.SimpleDateFormat; &nbsp;
import java.util.Date; &nbsp;
public class Demo
{ &nbsp;
&nbsp; &nbsp;public static void main(String[] args)
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;Date d = new Date(); &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp;SimpleDateFormat SDformat = new SimpleDateFormat("dd / MM / yy"); &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp;String curDate = SDformat.format(d); &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println("The date is: " + curDate); &nbsp;
&nbsp; &nbsp;}
}</pre></div></div><p><strong>The output of the above program is as follows:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-6q0j66qn2" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">The date is: 14 / 12 / 18</pre></div></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">45. Can we start a thread twice in Java?</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p>It is not possible to start a thread twice in Java. In other words, after a thread is started once, it cannot be started again. If the thread is started a second time, then the &nbsp;IllegalThreadStateException is thrown.</p><p>A program that demonstrates this is given as follows:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-duk3l3ppn" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">public class ThreadDemo extends Thread
{ &nbsp;
&nbsp; &nbsp;public void run()
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println("Thread is running"); &nbsp;
&nbsp; &nbsp;}
&nbsp; &nbsp;public static void main(String args[])
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;ThreadDemo thread = new ThreadDemo(); &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp;thread.start(); &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp;thread.start(); &nbsp;
&nbsp; &nbsp;}
} &nbsp;</pre></div></div><p><strong>The output of the above program is as follows:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-o7pgdi8c7" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">Thread is running
Exception in thread "main" java.lang.IllegalThreadStateException
at java.lang.Thread.start(Thread.java:708)
at ThreadDemo.main(ThreadDemo.java:13)</pre></div></div><p>As is seen from the above program, if the thread is started the second time, the &nbsp;IllegalThreadStateException is thrown.</p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">46. Out Of Memory Error in Java?</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>All the objects in Java are allocated memory from the heap memory. When an object cannot be allocated any memory because there is no more memory available and no memory can be obtained using the garbage collector, then the exception OutOfMemoryError occurs in Java.</p><p>The Out Of Memory Error usually occurs if there is too much data processing at a time or objects are held for too long. This exception can also occur because of problems that are out of programmer control such as an application server that doesn’t clean up after deploys</p><p>A program that demonstrates the Out Of Memory Error in Java is given as follows:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-d8m4zstql" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">import java.util.*;
public class Demo
{
&nbsp; &nbsp;static List&lt;String&gt; l = new ArrayList&lt;String&gt;();
&nbsp; &nbsp;public static void main(String args[]) throws Exception
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;Integer[] arr = new Integer[5000 * 5000];
&nbsp; &nbsp;}
}</pre></div></div><p><strong>The output of the above program is as follows:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-3qcnrmizk" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
at Demo.main(Demo.java:9)</pre></div></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">47. When do we throw ArrayStoreException in Java</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>If there is an attempt to store the wrong type of object into an array of objects, then the ArrayStoreException is thrown in Java. This exception is thrown at runtime.</p><p>A program that demonstrates a try-catch block to handle an ArrayStoreException in Java is given as follows:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-xohzh8jyc" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">public class Demo
{
&nbsp; &nbsp;public static void main(String args[])
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;try
&nbsp; &nbsp; &nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Object obj[] = new Integer[5];
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;obj[0] = 7.5;
&nbsp; &nbsp; &nbsp; &nbsp;}
&nbsp; &nbsp; &nbsp; &nbsp;catch (ArrayStoreException e)
&nbsp; &nbsp; &nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;System.out.println("The ArrayStoreException is found: " + e);
&nbsp; &nbsp; &nbsp; &nbsp;}
&nbsp; &nbsp;}
}</pre></div></div><p><strong>The output of the above program is as follows:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-voc8olhv2" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">The ArrayStoreException is found: java.lang.ArrayStoreException: java.lang.Double</pre></div></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">48. Volatile keyword in Java</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>A class can be made thread safe using the volatile keyword. This means that multiple threads can use the class instance or methods at the same time without any problem.</p><p>The usage of the volatile keyword on a particular variable means the following:</p><ol class="CertTheme__ol1 pt-spacing10"><li class="CertTheme__listItem pt-spacing10">The value of the variable with the volatile keyword is never cached thread locally. This means that all the read and write operations on the variable are saved in the main memory.</li><li class="CertTheme__listItem pt-spacing10">The access to the variable appears as though it is enclosed in a synchronized block and is synchronized on itself.</li></ol><p>An example of the volatile keyword is given as follows:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-k2522nc6k" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">class Shared
{
&nbsp; static volatile int value = 15;
}</pre></div></div><p>In the above example, if there are any changes made by one thread then they are reflected in the other threads as well using the volatile keyword.</p><p><strong>Differences between volatile and synchronized</strong></p><p>Some of the differences between volatile and synchronized are given as follows:</p><div class="overflow-x-auto mt-spacing10 mb-[16.8px] md:mb-6 max-w-full"><table class="min-w-full divide-y divide-gray-200 border"><thead><tr><th class="CertTheme__tableCell CertTheme__tableCellHeader" style="border:1px solid black;width:175px;vertical-align:top;text-align:start;background-color:rgb(242, 243, 245)">Characteristic<br></th><th class="CertTheme__tableCell CertTheme__tableCellHeader" style="border:1px solid black;width:175px;vertical-align:top;text-align:start;background-color:rgb(242, 243, 245)">volatile<br></th><th class="CertTheme__tableCell CertTheme__tableCellHeader" style="border:1px solid black;width:175px;vertical-align:top;text-align:start;background-color:rgb(242, 243, 245)">synchronized<br></th></tr></thead><tbody><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Is null allowed?<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Yes<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">No<br></td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Variable Type<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Object variable or primitive variable<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Object variable<br></td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">When does synchronization occur?<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">When a volatile variable is accessed<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">When a synchronized block is explicitly entered or exited.<br></td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Are all cached variables synchronized on access?<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">This is true from Java 5 onwards.<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Yes<br></td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Can this be used to combine several operations into a single atomic operation?<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">This is not possible before Java 5 but in Java 5 it is.<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Yes<br></td></tr></tbody></table></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">49. What is a Thread in Java? Can we start a dead thread again?</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p>A thread in Java is the path that is followed when a program is executed. There is atleast one thread in all Java programs that is created by the JVM at the start of the program. This is known as the main thread. The java.lang.Thread class creates and controls all the Java threads.</p><p>The thread life cycle in Java contains 5 states. These are given below:</p><ol class="CertTheme__ol1 pt-spacing10"><li class="CertTheme__listItem pt-spacing10">New</li><li class="CertTheme__listItem pt-spacing10">Runnable</li><li class="CertTheme__listItem pt-spacing10">Running</li><li class="CertTheme__listItem pt-spacing10">Blocked (Non-runnable)</li><li class="CertTheme__listItem pt-spacing10">Terminated</li></ol><p><strong>Can a dead thread be started again in Java?</strong></p><p>It is not possible to start a thread after it has completed execution i.e. after it is dead a thread cannot be brought to runnable state.</p><p>It is better to start a new instance. The actions that need to be executed should be wrapped in the Runnable interface and then the Runnable can be passed to the new instance of Thread.</p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">50. Iterator vs ListIterator in Java</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>Both Iterator and ListIterator in Java are an interface in the Collection framework. The Iterator is used to traverse the Collection elements by iterating each element individually in the forward direction.</p><p>ListIterator extends the Iterator and is used to traverse the Collection elements in both forward and backward directions. Also, elements can be added, modified and removed in the Collection using ListIterator which is not possible using Iterator.</p><p>The differences between Iterator and ListIterator are given as follows:</p><div class="overflow-x-auto mt-spacing10 mb-[16.8px] md:mb-6 max-w-full"><table class="min-w-full divide-y divide-gray-200 border"><thead><tr><th class="CertTheme__tableCell CertTheme__tableCellHeader" style="border:1px solid black;width:175px;vertical-align:top;text-align:start;background-color:rgb(242, 243, 245)">Iterator<br></th><th class="CertTheme__tableCell CertTheme__tableCellHeader" style="border:1px solid black;width:175px;vertical-align:top;text-align:start;background-color:rgb(242, 243, 245)">ListIterator<br></th></tr></thead><tbody><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">The Iterator is used to traverse the Collection elements in the forward direction.<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">The ListIterator is used to traverse the Collection elements in the forward and backward direction.<br></td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Maps, Lists, Sets etc. can be traversed using an Iterator.<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Only List objects can be traversed using a ListIterator.<br></td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Elements cannot be modified in a Collection by an Iterator.<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Elements can be modified in a Collection by a ListIterator.<br></td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Elements cannot be added to a Collection by an Iterator.<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">Elements can be added to a Collection by a ListIterator.<br></td></tr><tr><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">There is no method in the Iterator to find an element index in a Collection.<br></td><td class="CertTheme__tableCell" style="border:1px solid black;width:175px;vertical-align:top;text-align:start">There is a method in the ListIterator to find an element index in a Collection.<br></td></tr></tbody></table></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">51. Can we declare a class as Abstract without having any abstract method?</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>An abstract class is a class that cannot be instantiated on its own. It can be created in Java using the abstract keyword.</p><p>A class can be declared as an abstract class without having an abstract method. In that case, the class created cannot be instantiated but can be inherited.</p><p>A program that demonstrates this is given as follows:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-qu7cowdc8" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">abstract class BaseClass
{ &nbsp; &nbsp;
&nbsp; &nbsp;void display()
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println("Inside the BaseClass");
&nbsp; &nbsp;}
}
class DerivedClass extends BaseClass
{
}
public class Demo
{
&nbsp; &nbsp;public static void main(String args[])
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;DerivedClass obj = new DerivedClass();
&nbsp; &nbsp; &nbsp; &nbsp;obj.display();
&nbsp; &nbsp;}
}</pre></div></div><p><strong>The output of the above program is as follows:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-ov1qm91g1" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">Inside the BaseClass</pre></div></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">52. Can an Interface extend another Interface?</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p>An interface in Java is a collection of abstract methods. This interface is implemented by a class that abstract methods of the interface.</p><p>An interface can extend another interface using the extends keyword. In this way, the methods of the parent interface are inherited by the child interface.</p><p>An example of an interface extending another is given as follows:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-a891c6b7b" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">public interface Department
{
&nbsp; public void name();
}
public interface Finance extends Department
{
&nbsp; public void expenses();
&nbsp; public void quarterlyReports();
&nbsp; public void income();
}
public interface Marketing extends Department
{
&nbsp; public void onlineBudget();
&nbsp; public void offlineBudget();
}</pre></div></div><p>The class that implements the Finance interface needs to implement 4 methods as there are 3 methods in Finance and it inherits 1 method from Department. Similarly, the class that implements the Marketing interface needs to implement 3 methods as there are 2 methods in Marketing and it inherits 1 method from Department.</p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">53. Compare two integer arrays in Java</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>Two integer arrays in Java are said to be equal if they have the same number of elements and all the corresponding elements in the arrays are also the same. So, the two arrays can be compared in Java by using the Arrays.equals() method.</p><p>A program that demonstrates this method is given as follows:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-ajyty6oaf" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">import java.util.Arrays;
public class Demo
{
&nbsp; &nbsp;public static void main (String[] args) &nbsp;
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;int arr1[] = {5, 8, 2, 9, 7, 1, 6, 3, 4};
&nbsp; &nbsp; &nbsp; &nbsp;int arr2[] = {5, 8, 2, 9, 7, 1, 6, 3, 4};
&nbsp; &nbsp; &nbsp; &nbsp;int i;
&nbsp; &nbsp; &nbsp; &nbsp;System.out.print("The array 1 is: ");
&nbsp; &nbsp; &nbsp; &nbsp;for (i=0; i&lt;9; i++)
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;System.out.print(arr1[i] + " ");
&nbsp; &nbsp; &nbsp; &nbsp;System.out.print("\nThe array 2 is: ");
&nbsp; &nbsp; &nbsp; &nbsp;for (i=0; i&lt;9; i++)
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;System.out.print(arr2[i] + " ");
&nbsp; &nbsp; &nbsp; &nbsp;if (Arrays.equals(arr1, arr2))
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;System.out.println("\nThe above two arrays are the same");
&nbsp; &nbsp; &nbsp; &nbsp;else
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;System.out.println("\nThe above two arrays are not the same");
&nbsp; &nbsp;}
}</pre></div></div><p><strong>The output of the above program is as follows:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-gca5svq77" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">The array 1 is: 5 8 2 9 7 1 6 3 4
The array 2 is: 5 8 2 9 7 1 6 3 4
The above two arrays are the same</pre></div></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">54. A class can be made final. Can we make a Constructor final in Java?</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p>A class is made final in Java so that it cannot be extended. But we cannot make a Constructor final.</p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">55. Why overflow of Datatypes occurs in Java?</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p>Overflow occurs when the value is more than the maximum value of the specified datatype. Let’s say the datatype is LONG. If the value set is more than the Long.MAX_VALUE, then overflow occurs.</p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">56. Get current date and time in Java</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>The current date and time can be obtained using many methods in Java. One of these is using the LocalDateTime.now() method. The instance of the LocalDateTime class is returned by this method which can then be printed.</p><p>A program that demonstrates this is given as follows:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-6c5bwki9t" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">import java.time.format.DateTimeFormatter; &nbsp;
import java.time.LocalDateTime; &nbsp;&nbsp;
public class Demo
{ &nbsp; &nbsp;
&nbsp;public static void main(String[] args)
&nbsp;{ &nbsp;&nbsp;
&nbsp; DateTimeFormatter datetime = DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss"); &nbsp;
&nbsp; LocalDateTime curDateTime = LocalDateTime.now(); &nbsp;
&nbsp; System.out.println("The current date time is: " + datetime.format(curDateTime)); &nbsp;
&nbsp;} &nbsp;&nbsp;
}</pre></div></div><p><strong>The output of the above program is as follows:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-t3bymtjdv" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">The current date time is: 2018/12/15 12:18:54</pre></div></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">57. Check if a character is letter or number in Java</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>The method isLetterOrDigit() can be used to check if a character is a letter or a number in Java. If the character is a letter or a number then the method returns true, otherwise it returns false.</p><p>A program that demonstrates this is given as follows:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-f477dnt2i" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">public class MainClass
{
&nbsp;public static void main(String[] args)
&nbsp;{
&nbsp; &nbsp;char character1 = 'A';
&nbsp; &nbsp;char character2 = '*';
&nbsp; &nbsp;if (Character.isLetterOrDigit(character1))
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp;System.out.println(character1 + " is a character or digit");
&nbsp; &nbsp;}
&nbsp; &nbsp;else
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp;System.out.println(character1 + " is not a character or digit");
&nbsp; &nbsp;}
&nbsp; &nbsp;if (Character.isLetterOrDigit(character2))
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp;System.out.println(character2 + " is a character or digit");
&nbsp; &nbsp;}
&nbsp; &nbsp;else
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp;System.out.println(character2 + " is not a character or digit");
&nbsp; &nbsp;}
&nbsp;}
}</pre></div></div><p><strong>The output of the above program is as follows:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-46kp8rrsv" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">A is a character or digit
* is not a character or digit</pre></div></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">58. What were the drawbacks of Date/ Time API in Java 7 that lead to some enhancements to the API in Java 8?</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p>The following were the drawbacks:</p><ul><li class="CertTheme__listItem pt-spacing10">java.util.Date is not thread safe.</li><li class="CertTheme__listItem pt-spacing10">No uniformity, since the default Date starts from 1900, month starts from 1, and day starts from 0.</li></ul><p>The above drawbacks were fixed in Java 8 like introduction of utility methods for date operations.</p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">59. Get the name of the Enum constant in Java</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>The name of the enum constant is returned by the method java.lang.Enum.name(). The method returns the name exactly as it was declared in the enum declaration.</p><p>A program that demonstrates the java.lang.Enum.name() method is given as follows:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-7q00m0957" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">enum Shape
{
&nbsp; &nbsp;CIRCLE, TRIANGLE, SQUARE, RECTANGLE;
}
public class Demo
{
&nbsp; &nbsp;public static void main(String[] args)
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;Shape s = Shape.SQUARE;
&nbsp; &nbsp; &nbsp; &nbsp;System.out.print("The name of enum constant is: " + s.name());
&nbsp; &nbsp;}
}</pre></div></div><p><strong>The output of the above program is as follows:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-zkztcykc7" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">The name of enum constant is: SQUARE</pre></div></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">60. Can this keyword be used to refer static members?</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>This keyword cannot be used to refer to the static members of the class. The reason is the “this” keyword points to the current object of the class and the static member does not need any object to be called.</p><p>The static members of the class can be accessed directly as no object is required. A program that demonstrates this is as follows:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-qcddqxfdf" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">public class Demo
{
&nbsp; &nbsp;static int a = 45;
&nbsp; &nbsp;static int b;
&nbsp; &nbsp;static void func()
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println("Static function");
&nbsp; &nbsp; &nbsp; &nbsp;b = a + 5;
&nbsp; &nbsp;}
&nbsp; &nbsp;public static void main(String[] args)
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; func();
&nbsp; &nbsp; &nbsp; System.out.println("Value of a is: " + a);
&nbsp; &nbsp; &nbsp; System.out.println("Value of b is: " + b); &nbsp;
&nbsp; &nbsp;}
}</pre></div></div><p><strong>The output of the above program is as follows:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-whetvz1iq" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">Static function
Value of a is: 45
Value of b is: 50</pre></div></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">61. Restrict Inheritance for a class in Java</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p>Inheritance can be restricted for a class in Java using the keyword final. In other words, if a class is declared as final, then no other class can be extended from it. This is quite useful while creating an immutable class &nbsp;</p><p>An example of this is given as follows:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-bqmsl42m6" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">final class C1
{
&nbsp; &nbsp; // methods and fields
}
class C2 extends C1
{
&nbsp; &nbsp; // Not possible
}</pre></div></div><p>An error is generated if the class C2 tries to extend the class C1 as it is a final class and so cannot be inherited.</p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">62. What is blank or uninitialized final variable in Java</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>A final variable in Java is a special type of variable that can only be assigned a value one time, either at declaration time or at some other time.</p><p>A final variable that is not assigned a value at declaration time is known as a blank or uninitialized final variable. In other words, this variable is not initialized at its declaration time. An example is given as follows:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-fd8d8teoe" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">final int val; &nbsp; &nbsp;// This is a blank final variable
val = 6;</pre></div></div><p>A program that demonstrates a blank or uninitialized final variable in Java is given as follows:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-78nqf8r3c" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">class Demo
{
&nbsp; &nbsp;final int num;
&nbsp; &nbsp;Demo(int num1)
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;num = num1;
&nbsp; &nbsp;}
}
public class Main
{
&nbsp; &nbsp;public static void main(String args[])
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;Demo obj = new Demo(87);
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println("Value of num is: " + obj.num);
&nbsp; &nbsp;}
}</pre></div></div><p><strong>The output of the above program is as follows:&nbsp;</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-x97qcbdan" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">Value of num is: 87</pre></div></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">63. What is Spliterator in Java SE 8?</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>Spliterator is used for traversing the elements of a Collection, generator function, IO channel etc. It provides excellent support for parallel traversal as well as sequential traversal and hence is included in the JDK 8.</p><p>The Spliterator is quite useful even if parallel traversal is not required as it combines the hasNext and next operations into a single method.</p><p>A program that demonstrates a Spliterator in Java is given as follows:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-lz23kc5k1" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">import java.util.ArrayList;
import java.util.Spliterator;
import java.util.stream.Stream;
public class SpliteratorDemo &nbsp;
{
&nbsp; &nbsp;public static void main(String[] args) &nbsp;
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;ArrayList&lt;Integer&gt; arrList = new ArrayList&lt;&gt;();
&nbsp; &nbsp; &nbsp; &nbsp;arrList.add(7);
&nbsp; &nbsp; &nbsp; &nbsp;arrList.add(2);
&nbsp; &nbsp; &nbsp; &nbsp;arrList.add(1);
&nbsp; &nbsp; &nbsp; &nbsp;arrList.add(9);
&nbsp; &nbsp; &nbsp; &nbsp;arrList.add(4);
&nbsp; &nbsp; &nbsp; &nbsp;Stream&lt;Integer&gt; s1 = arrList.stream();
&nbsp; &nbsp; &nbsp; &nbsp;Spliterator&lt;Integer&gt; split = s1.spliterator();
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println("The estimated size is: " + split.estimateSize());
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println("The arraylist contents are:");
&nbsp; &nbsp; &nbsp; &nbsp;split.forEachRemaining((n) -&gt; System.out.println(n));
&nbsp; &nbsp;}
}</pre></div></div><p><strong>The output of the above program is as follows:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-kr7yetyhe" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">The estimated size is: 5
The arraylist contents are:
7
2
1
9
4</pre></div></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">64. Set permission to a file in Java</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>File permissions are set on the file when the operations permissible for the file need to be restricted by the user.</p><p>The permissible permissions for a file are given below:</p><ol class="CertTheme__ol1 pt-spacing10"><li class="CertTheme__listItem pt-spacing10"><strong>Readable</strong> - This permission tests if the application can read the file that is denoted by the abstract path name.</li><li class="CertTheme__listItem pt-spacing10"><strong>Writable</strong> - This permission tests if the application can change the file that is denoted by the abstract path name.</li><li class="CertTheme__listItem pt-spacing10"><strong>Executable</strong> - This permission tests if the application can execute the file that is denoted by the abstract path name.</li></ol><p>The methods that can be used to change the permissions of a file are setExecutable, setReadable and setWritable.</p><p>A program that demonstrates the permissions of a file is given as follows:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-5v9r9139y" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">import java.io.*;
public class Demo
{
&nbsp; &nbsp;public static void main(String[] args)
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;File f = new File("C:\\Users\\Aaron\\Desktop\\text.txt");
&nbsp; &nbsp; &nbsp; &nbsp;boolean exists = f.exists();
&nbsp; &nbsp; &nbsp; &nbsp;if(exists == true)
&nbsp; &nbsp; &nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;f.setExecutable(true);
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;f.setReadable(true);
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;f.setWritable(false);
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;System.out.println("The File permissions are now changed.");
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;System.out.println("Executable: " + f.canExecute());
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;System.out.println("Readable: " + f.canRead());
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;System.out.println("Writable: "+ f.canWrite());
&nbsp; &nbsp; &nbsp; &nbsp;}
&nbsp; &nbsp; &nbsp; &nbsp;else
&nbsp; &nbsp; &nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;System.out.println("File not found.");
&nbsp; &nbsp; &nbsp; &nbsp;}
&nbsp; &nbsp;}
}</pre></div></div><p><strong>The output of the above program is as follows:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-1ttx64r4h" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">The File permissions are now changed.
Executable: true
Readable: true
Writable: false </pre></div></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">65. Static vs Dynamic Binding in Java</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>Static binding can be resolved at the compile time by the compiler. All the static, final and private method binding is done at compile time. Another word for static binding is early binding.</p><p>An example of static binding is given as follows:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-mdu2uxkrn" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">public class Demo
{
&nbsp; &nbsp;public static class Animal
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;static void display()
&nbsp; &nbsp; &nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;System.out.println("This is an Animal");
&nbsp; &nbsp; &nbsp; &nbsp;}
&nbsp; &nbsp;}
&nbsp; &nbsp;public static class Mammal extends Animal
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;static void display()
&nbsp; &nbsp; &nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;System.out.println("This is a Mammal");
&nbsp; &nbsp; &nbsp; &nbsp;}
&nbsp; &nbsp;}
&nbsp; &nbsp;public static void main(String[] args)
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;Animal obj1 = new Animal();
&nbsp; &nbsp; &nbsp; &nbsp;Mammal obj2 = new Mammal();
&nbsp; &nbsp; &nbsp; &nbsp;obj1.display();
&nbsp; &nbsp; &nbsp; &nbsp;obj2.display();
&nbsp; &nbsp;}
}</pre></div></div><p><strong>The output of the above program is as follows:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-dw0093iel" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">This is an Animal
This is a Mammal</pre></div></div><p>In dynamic binding, the type of the object is determined at run time. One of the examples of dynamic binding is overriding.</p><p>An example of dynamic binding is given as follows:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-uerb2ho4r" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">public class Demo
{
&nbsp; &nbsp;public static class Animal
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;void display()
&nbsp; &nbsp; &nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;System.out.println("This is an Animal");
&nbsp; &nbsp; &nbsp; &nbsp;}
&nbsp; &nbsp;}
&nbsp; &nbsp;public static class Mammal extends Animal
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;@Override
&nbsp; &nbsp; &nbsp; &nbsp;void display()
&nbsp; &nbsp; &nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;System.out.println("This is a Mammal");
&nbsp; &nbsp; &nbsp; &nbsp;}
&nbsp; &nbsp;}
&nbsp; &nbsp;public static void main(String[] args)
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;Animal obj1 = new Animal();
&nbsp; &nbsp; &nbsp; &nbsp;Animal obj2 = new Mammal();
&nbsp; &nbsp; &nbsp; &nbsp;obj1.display();
&nbsp; &nbsp; &nbsp; &nbsp;obj2.display();
&nbsp; &nbsp;}
}</pre></div></div><p><strong>The output of the above program is as follows:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-qg5bzjmk6" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">This is an Animal
This is a Mammal</pre></div></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">66. Sort a HashMap according to values in Java</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>A method is created to sort the HashMap according to value. The HashMap contains the names of 5 students as the key and their average marks as the value. Therefore, the HashMap is sorted according to the marks obtained by the students.</p><p>A program that demonstrates this is given as follows:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-i7q0v96zx" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">import java.util.*;
import java.lang.*;
public class Example
{
&nbsp; &nbsp;public static HashMap&lt;String, Integer&gt; sortHashMapByValue(HashMap&lt;String, Integer&gt; studentDetails)
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;List&lt;Map.Entry&lt;String, Integer&gt; &gt; list =
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; new LinkedList&lt;Map.Entry&lt;String, Integer&gt; &gt;(studentDetails.entrySet());
&nbsp; &nbsp; &nbsp; &nbsp;Collections.sort(list, new Comparator&lt;Map.Entry&lt;String, Integer&gt; &gt;()
&nbsp; &nbsp; &nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;public int compare(Map.Entry&lt;String, Integer&gt; val1, &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Map.Entry&lt;String, Integer&gt; val2)
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return (val1.getValue()).compareTo(val2.getValue());
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}
&nbsp; &nbsp; &nbsp; &nbsp;});
&nbsp; &nbsp; &nbsp; &nbsp;HashMap&lt;String, Integer&gt; temp = new LinkedHashMap&lt;String, Integer&gt;();
&nbsp; &nbsp; &nbsp; &nbsp;for (Map.Entry&lt;String, Integer&gt; i : list)
&nbsp; &nbsp; &nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;temp.put(i.getKey(), i.getValue());
&nbsp; &nbsp; &nbsp; &nbsp;}
&nbsp; &nbsp; &nbsp; &nbsp;return temp;
&nbsp; &nbsp;}
&nbsp; &nbsp;public static void main(String[] args)
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;HashMap&lt;String, Integer&gt; studentDetails = new HashMap&lt;String, Integer&gt;();
&nbsp; &nbsp; &nbsp; &nbsp;studentDetails.put("Amy", 56);
&nbsp; &nbsp; &nbsp; &nbsp;studentDetails.put("John", 99);
&nbsp; &nbsp; &nbsp; &nbsp;studentDetails.put("Peter", 25);
&nbsp; &nbsp; &nbsp; &nbsp;studentDetails.put("Susan", 85);
&nbsp; &nbsp; &nbsp; &nbsp;studentDetails.put("Harry", 68);
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println("Original HashMap");
&nbsp; &nbsp; &nbsp; &nbsp;for (Map.Entry&lt;String, Integer&gt; i : studentDetails.entrySet())
&nbsp; &nbsp; &nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;System.out.println("Key = " + i.getKey() + &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;", Value = " + i.getValue());
&nbsp; &nbsp; &nbsp; &nbsp;}
&nbsp; &nbsp; &nbsp; &nbsp;Map&lt;String, Integer&gt; sortedStudentDetails = sortHashMapByValue(studentDetails);
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println("\nSorted HashMap");
&nbsp; &nbsp; &nbsp; &nbsp;for (Map.Entry&lt;String, Integer&gt; i : sortedStudentDetails.entrySet())
&nbsp; &nbsp; &nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;System.out.println("Key = " + i.getKey() + &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;", Value = " + i.getValue());
&nbsp; &nbsp; &nbsp; &nbsp;}
&nbsp; &nbsp;}
}</pre></div></div><p><strong>The output of the above program is as follows:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-jp6nkoc8t" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">Original HashMap
Key = Harry, Value = 68
Key = Susan, Value = 85
Key = John, Value = 99
Key = Peter, Value = 25
Key = Amy, Value = 56

Sorted HashMap
Key = Peter, Value = 25
Key = Amy, Value = 56
Key = Harry, Value = 68
Key = Susan, Value = 85
Key = John, Value = 99</pre></div></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">67. Are constructors inherited in Java?</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p>The constructors aren’t inherited in Java.</p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">68. Create Immutable class in Java</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p>An immutable class in Java is one that cannot change its state after its construction. Some of the requirements to create an immutable class in Java are given as follows:</p><ol class="CertTheme__ol1 pt-spacing10"><li class="CertTheme__listItem pt-spacing10">The class should be final so that other classes can’t extend it.</li><li class="CertTheme__listItem pt-spacing10">All the fields of the class should be final so that they are only initialized one time inside the constructor.</li><li class="CertTheme__listItem pt-spacing10">Setter methods should not be exposed.</li><li class="CertTheme__listItem pt-spacing10">A new instance of the class should be returned if any methods that modify the state of the class are exposed.</li><li class="CertTheme__listItem pt-spacing10">If there Is a mutable object inside the constructor, only a clone copy of the passed argument should be used.</li></ol><p>An example that demonstrates the creation of an immutable class in Java is given as follows:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-cq9gx9pom" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">public final class Employee
{
&nbsp; &nbsp;final int empNum;
&nbsp; &nbsp;final String name;
&nbsp; &nbsp;final int salary;
&nbsp; &nbsp;public Employee(int empNum, String name, int salary)
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;this.empNum = empNum;
&nbsp; &nbsp; &nbsp; &nbsp;this.name = name;
&nbsp; &nbsp; &nbsp; &nbsp;this.salary = salary;
&nbsp; &nbsp;}
&nbsp; &nbsp;public int empNumReturn()
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;return empNum;
&nbsp; &nbsp;}
&nbsp; &nbsp;public String nameReturn()
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;return name;
&nbsp; &nbsp;}
&nbsp; &nbsp;public int salaryReturn()
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;return salary;
&nbsp; &nbsp;}
}</pre></div></div><p>The class given above is a basic immutable class. This class does not contain any mutable object or any setter methods. This type of a basic class is normally used for caching purposes.</p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">69. Covariant return type in Java</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p>Covariant return types refer to the return type of the overriding method. It is possible to have different return types for overriding methods in the child class since Java 5. However, the return type of the child class should be a subtype of the return type of the parent class.</p><p>A program that demonstrates covariant return type in Java is given as follows:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-urkg68kxz" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">class C1
{ &nbsp;
&nbsp; &nbsp;C1 ret()
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;return this;
&nbsp; &nbsp;} &nbsp;
} &nbsp;
public class C2 extends C1
{ &nbsp;
&nbsp; &nbsp;C2 ret()
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;return this;
&nbsp; &nbsp;} &nbsp;
&nbsp; &nbsp;void display()
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println("This is the covariant return type");
&nbsp; &nbsp;} &nbsp;
&nbsp; &nbsp;public static void main(String args[])
&nbsp; &nbsp;{ &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp;new C2().ret().display(); &nbsp;
&nbsp; &nbsp;} &nbsp;
} &nbsp;</pre></div></div><p><strong>The output of the above program is as follows:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-i4wr6dz0y" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">This is the covariant return type</pre></div></div><p>The above program demonstrates covariant return type as the return type of the class C1 ret() method is C1 while the return type of the class C2 ret() method is C2 and it is method overriding while both methods have different return types.</p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">70. Which collection classes are thread-safe in Java</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>The collection classes that are thread safe in Java are Stack, Vector, Properties, Hashtable etc. Details about some of these collection classes are given as follows:</p><p><strong>Stack class in Java</strong><strong><br></strong></p><p>The Stack class in Java implements the stack data structure that is based on the principle of LIFO. So, the stack class can provide many operations such as push, pop, peek, search, empty etc.</p><p>A program that demonstrates the Stack class is given as follows:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-ka1gofz1f" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">import java.io.*;
import java.util.*;
public class Demo
{ &nbsp; &nbsp;
&nbsp; &nbsp;public static void main (String[] args)
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;Stack&lt;Integer&gt; stack = new Stack&lt;Integer&gt;();
&nbsp; &nbsp; &nbsp; &nbsp;stack.push(4);
&nbsp; &nbsp; &nbsp; &nbsp;stack.push(1);
&nbsp; &nbsp; &nbsp; &nbsp;stack.push(9);
&nbsp; &nbsp; &nbsp; &nbsp;Integer num1 = (Integer) stack.pop();
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println("The element popped is: " + num1);
&nbsp; &nbsp; &nbsp; &nbsp;Integer num2 = (Integer) stack.peek();
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println("Element on stack top is: " + num2);
&nbsp; &nbsp;}
}</pre></div></div><p>The output of the above program is as follows:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-x2v244p3l" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">The element popped is: 9
Element on stack top is: 1</pre></div></div><p><strong>Vector class in Java</strong><strong><br></strong></p><p>An array of objects that grows as required is implemented by the Vector class in Java. A program that demonstrates the Vector class is given as follows:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-ufx0gl3zo" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">import java.util.*;
public class Demo
{
&nbsp; &nbsp;public static void main(String[] arg)
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;Vector vector = new Vector();
&nbsp; &nbsp; &nbsp; &nbsp;vector.add(9);
&nbsp; &nbsp; &nbsp; &nbsp;vector.add(3);
&nbsp; &nbsp; &nbsp; &nbsp;vector.add("Apple");
&nbsp; &nbsp; &nbsp; &nbsp;vector.add(1);
&nbsp; &nbsp; &nbsp; &nbsp;vector.add("Mango");
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println("The vector is: " + vector);
&nbsp; &nbsp; &nbsp; &nbsp;vector.remove(1);
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println("The vector after element at index 1 is removed is: " + vector);
&nbsp; &nbsp;}
}</pre></div></div><p><strong>The output of the above program is as follows:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-md46e8o8q" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">The vector is: [9, 3, Apple, 1, Mango]
The vector after element at index 1 is removed is: [9, Apple, 1, Mango]</pre></div></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">71. What happens when an exception is thrown from the top of the stack in Java?</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>When an exception is thrown from the top of the stack, exception propagation occurs. Here are some of the points when the exception is not caught:</p><ul><li class="CertTheme__listItem pt-spacing10">The exception drops down the call stack of the preceding method.</li><li class="CertTheme__listItem pt-spacing10">If it is still not caught there itself, it further goes down to the preceding method.</li><li class="CertTheme__listItem pt-spacing10">The above goes till the method reaches the bottom of the call stack</li><li class="CertTheme__listItem pt-spacing10">This can also go on till it is caught somewhere in between.</li></ul><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">72. What are the restrictions applied to Java static methods?</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>The following are the restrictions applied to static methods in Java:</p><ul><li class="CertTheme__listItem pt-spacing10">Static method can access only static type data.</li><li class="CertTheme__listItem pt-spacing10">These methods cannot invoke non-static method directly.</li><li class="CertTheme__listItem pt-spacing10">The ‘this’ and ‘super’ cannot be used in static context.</li><li class="CertTheme__listItem pt-spacing10">You can’t override static methods in a subclass</li></ul><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">73. Why to use Argument Index in Java?</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>If you want to reorder output in Java, then use Argument Index.</p><p>Let’s say the output is:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-j2e9vj9cj" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">abc def ghi jkl mno</pre></div></div><p>And you want to reorder and display it as:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-q1bbfbanr" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">ghi jkl mno abc def</pre></div></div><p>For this, use the Argument Index as shown in the following example:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-xpce55h8w" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">public class Demo {
&nbsp;public static void main(String[] args) {
&nbsp; &nbsp; &nbsp; System.out.printf("Initial Output = %s %s %s %s %s\n", "abc", "def", "ghi", "jkl", "mno"); &nbsp;&nbsp;
&nbsp; &nbsp; &nbsp; System.out.printf("Update output = %3$s %4$s %5$s %1$s %2$s\n", "abc", "def", "ghi", "jkl", "mno" ); &nbsp;&nbsp;
&nbsp;}
}</pre></div></div><p>The above example displays that we have reordered the output:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-r3cq7w7jj" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">Initial Output = abc def ghi jkl mno
Update output = ghi jkl mno abc def</pre></div></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">74. Which class is used in Java to serialize an object?</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p>To serialize an Object, use the ObjectOutputStream class.</p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">75. Constructor vs Method in Java</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p>A method has a return type unlike constructor. Constructor is invoked implicitly. Whereas method is invoked explicitly.<br><br>The name of the constructor is the same as the class name. However, the name of the method may or may not be same as the name of the class.</p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">76. What enhancements Java 9 brought to Process API?</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>The Process API now provide more information like:</p><ul><li class="CertTheme__listItem pt-spacing10">Process's native process ID,</li><li class="CertTheme__listItem pt-spacing10">Accumulated CPU time,</li><li class="CertTheme__listItem pt-spacing10">Parent process</li><li class="CertTheme__listItem pt-spacing10">Method to destroy a process</li><li class="CertTheme__listItem pt-spacing10">Process’s Descendants, etc.</li></ul><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">77. What are the types of Base64 encoding in Java?</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p><strong>The following are the types of Base64 encoding:</strong></p><ul><li class="CertTheme__listItem pt-spacing10"><strong>Simple</strong>: The output is mapped to a set of characters lying in A-Za-z0-9+/.</li><li class="CertTheme__listItem pt-spacing10"><strong>URL</strong>: The output is mapped to set of characters lying in A-Za-z0-9+_.</li><li class="CertTheme__listItem pt-spacing10"><strong>MIME</strong>: The output is mapped to MIME friendly format. It is represented in lines of no more than 76 characters each, and uses a carriage return '\r' followed by a linefeed '\n' as the line separator.</li></ul><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">78. Why do we use variable length arguments in Java?</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>The variable length arguments come into picture when you do not initially know the number of arguments passed to the method.</p><p>The variable length arguments can be zero or more. An example is shown below:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-5lcvc4jpw" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">public class Demo
{
&nbsp;public static void Varargs(String... str)
&nbsp;{
&nbsp; &nbsp;System.out.println("Arguments... ");
&nbsp; &nbsp;for (String s : str)
&nbsp; &nbsp; &nbsp;System.out.println(s);
&nbsp; &nbsp;System.out.println("Count = " + str.length );
&nbsp;}
&nbsp;public static void main(String args[])
&nbsp;{
&nbsp; &nbsp;Varargs("arg1", "arg2");
&nbsp;}
}</pre></div></div><p><strong>The above program displays the following output:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-p6ksfp5ha" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">Arguments...
arg1
arg2
Count = 2</pre></div></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">79. C++ supports Pointers, while Java does not. Why?</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p>Pointers are considered unsafe in Java, so it does not support it. The lack of pointers is to stop Java programs from referencing memory locations illegally.</p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">80. What is a Static Nested Class in Java?</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p>A static nested class is a nested class declared as static. A nested class can’t access the data members and methods of the outer class.</p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">81. Best practices related to Java Collections Framework?</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p>Collections in Java is basically a framework that allows the storage and manipulation of a group of objects by providing an architecture. All the possible operations in Java such as searching, sorting, deletion, insertion etc. can be performed using the Java Collections.</p><p>Some of the best practices related to the Collections Framework in Java are given as follows:</p><ul><li class="CertTheme__listItem pt-spacing10"><strong>Using Arrays and Collections utility classes</strong></li></ul><p>The Arrays and Collections utility classes provided by the Java Collections Framework should be used as required as they provide many useful methods to search, sort and modify elements in a collection</p><ul><li class="CertTheme__listItem pt-spacing10"><strong>Do not use the classic for loop</strong></li></ul><p>Instead of using a classic for loop to iterate a list collection, use an iterator. This is because if the for loop variable is altered inside the loop, it can lead to bugs.</p><ul><li class="CertTheme__listItem pt-spacing10"><strong>Choosing the right collections</strong></li></ul><p>Before using collections, the right collection needs to be chosen according to the problem that needs to be solved.</p><ul><li class="CertTheme__listItem pt-spacing10"><strong>Using the Stream API on collections</strong></li></ul><p>There is a stream method in every collection in Java 8 that returns a stream of elements. This means that the aggregate functions can be easily performed using the Stream API.</p><ul><li class="CertTheme__listItem pt-spacing10"><strong>Prefer isEmpty() over size()</strong></li></ul><p>The isEmpty() method should be preferred over the size() method to check the emptiness of a collection. Even though there is performance difference between these two methods, this is done to enhance the readability of this code.</p><ul><li class="CertTheme__listItem pt-spacing10"><strong>Do not return null in a method that returns a collection</strong></li></ul><p>If a method returns a collection, then it should not return null if there is no element in the collection. Instead, it should return an empty collection.</p><ul><li class="CertTheme__listItem pt-spacing10"><strong>Specify initial capacity of a collection if possible</strong></li></ul><p>The initial capacity of a collection is always specified by an overloaded constructor that is contained in almost all concrete collection classes.</p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">82. Why do we call System.gc() in Java</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>The garbage collector is run using the System.gc() method in Java. The use of this method is an indicator to the JVM to recycle the unused objects so that the memory can be freed and available for quick reuse as required. The System.gc() method does not return any values.</p><p>A program that demonstrates this method is given as follows:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-19qwld978" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">public class Demo
{
&nbsp; &nbsp;public static void main(String[] args) throws InterruptedException
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;Demo obj = new Demo();
&nbsp; &nbsp; &nbsp; &nbsp;obj = null;
&nbsp; &nbsp; &nbsp; &nbsp;System.gc();
&nbsp; &nbsp;}
&nbsp; &nbsp;@Override
&nbsp; &nbsp;protected void finalize() throws Throwable
&nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println("The garbage collector is called...");
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println("The object that is garbage collected is: " + this);
&nbsp; &nbsp;}
}</pre></div></div><p><strong>The output of the above program is as follows:</strong></p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-3wtqditfq" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">The garbage collector is called...
The object that is garbage collected is: Demo@7978f9b4</pre></div></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">83. Can the main method be declared final?</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p></p><p>Yes, we can declare the main method as final like:</p><div class="jsx-189f2d4cbe17d436 code-block-wrapper mt-spacing10 mb-[16.8px] md:mb-[24px] bg-black p-4 rounded-[12px] relative text-[#708090] overflow-hidden"><div class="jsx-189f2d4cbe17d436 absolute top-4 right-4 z-10"><div class="jsx-189f2d4cbe17d436 px-spacing12 bg-white rounded-full h-10 flex items-center cursor-pointer"><i class="jsx-189f2d4cbe17d436 text-black text-sm icon-copy"></i></div></div><div class="jsx-189f2d4cbe17d436 overflow-x-auto pb-[12px] w-full"><pre id="code-block-le3ekshe9" class="jsx-189f2d4cbe17d436 whitespace-pre-wrap break-words w-full font-mono text-sm">public static final void main(String[] args)</pre></div></div><p></p></div></div></div></div><div class="rounded-xl mb-spacing24 last:mb-0 outline duration-300 transition ease-in-out outline-1 outline-neutral-200 hover:outline-neutral-400 hover:shadow-neutralShadow hidden"><div class="cursor-pointer items-center justify-between p-4 transition-all duration-500 undefined bg-white p-spacing16 pl-spacing24 flex gap-spacing8 rounded-xl"><div class="flex text-sm font-semibold items-center overflow-x-auto"><h3 class="text-neutral-800 font-bold text-sm leading-5.5 -indent-0 pl-5 overflow-hidden line-clamp-2">84. Does order of specifiers matter in Java? Will static public void work for main() method?</h3></div><div class="md:w-5 md:h-5 w-6 h-6 ml-spacing8 flex items-center transition-all duration-300"><i class="icon-chevron-up-filled inline-block transition-transform duration-300 text-xl rotate-180 text-primary-main"></i></div></div><div class="overflow-hidden p-0 transition-all duration-500 ease-in-out rounded-b-xl" style="max-height:0px"><div><div class="p-spacing24 bg-white border-t border-neutral-200 faq-editor-content last:rounded-b-xl"><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><span>Order of specifiers doesn’t matter in Java. The static public void will work for sure and the program would compile and run correctly.</span></p></div></div></div></div><div class="relative"><div class="mt-spacing20 z-10 relative text-center flex justify-center mt-0"><button class="flex items-center gap-x-spacing8 py-spacing4"><span class="text-sm underline font-semibold text-mono-black">View all questions</span><i class="icon-chevron-down-double text-xl leading-5 text-neutral-800"></i></button></div><div class="absolute bottom-0 block h-32 w-full bg-gradient-to-t from-subdued/100 from-30% md:from-40%"></div></div></div></div></div></div></div></div></div></div></div></section></div></div><div class="sticky top-0 self-start max-h-screen overflow-y-auto w-full"><div class="w-full overflow-hidden pt-spacing32"><div class="px-spacing16 py-spacing20 rounded-xl border border-neutral-200 bg-white"><div class=""><h5 class="text-lg leading-6 text-mono-black font-bold">Want to Know More?</h5></div><form novalidate="" class="pt-spacing20 w-full"><div class="mb-spacing12"><div class=" relative  w-full  group h-11 flex direction-row justify-between rounded-lg border-none
    hover:border-neutral-400  shadow-customShad focus:border-neutral-600 focus:shadow-neutral "><input type="text" placeholder="full Name" class="w-full h-full  text-sm text-neutral-800 placeholder-transparent leading-5.5 pl-4 pr-8 rounded-lg border-1 peer  focus:outline-none border-neutral-200 hover:border-neutral-400 focus:border-neutral-600 focus:shadow-neutral" name="fullName"><label class="absolute  left-3 -top-2 border-r-none text-sm transition-all peer-focus:-top-2 peer-focus:text-sm pointer-events-none pr-3.75 pl-1  bg-white 
          text-neutral-500 peer-placeholder-shown:text-sm peer-placeholder-shown:text-neutral-500 peer-placeholder-shown:top-3 peer-focus:text-neutral-500 peer-placeholder-shown:leading-5">Full Name<span class="text-red-500 ml-spacing4 pt-0.8 absolute">*</span></label></div></div><div class="mb-spacing12"><div class=" relative  w-full  group h-11 flex direction-row justify-between rounded-lg border-none
    hover:border-neutral-400  shadow-customShad focus:border-neutral-600 focus:shadow-neutral "><input type="text" placeholder="Email" class="w-full h-full text-sm text-neutral-800 leading-5.5 pl-4 pr-8 rounded-lg border-1 peer focus:outline-none border-neutral-200 hover:border-neutral-400 focus:border-neutral-600 focus:shadow-neutral placeholder-transparent" name="email"><label class="absolute  left-3 -top-2 border-r-none text-sm transition-all peer-focus:-top-2 peer-focus:text-sm pointer-events-none pr-3.75 pl-1 bg-white 
          text-neutral-500 peer-placeholder-shown:text-sm peer-placeholder-shown:text-neutral-500 peer-placeholder-shown:top-3 peer-focus:text-neutral-500 peer-placeholder-shown:leading-5">Email<span class="text-red-500 ml-spacing4 pt-0.8 absolute">*</span></label></div></div><div class="mb-spacing16"><div><div class="flex h-11 relative focus-within:shadow-neutral focus-within:border-neutral-600 rounded-lg border-1  focus:placeholder-transparent hover:border-neutral-400 focus:border-neutral-600 focus:shadow-neutral focus:outline-none border-neutral-200 shadow-customShad "><div class="p-3 cursor-pointer m-1 flex justify-center items-center rounded-r-lg !w-auto !px-0 !pr-2 !pl-3 leading-6 w-fit border-neutral-200 rounded-l-lg border-none hover:border-neutral-400 focus:border-neutral-600 focus:shadow-neutral focus:outline-none"><div class="pr-1 font-bold text-base text-blackDar"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 513 342"><path fill="#181A93" d="M17.3 0h478.4v342H17.3V0z"></path><path fill="#FFA44A" d="M0 0h513v114H0V0z"></path><path fill="#1A9F0B" d="M0 228h513v114H0V228z"></path><path fill="white" d="M0 114h513v114H0V114z"></path><circle fill="white" cx="256.5" cy="171" r="34.2"></circle><path fill="#181A93" d="M256.5 216.6c-25.1 0-45.6-20.5-45.6-45.6s20.5-45.6 45.6-45.6 45.6 20.5 45.6 45.6-20.5 45.6-45.6 45.6zm0-11.4c18.2 0 34.2-16 34.2-34.2s-15.9-34.2-34.2-34.2-34.2 16-34.2 34.2 16 34.2 34.2 34.2z"></path><circle fill="#181A93" cx="256.5" cy="171" r="22.8"></circle></svg></div><div class="pl-spacing4 text-xs w-6 items-center text-neutral-700 font-semibold">+91</div></div></div><i class="icon-chevron-right text-base rotate-90 leading-4 ml-spacing12"></i></div><input type="text" class="hidden" name="isd" value="+91"><div class="w-full"><div class="inline-block bg-white border-none undefined h-full w-full border-neutral-200 rounded-lg border-1 shadow-customShad group hover:border-neutral-400 focus:border-neutral-600 focus:shadow-neutral focus:outline-none"><input type="text" class="w-full h-full text-sm text-neutral-800 leading-5.5 px-spacing12 border-neutral-200 rounded-r-lg border-none peer focus:outline-none " placeholder="  " name="number"><label class="absolute  bg-white placeholder-transparent left-3 -top-2 text-sm transition-all peer-focus:-top-2 peer-focus:left-3 peer-focus:text-sm pointer-events-none  pr-3.75 pl-1 bg-white 
          text-neutral-500 peer-placeholder-shown:text-sm peer-placeholder-shown:text-neutral-500 peer-placeholder-shown:top-3 peer-focus:text-neutral-500 peer-placeholder-shown:leading-5 peer-placeholder-shown:left-24">Phone Number<span class="text-red-500 ml-spacing4 absolute pt-0.8">*</span></label></div></div></div><div class="max-w-61 !w-auto pt-spacing4 ml-3.5 md:mr-0 mr-4.25 bg-white absolute z-99 h-68 customized-scrollbar overflow-y-scroll border-1 text-xs border-neutral-400 rounded-lg hidden !ml-0"><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 513 342"><path fill="white" d="M0 0h513v342H0z"></path><g fill="#D80027"><path d="M0 0h513v38H0zM0 76h513v38H0zM0 152h513v38H0zM0 228h513v38H0zM0 304h513v38H0z"></path></g><path fill="#2E52B2" d="M0 0h256.5v190H0z"></path><g fill="white"><path d="M47.8 141.9l-4-12.8-4.3 12.8H26.3l10.7 7.7-4 12.8 10.8-7.9 10.7 7.9-4.2-12.8 10.9-7.7zM104.2 141.9l-4.1-12.8-4.2 12.8H82.7l10.7 7.7-4.1 12.8 10.8-7.9 10.7 7.9-4-12.8 10.8-7.7zM160.6 141.9l-4.2-12.8-4 12.8h-13.5l10.9 7.7-4.2 12.8 10.8-7.9 10.9 7.9-4.2-12.8 10.8-7.7zM216.9 141.9l-4.1-12.8-4.2 12.8h-13.2l10.7 7.7-4 12.8 10.7-7.9 10.8 7.9-4.2-12.8 10.9-7.7zM100.1 78.3l-4.2 12.8H82.7L93.4 99l-4.1 12.6 10.8-7.8 10.7 7.8-4-12.6 10.8-7.9h-13.4zM43.8 78.3l-4.3 12.8H26.3L37 99l-4 12.6 10.8-7.8 10.7 7.8L50.3 99l10.9-7.9H47.8zM156.4 78.3l-4 12.8h-13.5l10.9 7.9-4.2 12.6 10.8-7.8 10.9 7.8-4.2-12.6 10.8-7.9h-13.3zM212.8 78.3l-4.2 12.8h-13.2l10.7 7.9-4 12.6 10.7-7.8 10.8 7.8-4.2-12.6 10.9-7.9h-13.4zM43.8 27.7l-4.3 12.6H26.3L37 48.2l-4 12.7L43.8 53l10.7 7.9-4.2-12.7 10.9-7.9H47.8zM100.1 27.7l-4.2 12.6H82.7l10.7 7.9-4.1 12.7 10.8-7.9 10.7 7.9-4-12.7 10.8-7.9h-13.4zM156.4 27.7l-4 12.6h-13.5l10.9 7.9-4.2 12.7 10.8-7.9 10.9 7.9-4.2-12.7 10.8-7.9h-13.3zM212.8 27.7l-4.2 12.6h-13.2l10.7 7.9-4 12.7 10.7-7.9 10.8 7.9-4.2-12.7 10.9-7.9h-13.4z"></path></g></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">United States +1</div></div></div><div class="bg-mono-black/8 pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 513 342"><path fill="#181A93" d="M17.3 0h478.4v342H17.3V0z"></path><path fill="#FFA44A" d="M0 0h513v114H0V0z"></path><path fill="#1A9F0B" d="M0 228h513v114H0V228z"></path><path fill="white" d="M0 114h513v114H0V114z"></path><circle fill="white" cx="256.5" cy="171" r="34.2"></circle><path fill="#181A93" d="M256.5 216.6c-25.1 0-45.6-20.5-45.6-45.6s20.5-45.6 45.6-45.6 45.6 20.5 45.6 45.6-20.5 45.6-45.6 45.6zm0-11.4c18.2 0 34.2-16 34.2-34.2s-15.9-34.2-34.2-34.2-34.2 16-34.2 34.2 16 34.2 34.2 34.2z"></path><circle fill="#181A93" cx="256.5" cy="171" r="22.8"></circle></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">India +91</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 341.3"><path fill="white" d="M0 0h512v341.3H0z"></path><g fill="#D80027"><path d="M0 0h142v341.3H0zM370 0h142v341.3H370zM306.5 206l50.4-25.2-25.2-12.6V143l-50.4 25.2 25.2-50.4h-25.2L256.1 80l-25.2 37.8h-25.2l25.2 50.4-50.4-25.2v25.2l-25.2 12.6 50.4 25.2-12.6 25.2h50.4V269h25.2v-37.8h50.4z"></path></g></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Canada +1</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 513 342"><path fill="#0052B4" d="M0 0h513v342H0z"></path><g fill="white"><path d="M222.2 170.7c.3-.3.5-.6.8-.9-.2.3-.5.6-.8.9zM188 212.6l11 22.9 24.7-5.7-11 22.8 19.9 15.8-24.8 5.6.1 25.4-19.9-15.9-19.8 15.9.1-25.4-24.8-5.6 19.9-15.8-11.1-22.8 24.8 5.7zM385.9 241.1l5.2 10.9 11.8-2.7-5.3 10.9 9.5 7.5-11.8 2.6v12.2l-9.4-7.6-9.5 7.6.1-12.2-11.8-2.6 9.5-7.5-5.3-10.9 11.8 2.7zM337.3 125.1l5.2 10.9 11.8-2.7-5.3 10.9 9.5 7.5-11.8 2.7v12.1l-9.4-7.6-9.5 7.6.1-12.1-11.9-2.7 9.5-7.5-5.3-10.9L332 136zM385.9 58.9l5.2 10.9 11.8-2.7-5.3 10.9 9.5 7.5-11.8 2.7v12.1l-9.4-7.6-9.5 7.6.1-12.1-11.8-2.7 9.5-7.5-5.3-10.9 11.8 2.7zM428.4 108.6l5.2 10.9 11.8-2.7-5.3 10.9 9.5 7.5-11.8 2.6V150l-9.4-7.6-9.5 7.6v-12.2l-11.8-2.6 9.5-7.5-5.3-10.9 11.8 2.7zM398 166.5l4.1 12.7h13.3l-10.8 7.8 4.2 12.7-10.8-7.9-10.8 7.9 4.1-12.7-10.7-7.8h13.3z"></path><path d="M254.8 0v30.6l-45.1 25.1h45.1V115h-59.1l59.1 32.8v22.9h-26.7l-73.5-40.9v40.9H99v-48.6l-87.4 48.6H-1.2v-30.6L44 115H-1.2V55.7h59.1L-1.2 22.8V0h26.7L99 40.8V0h55.6v48.6L242.1 0z"></path></g><path fill="#D80027" d="M142.8 0h-32v69.3h-112v32h112v69.4h32v-69.4h112v-32h-112z"></path><path fill="#0052B4" d="M154.6 115l100.2 55.7v-15.8L183 115z"></path><path fill="white" d="M154.6 115l100.2 55.7v-15.8L183 115z"></path><g fill="#D80027"><path d="M154.6 115l100.2 55.7v-15.8L183 115zM70.7 115l-71.9 39.9v15.8L99 115z"></path></g><path fill="#0052B4" d="M99 55.7L-1.2 0v15.7l71.9 40z"></path><path fill="white" d="M99 55.7L-1.2 0v15.7l71.9 40z"></path><g fill="#D80027"><path d="M99 55.7L-1.2 0v15.7l71.9 40zM183 55.7l71.8-40V0L154.6 55.7z"></path></g></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Australia +61</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="white" d="M0 85.337h512v341.326H0z"></path><path fill="#D80027" d="M0 85.337h512V256H0z"></path><g fill="white"><path d="M83.478 170.666c0-24.865 17.476-45.637 40.812-50.734a52.059 52.059 0 00-11.13-1.208c-28.688 0-51.942 23.254-51.942 51.941s23.255 51.942 51.942 51.942c3.822 0 7.543-.425 11.13-1.208-23.336-5.095-40.812-25.867-40.812-50.733zM150.261 122.435l3.684 11.337h11.921l-9.645 7.007 3.684 11.337-9.644-7.006-9.645 7.006 3.685-11.337-9.645-7.007h11.921z"></path><path d="M121.344 144.696l3.683 11.337h11.921l-9.645 7.007 3.684 11.337-9.643-7.006-9.645 7.006 3.685-11.337-9.645-7.007h11.921zM179.178 144.696l3.684 11.337h11.921l-9.645 7.007 3.684 11.337-9.644-7.006-9.644 7.006 3.685-11.337-9.645-7.007h11.921zM168.047 178.087l3.684 11.337h11.921l-9.644 7.007 3.684 11.337-9.645-7.006-9.643 7.006 3.684-11.337-9.644-7.007h11.92zM132.474 178.087l3.683 11.337h11.921l-9.644 7.007 3.684 11.337-9.644-7.006-9.644 7.006 3.684-11.337-9.644-7.007h11.92z"></path></g></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Singapore +65</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="#0052B4" d="M0 85.334h512v341.337H0z"></path><g fill="#D80027"><path d="M425.301 233.745l3.388 10.428h10.963l-8.87 6.444 3.388 10.427-8.869-6.444-8.871 6.444 3.388-10.427-8.87-6.444h10.963zM386.107 308.817l5.083 15.642h16.445l-13.305 9.667 5.082 15.64-13.305-9.667-13.305 9.667 5.083-15.64-13.305-9.667h16.445zM387.588 185.971l4.236 13.036h13.704l-11.088 8.054 4.235 13.034-11.087-8.056-11.088 8.056 4.235-13.034-11.087-8.054h13.704zM349.876 233.291l5.082 15.641h16.446l-13.306 9.666 5.084 15.641-13.306-9.666-13.305 9.666 5.082-15.641-13.305-9.666h16.445z"></path></g><path fill="white" d="M256.003 85.329v30.564l-45.178 25.088h45.178v59.359H196.89l59.113 32.846v22.806h-26.69l-73.484-40.826v40.826h-55.652v-48.573l-87.429 48.573H.003v-30.553l45.168-25.099H.003v-59.359h59.103L.003 108.147V85.329h26.68l73.494 40.838V85.329h55.652v48.573l87.43-48.573z"></path><path fill="#D80027" d="M144 85.33h-32v69.334H0v32h112v69.334h32v-69.334h112v-32H144z"></path><path fill="#0052B4" d="M155.826 200.344L256 255.998v-15.739l-71.847-39.915z"></path><path fill="white" d="M155.826 200.344L256 255.998v-15.739l-71.847-39.915z"></path><g fill="#D80027"><path d="M155.826 200.344L256 255.998v-15.739l-71.847-39.915zM71.846 200.344L0 240.259v15.739l100.174-55.654z"></path></g><path fill="#0052B4" d="M100.174 140.983L0 85.33v15.738l71.847 39.915z"></path><path fill="white" d="M100.174 140.983L0 85.33v15.738l71.847 39.915z"></path><g fill="#D80027"><path d="M100.174 140.983L0 85.33v15.738l71.847 39.915zM184.154 140.983L256 101.068V85.33l-100.174 55.653z"></path></g></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">New Zealand +64</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="#D80027" d="M0 85.331h512v341.337H0z"></path><path d="M0 85.331h512v113.775H0z"></path><path fill="#FFDA44" d="M0 312.882h512v113.775H0z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Germany +49</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 513 342"><path fill="white" d="M0 0h513v342H0z"></path><path fill="#6DA544" d="M0 0h513v114H0z"></path><path d="M0 228h513v114H0z"></path><path fill="#dd0d12" d="M0 0h171v342H0z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">United Arab Emirates +971</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 513 342"><path fill="#D80027" d="M0 0h513v342H0z"></path><g fill="white"><path d="M274.2 119.8c-5.1 21.1-14.1 17.1-18.5 35.5-26.1-6.3-42.1-32.5-35.9-58.6 6.3-26.1 32.5-42.1 58.5-35.9-8.7 36.9.5 40.1-4.1 59zM206.6 135.4c18.5 11.3 11.9 18.7 28 28.6-14 22.9-43.9 30-66.8 16s-30-43.9-16-66.8c32.3 19.8 38.2 12.1 54.8 22.2zM200.6 204.6c16.5-14.1 21.4-5.5 35.8-17.8 17.4 20.4 15 51-5.4 68.4-20.4 17.4-51 15-68.4-5.4 28.7-24.6 23.2-32.6 38-45.2zM264.5 231.7c-8.3-20.1 1.4-22.1-5.9-39.6 24.8-10.3 53.2 1.5 63.4 26.3 10.3 24.8-1.5 53.2-26.3 63.4-14.5-35-23.8-32.2-31.2-50.1zM310 179.3c-21.6 1.7-20.6-8.1-39.5-6.6-2.1-26.7 17.9-50.1 44.6-52.2 26.7-2.1 50.1 17.9 52.2 44.6-37.7 2.9-37.9 12.7-57.3 14.2z"></path></g></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Hong Kong +852</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="white" d="M0 85.331h512v341.326H0z"></path><path fill="#6DA544" d="M0 85.331h170.663v341.337H0z"></path><path fill="#FF9811" d="M341.337 85.331H512v341.337H341.337z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Ireland +353</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 513 342"><path fill="#DB3E00" d="M0 0h513v342H0z"></path><path fill="#479900" d="M331 0h182v342H331z"></path><path d="M0 0h181.8v342H0z"></path><path fill="white" d="M256 126.7c-19.4 0-35.2 15.8-35.2 35.2v52.8h70.4v-52.8c0-19.5-15.8-35.2-35.2-35.2z"></path><path fill="white" d="M256 84.3c-47.7 0-86.4 38.7-86.4 86.4S208.3 257 256 257s86.4-38.7 86.4-86.4-38.7-86.3-86.4-86.3zm0 157.7c-39.4 0-71.4-32-71.4-71.4 0-39.4 32-71.4 71.4-71.4 39.4 0 71.4 32 71.4 71.4 0 39.5-32 71.4-71.4 71.4z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Afghanistan +93</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 513 342"><path fill="#0052B4" d="M0 0h513v342H0z"></path><path fill="#FFDA44" d="M513 210.9H202.2V342h-79.8V210.9H0V131.1h122.4V0h79.8v131.1H513v61.2z"></path><path fill="#D80027" d="M513 149.7v42.6H183.7V342H141V192.3H0v-42.6h141V0h42.7v149.7z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Aland Islands +358</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 90 60"><path fill="#ED2024" d="M0 0h90v60H0z"></path><path fill="#212121" d="M32.5 12.2v16l7.1 2.5-5 4.9 2.4 3 5.3-5.5 1.2 2.3-3 4.9 3.6 5.6-1.8 2.6 2.8 3.6 2.7-3.7-1.5-2.6 3-5.8-2.7-4.6 1.2-2.3 5.2 5.5 2.5-2.9-5.2-5.1 7.2-2.6V12.2l-5.2 1.9-.1 3.8-3.3.3v-2.6l1.7-2.3 5.6-2.2-2.3-.4 1.4-1.2.9.4-.8-1.4L54 9l-1-1.1L47.5 9l1.4 1.1-3.8 4.9-3.8-4.8 1.3-1.1-5-1.2L36.2 9l-1.5-.4-.8 1.4.9-.6 1.6 1.1-2.3.5 5.5 2 1.6 2.3v2.9l-3.3-.3v-3.6z"></path><g fill="#212121"><path d="M26.2 25h6.4v2.5h-6.4zM26.2 20.9h6.4v2.7h-6.4zM26.2 16.7h6.4v2.6h-6.4zM26.2 12.7h6.4v2.5h-6.4z"></path></g><g fill="#212121"><path d="M57.4 25h6.4v2.5h-6.4zM57.4 20.9h6.4v2.7h-6.4zM57.4 16.7h6.4v2.6h-6.4zM57.4 12.7h6.4v2.5h-6.4z"></path></g><path fill="#212121" d="M53.4 36.1h6.4V38h-6.4zM30.2 36.1h6.4V38h-6.4z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Albania +355</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 341.3"><path fill="#41662E" d="M0 0h512v341.3H0z"></path><path fill="white" d="M256 0h256v341.3H256z"></path><g fill="#D80027"><path d="M341.5 105.3l-29.4 40.4-47.5-15.4 29.4 40.4-29.4 40.4 47.5-15.4 29.4 40.4v-50l47.5-15.5-47.5-15.4z"></path><path d="M309.9 276.7c-58.5 0-106-47.5-106-106s47.5-106 106-106c18.3 0 35.4 4.6 50.4 12.7-23.5-23-55.7-37.2-91.2-37.2-72 0-130.4 58.4-130.4 130.4S197.1 301 269.1 301c35.5 0 67.7-14.2 91.2-37.2-14.9 8.2-32.1 12.9-50.4 12.9z"></path></g></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Algeria +213</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 513 342"><path fill="#0052B4" d="M0 0h513v342H0z"></path><path fill="#D80027" d="M513 33L95.3 171 513 310.76v30.57L0 171 513 0z"></path><path fill="white" d="M513 287.18v24.58L81.72 171 513 30v24.16"></path><path fill="#A2001D" d="M476.98 140.21l-21.89 10.68-3.18-15.32 31.19-29.77s-9.42-40.65-13.75-44.98l-112.32 55.82-6.84 36.76-31.9 28.59-.4 34.2 34.29-22.76 67.23-2.66-1.51 38.11h22.23l11.9-44.64 31.55-24.61-6.6-19.42z"></path><path fill="#EFC100" stroke="#231F20" stroke-miterlimit="10" d="M317.89 238.41l-22.24-11.11 22.24-11.11h144.46v22.22z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">AmericanSamoa +1684</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 513 342"><path fill="#FFDA44" d="M0 0h513v342H0z"></path><path fill="#0052B4" d="M0 0h171v342H0z"></path><path fill="#D80027" d="M342 0h171v342H342zM198.92 113.58H256v64.8h-57.08zM309.16 228.68L256 243.18v-64.8h57.08z"></path><path fill="#BC8B00" d="M182.24 95.92v92.2c0 34.32 27.26 54.17 48.63 64.46-.8 1.37 25.13 8.26 25.13 8.26s25.93-6.9 25.13-8.26c21.38-10.29 48.63-30.14 48.63-64.46v-92.2H182.24zm129.86 92.2c0 16.88-10 29.43-32.76 43.9-8.62 5.48-17.54 9.03-23.34 11.01-5.8-1.98-14.72-5.53-23.34-11.01-22.76-14.47-32.76-28.02-32.76-43.9v-74.54h112.2v74.54z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Andorra +376</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 513 342"><path d="M0 171h513v171H0z"></path><path fill="#D80027" d="M0 0h513v171H0z"></path><g fill="#FFDA44"><path d="M197.01 139.81c-9.32 12.37-9 27.81 3.37 37.12 0 0 162.62 122.13 164.64 123.93 2.02 1.8 6.3 2.38 11-3.27 4.46-5.36 3.31-9.78 1.04-11.63S197.01 139.81 197.01 139.81zM264.42 79.12l11.72 24.03 26.45 3.96-19.23 18.58 4.4 26.38-23.61-12.55-23.73 12.33 4.64-26.33L226 106.77l26.47-3.73z"></path><path d="M268.67 39.2l-3.2 22.04c51.81 3.9 92.64 47.18 92.64 99.99 0 55.38-44.9 100.28-100.28 100.28-40.82 0-75.94-24.39-91.59-59.4l-18.4 13.11c19.96 40.59 61.71 68.52 110 68.52 67.66 0 122.51-54.85 122.51-122.51-.01-64.01-49.1-116.54-111.68-122.03z"></path></g></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Angola +244</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 513 342"><path fill="#0052B4" d="M0 0h513v342H0z"></path><path fill="white" d="M454.8 265.38c7.94-10.93 13.24-24.27 13.24-40.42V104.89a59.754 59.754 0 01-36.02 12.01c-19.64 0-37.07-9.43-48.03-24.01-10.95 14.58-28.39 24.01-48.03 24.01-13.52 0-25.99-4.47-36.02-12v120.06c0 16.16 5.3 29.5 13.24 40.42H454.8z"></path><path fill="#8DCCFF" d="M310.23 260.98C332.65 296.96 384 309 384 309s51.35-12.04 73.77-48.02H310.23z"></path><path fill="#D87B00" d="M396.66 172.21c.32 1.42 8.72 10.17 17.56 20.15 1.39 1.57-8.74 12.63-6.91 12.59 4.75-.12 19.27-17.26 19.34 6.65.05 15.94-30 27.51-30 27.51h17.47l.65 14.96s4.97-13.34 7.59-16.57c8.1-9.97 20.18-30.07 34.59-27.1 14.41 2.97-13.66-13.92-13.66-13.92s-5.2-15.19-16.63-16.97c-10.06-1.57-14.29-2.51-26.64-7.3-1.68-.65-3.88-2.32-3.36 0z"></path><path fill="#D87B00" d="M359.69 198.69c1.07-.99 4.46-12.63 8.69-25.28.67-1.99 15.31 1.27 14.35-.3-2.47-4.06-24.58-8.08-3.9-20.08 13.79-8 38.82 12.27 38.82 12.27l-8.72-15.14 12.64-8.03s-14.05 2.35-18.14 1.69c-12.68-2.04-36.13-2.48-40.75-16.45-4.62-13.97-5.25 18.79-5.25 18.79s-10.56 12.08-6.4 22.88c3.66 9.5 4.96 13.64 6.97 26.73.29 1.79-.06 4.53 1.69 2.92z"></path><path fill="#D87B00" d="M395.67 219.87c-1.39-.43-13.16 2.49-26.22 5.18-2.06.42-6.59-13.88-7.47-12.26-2.27 4.17 5.36 25.31-15.41 13.45-13.84-7.91-8.89-39.73-8.89-39.73l-8.71 15.14-13.29-6.9s9.09 10.96 10.57 14.84c4.6 11.99 16 32.49 6.24 43.49-9.76 11.01 18.88-4.9 18.88-4.9s15.76 3.07 23-5.96c6.38-7.94 9.3-11.14 19.61-19.45 1.43-1.12 3.97-2.19 1.69-2.9z"></path><path fill="white" d="M256.5 0h-23.1L160 48.9V0H96v48.9L22.6 0H0v22.7l46.1 30.7H0v64h46.1L0 148.1V171h22.6L96 121.8V171h64v-49.2l73.4 49.2h23.1v-22.9l-46.6-30.7h46.6v-64h-46.6l46.6-30.7z"></path><path fill="#D80027" d="M144 0h-32v69.4H0v32h112V171h32v-69.6h112.5v-32H144z"></path><path fill="#D80027" d="M0 171v-11.3l62.5-42.3h22.6L7.3 171zM7.3.1l77.8 53.2H62.5L0 11.1V.1zM256.5.1v11l-63 42.3h-22.6L248.7.1zM248.7 171l-77.8-53.6h22.6l63 42.3V171z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Anguilla +1264</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 744 496"><path fill="#3A7DCE" d="M0 0h744v496H0V0z"></path><path fill="white" d="M120 125l90 63 54-14 23-81 61-36 92 14 105 55 6 90 34 12v92l-65 115-78 24-72-17 18-30-8-32-10 9-162-25-49-85 20-46-49-62z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Antarctica +672</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 513 342"><path d="M0 0h513v342H0z"></path><path fill="#186DD2" d="M88.8 136.5c-2.2 12.9-3.4 26.2-3.4 39.8 0 13.6 1.2 27 3.4 39.8L256 228.3l167.2-12.1c2.2-12.9 3.4-26.2 3.4-39.8s-1.2-27-3.4-39.8"></path><path fill="white" d="M423.2 219H88.8c15.8 69.8 84.7 122.3 167.2 122.3S407.4 288.8 423.2 219z"></path><path fill="#FFDA44" d="M365.9 136.5H146.1l44.9-21.1-23.9-43.5 48.8 9.4L222 32l34 36.2L290 32l6.1 49.3 48.8-9.4-23.9 43.5z"></path><g fill="#C32500"><path d="M256.5 342L0 0v342z"></path><path d="M513 342V0L256 342z"></path></g></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Antigua and Barbuda +1268</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 513 342"><path fill="white" d="M0 0h512v342H0z"></path><path fill="#338AF3" d="M0 0h512v114H0zM0 228h512v114H0z"></path><circle fill="#FFDA44" stroke="#d6ab00" stroke-width="5" cx="256.5" cy="171" r="40"></circle></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Argentina +54</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 513 342"><path fill="#0052B4" d="M0 0h513v342H0z"></path><path fill="#D80027" d="M0 0h513v114H0z"></path><path fill="#FF9811" d="M0 228h513v114H0z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Armenia +374</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 363 242"><path fill="#338AF3" d="M0 0h363v242H0z"></path><path fill="white" d="M57 96.9L14.7 78.2 57 59.6l18.6-42.2 18.6 42.2 42.3 18.6-42.3 18.7-18.6 42.2z"></path><path fill="#D80027" d="M75.6 40.6l11.5 26.1 26.1 11.5-26.1 11.5-11.5 26.1-11.5-26.1L38 78.2l26.1-11.5z"></path><g fill="#FFDA44"><path d="M0 152.2h363v15.7H0zM0 183.6h363v15.7H0z"></path></g></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Aruba +297</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 513 342"><path fill="#0052B4" d="M0 0h513v342H0z"></path><path fill="white" d="M440.1 181.1c-.1 39.2-6.4 81.4-57.4 101.5-51.1-20.1-57.3-62.3-57.4-101.5h114.8z"></path><path fill="#29DBFF" d="M439.6 197.7c-2.8 34.9-12.4 67.4-57 85-44.4-17.6-54.5-51.2-56.9-84.9"></path><path fill="white" d="M437.8 214.1c-3.2 24.3-16.7 53.5-55.1 68.6-38.4-15.1-50.5-42.5-55.1-68.4"></path><path fill="#29DBFF" d="M434.2 230.3c-5.7 17.7-19.3 39.4-51.3 52.8-32-12.6-45.2-33.8-51.4-53"></path><path fill="white" d="M426.7 246.9c-6.5 11.3-17.7 25.4-44 35.9-27.5-11.5-37.4-25.3-44-36.1"></path><path fill="#29DBFF" d="M412.4 265.1c-8.1 7.2-12 11.2-29.6 17.9-20.1-7.9-22.6-11.6-29.2-17.5"></path><path fill="#5CC85C" d="M383.3 231.6c-.2-.2-27.9 35.7-27.9 35.7-1.8-1.3-10-9.5-13.3-15l41.3-50.1 40.2 49.7c-3.9 6.5-11.4 13.6-13.2 15M382.6 85.3l-26.5 45h53z"></path><ellipse transform="rotate(-82.3 291.431 225.686)" fill="#F7A226" cx="291.4" cy="225.7" rx="48.7" ry="15.7"></ellipse><ellipse transform="rotate(-68.099 303.087 164.67)" fill="#DDC7AB" cx="303.1" cy="164.7" rx="11.7" ry="7.2"></ellipse><ellipse transform="rotate(-81.738 291.697 271.697)" fill="#DDC7AB" cx="291.7" cy="271.7" rx="11.4" ry="3.3"></ellipse><ellipse transform="matrix(.9986 -.05353 .05353 .9986 -13.992 16.424)" fill="#DDC7AB" cx="299.6" cy="269.4" rx="3.3" ry="11"></ellipse><ellipse transform="rotate(-21.518 314.54 201.06)" fill="#DDC7AB" cx="314.5" cy="201.1" rx="4.1" ry="13.7"></ellipse><ellipse transform="rotate(-21.518 317.511 178.077)" fill="#DDC7AB" cx="317.5" cy="178.1" rx="13.7" ry="4.1"></ellipse><ellipse transform="rotate(-7.7 473.781 225.857)" fill="#F7A226" cx="473.6" cy="225.9" rx="15.7" ry="48.7"></ellipse><ellipse transform="rotate(-21.901 462.057 164.866)" fill="#DDC7AB" cx="462" cy="164.9" rx="7.2" ry="11.7"></ellipse><ellipse transform="rotate(-8.27 473.27 271.908)" fill="#DDC7AB" cx="473.4" cy="271.9" rx="3.3" ry="11.4"></ellipse><ellipse transform="matrix(.05353 -.9986 .9986 .05353 171.34 719.998)" fill="#DDC7AB" cx="465.5" cy="269.6" rx="11" ry="3.3"></ellipse><ellipse transform="rotate(-68.482 450.552 201.247)" fill="#DDC7AB" cx="450.6" cy="201.2" rx="13.7" ry="4.1"></ellipse><ellipse transform="rotate(-68.482 447.58 178.265)" fill="#DDC7AB" cx="447.6" cy="178.3" rx="4.1" ry="13.7"></ellipse><path fill="#B0C6CC" d="M373.3 130.3L356.1 155l17.8 26.1H396l4.7-25.4-5.4-25.4z"></path><path fill="white" d="M256 0v117.4h-46.1l46.1 30.7v22.6h-22.6L160 121.8v48.9H96v-48.9l-73.4 48.9H0v-22.6l46.1-30.7H0v-64h46.1L0 22.7V0h22.6L96 48.9V0h64v48.9L233.4 0z"></path><path fill="#D80027" d="M144 0h-32v69.4H0v32h112v69.3h32v-69.3h112v-32H144z"></path><path fill="#2E52B2" d="M256 22.7v30.7h-46.1z"></path><g><path fill="#D80027" d="M0 170.7v-11l62.5-42.3h22.6L7.3 170.7z"></path></g><path fill="#D80027" d="M7.3.1l77.8 53.2H62.5L0 11.1V.1zM256 .1v11l-62.5 42.3h-22.6L248.7.1zM248.7 170.7l-77.8-53.3h22.6l62.5 42.3v11z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Ascension Island +247</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 513 342"><path fill="white" d="M0 114h513v114H0z"></path><path fill="#D80027" d="M0 0h513v114H0zM0 228h513v114H0z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Austria +43</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 513 342"><path fill="#D80027" d="M0 0h513v342H0z"></path><path fill="#338AF3" d="M0 0h513v114H0z"></path><path fill="#6DA544" d="M0 228h513v114H0z"></path><g fill="white"><path d="M265.6 212.6c-23 0-41.6-18.6-41.6-41.6s18.6-41.6 41.6-41.6c7.2 0 13.9 1.8 19.8 5-9.2-9-21.9-14.6-35.8-14.6-28.3 0-51.2 22.9-51.2 51.2s22.9 51.2 51.2 51.2c13.9 0 26.6-5.6 35.8-14.6-5.9 3.2-12.6 5-19.8 5z"></path><path d="M297.6 142.2l5.5 15.5 14.9-7.1-7.1 14.9 15.5 5.5-15.5 5.5 7.1 14.9-14.9-7.1-5.5 15.5-5.5-15.5-14.9 7.1 7.1-14.9-15.5-5.5 15.5-5.5-7.1-14.9 14.9 7.1z"></path></g></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Azerbaijan +994</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="#FFDA44" d="M0 85.337h512v341.326H0z"></path><g fill="#338AF3"><path d="M0 85.337h512v113.775H0zM0 312.888h512v113.775H0z"></path></g><path d="M256 256.006L0 426.668V85.331z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Bahamas +1242</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="#D80027" d="M2.216 86.076H512v339.848H2.216z"></path><path fill="white" d="M209.455 154.969l-50.236 25.267 50.236 25.257-50.236 25.267 50.236 25.257-50.236 25.266 50.236 25.257-50.236 25.268 50.236 25.257-50.236 25.267 50.236 25.268-36.45 18.33H0V86.07h172.939l36.516 18.364-50.236 25.267z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Bahrain +973</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="#496E2D" d="M0 85.331h512v341.337H0z"></path><circle fill="#F40B32" cx="218.902" cy="255.994" r="115"></circle></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Bangladesh +880</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 341.33"><path fill="#FFDA44" d="M0 0h512v341.34H0z"></path><g fill="#0052B4"><path d="M0 0h170.66v341.34H0zM341.34 0H512v341.34H341.34z"></path></g><path d="M325.74 101.02l-31.97 12.4c-.68 1.35-5.79 7.54-8.18 53.06h-17.05v-60.42L256 78.68l-12.54 27v60.8H226.4c-2.39-45.53-7.8-52.48-8.47-53.84l-31.68-11.63c.15.31 15.4 31.34 15.4 78.01v12.54h41.81v71.07h25.08v-71.07h41.81v-12.54c0-24.13 4.17-44.02 7.68-56.46 3.82-13.57 7.7-21.49 7.74-21.57l-.03.03z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Barbados +1246</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 341.3"><path fill="#75AF2B" d="M.6.2H512v341H.6z"></path><path fill="#D32424" d="M0 230h512V.2H0"></path><path fill="white" d="M100.1 230V.2H0v340.9h511.4-411.3z"></path><path fill="#D32424" d="M51.6 218l-38-47.7 38-46.9 38 46.9zM51.6 113.4l-38-47.7 38-46.9 38 46.9zM51.6 322.6l-38-47.7 38-46.9 38 46.9z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Belarus +375</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="#FFDA44" d="M0 85.331h512v341.326H0z"></path><path d="M0 85.331h170.663v341.337H0z"></path><path fill="#D80027" d="M341.337 85.331H512v341.337H341.337z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Belgium +32</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 341.3"><path fill="#0052B4" d="M0 0h512v341.3H0z"></path><circle fill="white" cx="260.9" cy="170.9" r="118.9"></circle><circle fill="none" stroke="#6DA544" stroke-width="18" stroke-miterlimit="10" cx="261.9" cy="173.1" r="94.5"></circle><g stroke="black"><path fill="#0052B4" d="M261.9 151.5l-50.6 23.4v20c0 11.8 6.1 22.8 16.2 28.9L262 239l34.5-15.2c10-6.2 16.2-17.1 16.2-28.9v-20l-50.8-23.4z"></path><path fill="#FFDA44" d="M211.3 128.1h101.3v46.7H211.3z"></path></g><g fill="#BC0029"><path d="M0 0h512v35H0zM0 306h512v35H0z"></path></g></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Belize +501</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="#6DA544" d="M0 85.337h512v341.326H0z"></path><path fill="#FFDA44" d="M196.641 85.337H512V256H196.641z"></path><path fill="#D80027" d="M196.641 256H512v170.663H196.641z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Benin +229</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 341.33"><path fill="#D80027" d="M0 0h512v341.34H0z"></path><path fill="#0052B4" d="M0 .1h256v170.6H0z"></path><path fill="white" d="M256 0h-22.6L160 48.9V0H96v48.9L22.6 0H0v22.7l46.1 30.7H0v64h46.1L0 148.1v22.6h22.6L96 121.8v48.9h64v-48.9l73.4 48.9H256v-22.6l-46.1-30.7H256v-64h-46.1L256 22.7z"></path><path fill="#D80027" d="M144 0h-32v69.4H0v32h112v69.3h32v-69.3h112v-32H144z"></path><path fill="#D80027" d="M0 170.7v-11l62.5-42.3h22.6L7.3 170.7zM7.3.1l77.8 53.2H62.5L0 11.1V.1zM256 .1v11l-62.5 42.3h-22.6L248.7.1zM248.7 170.7l-77.8-53.3h22.6l62.5 42.3v11z"></path><g transform="translate(13 5)"><path fill="white" d="M303.9 94.94v99.69c0 59.81 79.75 99.69 79.75 99.69s79.75-39.88 79.75-99.69V94.94H303.9z"></path><path fill="#2F8F22" d="M436.37 254.44H330.93c23.13 25.08 52.72 39.88 52.72 39.88s29.59-14.8 52.72-39.88z"></path><circle fill="#65B5D2" cx="383.65" cy="214.56" r="39.88"></circle><circle fill="#D80027" cx="343.77" cy="194.63" r="19.94"></circle><circle fill="#D80027" cx="423.52" cy="194.63" r="19.94"></circle><circle fill="#D80027" cx="383.65" cy="154.75" r="19.94"></circle></g></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Bermuda +1441</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 341.3"><path fill="#FF7415" d="M0 0h512v341.3H0z"></path><path fill="#FFDA44" d="M512 0H0v341.3"></path><path fill="none" stroke="white" stroke-width="42" stroke-miterlimit="10" d="M128.7 255.5s35 54 67.3 32.4c56.9-37.9-68.9-108.6-2.9-152.6 58.3-38.8 76.6 103.5 137.6 62.8 59-39.3-64.7-111.4-9.2-148.4 33.4-22.2 67.1 32.6 67.1 32.6"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Bhutan +975</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="#FFDA44" d="M0 85.337h512v341.326H0z"></path><path fill="#D80027" d="M0 85.337h512v113.775H0z"></path><path fill="#6DA544" d="M0 312.888h512v113.775H0z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Bolivia +591</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="#0052B4" d="M0 85.334h512v341.337H0z"></path><path fill="#FFDA44" d="M99.905 85.329h341.333v341.334"></path><g fill="white"><path d="M36.561 100.645l14.843-10.807 14.867 10.794-4.979-15.302H41.525z"></path><path d="M88.332 103.632L82.649 86.16l-5.672 17.472-18.365.012 14.867 10.796-5.661 17.461 14.843-10.806 14.866 10.795-5.684-17.474 14.854-10.795z"></path><path d="M119.59 134.89l-5.684-17.474-5.673 17.474-18.365.011 14.867 10.795-5.661 17.462 14.844-10.807 14.866 10.796-5.685-17.474 14.856-10.794z"></path><path d="M150.846 166.146l-5.683-17.473-5.673 17.473-18.364.011 14.866 10.796-5.661 17.461 14.843-10.806 14.866 10.795-5.683-17.474 14.855-10.794z"></path><path d="M182.103 197.403l-5.683-17.474-5.672 17.474-18.366.011 14.866 10.795-5.66 17.462 14.843-10.807 14.866 10.796-5.684-17.473 14.855-10.795z"></path><path d="M213.359 228.659l-5.683-17.472-5.672 17.472-18.365.012 14.866 10.795-5.66 17.462 14.842-10.806 14.866 10.794-5.683-17.473 14.855-10.795z"></path><path d="M244.616 259.916l-5.683-17.473-5.672 17.473-18.366.012 14.867 10.795-5.661 17.462 14.844-10.807 14.866 10.794-5.685-17.472 14.855-10.794z"></path><path d="M275.872 291.173L270.19 273.7l-5.673 17.473-18.365.011 14.867 10.796-5.661 17.461 14.843-10.806 14.866 10.795-5.683-17.474 14.853-10.794z"></path><path d="M307.13 322.43l-5.683-17.474-5.674 17.474-18.364.011 14.866 10.795-5.661 17.462 14.844-10.807 14.866 10.796-5.684-17.474 14.855-10.794z"></path><path d="M338.386 353.686l-5.683-17.472-5.672 17.472-18.365.012 14.866 10.795-5.661 17.462 14.843-10.807 14.866 10.795-5.683-17.472 14.855-10.796z"></path><path d="M369.643 384.943l-5.683-17.473-5.672 17.473-18.366.012 14.866 10.794-5.66 17.463 14.843-10.807 14.866 10.795-5.684-17.473 14.855-10.795z"></path><path d="M395.216 398.727l-5.672 17.472-18.365.012 14.394 10.453h19.278l14.414-10.476-18.366.011z"></path></g></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Bosnia and Herzegovina +387</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="white" d="M0 85.337h512v341.326H0z"></path><g fill="#338AF3"><path d="M0 322.783h512v103.88H0zM0 85.337h512v104.515H0z"></path></g><path d="M0 210.877h512v89.656H0z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Botswana +267</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 341.3"><path fill="#6DA544" d="M0 0h512v341.3H0z"></path><path fill="#FFDA44" d="M256 19.3l205.4 151.4L256 322 50.6 170.7z"></path><circle fill="white" cx="256" cy="170.7" r="86.5"></circle><g fill="#0052B4"><path d="M212.8 165.3c-15 0-29.5 2.3-43.2 6.5.6 47.2 39.1 85.3 86.4 85.3 29.3 0 55.2-14.6 70.8-36.9-26.7-33.4-67.9-54.9-114-54.9zM340.9 187.2c1-5.4 1.6-10.9 1.6-16.6 0-47.8-38.7-86.5-86.5-86.5-35.6 0-66.2 21.6-79.5 52.3 11.7-2.4 23.8-3.7 36.2-3.7 50.3.1 95.7 21 128.2 54.5z"></path></g></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Brazil +55</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 513 342"><path fill="white" d="M0-.3h513V342H0V-.3z"></path><path fill="#0052B4" d="M462.9 198.1c-4 0-14-5-21-9-11-6-21-12-31.1-12s-20 6-31.1 12c-7 4-16 9-20 9s-14-5-20-9c-11-6-22-12-32.1-12-9 0-20 6-31.1 12-7 4-16 9-20 9s-13-5-20-9c-11-6-22-12-31.1-12-10 0-21 6-32.1 12-6 4-16 9-20 9s-13-5-20-9c-11-6-21-12-31.1-12s-20 6-31.1 12c-7 4-17 9-21 9s-13-5-20-9c-10-6-20-12-30.1-12v22l19 10c11 6 21 12 31.1 12s21-6 32.1-12c6-4 16-10 20-10s13 6 20 10c11 6 21 12 31.1 12s20-6 31.1-12c7-4 17-10 21-10s13 6 20 10c11 6 21 12 31.1 12s20-6 31.1-12c7-4 16-10 20-10s14 6 21 10c11 6 21 12 31.1 12s20-6 31.1-12c7-4 16-10 20-10s14 6 20 10c11 6 22 12 32.1 12s20-6 31.1-12l19-10v-22c-10 0-20 6-30.1 12-7 4-16 9-20 9zM0 31.7l19 10c11 6 21 12 31.1 12s21-6 32.1-12c6-4 16-10 20-10s13 6 20 10c11 6 21 12 31.1 12s20-6 31.1-12c7-4 17-10 21-10s13 6 20 10c11 6 21 12 31.1 12s20-6 31.1-12c7-4 16-10 20-10s14 6 21 10c11 6 21 12 31.1 12s20-6 31.1-12c7-4 16-10 20-10s14 6 20 10c11 6 22 12 32.1 12s20-6 31.1-12l19-10v-22c-10 1-20 6-30.1 12-7 4-16 9-20 9s-14-5-21-9c-11-6-21-12-31.1-12s-20 6-31.1 12c-7 4-16 9-20 9s-14-5-20-9c-11-6-22-12-32.1-12s-20 6-31.1 12c-7 4-16 9-20 9s-13-5-20-9c-11-6-22-12-31.1-12s-21 6-32.1 12c-6 4-16 9-20 9s-13-5-20-9c-11-6-21-12-31.1-12s-20 6-31.1 12c-7 4-17 9-21 9s-13-5-20-9c-10-6-20-11-30.1-12v22zm462.9 55.2c-4 0-14-5-21-9-11-6-21-12-31.1-12s-20 6-31.1 12c-7 4-16 9-20 9s-14-5-20-9c-11-6-22-12-32.1-12-9 0-20 6-31.1 12-7 4-16 9-20 9s-13-5-20-9c-11-6-22-12-31.1-12-10 0-21 6-32.1 12-6 4-16 9-20 9s-13-5-20-9c-11-6-21-12-31.1-12s-20 6-31.1 12c-7 4-17 9-21 9s-13-5-20-9c-10-6-20-12-30.1-12v22l19 9c11 6 21 12 31.1 12s21-6 32.1-12c6-4 16-9 20-9s13 5 20 9c11 6 21 12 31.1 12s20-6 31.1-12c7-4 17-9 21-9s13 5 20 9c11 6 21 12 31.1 12s20-6 31.1-12c7-4 16-9 20-9s14 5 21 9c11 6 21 12 31.1 12s20-6 31.1-12c7-4 16-9 20-9s14 5 20 9c11 6 22 12 32.1 12s20-6 31.1-12l19-9v-22c-10 0-20 6-30.1 12-7 3.9-16 9-20 9zm50.1 34c-10 1-20 6-30.1 12-7 4-16 10-20 10s-14-6-21-10c-11-6-21-12-31.1-12s-20 6-31.1 12c-7 4-16 10-20 10s-14-6-20-10c-11-6-22-12-32.1-12s-20 6-31.1 12c-7 4-16 10-20 10s-13-6-20-10c-11-6-22-12-31.1-12s-21 6-32.1 12c-6 4-16 10-20 10s-13-6-20-10c-11-6-21-12-31.1-12s-20 6-31.1 12c-7 4-17 10-21 10s-13-6-20-10c-10-6-20-11-30.1-12v23c4 1 13 5 19 9 11 6 21 12 31.1 12s21-6 32.1-12c6-4 16-9 20-9s13 5 20 9c11 6 21 12 31.1 12s20-6 31.1-12c7-4 17-9 21-9s13 5 20 9c11 6 21 12 31.1 12s20-6 31.1-12c7-4 16-9 20-9s14 5 21 9c11 6 21 12 31.1 12s20-6 31.1-12c7-4 16-9 20-9s14 5 20 9c11 6 22 12 32.1 12s20-6 31.1-12c6-4 15-8 19-9v-23zm-50.1 133.3c-4 0-14-5-21-9-11-6-21-12-31.1-12s-20 6-31.1 12c-7 4-16 9-20 9s-14-5-20-9c-11-6-22-12-32.1-12-9 0-20 6-31.1 12-7 4-16 9-20 9s-13-5-20-9c-11-6-22-12-31.1-12-10 0-21 6-32.1 12-6 4-16 9-20 9s-13-5-20-9c-11-6-21-12-31.1-12s-20 6-31.1 12c-7 4-17 9-21 9s-13-5-20-9c-10-6-20-12-30.1-12v22l19 9c11 6 21 12 31.1 12s21-6 32.1-12c6-4 16-9 20-9s13 5 20 9c11 6 21 12 31.1 12s20-6 31.1-12c7-4 17-9 21-9s13 5 20 9c11 6 21 12 31.1 12s20-6 31.1-12c7-4 16-9 20-9s14 5 21 9c11 6 21 12 31.1 12s20-6 31.1-12c7-4 16-9 20-9s14 5 20 9c11 6 22 12 32.1 12s20-6 31.1-12l19-9v-22c-10 0-20 6-30.1 12-7 4-16 9-20 9zm50.1 34c-10 1-20 6-30.1 12-7 4-16 10-20 10s-14-6-21-10c-11-6-21-12-31.1-12s-20 6-31.1 12c-7 4-16 10-20 10s-14-6-20-10c-11-6-22-12-32.1-12s-20 6-31.1 12c-7 4-16 10-20 10s-13-6-20-10c-11-6-22-12-31.1-12s-21 6-32.1 12c-6 4-16 10-20 10s-13-6-20-10c-11-6-21-12-31.1-12s-20 6-31.1 12c-7 4-17 10-21 10s-13-6-20-10c-10-6-20-11-30.1-12v23c4 0 13 5 19 9 11 6 21 12 31.1 12s21-6 32.1-12c6-4 16-9 20-9s13 5 20 9c11 6 21 12 31.1 12s20-6 31.1-12c7-4 17-9 21-9s13 5 20 9c11 6 21 12 31.1 12s20-6 31.1-12c7-4 16-9 20-9s14 5 21 9c11 6 21 12 31.1 12s20-6 31.1-12c7-4 16-9 20-9s14 5 20 9c11 6 22 12 32.1 12s20-6 31.1-12c6-4 15-9 19-9v-23z"></path><path fill="white" d="M0-.3h256v171H0V-.3z"></path><path d="M389.8 119.9H408v78.8h-18.3l.1-78.8zm0 117.8H408v75.1h-18.3l.1-75.1z" fill="#A2001D"></path><g fill="#D80027"><path d="M144-.3h-32v70H0v32h112v69h32v-69h112v-32H144v-70z"></path><path d="M0-.3v15l57 39h23L0-.3zM256-.3v15l-57 39h-23l80-54z"></path><path d="M0-.3v15l57 39h23L0-.3zM256-.3v15l-57 39h-23l80-54zM0 170.7v-15l57-38h23l-80 53zM256 170.7v-15l-57-38h-23l80 53z"></path></g><g fill="#2E52B2"><path d="M0 22.7v31h46l-46-31zm96-23v49L23-.3h73zM256 22.7v31h-46l46-31zm-96-23v49l73-49h-73z"></path><path d="M0 22.7v31h46l-46-31zm96-23v49L23-.3h73zM256 22.7v31h-46l46-31zm-96-23v49l73-49h-73zM0 147.7v-30h46l-46 30zm96 23v-49l-73 49h73zM256 147.7v-30h-46l46 30zm-96 23v-49l73 49h-73z"></path></g><path fill="#5DA51E" stroke="#45602C" stroke-width="4" stroke-miterlimit="10" d="M462.8 91.5h-29.1l25.7-25.7c4.5-4.4 4.5-11.4 0-15.8l-3.4-3.4c-4.4-4.4-11.4-4.4-15.8 0l-25.9 25.9V37.4c0-6.2-5.1-11.3-11.3-11.3h-4.7c-6.2 0-11.3 5.1-11.3 11.3v31.7l-23.5-23.8c-4.7-4.7-12.2-4.7-16.9 0l-3.6 3.6c-4.7 4.7-4.7 12.4 0 17.2l25 25.4h-30.6c-6 0-10.9 4.9-10.9 10.9v4.6c0 6 4.9 10.9 10.9 10.9H369l-20.7 20.7c-4.4 4.4-4.4 11.4 0 15.8l3.4 3.4c4.4 4.4 11.4 4.4 15.8 0l19.6-19.6V167c0 6.1 5.1 11.1 11.3 11.3h4.7c6.2 0 11.3-5.1 11.3-11.3v-28.3l22.2 22.6c4.7 4.7 12.4 4.7 17.1 0l3.6-3.6c4.7-4.7 4.7-12.4 0-17.2L435.2 118h27.6c5.9 0 10.7-4.9 10.9-10.9v-4.6c0-6.1-4.9-11-10.9-11z"></path><path fill="#E2DD24" stroke="#525625" stroke-width="4" stroke-miterlimit="10" d="M439.2 249.1h-79.8s-.9-13.4-6-21.8c-6.2-10.4-13.9-28.1-1.4-36.7 15.9-10.9 33.7.8 48.2.8 11.8.1 26.9-14 45-.8 12.2 8.9 3.9 28.2-1.3 36.7-7 11.5-4.7 21.8-4.7 21.8z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">British Indian Ocean Territory +246</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 341.33"><path fill="#FFDA44" d="M0 0h512v341.33H0z"></path><path d="M0 193.74l512 127.19V214.26L0 97.08z"></path><path fill="white" d="M512 234.26v-86.67L0 20.41v86.67"></path><g fill="#D80027" stroke="#231F20" stroke-width="3" stroke-miterlimit="10"><path d="M306.4 134.01a50.28 50.28 0 016.07 24.02c0 21.55-13.51 39.94-32.52 47.19v-59.51c5.7-1.19 10-6.37 10-12.59 6.9 0 12.5-5.75 12.5-12.85h-.42c6.9 0 12.91-5.75 12.91-12.85h-34.99V76.58l-14.99-27.71-15 27.71v30.84h-34.99c0 7.1 6.01 12.85 12.91 12.85h-.42c0 7.1 5.6 12.85 12.5 12.85 0 6.22 4.29 11.4 9.99 12.59v61.37c-22.09-5.39-38.48-25.3-38.48-49.05 0-8.7 2.2-16.88 6.07-24.02-10.96 11.21-17.72 26.53-17.72 43.44 0 34.32 27.82 62.15 62.15 62.15s62.15-27.83 62.15-62.15c0-16.91-6.77-32.24-17.72-43.44z"></path><path d="M198.46 226.81s20.69 27.71 66.5 27.71 66.5-27.71 66.5-27.71l13.47 28.37s-21.03 27.71-79.97 27.71-79.97-27.71-79.97-27.71l13.47-28.37zM129.24 133.18h20.88l24.93 27.26v73.45h-26.28v-68.37zM400 133.18h-20.88l-24.93 27.26v73.45h26.27v-68.37z"></path></g></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Brunei Darussalam +673</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="#496E2D" d="M0 85.337h512v341.326H0z"></path><path fill="white" d="M0 85.337h512v113.775H0z"></path><path fill="#D80027" d="M0 312.888h512v113.775H0z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Bulgaria +359</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 341.3"><path fill="#6DA544" d="M0 0h512v341.3H0z"></path><path fill="#D80027" d="M0 0h512v170.7H0z"></path><path fill="#FFDA44" d="M256 66.9l25.8 79.3h83.3l-67.4 49 25.7 79.3-67.4-49-67.4 49 25.7-79.3-67.4-49h83.3z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Burkina Faso +226</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 341.3"><path fill="#D80027" d="M0 0h512v341.3H0z"></path><g fill="#6DA544"><path d="M215.9 170.7L0 314.6V26.8zM512 26.8v287.8L296.1 170.7z"></path></g><path fill="#0052B4" d="M512 26.8L296.1 170.7 512 314.6v26.7h-40.1L256 197.4 40.1 341.3H0v-26.7l215.9-143.9L0 26.8V0h40.1L256 143.9 471.9 0H512z"></path><path fill="white" d="M512 26.8L296.1 170.7 512 314.6v26.7h-40.1L256 197.4 40.1 341.3H0v-26.7l215.9-143.9L0 26.8V0h40.1L256 143.9 471.9 0H512z"></path><circle fill="white" cx="251.6" cy="170.7" r="100.2"></circle><g fill="#D80027"><path d="M251.6 93.3l10.1 17.5h20.2l-10.1 17.5 10.1 17.5h-20.2l-10.1 17.5-10.1-17.5h-20.2l10.1-17.5-10.1-17.5h20.2zM210.3 163.4l10.1 17.5h20.3l-10.1 17.5 10.1 17.5h-20.3l-10.1 17.5-10.1-17.5H180l10.1-17.5-10.1-17.5h20.2zM292.8 163.4l10.1 17.5h20.2L313 198.4l10.1 17.5h-20.2l-10.1 17.5-10.1-17.5h-20.2l10.1-17.5-10.1-17.5h20.2z"></path></g></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Burundi +257</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="#D80027" d="M0 85.337h512v341.326H0z"></path><g fill="#0052B4"><path d="M0 85.337h512v113.775H0zM0 312.888h512v113.775H0z"></path></g><path fill="white" d="M303.49 281.971v-17.809h-11.873v-23.745l-11.872-11.872-11.872 11.872v-23.744L256 204.8l-11.873 11.873v23.744l-11.872-11.872-11.872 11.872v23.745H208.51v17.809h-11.872v17.808h118.724v-17.808z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Cambodia +855</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 341.3"><path fill="#D80027" d="M0 0h512v341.3H0z"></path><path fill="#496E2D" d="M0 0h170.7v341.3H0z"></path><g fill="#FFDA44"><path d="M341.3 0H512v341.3H341.3zM256 102.2l17.2 53H329L283.9 188l17.2 53-45.1-32.7-45.1 32.7 17.2-53-45.1-32.8h55.8z"></path></g></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Cameroon +237</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 341.3"><path fill="#0052B4" d="M0 0h512v341.3H0z"></path><path fill="#D80027" d="M0 182.2h512v41.4H0z"></path><path fill="white" d="M0 140.8h512v41.4H0zM0 223.6h512V265H0z"></path><g fill="#FFDA44" stroke="black" stroke-miterlimit="10"><path d="M150.4 70l6.9 21.1h22.2l-18 13.1 6.9 21.1-18-13.1-17.9 13.1 6.8-21.1-17.9-13.1h22.2zM150.4 279.7l6.9 21.1h22.2l-18 13 6.9 21.2-18-13.1-17.9 13.1 6.8-21.2-17.9-13h22.2zM52.8 208.8l6.9 21.1h22.2l-18 13 6.9 21.2-18-13.1-17.9 13.1 6.8-21.2-17.9-13H46zM90.1 91l6.9 21.1h22.2l-18 13 6.9 21.2-18-13.1-17.9 13.1 6.8-21.2-18-13h22.3zM23.8 162H46l6.8-21.1 6.9 21.1h22.2l-18 13.1 6.9 21.1-18-13-17.9 13 6.8-21.1zM72.2 310.9l6.8-21.1-18-13h22.3l6.8-21.2 6.9 21.2h22.2l-18 13 6.9 21.1-18-13zM248 208.8l-6.9 21.1h-22.2l18 13-6.9 21.2 18-13.1 18 13.1-6.9-21.2 18-13h-22.2zM210.7 91l-6.8 21.1h-22.2l17.9 13-6.8 21.2 17.9-13.1 18 13.1-6.9-21.2 18-13h-22.2zM277.1 162h-22.2l-6.9-21.1-6.9 21.1h-22.2l18 13.1-6.9 21.1 18-13 18 13-6.9-21.1zM228.7 310.9l-6.9-21.1 18-13h-22.2l-6.9-21.2-6.8 21.2h-22.2l17.9 13-6.8 21.1 17.9-13z"></path></g></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Cape Verde +238</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="#0052B4" d="M0 85.334h512v341.337H0z"></path><circle fill="#6DA544" cx="384" cy="181.79" r="29.682"></circle><path fill="#D80027" d="M332.054 174.377h103.88v44.522h-103.88z"></path><path fill="#496E2D" d="M435.942 255.997v-.001.001z"></path><path fill="#FFDA44" d="M332.058 285.678v29.682h15.616c9.364 9.176 22.18 14.84 36.326 14.84 14.147 0 26.962-5.664 36.326-14.84h15.616v-29.682H332.058z"></path><path fill="#338AF3" d="M332.058 211.475v44.522c0 39.759 51.942 51.942 51.942 51.942s51.942-12.182 51.942-51.942v-44.522H332.058z"></path><g fill="#F3F3F3"><path d="M383.997 235.256c-12.985 0-12.985 11.873-25.97 11.873s-12.985-11.873-25.97-11.873v20.777c12.985 0 12.985 11.873 25.97 11.873s12.985-11.873 25.97-11.873c12.986 0 12.986 11.873 25.973 11.873 12.986 0 12.986-11.873 25.973-11.873v-20.777c-12.986 0-12.986 11.873-25.973 11.873-12.986-.001-12.986-11.873-25.973-11.873zM383.997 193.666c-12.985 0-12.985 11.873-25.97 11.873s-12.985-11.873-25.97-11.873v20.777c12.985 0 12.985 11.873 25.97 11.873s12.985-11.873 25.97-11.873c12.986 0 12.986 11.873 25.973 11.873 12.986 0 12.986-11.873 25.973-11.873v-20.777c-12.986 0-12.986 11.873-25.973 11.873-12.986 0-12.986-11.873-25.973-11.873z"></path></g><path fill="white" d="M256 85.334v22.617l-46.069 30.709H256v64h-46.069L256 233.38v22.617h-22.628L160 207.078v48.919H96v-48.919l-73.372 48.919H0V233.38l46.069-30.72H0v-64h46.069L0 107.951V85.334h22.628L96 134.241V85.334h64v48.907l73.372-48.907z"></path><g fill="#D80027"><path d="M144 85.329h-32v69.334H0v32h112v69.334h32v-69.334h112v-32H144z"></path><path d="M0 85.329v15.082l57.377 38.252H80zM256 85.329v15.082l-57.377 38.252H176z"></path><path d="M0 85.329v15.082l57.377 38.252H80zM256 85.329v15.082l-57.377 38.252H176zM0 255.997v-15.082l57.377-38.252H80zM256 255.997v-15.082l-57.377-38.252H176z"></path></g></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Cayman Islands +1345</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 341.3"><path fill="#D80027" d="M0 0h512v341.3H0z"></path><g fill="#6DA544"><path d="M0 170.7h211.5V256H0zM300.5 170.7H512V256H300.5z"></path></g><path fill="#0052B4" d="M0 0v85.3h211.5V0h89v85.3H512V0z"></path><g fill="white"><path d="M300.5 85.3H512v85.3H300.5zM0 85.3h211.5v85.3H0z"></path></g><g fill="#FFDA44"><path d="M300.5 341.3h-89V256H0v85.3h512V256H300.5zM105.7 8.6l8.6 26.2h27.5L119.5 51l8.6 26.2L105.7 61 83.4 77.2 91.9 51 69.6 34.8h27.6z"></path></g></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Central African Republic +236</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="#FFDA44" d="M0 85.331h512v341.337H0z"></path><path fill="#0052B4" d="M0 85.331h170.663v341.337H0z"></path><path fill="#D80027" d="M341.337 85.331H512v341.337H341.337z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Chad +235</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="#D80027" d="M0 85.337h512v341.326H0z"></path><path fill="white" d="M256 85.337h256V256H256z"></path><path fill="#0052B4" d="M0 85.337h256V256H0z"></path><path fill="white" d="M128 109.801l15.108 46.498H192l-39.554 28.739 15.108 46.498L128 202.799l-39.554 28.737 15.108-46.498L64 156.299h48.892z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Chile +56</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 341.3"><path fill="#D80027" d="M0 0h512v341.3H0z"></path><g fill="#FFDA44"><path d="M352.3 312.6L328 294.9l-24.4 17.7 9.3-28.6-24.3-17.7h30.1l9.3-28.6 9.3 28.6h30.1L343 284zM415.9 120.9l-24.4 17.7 9.3 28.6-24.3-17.7-24.4 17.7 9.3-28.6-24.3-17.7h30.1l9.3-28.6 9.3 28.6zM367.4 57.4L343 75l9.3 28.7L328 86l-24.4 17.7 9.3-28.7-24.3-17.6h30.1l9.3-28.7 9.3 28.7zM415.9 204.4L391.5 222l9.3 28.7-24.3-17.7-24.4 17.7 9.3-28.7-24.3-17.6h30.1l9.3-28.7 9.3 28.7z"></path></g><path fill="#FFDA44" d="M167.6 64.4l26 80.3h84.5l-68.3 49.6 26.1 80.4-68.3-49.7-68.4 49.7 26.1-80.4L57 144.7h84.5z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">China +86</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 341.3"><path fill="#0052B4" d="M0 0h512v341.3H0z"></path><path fill="#6DA544" d="M0 0h512v341.3"></path><g fill="white"><path d="M77.6 272l5.7 11.9 12.8-3-5.7 11.9 10.3 8.1-12.8 2.9V317l-10.3-8.3-10.2 8.3v-13.2l-12.8-2.9 10.3-8.1-5.8-11.9 12.9 3zM40.5 173.1l5.7 11.9 12.8-3-5.7 11.8 10.3 8.2-12.9 2.9.1 13.2-10.3-8.3-10.3 8.3.1-13.2-12.9-2.9 10.4-8.2L22 182l12.8 3zM77.6 92.2l5.7 11.8 12.8-2.9-5.7 11.8 10.3 8.2-12.8 2.9v13.1l-10.3-8.2-10.2 8.2V124l-12.8-2.9 10.3-8.2-5.8-11.8L72 104zM123.7 155.1l5.7 11.9 12.8-3-5.7 11.9 10.3 8.1-12.8 2.9v13.2l-10.3-8.2-10.2 8.2v-13.2l-12.8-2.9 10.3-8.1-5.7-11.9 12.8 3zM90.8 209.1l4.4 13.7h14.5L98 231.3l4.5 13.7-11.7-8.4-11.7 8.4 4.5-13.7-11.7-8.5h14.4z"></path></g><circle fill="#FFDA44" cx="267.1" cy="170.7" r="74.5"></circle><path fill="#6DA544" d="M267.1 220.3h24.8s10.8-19 0-37.2l24.8-24.8-12.4-24.8h-12.4s-6.2 18.6-31 18.6-31-18.6-31-18.6h-12.4l12.4 24.8-12.4 24.8 12.4 12.4s12.4-24.8 37.2-12.4c0 0 10.5 15.5 0 37.2z"></path><path fill="#FFDA44" d="M464.4 92.2c.6-2.9-.2-17.6-.2-20.7 0-21.3-13.9-39.4-33.2-45.7 5.9 12 9.2 25.4 9.2 39.7 0 4.8-.4 9.5-1.1 14.1-2.9-4.7-6.6-8.9-11.2-12.6-17.1-13.6-40.6-14-57.9-2.5 13.4 2.9 26.3 8.9 37.7 18 9 7.1 16.2 16.8 21.7 26.1 0 0-17.8 10.9-31 15.1s-42.3 7.9-42.3 7.9c72 12 132-36 132-36-6.5-13.4-15.8-4-23.7-3.4z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Christmas Island +61</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 341.3"><path fill="#6DA544" d="M0 0h512v341.3H0z"></path><g fill="#FFDA44"><path d="M422.7 252.4l6.2 12.8 13.8-3.2-6.2 12.8 11.2 8.8-13.9 3.2V301l-11.1-8.9-11.1 8.9v-14.2l-13.8-3.2 11.1-8.8-6.2-12.8 13.9 3.2zM376.1 116.1l6.2 12.9 13.8-3.2-6.2 12.8 11.2 8.8-13.9 3.1v14.3l-11.1-8.9-11.1 8.9.1-14.3-13.9-3.1 11.1-8.8-6.2-12.8L370 129zM413.1 38.3l6.2 12.8 13.8-3.2-6.2 12.8 11.2 8.9-13.9 3.1v14.2L413.1 78 402 86.9l.1-14.2-13.9-3.1 11.1-8.9-6.2-12.8 13.9 3.2zM464.9 96.7l6.2 12.8 13.9-3.2-6.3 12.8 11.2 8.9-13.9 3.1.1 14.2-11.2-8.9-11.1 8.9.1-14.2L440 128l11.2-8.9-6.3-12.8 13.9 3.2zM436.9 164.8l4.9 14.8h15.6l-12.6 9.2 4.8 14.9-12.7-9.2-12.6 9.2 4.8-14.9-12.6-9.2h15.6z"></path></g><path fill="#FFDA44" d="M306.8 254.7c-49.2 0-89.1-39.9-89.1-89.1s39.9-89.1 89.1-89.1c15.3 0 29.8 3.9 42.4 10.7C329.4 67.9 302.3 56 272.5 56c-60.5 0-109.6 49.1-109.6 109.6S212 275.3 272.5 275.3c29.8 0 56.9-11.9 76.6-31.3-12.6 6.8-27 10.7-42.3 10.7zM140.4 59.5C129.7 41 109.7 28.6 86.8 28.6S44 41 33.3 59.5h107.1zM140.6 59.9l-53.8 53.8-53.7-53.8C28 68.9 25 79.3 25 90.5c0 34.2 27.7 61.9 61.9 61.9s61.9-27.7 61.9-61.9c-.1-11.2-3.1-21.6-8.2-30.6z"></path><path fill="#A2001D" d="M71.4 98.2v52.2c4.9 1.3 10.1 1.9 15.5 1.9s10.5-.7 15.5-1.9V98.2h-31z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Cocos (Keeling) Islands +61</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="#FFDA44" d="M0 85.337h512v341.326H0z"></path><path fill="#D80027" d="M0 343.096h512v83.567H0z"></path><path fill="#0052B4" d="M0 256h512v87.096H0z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Colombia +57</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="#0052B4" d="M0 85.337h512v341.326H0z"></path><path fill="#FFDA44" d="M0 85.337h512v85.337H0z"></path><path fill="white" d="M0 170.663h512V256H0z"></path><path fill="#D80027" d="M0 256h512v85.337H0z"></path><path fill="#6DA544" d="M256 256.006L0 426.668V85.331z"></path><g fill="white"><path d="M68.638 256c0-24.865 17.476-45.638 40.812-50.734a52.059 52.059 0 00-11.13-1.208c-28.688 0-51.942 23.255-51.942 51.942s23.255 51.942 51.942 51.942c3.822 0 7.543-.425 11.13-1.208-23.337-5.096-40.812-25.869-40.812-50.734z"></path><path d="M108.877 211.478l2.762 8.503h8.94l-7.232 5.256 2.762 8.502-7.232-5.255-7.234 5.255 2.764-8.502-7.234-5.256h8.94zM108.877 233.739l2.762 8.503h8.94l-7.232 5.255 2.762 8.503-7.232-5.255-7.234 5.255 2.764-8.503-7.234-5.255h8.94zM108.877 256l2.762 8.503h8.94l-7.232 5.255 2.762 8.503-7.232-5.255-7.234 5.255 2.764-8.503-7.234-5.255h8.94zM108.877 278.261l2.762 8.502h8.94l-7.232 5.256 2.762 8.503-7.232-5.255-7.234 5.255 2.764-8.503-7.234-5.256h8.94z"></path></g></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Comoros +269</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="#D80027" d="M0 85.331h512v341.337H0z"></path><path fill="#6DA544" d="M443.726 85.331L102.4 426.657H0V85.331z"></path><path fill="#FFDA44" d="M500.124 85.331L158.798 426.657H11.876L353.202 85.331z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Congo +242</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="#0052B4" d="M0 85.332h512v341.337H0z"></path><g fill="white"><path d="M384 156.705l5.283 16.254h17.089l-13.826 10.045 5.281 16.254L384 189.211l-13.825 10.047 5.28-16.254-13.825-10.045h17.089zM313.791 185.786l15.228 7.758 12.084-12.083-2.673 16.879 15.227 7.759-16.879 2.673-2.674 16.88-7.76-15.227-16.878 2.673 12.086-12.084zM284.71 255.995l16.254-5.281.001-17.089 10.044 13.825 16.254-5.282-10.046 13.827 10.046 13.826-16.254-5.28-10.044 13.825v-17.09zM313.791 326.204l7.759-15.229-12.084-12.084 16.881 2.674 7.757-15.227 2.674 16.879 16.879 2.672-15.227 7.759 2.673 16.882-12.084-12.087zM384 355.284l-5.281-16.253h-17.091l13.827-10.045-5.28-16.254L384 322.776l13.827-10.044-5.281 16.254 13.826 10.045h-17.089zM454.209 326.204l-15.229-7.758-12.083 12.084 2.673-16.882-15.227-7.756 16.879-2.675 2.675-16.879 7.756 15.227 16.881-2.674-12.086 12.085zM483.29 255.995l-16.254 5.281v17.09l-10.045-13.826-16.254 5.281 10.046-13.826-10.046-13.827 16.254 5.282 10.045-13.825v17.089zM454.209 185.788l-7.757 15.226 12.082 12.084-16.881-2.673-7.756 15.227-2.675-16.88-16.879-2.675 15.227-7.757-2.673-16.878 12.084 12.082zM0 186.665v16h46.069L0 233.377v7.539l57.377-38.252H80L0 255.998h112v-69.334H0zm96 69.331H22.628L96 207.083v48.913zM176 138.665l80-53.334H144v69.334h112v-16h-46.069L256 107.951v-7.539l-57.377 38.251H176v.002zm-16-53.332h73.372L160 134.246V85.333zM144 255.998h112l-80-53.334h22.623L256 240.917v-7.539l-46.069-30.713H256v-16H144v69.333zm16-48.915l73.372 48.913H160v-48.913zM112 85.331H0l80 53.334H57.377L0 100.413v7.539l46.069 30.712H0v16h112V85.331zm-16 48.915L22.628 85.333H96v48.913z"></path></g><g fill="#D80027"><path d="M144 85.331h-32v69.334H0v32h112v69.333h32v-69.333h112v-32H144z"></path><path d="M80 138.665L0 85.331v15.082l57.377 38.252zM176 138.665h22.623L256 100.413V85.331zM57.377 202.665L0 240.917v15.081l80-53.333zM176 202.665l80 53.333v-15.081l-57.377-38.252z"></path></g></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Cook Islands +682</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="white" d="M0 85.331h512v341.326H0z"></path><path fill="#D80027" d="M0 211.473h512v89.043H0z"></path><g fill="#0052B4"><path d="M0 352.462h512v74.207H0zM0 85.331h512v74.207H0z"></path></g></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Costa Rica +506</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="white" d="M0 85.331h512v341.326H0z"></path><path fill="#6DA544" d="M330.207 85.331H512v341.337H330.207z"></path><path fill="#FF9811" d="M0 85.331h181.793v341.337H0z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Cote d'Ivoire +225</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 513 342"><path fill="white" d="M0 0h513v342H0z"></path><path fill="#D80027" d="M0 0h513v114H0z"></path><path fill="#0052B4" d="M0 228h513v114H0z"></path><g fill="#338AF3"><path d="M309.3 113.2v-44l17.5-14.4 17.7 14.4v44zM203.7 113.2v-44l-17.3-14.4-17.9 14.4v44zM238.9 113.2v-44l17.6-14.4 17.6 14.4v44z"></path></g><g fill="#0052B4"><path d="M309.3 113.2h-35.2v-44l17.5-14.4 17.7 14.4zM238.9 113.2h-35.2v-44l17.5-14.4 17.7 14.4z"></path></g><path stroke="#D80027" fill="white" d="M168.5 113.2v101.9c0 24.3 14.4 46.2 35.4 59.4 21.3 13.4 42.1 14.7 52.6 14.7s31.4-1.7 52.6-14.8c21-13 35.4-35.1 35.4-59.3V113.2h-176z"></path><g fill="#D80027"><path d="M168.5 113.2h35.2v35.2h-35.2zM238.9 113.2h35.2v35.2h-35.2zM309.3 113.2h35.2v35.2h-35.2zM203.7 148.4h35.2v35.2h-35.2zM274.1 148.4h35.2v35.2h-35.2zM168.5 183.6h35.2v35.2h-35.2zM203.7 218.8h35.2V254h-35.2zM238.9 183.6h35.2v35.2h-35.2zM309.3 183.6h35.2v35.2h-35.2zM274.1 218.8h35.2V254h-35.2zM309.3 274.3c8.6-5.4 16.2-12.3 22-20.3h-22v20.3zM181.7 254c5.8 8 13.3 14.9 22 20.4V254h-22zM238.9 254v33.7c7.2 1.2 13.3 1.5 17.6 1.5 4.3 0 10.4-.3 17.6-1.6V254h-35.2z"></path></g></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Croatia +385</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 341.3"><path fill="#FF9811" d="M0-40.8v422.9-211.4z"></path><path fill="white" d="M0 0h512v341.3H0z"></path><g fill="#0052B4"><path d="M0 0h512v68.3H0zM0 136.5h512v68.3H0zM0 273.1h512v68.3H0z"></path></g><path fill="#D80027" d="M256 170.7L0 341.3V0z"></path><path fill="white" d="M81.5 94.8l16.9 51.9H153l-44.2 32.1 16.9 52-44.2-32.1-44.2 32.1 16.9-52L10 146.7h54.6z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Cuba +53</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 341.3"><path fill="white" d="M0 0h512v341.3H0z"></path><path fill="#6DA544" d="M371.5 275.9l-11.1-15c-22.4 16.1-67.7 35.8-104.3 35.8-35.8 0-79.6-17.1-104.3-35.8l-11.1 15c10 10.3 46.9 27 88.4 38.4-3.9 6-1.6 6.1 2.6 10.8 8.5-6.6 17.4-1.5 24.9-7.3 7.5 5.8 16.3.7 24.9 7.3 5.4-5.6 5.4-5.6 2.5-11.1 41-11.7 77-27.6 87.5-38.1z"></path><path fill="#DB7D00" d="M113.7 168.7s.2 79.9 89 77.8L208 263h10.6s-8.9-49 71.7-49.4c0 0 0-32.9 32.9-32.9h49.4S294 119 442.8 40.1l2.2-15.6s-154.8 84.6-237 68.1c0 0 12.7 50.7-12.9 50.7-12.8 0-11.6-9.6-38.4-9.6-22.3 0-20.6 23.5-31.3 23.2S103 142.3 102 144.8s11.7 23.9 11.7 23.9z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Cyprus +357</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="#0052B4" d="M0 85.337h512v341.326H0z"></path><path fill="#D80027" d="M512 256v170.663H0L215.185 256z"></path><path fill="white" d="M512 85.337V256H215.185L0 85.337z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Czech Republic +420</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 341.3"><path fill="#338AF3" d="M0 0h512v341.3H0z"></path><path fill="#FFDA44" d="M512 66.9V0H411.7L0 274.4v66.9h100.3z"></path><path fill="#D80027" d="M512 0v40.1L60.2 341.3H0v-40.1L451.8 0z"></path><path fill="#FFDA44" d="M93.6 31.2l16.3 50.4H163l-42.9 31.2 16.4 50.5-42.9-31.2-43 31.2L67 112.8 24.1 81.6h53.1z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Democratic Republic of the Congo +243</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 513 342"><path fill="#D80027" d="M0 0h513v342H0z"></path><path fill="white" d="M190 0h-60v140H0v60h130v142h60V200h323v-60H190z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Denmark +45</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 341.3"><path fill="#6DA544" d="M0 0h512v341.3H0z"></path><path fill="#338AF3" d="M512 0v166.7L0 170.8V0z"></path><path fill="white" d="M256 170.7L0 341.3V0z"></path><path fill="#D80027" d="M89.8 92.5l17 52.4H162l-44.6 32.5 17 52.4-44.6-32.4-44.6 32.4 17-52.4-44.6-32.5h55.2z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Djibouti +253</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 341.3"><path fill="#496E2D" d="M0 0h512v341.3H0z"></path><path d="M0 110.7v120h512v-120z"></path><path fill="#FFDA44" d="M0 110.7h512v40H0z"></path><path fill="white" d="M0 190.7h512v40H0z"></path><path d="M196 0h120v341.3H196z"></path><path fill="#FFDA44" d="M196 0h40v341.3h-40z"></path><path fill="white" d="M274.7 0h40v341.3h-40z"></path><circle fill="#D80027" cx="256" cy="170.7" r="123.1"></circle><g fill="#496E2D"><path d="M256 58.6l4.6 14.2h15l-12.1 8.9 4.6 14.2-12.1-8.8-12.1 8.8 4.6-14.2-12.1-8.9h15zM190.1 80l12.2 8.8 12.1-8.8-4.6 14.3 12.1 8.8h-15l-4.6 14.2-4.7-14.2h-15l12.1-8.8zM149.4 136h15l4.6-14.2 4.7 14.2h15l-12.2 8.8 4.7 14.3-12.2-8.8-12.1 8.8 4.6-14.3zM149.4 205.3l12.1-8.8-4.6-14.3L169 191l12.2-8.8-4.7 14.3 12.2 8.8h-15l-4.7 14.3-4.6-14.3zM190.1 261.4l4.6-14.3-12.1-8.8h15l4.7-14.3 4.6 14.3h15l-12.1 8.8 4.6 14.3-12.1-8.9zM256 282.8l-4.6-14.3h-15l12.1-8.8-4.6-14.3 12.1 8.8 12.1-8.8-4.6 14.3 12.1 8.8h-15zM321.9 261.4l-12.2-8.9-12.1 8.9 4.6-14.3-12.1-8.8h15l4.6-14.3 4.7 14.3h15l-12.1 8.8zM362.6 205.3h-15l-4.6 14.3-4.7-14.3h-15l12.2-8.8-4.7-14.3L343 191l12.1-8.8-4.6 14.3zM362.6 136l-12.1 8.8 4.6 14.3-12.1-8.8-12.2 8.8 4.7-14.3-12.2-8.8h15l4.7-14.2 4.6 14.2zM321.9 80l-4.6 14.3 12.1 8.8h-15l-4.7 14.2-4.6-14.2h-15l12.1-8.8-4.6-14.3 12.1 8.8z"></path></g><path fill="#496E2D" d="M279.3 168.7c-11-21.1-14.5-25.1-14.5-25.1s.4-9.7.4-15.6c0-8.8-7.4-15.8-16.5-15.8-8.6 0-15.7 2.9-16.5 11-4.2.9-8.6 4.1-8.6 10.7 0 4.8 1 7.3 5.2 9.3 2.1-4.6 4.3-4.8 9.3-6.4.8.6 1.7 3 2.6 3.4l.3 1s-13.3 6.6-13.3 30.9c0 29.5 22 45.4 22 45.4l-1.8.3-1.9 7.1h22v-7.2l11 17.5c.3-.3 10.2-47.6.3-66.5z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Dominica +1767</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 341.3"><path fill="white" d="M0 0h512v341.3H0z"></path><path fill="#D80027" d="M0 215.2h211.5v126.1H0z"></path><path fill="#0052B4" d="M0 0h211.5v126.2H0z"></path><path fill="#D80027" d="M300.5 0H512v126.2H300.5z"></path><path fill="#0052B4" d="M300.5 215.2H512v126.1H300.5z"></path><g stroke="white" stroke-width="5" stroke-miterlimit="10"><path fill="#0052B4" d="M256 130h-49.9v49.4s19.5 6 49.9 6V130z"></path><path fill="#D80027" d="M206.1 179.4v6c0 27.5 22.3 49.9 49.9 49.9v-49.9c-30.4 0-49.9-6-49.9-6z"></path><path fill="#0052B4" d="M256 235.3c27.5 0 49.9-22.3 49.9-49.9v-6s-19.5 6-49.9 6v49.9z"></path><path fill="#D80027" d="M256 130v55.4c30.4 0 49.9-6 49.9-6V130H256z"></path></g></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Dominican Republic +1849</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 341.3"><path fill="#FFDA44" d="M0 0h512v341.3H0z"></path><path fill="#0052B4" d="M0 170.7h512V256H0z"></path><path fill="#D80027" d="M0 256h512v85.3H0z"></path><circle fill="#FFDA44" cx="256" cy="170.7" r="59.4"></circle><path fill="#4C1F00" d="M369.2 79.9s-27.2-13.8-33.9-16c-6.7-2.2-49.1-13.2-49.1-7 0 10.3-13.5 12-15.5 12s-2-5.3-14.8-5.3-13.7 4.8-15.8 4.8c-2.2 0-14.5-1-14.5-11.5 0-5.2-42.9 4-49.1 7-6.1 3.1-33.9 16-33.9 16s45.8 2.7 53.9 6.2 43.8 16.5 43.8 16.5l-2.8 13.3h37.8l-3.8-13.3s35.1-12.7 43.8-16.5 53.9-6.2 53.9-6.2z"></path><path fill="#57BA17" d="M217.7 171.7c0 21.1 17.2 38.3 38.3 38.3 21.1 0 38.3-17.2 38.3-38.3v-11.5h-76.5v11.5z"></path><path fill="#338AF3" d="M256 110.5c-21.1 0-38.3 17.2-38.3 38.3v11.5h76.5v-11.5c.1-21.1-17.1-38.3-38.2-38.3z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Ecuador +593</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 341.3"><path fill="white" d="M0 0h512v341.3H0z"></path><path fill="#D80027" d="M0 0h512v113.8H0z"></path><path d="M0 227.6h512v113.8H0z"></path><path fill="#C09300" d="M220.3 204.4s0-58.4 4.5-64.7c3.1-4.3 16.8 5.2 22.7 4.5 0 0 4.2-7.5 4.5-12 .3-4.6-1.1-7.6-4.9-6.2 0 0-1.2-2.1.5-3.3 1.6-1.2 5.6.1 5.6.1s-.5-1 1.6-.9c2.9.2 7.2 1.4 7.4 5.6.2 3.1.3 7.7.4 8.7.7 6.8 2.7 8.7 2.7 8.7s18.4-9.2 22-5.2c3.3 3.8 4.5 64.7 4.5 64.7l-18.1-16.8 12.1 29.5s-14.4 2.4-28.9 2.4c-14.5 0-31.1-4.2-31.1-4.2l13.8-28.2-19.3 17.3z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Egypt +20</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="white" d="M0 85.337h512v341.326H0z"></path><g fill="#0052B4"><path d="M0 85.337h512v113.775H0zM0 312.888h512v113.775H0z"></path></g><path fill="#FFDA44" d="M228.582 261.936L256 214.447l27.418 47.489z"></path><path fill="#6DA544" d="M291.616 277.616L256 295.425l-35.616-17.809v-23.744h71.232z"></path><path fill="#FFDA44" d="M289.579 216.485l-12.592 12.592c5.37 5.372 8.693 12.791 8.693 20.988 0 16.392-13.289 29.68-29.68 29.68-16.392 0-29.68-13.289-29.68-29.68 0-8.195 3.322-15.616 8.693-20.988l-12.592-12.592c-8.594 8.594-13.91 20.466-13.91 33.579 0 26.228 21.261 47.489 47.489 47.489s47.489-21.261 47.489-47.489c0-13.114-5.316-24.987-13.91-33.579z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">El Salvador +503</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 513 342"><path fill="white" d="M0 0h513v342H0z"></path><path fill="#6DA544" d="M0 0h513v113.8H0z"></path><path fill="#D80027" d="M0 227.6h513V342H0z"></path><path fill="#0070C8" d="M126 170.7L0 341.3V0z"></path><path fill="none" stroke="black" stroke-miterlimit="10" d="M233.8 139.4v40.4c0 35.6 35.6 35.6 35.6 35.6s35.6 0 35.6-35.6v-40.4h-71.2z"></path><path fill="#786145" d="M264.5 179.8h9.8l4 25.8h-17.8z"></path><path fill="#6DA544" d="M287.2 162c0-9.8-8-14.8-17.8-14.8s-17.8 5-17.8 14.8c-4.9 0-8.9 4-8.9 8.9s4 8.9 8.9 8.9h35.6c4.9 0 8.9-4 8.9-8.9s-4-8.9-8.9-8.9z"></path><g fill="#FFDA00" stroke="black" stroke-miterlimit="10"><path d="M230.7 120l1.9 3.3h3.8l-1.9 3.3 1.9 3.2h-3.8l-1.9 3.3-1.9-3.3H225l1.9-3.2-1.9-3.3h3.8zM246 120l1.9 3.3h3.7l-1.9 3.3 1.9 3.2h-3.7l-1.9 3.3-1.9-3.3h-3.8l1.9-3.2-1.9-3.3h3.8zM261.3 120l1.9 3.3h3.7l-1.9 3.3 1.9 3.2h-3.7l-1.9 3.3-1.9-3.3h-3.8l1.9-3.2-1.9-3.3h3.8zM277.1 120l1.9 3.3h3.8l-1.9 3.3 1.9 3.2H279l-1.9 3.3-1.9-3.3h-3.7l1.8-3.2-1.8-3.3h3.7zM293.1 120l1.9 3.3h3.8l-1.9 3.3 1.9 3.2H295l-1.9 3.3-1.9-3.3h-3.7l1.8-3.2-1.8-3.3h3.7zM308.1 120l1.9 3.3h3.7l-1.9 3.3 1.9 3.2H310l-1.9 3.3-1.9-3.3h-3.8l1.9-3.2-1.9-3.3h3.8z"></path></g></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Equatorial Guinea +240</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 341.3"><path fill="#338AF3" d="M0 0h512v341.3H0z"></path><path fill="#56AF35" d="M0 0h512v170.7H0z"></path><path fill="#D80027" d="M0 341.3l512-170.7L0 0v341.3z"></path><g fill="#ffc945"><path d="M134.7 231.5c33.6 0 60.8-27.2 60.8-60.8s-27.2-60.8-60.8-60.8-60.8 27.2-60.8 60.8 27.2 60.8 60.8 60.8zm0 24.3c-47 0-85.2-38.1-85.2-85.2s38.1-85.2 85.2-85.2 85.2 38.1 85.2 85.2-38.2 85.2-85.2 85.2z"></path><circle cx="119.5" cy="148.3" r="17.5"></circle><circle cx="148.9" cy="158.5" r="17.5"></circle><circle cx="134.7" cy="135.2" r="17.5"></circle><circle cx="119.5" cy="172.7" r="17.5"></circle><circle cx="149.9" cy="182.8" r="17.5"></circle><circle cx="122.5" cy="198" r="17.5"></circle><circle cx="145.9" cy="205.2" r="17.5"></circle></g></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Eritrea +291</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="#111" d="M0 85.337h512v341.326H0z"></path><path fill="#368FD8" d="M0 85.337h512v113.775H0z"></path><path fill="white" d="M0 312.888h512v113.775H0z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Estonia +372</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 900 600"><path fill="#2B5DEA" d="M0 0h900v600H0V0z"></path><path fill="#FFDF29" d="M0 100h900v400H0V100z"></path><path fill="#D70000" d="M0 150h900v300H0V150z"></path><path fill="white" d="M450 171.4v257.2c114.3 0 171.4-85.7 214.3-128.6-42.9-42.9-100-128.6-214.3-128.6z"></path><path d="M450 171.4c-100 0-171.4 85.7-214.3 128.6C278.6 342.9 350 428.6 450 428.6V171.4z"></path><path fill="white" d="M346.3 254.3h21v91.3h-21zM398.2 254.3h21v91.3h-21z"></path><path d="M477.8 254.3h21v91.3h-21zM529.7 254.3h21v91.3h-21z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Eswatini +268</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 22.5 15"><path fill="#20AA46" d="M0 0h22.5v5H0V0z"></path><path fill="#E92F3B" d="M0 10h22.5v5H0v-5z"></path><path fill="#FADF50" d="M0 5h22.5v5H0V5z"></path><circle fill="#205CCA" cx="11.3" cy="7.5" r="5.2"></circle><path fill="#FFDB3D" d="M11.2 9.2L8.8 11l.9-2.9-2.4-1.8h3l1-2.8 1 2.9h3l-2.4 1.8.9 2.9-2.6-1.9zm0-1l.9.6-.3-1.1.9-.7h-1.1l-.4-1.1-.4 1.1H9.7l.9.7-.3 1.1c0 .1.9-.6.9-.6z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Ethiopia +251</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 341.3"><path fill="#0052B4" d="M0 0h512v341.3H0z"></path><path fill="white" d="M256 0v30.6l-45.2 25.1H256V115h-59.1l59.1 32.8v22.9h-26.7l-73.5-40.9v40.9h-55.6v-48.6l-87.5 48.6H0v-30.6L45.2 115H0V55.7h59.1L0 22.8V0h26.7l73.5 40.8V0h55.6v48.6L243.3 0z"></path><path fill="#D80027" d="M144 0h-32v69.3H0v32h112v69.4h32v-69.4h112v-32H144z"></path><path fill="#0052B4" d="M155.8 115L256 170.7v-15.8L184.2 115z"></path><path fill="white" d="M155.8 115L256 170.7v-15.8L184.2 115z"></path><g fill="#D80027"><path d="M155.8 115L256 170.7v-15.8L184.2 115zM71.8 115L0 154.9v15.8L100.2 115z"></path></g><path fill="#0052B4" d="M100.2 55.6L0 0v15.7l71.8 39.9z"></path><path fill="white" d="M100.2 55.6L0 0v15.7l71.8 39.9z"></path><g fill="#D80027"><path d="M100.2 55.6L0 0v15.7l71.8 39.9zM184.2 55.6L256 15.7V0L155.8 55.6z"></path></g><path fill="#1F8BDE" d="M312.2 194.2v-90c0-8.5 6.5-15.3 15-15.3h120.5c8.3 0 15 6.8 15 15.3v90c0 75.2-75.2 105.3-75.2 105.3s-75.3-30.1-75.3-105.3z"></path><path fill="white" d="M312.2 194.2v-90c0-8.5 6.5-15.3 15-15.3h120.5c8.3 0 15 6.8 15 15.3v90c0 75.2-75.2 105.3-75.2 105.3s-75.3-30.1-75.3-105.3zm79.6 86.3c7.9-4.5 15.9-10 23.2-16.7 20.5-18.5 32.6-41.4 32.6-69.7v-90c0-.3-120.4-.3-120.4-.3v90.3c0 28.3 12.1 51.2 32.6 69.7 8.3 7.5 17.6 13.9 27.6 19 1.4-.6 2.8-1.4 4.4-2.3z"></path><path fill="#187536" d="M347.1 193.4c-2.6-7.9 1.7-14.3 10.1-14.3h60.5c8.2 0 12.8 6.3 10.1 14.3l-5.5 16.5c-2.6 7.9-8.9 9.2-15.8 4 0 0 2.6-4.8-19.1-4.8-21.7 0-19.1 4.8-19.1 4.8-6.1 5.7-13.1 4-15.8-4 .1.1-5.4-16.5-5.4-16.5z"></path><path fill="white" d="M357.4 179.1c8.1 1.6 17.8-15 30.1-15 13.1 0 21.8 17.1 30.1 15 7.4-1.8 15-22.2 15-30.1 0-16.6-20.2-30.1-45.1-30.1-24.9 0-45.1 13.5-45.1 30.1-.1 8.5 6.6 28.5 15 30.1zM356 270.7c6.2.4 12.5-1.8 17.2-6.5l9-9c2.9-2.9 7.5-2.9 10.4 0l9 9c4.7 4.7 11 6.9 17.1 6.5 5.3-.3 32.5-33.5 25.7-32.6-4.6.6-9.1 2.8-12.7 6.3l-.1.1-9 9c-2.9 2.9-7.5 2.9-10.4 0l-9-9c-8.7-8.8-22.9-8.8-31.7-.1l-.1.1-9 9c-2.9 2.9-7.5 2.9-10.4 0l-9-9c-3.5-3.5-7.8-5.6-12.3-6.3-6.7-1.1 20.1 32.2 25.3 32.5zM322.1 210c2.9-2.9 7.5-2.9 10.4 0l9 9c8.8 8.7 22.9 8.7 31.7 0l9-9c2.9-2.9 7.5-2.9 10.4 0l9 9c8.8 8.7 22.9 8.7 31.7 0l9-9c2.9-2.9 7.5-2.9 10.4 0 0 0 5.5-14.8 2.5-15.9-7.9-2.9-17.2-1.2-23.5 5.2l-.1.1-9 9c-2.9 2.9-7.5 2.9-10.4 0l-9-9c-8.7-8.8-22.9-8.8-31.7-.1l-.1.1-9 9c-2.9 2.9-7.5 2.9-10.4 0l-9-9c-6.2-6.2-15.1-8-22.8-5.5-3.1 1.1 1.9 16.1 1.9 16.1z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Falkland Islands (Malvinas) +500</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 341.3"><path fill="white" d="M0 0h512v341.3H0z"></path><path fill="#0F61A5" d="M512 214.5H206.2v126.8H118.4V214.5H0v-87.7h118.4V0H206.2v126.8H512V192z"></path><path fill="#E50E3D" d="M512 149.3V192H183.7v149.3H141V192H0v-42.7h141V0h42.7v149.3z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Faroe Islands +298</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 341.3"><path fill="#2E52B2" d="M0 0h512v341.3H0z"></path><path fill="white" d="M256 0v22.6l-46.1 30.7H256v64h-46.1L256 148v22.7h-22.6l-73.4-49v49H96v-49l-73.4 49H0V148l46.1-30.7H0v-64h46.1L0 22.6V0h22.6L96 48.9V0h64v48.9L233.4 0z"></path><g fill="#D80027"><path d="M144 0h-32v69.3H0v32h112v69.4h32v-69.4h112v-32H144z"></path><path d="M0 0v15.1l57.4 38.2H80zM256 0v15.1l-57.4 38.2H176z"></path><path d="M0 0v15.1l57.4 38.2H80zM256 0v15.1l-57.4 38.2H176zM0 170.7v-15.1l57.4-38.3H80zM256 170.7v-15.1l-57.4-38.3H176z"></path></g><path fill="#F3F3F3" d="M307.1 127.1v92c0 61.6 80.5 80.5 80.5 80.5s80.4-19 80.4-80.6v-92l-80.5-23-80.4 23.1z"></path><path fill="#D80027" d="M468 132.8V98.3H307.1v34.5h69v69h-69v23h69V296c6.9 2.5 11.5 3.5 11.5 3.5s4.6-1.1 11.5-3.5v-71.2h69v-23h-69v-69H468z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Fiji +679</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 341.3"><path fill="white" d="M0 0h512v341.3H0z"></path><path fill="#2E52B2" d="M512 129.3V212H203.7v129.3H121V212H0v-82.7h121V0h82.7v129.3z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Finland +358</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="white" d="M0 85.331h512v341.337H0z"></path><path fill="#0052B4" d="M0 85.331h170.663v341.337H0z"></path><path fill="#D80027" d="M341.337 85.331H512v341.337H341.337z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">France +33</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 90 60"><path fill="#FDEB01" d="M0 0l90 60H0z"></path><path fill="#58A846" d="M90 0v60L0 0z"></path><path fill="#ED3D24" stroke="#A02021" stroke-miterlimit="10" d="M54.1 35.3l14.7-10.7H50.6L45 7.3l-5.6 17.3H21.2l14.7 10.7-5.6 17.4L45 42l14.7 10.7z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">French Guiana +594</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="white" d="M0 85.337h512v341.326H0z"></path><g fill="#D80027"><path d="M0 85.337h512v113.775H0zM0 312.888h512v113.775H0z"></path></g><path fill="#FFDA44" d="M293.991 256c0 20.982-17.01 33.243-37.992 33.243S218.008 276.982 218.008 256s17.01-37.992 37.992-37.992 37.991 17.01 37.991 37.992z"></path><path fill="#0052B4" d="M293.991 256c0 20.982-17.01 37.992-37.992 37.992s-37.992-17.01-37.992-37.992"></path><g fill="#D80027"><path d="M232.259 246.506h9.498v19h-9.498zM270.247 246.506h9.498v19h-9.498zM251.247 232.259h9.498v33.243h-9.498z"></path></g></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">French Polynesia +689</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="#FFDA44" d="M0 85.337h512v341.326H0z"></path><path fill="#6DA544" d="M0 85.337h512v113.775H0z"></path><path fill="#0052B4" d="M0 312.888h512v113.775H0z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Gabon +241</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="white" d="M0 85.337h512v341.326H0z"></path><path fill="#1a7e25" d="M0 322.783h512v103.88H0z"></path><path fill="#cf0d19" d="M0 85.337h512v104.515H0z"></path><path fill="#0052B4" d="M0 210.877h512v89.656H0z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Gambia +220</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 22.5 15"><path fill="white" d="M.8 0h21v15H.8V0z"></path><path fill="#eb000e" d="M9.8 6H0v3h9.8v6h3V9h9.8V6h-9.8V0h-3v6z"></path><path fill="#eb000e" d="M17.3 2.7l-.2-1.2h1l-.2 1.2 1.2-.2v1l-1.2-.2.2 1.2h-1l.2-1.2-1.2.2v-1l1.2.2zm-12.7 0l-.2-1.2h1l-.2 1.2 1.2-.2v1l-1.2-.2.2 1.2h-1l.2-1.2-1.2.2v-1l1.2.2zm0 9l-.2-1.2h1l-.2 1.2 1.2-.2v1l-1.2-.2.2 1.2h-1l.2-1.2-1.2.2v-1l1.2.2zm12.7 0l-.2-1.2h1l-.2 1.2 1.2-.2v1l-1.2-.2.2 1.2h-1l.2-1.2-1.2.2v-1l1.2.2z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Georgia +995</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="#FFDA44" d="M0 85.337h512v341.326H0z"></path><path fill="#D80027" d="M0 85.337h512v113.775H0z"></path><path fill="#496E2D" d="M0 312.888h512v113.775H0z"></path><path d="M255.883 199.111l14.119 43.458 40.366 3.2-36.969 26.861 19.453 40.259-36.969-26.859-36.97 26.859 14.123-43.459-36.969-26.861h45.696z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Ghana +233</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 513 342"><path fill="white" d="M0 0h513v342H0z"></path><path fill="#D80027" d="M0 230h513v112H0z"></path><path fill="#D80027" stroke="black" stroke-miterlimit="10" d="M363.1 131.8V99.1H374V77.3h-21.9v10.9h-21.8V77.3h-21.8v21.8h10.9v32.7h-21.8V55.5h10.9V33.7h-21.8v10.9h-10.9V33.7H254v10.9h-10.9V33.7h-21.8v21.8h10.9v76.3h-21.8V99.1h10.9V77.3h-21.8v10.9h-21.8V77.3h-21.8v21.8h10.9v32.7H145V219h239.9v-87.2z"></path><path fill="#FFDA44" stroke="black" stroke-miterlimit="10" d="M264.9 235.5l-24.2 18.2 19.1 14.3v31.3h-23.2v9h23v7.9h-23v9.3H270V268l19.1-14.3-24.2-18.2zm0 25.3l-10.1-7.1 10.1-7.1 10.1 7.1-10.1 7.1z"></path><path d="M239.6 209.7v-27.9s.1-22.3 25-22.3c24.8 0 25.7 22 25.7 22v28.2h-50.7zM170.5 209.7v-24.3s.1-18.7 19.6-18.7 20.2 18.4 20.2 18.4v24.5h-39.8z"></path><path d="M169.1 209.7v-24.3s.1-18.7 19.6-18.7 20.2 18.4 20.2 18.4v24.5h-39.8zM320.9 209.7v-24.3s.1-18.7 19.6-18.7 20.2 18.4 20.2 18.4v24.5h-39.8zM329.3 132v-15.7s.1-12.1 11.3-12.1c11.3 0 11.7 11.9 11.7 11.9V132h-23zM250.5 132v-23.7s.1-18.3 14.3-18.3c14.2 0 14.7 18 14.7 18v24h-29zM177.5 132v-15.7s.1-12.1 11.3-12.1 11.7 11.9 11.7 11.9V132h-23z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Gibraltar +350</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 513 342"><path fill="white" d="M0 0h513v342H0z"></path><g fill="#1571CC"><path d="M0 0h513v38H0zM0 76h513v38H0zM0 152h513v38H0zM0 228h513v38H0zM0 304h513v38H0z"></path></g><path fill="#1571CC" d="M0 0h190v190H0z"></path><g fill="white"><path d="M0 76h190v38H0z"></path><path d="M76 0h38v190H76z"></path></g></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Greece +30</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 513 342"><path fill="#D80027" d="M0 0h513v342H0z"></path><path fill="white" d="M513 0v171H0V0z"></path><circle fill="white" cx="185.8" cy="171.2" r="117.8"></circle><path fill="#D80027" d="M68 171c0-65.1 52.8-117.8 117.8-117.8 65.1 0 117.8 52.8 117.8 117.8"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Greenland +299</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 341.3"><path fill="#c60a0a" d="M0 0h512v341.3H0z"></path><path fill="#3E8446" d="M256 170.7L44.5 296.8V44.5z"></path><g fill="#FFDA44"><path d="M256 170.7l211.5 126.1h-423zM467.5 44.5L256 170.7 44.5 44.5z"></path></g><path fill="#3E8446" d="M467.5 44.5v252.3L256 170.7z"></path><g fill="#FFDA44"><path d="M256 10.4l3.3 10.2H270l-8.6 6.3 3.3 10.2-8.7-6.3-8.7 6.3 3.3-10.2-8.6-6.3h10.7zM170.1 10.4l3.3 10.2h10.7l-8.6 6.3 3.3 10.2-8.7-6.3-8.7 6.3 3.3-10.2-8.6-6.3h10.7zM341.9 10.4l3.3 10.2H356l-8.7 6.3 3.3 10.2-8.7-6.3-8.7 6.3 3.3-10.2-8.6-6.3h10.7zM256 304.2l3.3 10.2H270l-8.6 6.3 3.3 10.2-8.7-6.3-8.7 6.3 3.3-10.2-8.6-6.3h10.7zM170.1 304.2l3.3 10.2h10.7l-8.6 6.3 3.3 10.2-8.7-6.3-8.7 6.3 3.3-10.2-8.6-6.3h10.7zM341.9 304.2l3.3 10.2H356l-8.7 6.3 3.3 10.2-8.7-6.3-8.7 6.3 3.3-10.2-8.6-6.3h10.7z"></path></g><circle fill="#c60a0a" cx="244.5" cy="170.7" r="76.2"></circle><path fill="#FFDA44" d="M244.5 110.1l13.6 41.8h44l-35.6 25.8 13.6 41.8-35.6-25.8-35.5 25.8 13.6-41.8-35.6-25.8h44zM107.7 167.8c4.4 6.9 2.3 16.1-4.6 20.5s-16.1 2.3-20.5-4.6c-7.9-12.5-3.3-33-3.3-33s20.4 4.6 28.4 17.1z"></path><circle fill="#A2001D" cx="99.1" cy="182.1" r="7.4"></circle></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Grenada +1473</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="white" d="M0 85.331h512v341.337H0z"></path><path fill="#0052B4" d="M0 85.331h170.663v341.337H0z"></path><path fill="#D80027" d="M341.337 85.331H512v341.337H341.337z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Guadeloupe +590</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 513 342"><path fill="#D80027" d="M0 0h512v341.3H0z"></path><path fill="#0052B4" d="M11.1 11.1h489.7v319.1H11.1z"></path><path fill="#7DBEF1" d="M256 285.3s76.4-51.3 76.4-114.6S256 56 256 56s-76.4 51.3-76.4 114.6S256 285.3 256 285.3z"></path><path fill="#1C8AE6" d="M179.8 180.7h152.6l-29.3 64.9h-95.2z"></path><path fill="#FFF042" d="M192.3 205.9s40.5 38.2 51 38.2c12.4 0 12.6-18.4 25.5-25.5 20.2-11.1 51-12.7 51-12.7L297 248.7l-41 36.6-46.8-39.7-16.9-39.7z"></path><path fill="#259C7B" d="M256 157.5l-22.5 15.6 7.9-26.2-21.8-16.5 27.4-.5 9-25.9 9 25.9 27.4.5-21.8 16.6 7.9 26.2-22.5-15.7z"></path><path fill="#8E5715" d="M249.7 144.6c-.9 9.2-1.5 18.4-1.7 27.6-.3 11.9.3 20.7 2 26 2.2 6.6 7.2 12.9 14.2 18.9 5.3 4.6 10.6 8.1 14.2 10.1 3.1 1.7 7 .6 8.7-2.4 1.7-3.1.6-7-2.4-8.7-4.3-2.5-8.4-5.4-12.2-8.7-5.4-4.6-9.1-9.2-10.4-13.3-1.1-3.4-1.6-11.3-1.4-21.7.2-8.9.8-17.8 1.7-26.6.4-3.5-2.2-6.6-5.7-7-3.6-.3-6.7 2.3-7 5.8z"></path><path fill="white" d="M217.8 170.7l25.5 38.2h-25.5v-38.2z"></path><path fill="none" stroke="#D80027" stroke-width="12" stroke-miterlimit="10" d="M256 285.3s76.4-51.3 76.4-114.6S256 56 256 56s-76.4 51.3-76.4 114.6S256 285.3 256 285.3z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Guam +1671</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 513 342"><path fill="white" d="M0 0h513v342H0z"></path><g fill="#338AF3"><path d="M0 0h171v342H0zM342 0h171v342H342z"></path></g><circle fill="#DCC26D" cx="256" cy="155.8" r="25.5"></circle><path fill="#628A40" d="M194.2 155.9c0 22.1 11.8 42.5 30.8 53.5 5.9 3.4 13.5 1.4 16.9-4.5 3.4-5.9 1.4-13.5-4.5-16.9-11.5-6.6-18.5-18.9-18.5-32.1 0-6.8-5.5-12.4-12.4-12.4s-12.3 5.5-12.3 12.4zm95.1 52.1c17.8-11.4 28.6-31 28.5-52.1 0-6.8-5.5-12.4-12.4-12.4-6.8 0-12.4 5.5-12.4 12.4 0 12.7-6.5 24.5-17.1 31.3-5.8 3.6-7.7 11.2-4.1 17 3.6 5.8 11.2 7.7 17 4.1.2-.1.3-.2.5-.3z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Guatemala +502</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 513 342"><path fill="white" d="M0 0h513v342H0z"></path><path fill="#D80027" d="M308 0H204v118.7H0v104h204V342h104V222.7h205v-104H308z"></path><path fill="#FFDA44" d="M368.6 188l26 17.3V136l-26 17.3h-95.3V58.1l17.3-26h-69.2l17.3 26v95.2h-95.3l-26-17.3v69.3l26-17.3h95.3v95.2l-17.3 26h69.2l-17.3-26V188z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Guernsey +44</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 513 342"><path fill="#FFDA44" d="M0 0h512v342H0z"></path><path fill="#6DA544" d="M342 0h171v342H342z"></path><path fill="#D80027" d="M0 0h171v342H0z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Guinea +224</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="#6DA544" d="M0 85.331h512v341.337H0z"></path><path fill="#FFDA44" d="M0 85.331h512v170.663H0z"></path><path fill="#D80027" d="M0 85.331h181.793v341.337H0z"></path><path d="M98.32 195.127l15.107 46.497h48.894l-39.555 28.74 15.108 46.498-39.554-28.737-39.556 28.737 15.111-46.498-39.554-28.74h48.891z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Guinea-Bissau +245</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 900 600"><path fill="#009E49" d="M0 0h900v600H0V0z"></path><path fill="white" d="M0 0l947 300L0 600V0z"></path><path fill="#FFD00D" d="M0 26.1L870 300 0 573.9V26.1z"></path><path fill="#2D2D2D" d="M0 0l450 300L0 600V0z"></path><path fill="#D3132F" d="M0 35l397.5 265L0 565V35z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Guyana +592</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 513 342"><path fill="#A2001D" d="M0 0h513v172H0z"></path><path fill="#0052B4" d="M0 172h513v172H0z"></path><path fill="white" d="M381.4 251.5l-110.7-13.8-110.8 13.8V85.4h221.5z"></path><circle fill="#0052B4" cx="270.7" cy="182.3" r="55.4"></circle><circle fill="#A2001D" cx="270.7" cy="182.3" r="27.7"></circle><path fill="#6DA544" d="M229.1 113.1h83.1l-41.5 41.5z"></path><path fill="#FFDA44" d="M256.8 140.8h27.7v83h-27.7z"></path><path fill="#6DA544" d="M314.9 215.5h-88.5l-66.5 36h221.5z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Haiti +509</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="#FFDA44" d="M0 85.331h512v341.326H0z"></path><path fill="white" d="M256 85.331h256v341.337H256z"></path><path fill="#ACABB1" d="M321.353 233.837l32.073 42.43c-5.053 7.651-5.026 17.961.817 25.692 7.414 9.807 21.374 11.748 31.182 4.335 9.807-7.414 11.748-21.374 4.334-31.182-5.843-7.731-15.756-10.568-24.495-7.795l-49.988-66.129-11.838 8.949-17.759 13.424 17.899 23.677 17.775-13.401zm46.175 48.78a7.421 7.421 0 118.95 11.84 7.421 7.421 0 01-8.95-11.84z"></path><path fill="#FFDA44" d="M376.367 247.24l17.899-23.677-17.759-13.424-11.838-8.949-49.988 66.129c-8.74-2.775-18.651.063-24.495 7.795-7.414 9.808-5.473 23.768 4.334 31.182 9.808 7.414 23.768 5.473 31.182-4.335 5.845-7.731 5.871-18.041.817-25.692l32.073-42.43 17.775 13.401zm-62.504 45.771a7.42 7.42 0 11-11.84-8.95 7.42 7.42 0 0111.84 8.95z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Holy See (Vatican City State) +379</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 513 342"><path fill="white" d="M0 0h513v342H0z"></path><g fill="#338AF3"><path d="M0 0h513v114H0zM0 228h513v114H0zM203.5 117.9l6.7 16.6 17.6 1-14 10.9 4.7 17.7-15-9.9-15 9.9 4.7-17.7-14-10.9 17.6-1zM308.5 117.9l6.7 16.6 17.6 1-14 10.9 4.7 17.7-15-9.9-15 9.9 4.7-17.7-14-10.9 17.6-1zM256 147.6l6.7 16.6 17.6 1-14 10.9 4.7 17.7-15-9.9-15 9.9 4.7-17.7-14-10.9 17.6-1zM203.5 177.3l6.7 16.6 17.6 1-14 10.9 4.7 17.6-15-9.9-15 9.9 4.7-17.6-14-10.9 17.6-1zM308.5 177.3l6.7 16.6 17.6 1-14 10.9 4.7 17.6-15-9.9-15 9.9 4.7-17.6-14-10.9 17.6-1z"></path></g></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Honduras +504</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="white" d="M0 85.337h512v341.326H0z"></path><path fill="#D80027" d="M0 85.337h512v113.775H0z"></path><path fill="#6DA544" d="M0 312.888h512v113.775H0z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Hungary +36</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="#0052B4" d="M0 85.334h512v341.337H0z"></path><path fill="white" d="M512 295.883H202.195v130.783H122.435V295.883H0V216.111h122.435V85.329H202.195v130.782H512V277.329z"></path><path fill="#D80027" d="M512 234.666v42.663H183.652v149.337h-42.674V277.329H0v-42.663h140.978V85.329h42.674v149.337z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Iceland +354</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="white" d="M0 85.337h512v341.326H0z"></path><path fill="#A2001D" d="M0 85.337h512V256H0z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Indonesia +62</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 513 342"><path fill="white" d="M0 0h512v342H0z"></path><path fill="#6DA544" d="M0 0h513v114H0z"></path><g fill="#D80027"><path d="M0 227.9h513v114H0zM278.8 134.8c.1 2 8.7 26.2 4.4 39.4-6.6 20.3-15.8 21.8-19.8 24.5V134l-6.9-4.2-6.9 4.2v64.7c-4-2.7-12.4-2.4-19.8-24.5-4.3-12.7 5.7-37.3 5.8-39.2 0 0-9.5 8.1-15.8 24-5.9 14.8 1.9 49.6 29.5 54.8 2.3.4 4.7 5.6 7.2 5.6 2.1 0 4.1-5.2 6-5.5 28.4-4.6 35-41.7 29.9-55.6-5.4-14.6-13.6-23.5-13.6-23.5z"></path></g><g fill="white" opacity=".5"><path d="M44.6 98.9h22.3v24.4H44.6zM0 98.9h22.3v24.4H0zM89.2 98.9h22.3v24.4H89.2zM133.8 98.9h22.3v24.4h-22.3zM178.4 98.9h22.3v24.4h-22.3zM223 98.9h22.3v24.4H223zM267.7 98.9H290v24.4h-22.3zM312.3 98.9h22.3v24.4h-22.3zM356.9 98.9h22.3v24.4h-22.3zM401.5 98.9h22.3v24.4h-22.3zM446.1 98.9h22.3v24.4h-22.3zM490.7 98.9H513v24.4h-22.3zM44.6 216.9h22.3v25.5H44.6zM0 216.9h22.3v25.5H0zM89.2 216.9h22.3v25.5H89.2zM133.8 216.9h22.3v25.5h-22.3zM178.4 216.9h22.3v25.5h-22.3zM223 216.9h22.3v25.5H223zM267.7 216.9H290v25.5h-22.3zM312.3 216.9h22.3v25.5h-22.3zM356.9 216.9h22.3v25.5h-22.3zM401.5 216.9h22.3v25.5h-22.3zM446.1 216.9h22.3v25.5h-22.3zM490.7 216.9H513v25.5h-22.3z"></path></g></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Iran +98</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 513 342"><path fill="white" d="M0 0h513v342H0z"></path><path fill="#CE1126" d="M0 0h513v114H0z"></path><path d="M0 228h513v114H0z"></path><g fill="#547C31"><path d="M219.2 160.7h-29.3c1.5-5.7 6.6-9.9 12.8-9.9v-19.9c-18.3 0-33.1 14.9-33.1 33.1v16.5h49.6c1.8 0 3.3 1.5 3.3 3.3v6.6h-66.2v19.9h86.1v-26.5c0-12.7-10.4-23.1-23.2-23.1zM268.8 190.5v-59.6H249v79.5h33.1v-19.9zM335 190.5v-59.6h-19.8v59.6h-6.6v-19.8h-19.9v39.7h59.6v-19.9z"></path></g></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Iraq +964</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 513 342"><path fill="#E52D42" d="M0 0h513v342H0z"></path><path fill="white" d="M393.3 68.2h-45.8l-33.8 80.2-34.4-22.9s-24.7-59.1-34.4-68.2c-9.7-9.7-18.7-.6-48.9 7.8-29.6 8.4-30.8 18.7-42.2 18.7-4.8 0-19.9-17.5-27.7-22.3-12.1-7.8-16.9-4.2-13.9 7.2 1.2 4.8 10.9 10.9 16.9 19.9 7.8 11.5 12.7 25.9 12.7 25.9s10.9-10.3 16.9-12.1c9-2.4 19.3 1.8 31.4 0 15.1-2.4 31.4-10.9 31.4-10.9l4.2 43.4s-54.3 50.7-49.5 70.6 56.1 44.6 68.2 62.7c12.1 17.5-7.2 24.1-7.2 32.6s-1.8 19.9 7.2 16.3c9-3.6 10.3-18.1 18.7-31.4 6-9 10.3-13.9 11.5-17.5 1.8-9-23.5-32-37.4-48.9-6.6-7.8-19.9-18.7-19.9-18.7l39.2-29.6s67.6 27.7 82.6 18.7c15.1-9 19.3-98.3 19.3-98.3l47-11.5-12.1-11.7z"></path><path fill="#F8DD4E" d="M279.3 262.4c-6 0-11.5-4.8-11.5-11.5s4.8-11.5 11.5-11.5c6 0 11.5 4.8 11.5 11.5s-5.5 11.5-11.5 11.5zm45.8-182.8c-6 0-11.5-4.8-11.5-11.5s4.8-11.5 11.5-11.5c6 0 11.5 4.8 11.5 11.5s-5.5 11.5-11.5 11.5zm0 91.1c-6 0-11.5-4.8-11.5-11.5 0-6 4.8-11.5 11.5-11.5 6 0 11.5 4.8 11.5 11.5-.6 6.7-5.5 11.5-11.5 11.5zm-136.9 45.8c-6 0-11.5-4.8-11.5-11.5 0-6 4.8-11.5 11.5-11.5 6.6 0 11.5 4.8 11.5 11.5s-5.5 11.5-11.5 11.5zm45.2-136.9c-6 0-11.5-4.8-11.5-11.5s4.8-11.5 11.5-11.5c6 0 11.5 4.8 11.5 11.5s-4.8 11.5-11.5 11.5zm22.9 91.1c-6 0-11.5-10.3-11.5-22.9s4.8-22.9 11.5-22.9c6 0 11.5 10.3 11.5 22.9s-4.8 22.9-11.5 22.9zm-114-45.2c-6 0-11.5-4.8-11.5-11.5 0-6.6 4.8-11.5 11.5-11.5 6.6 0 11.5 4.8 11.5 11.5 0 6.6-4.8 11.5-11.5 11.5z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Isle of Man +44</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 513 342"><path fill="white" d="M0 0h513v342H0z"></path><g fill="#2E52B2"><path d="M340.6 122.4h-56.1l-28-48.6-28 48.6h-56.1l28 48.6-28 48.6h56.1l28 48.6 28-48.6h56.1l-28-48.6 28-48.6zM293.2 171L276 204.2h-38.9L219.8 171l17.2-33.2h38.9l17.3 33.2zm-36.7-71.8l11.9 23.3h-23.9l12-23.3zm-58.3 38.6h23.9l-10.8 21-13.1-21zm0 66.4l13-22.1 11.9 22.1h-24.9zm58.3 37.5l-11.9-22.1h23.9l-12 22.1zm59.4-37.5h-25l11.9-22.1 13.1 22.1zm-26.1-66.4h26.1l-13 22.1-13.1-22.1zM0 21.3h512V64H0zM0 277.3h512V320H0z"></path></g></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Israel +972</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="white" d="M341.334 85.33H0v341.332h512V85.33z"></path><path fill="#6DA544" d="M0 85.333h170.663V426.67H0z"></path><path fill="#D80027" d="M341.337 85.333H512V426.67H341.337z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Italy +39</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="#6DA544" d="M0 85.337h512v341.326H0z"></path><path d="M215.864 256.006L0 399.911V112.089zM512 112.089v287.822L296.136 256.006z"></path><path fill="#0052B4" d="M512 112.089L296.136 256.006 512 399.911v26.757h-40.125L256 282.752 40.125 426.668H0v-26.757l215.864-143.905L0 112.089V85.331h40.125L256 229.248 471.875 85.331H512z"></path><path fill="#FFDA44" d="M512 112.089L296.136 256.006 512 399.911v26.757h-40.125L256 282.752 40.125 426.668H0v-26.757l215.864-143.905L0 112.089V85.331h40.125L256 229.248 471.875 85.331H512z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Jamaica +1876</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="white" d="M0 85.331h512v341.337H0z"></path><circle fill="#D80027" cx="256" cy="255.994" r="96"></circle></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Japan +81</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 513 342"><path fill="white" d="M0 0h513v342H0z"></path><path fill="#D80027" d="M301.8 171L513 30.2V0h-45.3L256.5 140.8 45.3 0H0v30.2L211.2 171 0 311.8V342h45.3l211.2-140.8L467.7 342H513v-30.2z"></path><path fill="#FFDA44" d="M233.7 44.6l22.3 5.6 22.3-5.6 4-20.9-14.9 6.5L256 14.8l-11.4 15.4-14.9-6.5z"></path><path fill="#D80027" d="M233.7 44.6s-4 12.9-4 29.9c0 27.9 26.3 41.3 26.3 41.3s26.3-15.5 26.3-41.3c0-15.4-4-29.9-4-29.9s-8.1-5-22.3-5-22.3 5-22.3 5z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Jersey +44</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="white" d="M0 85.339h512v341.326H0z"></path><path d="M0 85.339h512v113.775H0z"></path><path fill="#6DA544" d="M0 312.89h512v113.775H0z"></path><path fill="#D80027" d="M256 256.006L0 426.669V85.331z"></path><path fill="white" d="M77.913 224.802l7.876 16.469 17.786-4.11-7.965 16.426 14.303 11.343-17.808 4.014.049 18.255-14.241-11.421-14.241 11.421.05-18.255-17.809-4.014 14.303-11.343-7.965-16.426 17.786 4.11z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Jordan +962</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 513 342"><path fill="#36B6CC" d="M0 0h513v342H0V0z"></path><circle fill="#FFD400" cx="256.5" cy="170.9" r="68.4"></circle><path fill="#FFD400" d="M256.5 251.5l-27.9 41.7-7.1-49.7-43.2 25.5 15.2-47.8-50 4.2 34.4-36.5-46.9-18 46.8-18-34.4-36.5 50 4.2-15.2-47.8 43.2 25.4 7.1-49.7 27.9 41.7 27.9-41.7 7.1 49.7 43.2-25.4-15.2 47.8 50-4.2-34.3 36.6 46.8 17.9-46.8 18 34.4 36.5-50-4.2 15.2 47.8-43.2-25.4-7.1 49.7c0-.1-27.9-41.8-27.9-41.8zm0-.8c44.1 0 79.9-35.8 79.9-79.9S300.6 91 256.5 91s-79.9 35.8-79.9 79.9 35.8 79.8 79.9 79.8zM22.8 28.3c0-3.2 2.4-5.7 5.7-5.7h11.3c3.2 0 5.7 2.4 5.7 5.7v11.3c.1 3.1-2.4 5.7-5.6 5.7H28.5c-3.1 0-5.7-2.5-5.7-5.6v-.1-11.3zm0 45.7c0-3.2 2.4-5.7 5.7-5.7h11.3c3.2 0 5.7 2.4 5.7 5.7v11.3c.1 3.1-2.4 5.7-5.6 5.7H28.5c-3.1 0-5.7-2.5-5.7-5.6V74zm0 45.6c0-3.2 2.4-5.7 5.7-5.7h11.3c3.2 0 5.7 2.4 5.7 5.7v11.3c.1 3.1-2.4 5.7-5.6 5.7H28.5c-3.1 0-5.7-2.5-5.7-5.6v-.1-11.3zm0 45.6c0-3.2 2.4-5.7 5.7-5.7h11.3c3.2 0 5.7 2.4 5.7 5.7v11.3c.1 3.1-2.4 5.7-5.6 5.7H28.5c-3.1 0-5.7-2.5-5.7-5.6v-.1-11.3zm0 45.7c0-3.2 2.4-5.7 5.7-5.7h11.3c3.2 0 5.7 2.4 5.7 5.7v11.3c.1 3.1-2.4 5.7-5.6 5.7H28.5c-3.1 0-5.7-2.5-5.7-5.6v-11.4zm0 45.6c0-3.2 2.4-5.7 5.7-5.7h11.3c3.2 0 5.7 2.4 5.7 5.7v11.3c.1 3.1-2.4 5.7-5.6 5.7H28.5c-3.1 0-5.7-2.5-5.7-5.6v-11.4zm0 45.6c0-3.2 2.4-5.7 5.7-5.7h11.3c3.2 0 5.7 2.4 5.7 5.7v11.3c.1 3.1-2.4 5.7-5.6 5.7H28.5c-3.1 0-5.7-2.5-5.7-5.6v-11.4zm22.8-22.8c0-3.2 2.4-5.7 5.7-5.7h11.3c3.2 0 5.7 2.4 5.7 5.7v11.3c.1 3.1-2.4 5.7-5.6 5.7H51.3c-3.1 0-5.7-2.5-5.7-5.6v-11.4zm0-45.6c0-3.2 2.4-5.7 5.7-5.7h11.3c3.2 0 5.7 2.4 5.7 5.7V245c.1 3.1-2.4 5.7-5.6 5.7H51.3c-3.1 0-5.7-2.5-5.7-5.6v-11.4zm0-45.7c0-3.2 2.4-5.7 5.7-5.7h11.3c3.2 0 5.7 2.4 5.7 5.7v11.3c.1 3.1-2.4 5.7-5.6 5.7H51.3c-3.1 0-5.7-2.5-5.7-5.6V188zm0-45.6c0-3.2 2.4-5.7 5.7-5.7h11.3c3.2 0 5.7 2.4 5.7 5.7v11.3c.1 3.1-2.4 5.7-5.6 5.7H51.3c-3.1 0-5.7-2.5-5.7-5.6v-.1-11.3zm0-45.6c0-3.2 2.4-5.7 5.7-5.7h11.3c3.2 0 5.7 2.4 5.7 5.7v11.3c.1 3.1-2.4 5.7-5.6 5.7H51.3c-3.1 0-5.7-2.5-5.7-5.6v-.1-11.3zm0-45.6c0-3.2 2.4-5.7 5.7-5.7h11.3c3.2 0 5.7 2.4 5.7 5.7v11.3c.1 3.1-2.4 5.7-5.6 5.7H51.3c-3.1 0-5.7-2.5-5.7-5.6V51.2z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Kazakhstan +77</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="white" d="M0 85.331h512v341.337H0z"></path><path d="M0 85.331h512v90.579H0z"></path><path fill="#496E2D" d="M0 336.089h512v90.568H0z"></path><path fill="#A2001D" d="M0 198.606h512v114.799H0z"></path><g fill="white"><path d="M323.265 139.803l-25.583-11.809L256 222.376l-41.682-94.382-25.583 11.809 51.749 116.191-51.749 116.192 25.583 11.808L256 289.613l41.682 94.381 25.583-11.808-51.749-116.192z"></path><path d="M273.376 150.931C263.472 140.115 256 133.898 256 133.898s-7.472 6.216-17.376 17.032v210.127C248.528 371.873 256 378.091 256 378.091s7.472-6.216 17.376-17.033V150.931z"></path></g><g fill="#A2001D"><path d="M209.04 191.226v129.535c10.465 18.542 23.274 33.742 32.872 43.818V147.408c-9.599 10.076-22.408 25.275-32.872 43.818zM302.96 191.226c-10.465-18.543-23.274-33.742-32.872-43.818V364.58c9.599-10.077 22.407-25.276 32.872-43.818V191.226z"></path></g><path d="M302.96 191.226v129.535c10.594-18.774 18.784-40.973 18.784-64.767s-8.19-45.993-18.784-64.768zM209.04 191.226v129.535c-10.594-18.774-18.784-40.973-18.784-64.767s8.19-45.993 18.784-64.768z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Kenya +254</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 450 300"><path fill="#CE1126" d="M0 0h450v300H0V0z"></path><g fill="#FCD116"><circle cx="227.6" cy="161.2" r="56.2"></circle><path d="M254.1 73.4l-23.7 26 28.6 6.5zM202.6 73.6l-4.8 33.1 28.5-8zM296.9 100.3l-34.7 8.5 20.1 23.7zM158.6 98.5l15.5 32.7 20.2-22.7zM317.6 143.8l-34.4-9.9 5.6 29.5zM135.6 141.2l31.9 19.8 5.2-27.7z"></path></g><path fill="#003F87" d="M0 175h450v125H0V175z"></path><path fill="white" d="M0 267c15 0 30 13 45 13s30-13 45-13 30 13 45 13 30-13 45-13 30 13 45 13 30-13 45-13 30 13 45 13 30-13 45-13 30 13 45 13 30-13 45-13v-21c-15 0-30 13-45 13s-30-13-45-13-30 13-45 13-30-13-45-13-30 13-45 13-30-13-45-13-30 13-45 13-30-13-45-13-30 13-45 13-30-13-45-13v21zm0-43c15 0 30 13 45 13s30-13 45-13 30 13 45 13 30-13 45-13 30 13 45 13 30-13 45-13 30 13 45 13 30-13 45-13 30 13 45 13 30-13 45-13v-21c-15 0-30 13-45 13s-30-13-45-13-30 13-45 13-30-13-45-13-30 13-45 13-30-13-45-13-30 13-45 13-30-13-45-13-30 13-45 13-30-13-45-13v21zm0-43c15 0 30 13 45 13s30-13 45-13 30 13 45 13 30-13 45-13 30 13 45 13 30-13 45-13 30 13 45 13 30-13 45-13 30 13 45 13 30-13 45-13v-21c-15 0-30 13-45 13s-30-13-45-13-30 13-45 13-30-13-45-13-30 13-45 13-30-13-45-13-30 13-45 13-30-13-45-13-30 13-45 13-30-13-45-13v21z"></path><path fill-rule="evenodd" clip-rule="evenodd" fill="#FCD116" d="M183.2 48.3l-1.1-5.3 22.4-3.7s-30.1-7.1-40-10.7c-14.3-5.1-16.3-12.1-16.3-12.1s44.7 11 64.8 11c4.3 0 12.8 10.7 12.8 10.7s14.8-14.9 21.9-15.4c32.1-2.3 66.6-6.4 66.6-6.4s-10 6.7-16 8.5c-16.2 4.9-50.6 11.7-50.6 11.7l-4.8 7.5H277l-14.4 4.3 7.4 6.9s-7.8-4.1-18.1-2.1c-7.1 1.3-15.4 6-22.9 8-18.7 4.8-29.9-12.8-29.9-12.8l-15.9-.1z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Kiribati +686</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="#91DC5A" d="M0 85.331h512v341.337H0z"></path><path fill="white" d="M0 85.331h512v341.337H0z"></path><g fill="#0052B4"><path d="M0 85.331h512v57.188H0zM0 369.48h512v57.177H0z"></path></g><path fill="#D80027" d="M0 165.215h512v181.582H0z"></path><circle fill="white" cx="190.33" cy="255.994" r="65.668"></circle><path fill="#D80027" d="M190.332 190.332l14.734 45.346h47.757l-38.65 28.028 14.849 45.481-38.69-28.16-38.631 28.107 14.79-45.428-38.616-28.028h47.722z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Korea, Democratic People's Republic of Korea +850</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 900 600"><path fill="white" d="M0 0h900v600H0z"></path><g transform="rotate(-56.31)"><g stroke="black" stroke-width="25"><path d="M-75 228.3H75m-150 37.5H75m-150 37.5H75M-75 778.3H75m-150 37.5H75m-150 37.5H75"></path></g><path stroke="white" stroke-width="12.5" d="M0 753.3v125"></path><circle fill="#ca163a" cy="540.8" r="150"></circle><path fill="#0e4896" d="M0 390.8c-41.4 0-75 33.6-75 75s33.6 75 75 75 75 33.6 75 75-33.6 75-75 75c-82.8 0-150-67.2-150-150s67.2-150 150-150z"></path></g><g stroke="black" stroke-width="25"><path d="M231.56 535.73l-83.205-124.808M262.76 514.928l-83.205-124.807m114.407 104.006l-83.205-124.808M689.187 230.644l-83.205-124.807M720.39 209.843L637.184 85.036m114.407 104.006L668.386 64.234"></path></g><path stroke="white" stroke-width="12.5" d="M205.6 462.897l31.202-20.8m389.981-259.989l36.444-24.296m31.202-20.801l31.202-20.801"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Korea, Republic of South Korea +82</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 341.33"><path fill="#0052B4" d="M0 0h512v341.34H0z"></path><g fill="white"><path d="M220.72 42.63l7.95 16.11 17.77 2.58-12.86 12.54 3.04 17.7-15.9-8.36-15.9 8.36 3.03-17.7-12.86-12.54 17.78-2.58zM291.28 42.57l7.95 16.1 17.78 2.59-12.86 12.53 3.03 17.71-15.9-8.36-15.9 8.36 3.04-17.71-12.86-12.53 17.77-2.59zM353.36 53.93l7.95 16.11 17.77 2.58-12.86 12.54 3.04 17.7-15.9-8.35-15.9 8.35 3.04-17.7-12.87-12.54 17.78-2.58zM416.37 72.23l7.95 16.11 17.77 2.59-12.86 12.53 3.04 17.71-15.9-8.36-15.9 8.36 3.03-17.71-12.86-12.53 17.78-2.59zM158.64 53.93l7.95 16.11 17.78 2.58-12.87 12.54 3.04 17.7-15.9-8.35-15.9 8.35 3.04-17.7-12.86-12.54 17.77-2.58zM95.63 72.23l7.95 16.11 17.78 2.59-12.86 12.53 3.03 17.71-15.9-8.36-15.9 8.36 3.04-17.71-12.86-12.53 17.77-2.59z"></path></g><path fill="#FFDA44" d="M217.53 259.33l-27.22-13.61-27.22-54.43h27.22l27.22-27.22 13.61-27.22 27.22-13.61 13.61 13.61 27.22 13.61v13.61l13.61 13.61 40.83 27.22L340 245.73l-40.83 40.83-13.61-27.22-40.83 27.22v27.22l-13.61-13.61-13.59-40.84z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Kosovo +383</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 342"><g fill="#D80027"><path d="M0 0h513v342H0z"></path><circle cx="256" cy="170.7" r="170.7"></circle></g><path fill="#FFDA44" d="M382.4 170.7L330.8 195l27.5 50-56.1-10.7-7.1 56.6-39.1-41.7-39.1 41.7-7.1-56.6-56.1 10.7 27.5-50-51.6-24.3 51.6-24.3-27.5-50.1 56.1 10.8 7.1-56.7L256 92.1l39.1-41.7 7.1 56.7 56.1-10.8-27.5 50.1z"></path><circle fill="#D80027" cx="257.4" cy="170.7" r="71.6"></circle><g fill="#FFDA44"><path d="M214.2 170.7c-2.1 0-4.1.1-6.2.3.1 12 4.4 22.9 11.6 31.5 3.8-10.3 9.5-19.6 16.7-27.7-6.9-2.7-14.3-4.1-22.1-4.1zM240.8 217.2c5.2 1.9 10.8 2.9 16.6 2.9 5.8 0 11.4-1 16.6-2.9-2.8-11.1-8.7-21-16.6-28.8-7.9 7.8-13.8 17.7-16.6 28.8zM300.2 146c-8.5-14.8-24.5-24.7-42.8-24.7-18.3 0-34.2 9.9-42.8 24.7 15.6.1 30.2 4.3 42.8 11.6 12.6-7.3 27.2-11.6 42.8-11.6zM278.5 174.8c7.2 8 12.9 17.4 16.7 27.7 7.2-8.5 11.5-19.5 11.6-31.5-2-.2-4.1-.3-6.2-.3-7.7 0-15.2 1.4-22.1 4.1z"></path></g></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Kyrgyzstan +996</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 513 342"><path fill="#0052B4" d="M0 0h513v342H0z"></path><g fill="#D80027"><path d="M0 .1h513v90.7H0zM0 251.3h513V342H0z"></path></g><circle fill="white" cx="256.5" cy="171" r="65.9"></circle></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Laos +856</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 513 342"><path fill="white" d="M0 0h513v342H0z"></path><g fill="#A2001D"><path class="prefix__st1" d="M0 0h513v127.6H0zM0 214.4h513V342H0z"></path></g></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Latvia +371</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 513 342"><path fill="white" d="M0 0h513v342H0z"></path><g fill="#D80027"><path d="M0 .2h513v90.7H0zM.5 251.3H513V342H.5z"></path></g><path fill="#6DA544" d="M290.3 193.5L256 130.7l-34.3 62.8h25.7v17.2h17.2v-17.2z"></path><path fill="#14AF5A" d="M241.3 213.1c4.4-4.4 4.4-11.6-.1-16l4.7 4.7c-5.2-4.7-12.2-6.6-19.1-5.3l-23.5 5.9c-6.1 1.5-6.8-.4-1.8-4.2l27.1-20.3c5.1-3.8 4.2-6.9-2.3-6.9h-11c-6.4 0-7-2.3-1.5-5.1l25.3-12.7c5.6-2.8 5.1-5.1-1.5-5.1h-11c-6.4 0-7.4-3.1-2.3-6.9l27.1-20.3c5.6-3.8 12.9-3.8 18.5 0l27.1 20.3c5.1 3.8 4.2 6.9-2.3 6.9h-11c-6.4 0-7 2.3-1.5 5.1l25.3 12.7c5.6 2.8 5.1 5.1-1.5 5.1h-11c-6.4 0-7.4 3.1-2.3 6.9l27.1 20.3c5.1 3.8 4.4 5.7-1.8 4.2l-23.5-5.9c-6.8-1.3-13.9.6-19.1 5.3l4.7-4.7c-4.4 4.4-4.5 11.5-.1 16l6.8 6.8c4.4 4.4 3.1 8-3.3 8h-45.8c-6.2 0-7.7-3.6-3.3-8 .1.1 6.9-6.8 6.9-6.8z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Lebanon +961</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 513 342"><path fill="white" d="M0 0h513v342H0z"></path><path fill="#0052B4" d="M0 0h513v114H0z"></path><path fill="#6DA544" d="M0 227.6h513v114H0z"></path><path d="M245.2 171l7.7-23.1c2-5.9 5.1-6 7.1 0l7.7 23.1 19.4 29.1c1.7 2.6 1.3 6.3-1.2 8 0 0-6.9 8-29.5 8s-29.5-8-29.5-8c-2.4-2-2.9-5.4-1.2-8l19.5-29.1z"></path><path d="M256.5 171c-12.5 0-22.6-10.1-22.6-22.6 0-12.5 10.1-22.6 22.6-22.6s22.6 10.1 22.6 22.6c0 12.5-10.2 22.6-22.6 22.6zm0 0c6.2 0 11.3-16.3 11.3-22.6 0-6.2-5.1-11.3-11.3-11.3-6.2 0-11.3 5.1-11.3 11.3 0 6.3 5 22.6 11.3 22.6z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Lesotho +266</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="white" d="M0 91.476h512v341.337H0z"></path><g fill="#D80027"><path d="M0 91.476h512v31.031H0zM0 153.539h512v31.031H0zM0 215.603h512v31.031H0zM0 277.666h512v31.031H0zM0 339.729h512v31.031H0zM0 401.793h512v31.031H0z"></path></g><path fill="#0052B4" d="M0 79.177h256v167.457H0z"></path><path fill="white" d="M127.999 118.382l11.05 34.01h35.764l-28.932 21.021 11.05 34.012-28.932-21.021-28.933 21.021 11.053-34.012-28.932-21.021h35.762z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Liberia +231</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path d="M0 85.337h512v341.326H0z"></path><path fill="#D80027" d="M0 85.337h512v113.775H0z"></path><path fill="#496E2D" d="M0 312.888h512v113.775H0z"></path><g fill="white"><path d="M281.424 236.026l8.962 12.35 14.513-4.706-8.975 12.339 8.961 12.349-14.509-4.724-8.976 12.34.01-15.258-14.51-4.725 14.514-4.706z"></path><path d="M256.965 286.868c-17.048 0-30.868-13.821-30.868-30.868s13.821-30.868 30.868-30.868a30.742 30.742 0 0114.684 3.71c-6.851-6.698-16.218-10.833-26.556-10.833-20.982 0-37.992 17.01-37.992 37.992s17.01 37.992 37.992 37.992c10.338 0 19.706-4.135 26.556-10.833a30.738 30.738 0 01-14.684 3.708z"></path></g></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Libya +218</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 513 342"><path fill="#D80027" d="M0 0h513v342H0z"></path><path fill="#0052B4" d="M0 0h513v171H0z"></path><path fill="#FFDA44" d="M149.3 98.1c0-14-11.3-25.3-25.3-25.3-6.5 0-12.4 2.4-16.9 6.4V64.4h8.4V47.5h-8.4v-8.4H90.3v8.4h-8.4v16.9h8.4v14.9c-4.5-4-10.4-6.4-16.9-6.4-14 0-25.3 11.3-25.3 25.3 0 7.5 3.3 14.2 8.4 18.8v14.9h84.3V117c5.3-4.7 8.5-11.5 8.5-18.9z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Liechtenstein +423</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="#6DA544" d="M0 85.337h512v341.326H0z"></path><path fill="#FFDA44" d="M0 85.337h512v113.775H0z"></path><path fill="#D80027" d="M0 312.888h512v113.775H0z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Lithuania +370</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="white" d="M0 85.337h512v341.326H0z"></path><path fill="#D80027" d="M0 85.337h512v113.775H0z"></path><path fill="#338AF3" d="M0 312.888h512v113.775H0z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Luxembourg +352</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="#496E2D" d="M0 85.331h512v341.337H0z"></path><path fill="white" d="M285.682 248.878c-4.19 0-8.166.836-11.861 2.164 2.023-4.509 3.379-9.527 3.379-14.885 0-21.201-21.201-37.101-21.201-37.101s-21.201 15.901-21.201 37.101c0 5.357 1.356 10.375 3.379 14.885-3.693-1.328-7.671-2.164-11.861-2.164-21.201 0-37.101 21.201-37.101 21.201s15.901 21.201 37.101 21.201c12.429 0 23.031-7.286 29.682-13.315 6.65 6.03 17.251 13.315 29.682 13.315 21.201 0 37.101-21.201 37.101-21.201s-15.899-21.201-37.099-21.201z"></path><g fill="#FFDA44"><path d="M256 152.111l4.38 13.476h14.171l-11.464 8.332 4.376 13.476-11.463-8.33-11.463 8.33 4.376-13.476-11.464-8.332h14.171zM202.112 175.683l8.425 7.585 9.818-5.667-4.61 10.355 8.423 7.588-11.274-1.185-4.611 10.355-2.358-11.088-11.275-1.185 9.818-5.669zM162.662 215.132l11.09 2.358 5.668-9.818 1.186 11.274 11.089 2.358-10.357 4.61 1.186 11.274-7.587-8.423-10.357 4.61 5.669-9.818zM309.889 175.683l-8.425 7.585-9.818-5.667 4.611 10.355-8.425 7.588 11.275-1.185 4.61 10.355 2.359-11.088 11.275-1.185-9.818-5.669zM349.338 215.132l-11.089 2.358-5.669-9.818-1.186 11.274-11.088 2.358 10.357 4.61-1.185 11.274 7.586-8.423 10.357 4.61-5.669-9.818z"></path></g><g fill="white"><path d="M256 350.642c16.84 0 32.363-5.619 44.816-15.073h-89.63c12.451 9.454 27.974 15.073 44.814 15.073zM187.977 306.12a74.138 74.138 0 008.85 15.073h118.345a74.13 74.13 0 008.85-15.073H187.977z"></path></g></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Macau +853</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="#6DA544" d="M512 426.666V85.329H0v341.337h512z"></path><path fill="#D80027" d="M512 85.331H0v170.666h512V85.331z"></path><path fill="white" d="M0 85.334h181.793v341.337H0z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Madagascar +261</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="#D80027" d="M0 85.337h512v341.326H0z"></path><path d="M0 85.337h512v113.775H0z"></path><path fill="#496E2D" d="M0 312.888h512v113.775H0z"></path><path fill="#D80027" d="M307.01 166.957l-20.842-9.804 11.099-20.186-22.634 4.329-2.868-22.864L256 135.248l-15.764-16.816-2.869 22.864-22.633-4.329 11.099 20.186-20.843 9.804z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Malawi +265</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 341.3"><path fill="white" d="M0 0h512v341.3H0z"></path><g fill="#D80027"><path d="M0 42.7h512v42.7H0zM0 128h512v42.7H0zM0 213.3h512V256H0zM0 298.7h512v42.7H0z"></path></g><path fill="#0052B4" d="M0 0h256v170.7H0z"></path><g fill="#FFDA44"><path d="M141.1 134.8c-28 0-45.9-24.8-45.9-49.5 0-24.8 17.9-49.5 45.9-49.5 8.7 0 18.1 1 25.3 4.9-11.2-11-26.6-17.8-43.6-17.8-34.4 0-62.4 27.9-62.4 62.4s27.9 62.4 62.4 62.4c17 0 32.3-6.8 43.6-17.8-7.1 3.9-16.5 4.9-25.3 4.9z"></path><path d="M171 49.7l9 18.8 20.3-4.7-9.1 18.8 16.4 12.9-20.4 4.6.1 20.9-16.3-13.1-16.2 13.1v-20.9l-20.3-4.6 16.3-12.9-9.1-18.8 20.3 4.7z"></path></g></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Malaysia +60</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="#D80027" d="M0 85.331h512v341.333H0z"></path><path fill="#6DA544" d="M144.696 174.375h222.609v163.25H144.696z"></path><path fill="white" d="M283.484 304.226c-26.637 0-48.232-21.594-48.232-48.232s21.594-48.232 48.232-48.232c8.306 0 16.12 2.1 22.943 5.797-10.703-10.467-25.341-16.927-41.494-16.927-32.784 0-59.362 26.577-59.362 59.362s26.578 59.362 59.362 59.362c16.154 0 30.791-6.461 41.494-16.927-6.822 3.698-14.636 5.797-22.943 5.797z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Maldives +960</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="#FFDA44" d="M0 85.331h512v341.337H0z"></path><path fill="#6DA544" d="M0 85.331h170.663v341.337H0z"></path><path fill="#D80027" d="M341.337 85.331H512v341.337H341.337z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Mali +223</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="white" d="M0 85.331h512v341.326H0z"></path><path fill="#D80027" d="M256 85.331h256v341.337H256z"></path><path fill="#ACABB1" d="M208.231 138.671v-21.334h-21.332v21.334h-21.334v21.332h21.334v21.334h21.332v-21.334h21.334v-21.332z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Malta +356</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="#0052B4" d="M0 85.337h512v341.326H0z"></path><g fill="white"><path d="M233.839 185.115l-20.844 9.803 11.1 20.187-22.633-4.33-2.868 22.864-15.765-16.816-15.766 16.816-2.867-22.864-22.634 4.33 11.1-20.187-20.843-9.803 20.843-9.805-11.1-20.185 22.633 4.328 2.869-22.864 15.765 16.816 15.765-16.816 2.868 22.864 22.634-4.328-11.1 20.186zM426.917 85.337L0 421.52v3.762L503.756 85.337z"></path></g><path fill="#FF9811" d="M512 85.337h-8.244L0 425.282v1.381h3.723L512 136.998z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Marshall Islands +692</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="#0052B4" d="M0 85.331h512v341.337H0z"></path><g fill="white"><path d="M512 233.734v44.521H278.261v148.402h-44.522V278.255H0v-44.521h233.739V85.331h44.522v148.403z"></path><path d="M386.607 175.885a4.119 4.119 0 014.115-4.114h8.816c13.936 0 25.274-11.337 25.274-25.273 0-13.935-11.337-25.273-25.274-25.273h-8.372c-2.733-2.052-6.399-3.318-10.443-3.318-8.436 0-15.273 5.471-15.273 12.219 0 6.683 6.707 12.104 15.029 12.209l-.003.049h19.062c2.27 0 4.115 1.845 4.115 4.115s-1.845 4.114-4.115 4.114h-8.816c-13.936 0-25.273 11.337-25.273 25.273 0 13.935 11.336 25.273 25.273 25.273h34.09V180h-34.09a4.12 4.12 0 01-4.115-4.115zM108.346 175.885a4.119 4.119 0 014.115-4.114h8.816c13.936 0 25.274-11.337 25.274-25.273 0-13.935-11.337-25.273-25.274-25.273h-8.372c-2.733-2.052-6.399-3.318-10.443-3.318-8.436 0-15.273 5.471-15.273 12.219 0 6.683 6.707 12.104 15.029 12.209l-.003.049h19.062c2.27 0 4.115 1.845 4.115 4.115s-1.845 4.114-4.115 4.114h-8.816c-13.936 0-25.273 11.337-25.273 25.273 0 13.935 11.336 25.273 25.273 25.273h34.09V180h-34.09a4.12 4.12 0 01-4.115-4.115zM386.607 368.809a4.119 4.119 0 014.115-4.114h8.816c13.936 0 25.274-11.337 25.274-25.273 0-13.935-11.337-25.273-25.274-25.273h-8.372c-2.733-2.052-6.399-3.318-10.443-3.318-8.436 0-15.273 5.471-15.273 12.219 0 6.683 6.707 12.104 15.029 12.209l-.003.049h19.062c2.27 0 4.115 1.845 4.115 4.115s-1.845 4.114-4.115 4.114h-8.816c-13.936 0-25.273 11.337-25.273 25.273 0 13.935 11.336 25.273 25.273 25.273h34.09v-21.159h-34.09a4.119 4.119 0 01-4.115-4.115zM108.346 368.809a4.119 4.119 0 014.115-4.114h8.816c13.936 0 25.274-11.337 25.274-25.273 0-13.935-11.337-25.273-25.274-25.273h-8.372c-2.733-2.052-6.399-3.318-10.443-3.318-8.436 0-15.273 5.471-15.273 12.219 0 6.683 6.707 12.104 15.029 12.209l-.003.049h19.062c2.27 0 4.115 1.845 4.115 4.115s-1.845 4.114-4.115 4.114h-8.816c-13.936 0-25.273 11.337-25.273 25.273 0 13.935 11.336 25.273 25.273 25.273h34.09v-21.159h-34.09a4.119 4.119 0 01-4.115-4.115z"></path></g></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Martinique +596</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="#496E2D" d="M0 85.331h512v341.337H0z"></path><g fill="#FFDA44"><path d="M256 298.851c-45.956 0-84.348-32.298-93.767-75.429A96.288 96.288 0 00160 243.994c0 53.02 42.979 96 96 96s96-42.98 96-96c0-7.066-.785-13.942-2.233-20.572-9.419 43.131-47.811 75.429-93.767 75.429z"></path><path d="M255.999 171.994l8.935 27.502h28.918l-23.394 16.996 8.936 27.503-23.395-16.998-23.394 16.998 8.937-27.503-23.394-16.996h28.915z"></path></g></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Mauritania +222</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="#FFDA44" d="M0 85.331h512v341.326H0z"></path><path fill="#D80027" d="M0 85.331h512v85.337H0z"></path><path fill="#0052B4" d="M0 170.657h512v85.337H0z"></path><path fill="#6DA544" d="M0 341.331h512v85.337H0z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Mauritius +230</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 90 60"><path fill="white" d="M0 0h90v60H0z"></path><path stroke="#7f7f7f" stroke-width=".25" fill="#ABABAB" d="M12.8 38.5s4 1.6 1.2-.5c-2.4-1.7-5 2.4-5 5.1s1.2 7 7.5 7c7.6 0 11.4-5.7 11.4-11.4 0-4.8-3.7-13.5-6.5-14.6-3.1-1.2-6.7-3.5-6.8-5 0-.5 1.4-.1 3.3.9 3.1 1.7 6.6 2.5 6.6 1.4s-2.9-3.1-4-4.6c-1.2-1.6-.9-5.5-3-5.5-7.6 0-9.9 7.7-7 11.7 1.9 2.6-4.3 1-4.3 1s0 5.3 3.2 7.3c3 1.8 4.8 3.9 4.8 3.9s-.2-4.6.5-3.9c.6.7 11.1 4.5 10.3 12-.3 3-4.5 5.4-8.5 5.2-4-.2-6.8-2.4-6.4-5.4.2-4.2 2.7-4.6 2.7-4.6zM77.2 38.5s-4 1.6-1.2-.5c2.4-1.8 5.1 2.3 5.1 5.1s-1.2 7-7.5 7c-7.6 0-11.4-5.7-11.4-11.4 0-4.8 3.7-13.5 6.5-14.6 3.1-1.2 6.7-3.5 6.8-5 0-.5-1.4-.1-3.3.9-3.1 1.7-6.6 2.5-6.6 1.4s2.9-3.1 4-4.6c1.2-1.6.9-5.5 3-5.5 7.6 0 9.9 7.7 7 11.7-1.9 2.6 4.3 1 4.3 1s0 5.3-3.2 7.3c-3 1.8-4.8 3.9-4.8 3.9s.2-4.6-.5-3.9c-.6.7-11.1 4.5-10.3 12 .3 3 4.5 5.4 8.5 5.2 4-.2 6.8-2.4 6.4-5.4-.3-4.2-2.8-4.6-2.8-4.6z"></path><path fill="#DE393A" d="M31 28.8v14c0 1.9 2.1 1.6 2.1 1.6h9.3c1.2 0 2.6 2.3 2.6 2.3s1.4-2.3 2.5-2.3h9.6s2 .2 2-1.8V28.7H31z"></path><path fill="#3951A3" d="M31 13.1h28v15.7H31z"></path><path fill="white" d="M50.1 16.5c-.4 2.4-2.5 4.2-5.1 4.2-2.5 0-4.6-1.8-5.1-4.2-.5.9-.8 1.9-.8 3 0 3.3 2.6 5.9 5.9 5.9 3.3 0 5.9-2.6 5.9-5.9 0-1.1-.3-2.1-.8-3z"></path><circle fill="#FEE05F" cx="39.1" cy="36.5" r="3"></circle><circle fill="#FEE05F" cx="50.9" cy="36.5" r="3"></circle></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Mayotte +262</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="#D80027" d="M341.334 85.33H0v341.332h512V85.33z"></path><path fill="#6DA544" d="M0 85.333h170.663V426.67H0z"></path><path fill="white" d="M170.663 85.333h170.663V426.67H170.663z"></path><path fill="#6DA544" d="M208 255.996c0 26.509 21.491 48 48 48s48-21.491 48-48v-16h-96v16z"></path><path fill="#FF9811" d="M320 223.996h-48c0-8.836-7.164-16-16-16s-16 7.164-16 16h-48c0 8.836 7.697 16 16.533 16H208c0 8.836 7.164 16 16 16 0 8.836 7.164 16 16 16h32c8.836 0 16-7.164 16-16 8.836 0 16-7.164 16-16h-.533c8.836 0 16.533-7.163 16.533-16z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Mexico +52</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 341.3"><path fill="#338AF3" d="M0 0h512v341.3H0z"></path><g fill="white"><path d="M256 37.9l10.1 31.2H299l-26.6 19.3 10.2 31.2-26.6-19.3-26.6 19.3 10.2-31.2L213 69.1h32.9zM123.2 170.7l31.2-10.2v-32.8l19.3 26.6 31.2-10.2-19.3 26.6 19.3 26.5-31.2-10.1-19.3 26.5v-32.8zM256 303.5l-10.1-31.2H213l26.6-19.3-10.2-31.3L256 241l26.6-19.3-10.2 31.3 26.6 19.3h-32.9zM388.8 170.7l-31.2 10.1v32.8l-19.3-26.5-31.2 10.1 19.3-26.5-19.3-26.6 31.2 10.2 19.3-26.6v32.8z"></path></g></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Micronesia, Federated States of Micronesia +691</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 513 342"><path fill="#FFDA44" d="M0 0h513v342H0z"></path><path fill="#D80027" d="M342 0h171v342H342z"></path><path fill="#0052B4" d="M0 0h171v342H0z"></path><path fill="#AF7F59" d="M206.2 129.1h33.2L256 79.3l16.6 49.8h33.2v99.6L256 262l-49.8-33.2v-99.7zm33.2 33.3v49.8h33.2v-49.8h-33.2z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Moldova +373</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="white" d="M0 85.34h512v341.326H0z"></path><path fill="#D80027" d="M512 85.334v166.69L0 256.175V85.334z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Monaco +377</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="#0052B4" d="M0 85.331h512v341.326H0z"></path><g fill="#A2001D"><path d="M330.207 85.331H512v341.337H330.207zM0 85.331h181.793v341.337H0z"></path></g><g fill="#FFDA44"><path d="M113.163 267.125h14.84v59.359h-14.84zM53.793 267.125h14.84v59.359h-14.84z"></path><circle cx="90.902" cy="289.386" r="14.84"></circle><circle cx="90.902" cy="237.44" r="7.421"></circle><path d="M76.054 311.647h29.682v14.84H76.054zM76.054 252.288h29.682v14.84H76.054zM90.897 185.502l5.255 16.173h17.006l-13.757 9.996 5.252 16.173-13.756-9.996-13.756 9.996 5.251-16.173-13.756-9.996h17.005z"></path></g></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Mongolia +976</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="#FFDA44" d="M0 85.337h512v341.326H0z"></path><path fill="#A2001D" d="M0 115.011h512v281.978H0z"></path><g fill="#FFDA44"><path d="M218.899 211.478h74.202v-29.681l-14.84 7.42L256 166.957l-22.261 22.26-14.84-7.42zM322.783 256h-37.088a17 17 0 002.3-8.543c0-9.458-7.668-17.124-17.124-17.124-6.534 0-12.209 3.661-15.096 9.041-2.887-5.38-8.562-9.041-15.096-9.041-9.456 0-17.124 7.666-17.124 17.124 0 3.114.846 6.026 2.3 8.543h-36.636c0 11.349 9.885 20.549 21.232 20.549h-.685c0 9.31 6.192 17.168 14.68 19.694l-16.678 16.678 15.741 15.741 22.329-22.329c.875.321 1.78.577 2.714.752l-13.492 30.464c6.466 2.629 13.531 4.088 20.941 4.088s14.475-1.46 20.941-4.088l-13.492-30.464a17.108 17.108 0 002.714-.752l22.329 22.329 15.741-15.741-16.678-16.678c8.488-2.526 14.68-10.385 14.68-19.694h-.685c11.347 0 21.232-9.2 21.232-20.549z"></path></g><path fill="#6DA544" d="M256 267.13l-24.116 11.131v22.261L256 315.362l24.116-14.84v-22.261z"></path><path fill="#0052B4" d="M231.88 256h48.228v29.682H231.88z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Montenegro +382</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="#0052B4" d="M0 85.333h512V426.67H0z"></path><path fill="#338AF3" d="M334.222 191.996v78.221c0 38.103 49.777 49.779 49.777 49.779s49.778-11.675 49.778-49.779v-78.221h-99.555z"></path><path fill="#A2001D" d="M334.222 270.217c0 38.103 49.777 49.779 49.777 49.779s49.778-11.675 49.778-49.779h-99.555z"></path><path d="M405.334 227.552H391.11v-14.223h-14.222v14.223h-14.222v14.223h14.222v42.665h14.222v-42.665h14.224z"></path><path fill="white" d="M256 85.333v30.553l-45.167 25.099H256v59.359h-59.103L256 233.179v22.817h-26.68l-73.494-40.826v40.826h-55.652v-48.573l-87.43 48.573H0v-30.554l45.167-25.098H0v-59.359h59.103L0 108.139V85.333h26.68l73.494 40.825V85.333h55.652v48.572l87.43-48.572z"></path><path fill="#D80027" d="M144 85.33h-32v69.332H0v32h112v69.334h32v-69.334h112v-32H144z"></path><path fill="#0052B4" d="M155.826 200.344L256 255.996v-15.737l-71.847-39.915z"></path><path fill="white" d="M155.826 200.344L256 255.996v-15.737l-71.847-39.915z"></path><g fill="#D80027"><path d="M155.826 200.344L256 255.996v-15.737l-71.847-39.915zM71.846 200.344L0 240.259v15.737l100.174-55.652z"></path></g><path fill="#0052B4" d="M100.174 140.982L0 85.33v15.737l71.847 39.915z"></path><path fill="white" d="M100.174 140.982L0 85.33v15.737l71.847 39.915z"></path><g fill="#D80027"><path d="M100.174 140.982L0 85.33v15.737l71.847 39.915zM184.154 140.982L256 101.067V85.33l-100.174 55.652z"></path></g></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Montserrat +1664</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="#D80027" d="M0 85.337v341.326h512V85.337z"></path><path fill="#20661b" d="M352 226.484h-73.337L256 156.738l-22.663 69.748H160l59.331 43.107-22.663 69.749L256 296.232l59.332 43.107-22.663-69.749L352 226.484zm-116.063 37.711l7.663-23.585h24.8l7.663 23.585v.001L256 278.772l-20.063-14.577zm27.873-37.711h-15.619L256 202.447l7.81 24.037zm24.269 28.982l-4.827-14.856h25.274l-20.447 14.856zm-59.331-14.856l-4.827 14.856-20.447-14.856h25.274zm-5.211 61.748l7.81-24.036 12.636 9.181-20.446 14.855zm44.479-14.856l12.636-9.181 7.81 24.036-20.446-14.855z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Morocco +212</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="white" d="M0 85.337h512v341.326H0z"></path><path fill="#FFDA44" d="M0 322.783h512v103.88H0z"></path><path fill="#496E2D" d="M0 85.337h512v104.515H0z"></path><path d="M0 210.877h512v89.656H0z"></path><path fill="#A2001D" d="M256 256.006L0 426.668V85.331z"></path><path fill="#FFDA44" d="M83.477 195.132l15.107 46.498h48.894l-39.554 28.739 15.107 46.499-39.554-28.738-39.555 28.738 15.11-46.499-39.554-28.739H68.37z"></path><path fill="white" d="M39.268 256h88.42v40.578h-88.42z"></path><path d="M144.443 209.479l-14.347-14.347-46.618 46.618-46.617-46.618-14.347 14.347 46.658 46.577-46.658 46.658 14.347 14.154 46.617-46.534 46.618 46.534 14.347-14.154-46.659-46.658z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Mozambique +258</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="#6DA544" d="M0 85.337h512v341.326H0z"></path><path fill="#FFDA44" d="M0 85.337h512v113.775H0z"></path><path fill="#D80027" d="M0 312.888h512v113.775H0z"></path><path fill="white" d="M384 227.261h-97.783L256 134.265l-30.217 92.997H128l79.108 57.475-30.217 92.998L256 320.925l79.108 56.81-30.217-92.998L384 227.261z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Myanmar +95</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="#496E2D" d="M0 85.337h512v341.326H0z"></path><path fill="#0052B4" d="M0 426.663V85.337h512"></path><path fill="white" d="M512 152.222V85.337H411.67L0 359.778v66.885h100.33z"></path><path fill="#A2001D" d="M512 85.337v40.125L60.193 426.663H0v-40.125L451.807 85.337z"></path><path fill="#FFDA44" d="M187.737 189.212l-22.741 10.696 12.11 22.024-24.693-4.724-3.129 24.945-17.199-18.347-17.2 18.347-3.129-24.945-24.693 4.723 12.109-22.023-22.739-10.696 22.74-10.697-12.11-22.022 24.693 4.722 3.13-24.944 17.199 18.347 17.2-18.347 3.128 24.944 24.693-4.722-12.108 22.024z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Namibia +264</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="#0052B4" d="M0 85.337h512v341.326H0z"></path><path fill="#FFDA44" d="M0 239.994h512v32H0z"></path><path fill="white" d="M174.802 341.329l-19.124 8.996 10.184 18.521-20.767-3.973-2.631 20.978L128 370.422l-14.465 15.429-2.63-20.978-20.767 3.973 10.183-18.521-19.123-8.996 19.124-8.995-10.184-18.52 20.766 3.971 2.632-20.978L128 312.236l14.465-15.429 2.63 20.978 20.767-3.971-10.183 18.521z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Nauru +674</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="white" d="M0 85.337h512v341.326H0z"></path><path fill="#0052B4" d="M0 426.663V85.337l280.419 174.75H87.61l183.576 166.576z"></path><path fill="#D80027" d="M244.769 249.888L10.199 103.71v312.754h234.57L61.193 249.888z"></path><g fill="white"><path d="M98.003 324.433l-14.589-6.863 7.77-14.13-15.844 3.03-2.008-16.005-11.035 11.772-11.036-11.772-2.008 16.005-15.843-3.031 7.77 14.131-14.591 6.863 14.591 6.862-7.77 14.13 15.844-3.029 2.007 16.004 11.036-11.772L73.332 358.4l2.008-16.004 15.843 3.03-7.769-14.13zM88.268 191.662l-10.612-4.991 5.651-10.278-11.523 2.205-1.461-11.641-8.026 8.561-8.026-8.561-1.46 11.641-11.525-2.205 5.652 10.278-10.613 4.991 25.972 5.194z"></path><path d="M93.462 191.662c0 17.212-13.953 31.165-31.165 31.165s-31.165-13.953-31.165-31.165"></path></g></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Nepal +977</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="white" d="M0 85.337h512v341.326H0z"></path><path fill="#A2001D" d="M0 85.337h512v113.775H0z"></path><path fill="#0052B4" d="M0 312.888h512v113.775H0z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Netherlands +31</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 426.7"><path fill="#009543" d="M0 293h640v133.7H0V293z"></path><path fill="#ED4135" d="M0 132h640v161.3H0V132z"></path><path fill="#0035AD" d="M0 0h640v133.3H0V0z"></path><circle fill="#FAE600" stroke="black" stroke-width="5.3" cx="240" cy="213.3" r="157.3"></circle><path d="M307.9 354.5l-31.8 12-36.1 4.2-37.8-2.4-35.9-15.5s28.6-29.3 40.7-33.5c8.6-3 22.4-3.7 22.4-3.7V122l-.3-66H246l-.5 67.5v191.7s15.3 1.2 22.1 4.1c11.3 4.9 40.3 35.2 40.3 35.2z"></path><path d="M212.727 102.375l42.955-21.418 5.577 11.187-42.955 21.417z"></path><ellipse cx="237.8" cy="280.5" rx="16.8" ry="26.5"></ellipse><circle cx="237.4" cy="143.4" r="20.9"></circle><ellipse cx="238.4" cy="211.1" rx="19.9" ry="12.1"></ellipse><path d="M213.8 177h47v10h-47zM213.8 234h47v10h-47z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">New Caledonia +687</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="white" d="M0 85.337h512v341.326H0z"></path><g fill="#338AF3"><path d="M0 85.337h512v113.775H0zM0 312.888h512v113.775H0z"></path></g><path fill="#FFDA44" d="M256 214.447c-22.949 0-41.553 18.603-41.553 41.553S233.05 297.553 256 297.553c22.949 0 41.553-18.603 41.553-41.553S278.949 214.447 256 214.447zm0 65.298c-13.114 0-23.745-10.631-23.745-23.745s10.631-23.745 23.745-23.745 23.745 10.631 23.745 23.745-10.631 23.745-23.745 23.745z"></path><path fill="#0052B4" d="M276.563 261.936L256 256l-20.563 5.936-6.855 11.873h54.836z"></path><path fill="#338AF3" d="M256 226.32l-13.709 23.744L256 256l13.709-5.936z"></path><path fill="#6DA544" d="M235.437 261.936h41.126l-6.854-11.872h-27.418z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Nicaragua +505</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="white" d="M0 85.337h512v341.326H0z"></path><path fill="#FF9811" d="M0 85.337h512v113.775H0z"></path><path fill="#6DA544" d="M0 312.888h512v113.775H0z"></path><circle fill="#FF9811" cx="256" cy="256" r="32"></circle></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Niger +227</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="white" d="M0 85.331h512v341.337H0z"></path><g fill="#6DA544"><path d="M0 85.331h170.663v341.337H0zM341.337 85.331H512v341.337H341.337z"></path></g></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Nigeria +234</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="#FFDA44" d="M0 85.334h512v341.337H0z"></path><path fill="white" d="M0 85.334h256v170.663H0z"></path><g fill="#D80027"><path d="M144 85.33h-32v69.333H0v32h112v69.334h32v-69.334h112v-32H144z"></path><path d="M0 85.329v15.083l57.377 38.251H80z"></path></g><g fill="#2E52B2"><path d="M0 107.951v30.712h46.069zM96 85.331v48.913L22.628 85.331z"></path></g><path fill="#D80027" d="M256 85.329v15.083l-57.377 38.251H176z"></path><g fill="#2E52B2"><path d="M256 107.951v30.712h-46.069zM160 85.331v48.913l73.372-48.913z"></path></g><path fill="#D80027" d="M0 85.329v15.083l57.377 38.251H80z"></path><g fill="#2E52B2"><path d="M0 107.951v30.712h46.069zM96 85.331v48.913L22.628 85.331z"></path></g><path fill="#D80027" d="M256 85.329v15.083l-57.377 38.251H176z"></path><g fill="#2E52B2"><path d="M256 107.951v30.712h-46.069zM160 85.331v48.913l73.372-48.913z"></path></g><path fill="#D80027" d="M0 255.997v-15.082l57.377-38.252H80z"></path><g fill="#2E52B2"><path d="M0 233.376v-30.713h46.069zM96 255.994v-48.912l-73.372 48.912z"></path></g><path fill="#D80027" d="M256 255.997v-15.082l-57.377-38.252H176z"></path><g fill="#2E52B2"><path d="M256 233.376v-30.713h-46.069zM160 255.994v-48.912l73.372 48.912z"></path><circle cx="128" cy="170.66" r="22.627"></circle></g><g fill="#FFDA44"><path d="M128 154.663l3.97 12.222h12.854l-10.398 7.556 3.971 12.222L128 179.109l-10.398 7.554 3.972-12.222-10.398-7.556h12.853zM128 219.803l2.364 7.278h7.653l-6.19 4.498 2.364 7.278-6.191-4.498-6.191 4.498 2.364-7.278-6.19-4.498h7.652zM128 102.469l2.364 7.278h7.653l-6.19 4.498 2.364 7.278-6.191-4.498-6.191 4.498 2.364-7.278-6.19-4.498h7.652zM197.931 161.136l2.365 7.277h7.653l-6.192 4.499 2.365 7.279-6.191-4.498-6.191 4.498 2.365-7.279-6.191-4.499h7.652zM58.069 161.136l2.364 7.277h7.653l-6.191 4.499 2.364 7.279-6.19-4.498-6.191 4.498 2.365-7.279-6.192-4.499h7.653z"></path></g></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Niue +683</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="white" d="M0 85.331h512v341.337H0z"></path><g fill="#6DA544"><path d="M0 85.331h170.663v341.337H0zM341.337 85.331H512v341.337H341.337zM304 311.995l-48-152.001-48 152.001h36v39.999h24v-39.999z"></path></g></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Norfolk Island +672</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="#FFDA44" d="M0 85.333h512V426.67H0z"></path><g fill="#D80027"><path d="M383.875 426.662L256 252.286l26.827 174.376zM133.565 85.33L256 252.286 230.314 85.33zM229.171 426.662L256 252.286 128.124 426.662zM0 85.33V212.9l256 39.386L28.333 85.33zM0 426.662h18.212L256 252.286 0 291.67zM256 252.286L512 212.9V85.33h-28.331zM281.686 85.33L256 252.286 378.434 85.33zM512 426.662V291.671l-256-39.385 237.787 174.376z"></path><circle cx="256" cy="252.29" r="59.359"></circle></g><circle fill="#FFDA44" cx="256" cy="252.29" r="44.522"></circle></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">North Macedonia +389</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 750 500"><path fill="#0071BC" d="M0 0h750v500H0V0z"></path><g fill="white" stroke="black" stroke-width="1.9"><circle cx="375" cy="245" r="225" fill="white"></circle><circle cx="375" cy="245" r="165" fill="#0071BC"></circle></g><g stroke="black"><path fill="#8C8A8C" stroke-width="1.9" d="M444.7 450c.7 11-7.8 20-18.8 20H323.6c-11 0-19.5-9-19-20l16.7-325c.6-11 10-20 21-20h61.4c11 0 20.5 9 21.2 20l19.8 325z"></path><path fill="white" stroke-width="2" stroke-linejoin="round" d="M373 114l30 93h97l-78 56 29 92-78-56-78 57 30-93-79-57h97l30-92z"></path></g></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Northern Mariana Islands +1670</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="#D80027" d="M0 85.334h512v341.337H0z"></path><path fill="white" d="M512 295.883H202.195v130.783H122.435V295.883H0V216.111h122.435V85.329H202.195v130.782H512V277.329z"></path><path fill="#2E52B2" d="M512 234.666v42.663H183.652v149.337h-42.674V277.329H0v-42.663h140.978V85.329h42.674v149.337z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Norway +47</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><g fill="#D80027"><path d="M0 85.331h512v341.326H0z"></path><path d="M0 85.331h512v341.337H0z"></path></g><g fill="white"><path d="M189.746 160.439l-15.739-15.741-10.494 10.494-10.493-10.494-15.741 15.741 10.494 10.493-10.495 10.494 15.74 15.741 10.494-10.494 10.495 10.494 15.739-15.741-10.494-10.494zM211.478 85.331H512v111.315H211.478z"></path></g><path fill="#6DA544" d="M211.478 315.353H512v111.304H211.478z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Oman +968</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><g fill="white"><path d="M393.508 170.516l17.512 18.875 23.363-10.821-12.541 22.487 17.513 18.876-25.263-4.978-12.539 22.488-3.073-25.564-25.263-4.978 23.363-10.82z"></path><path d="M0 85.343h512v341.326H0z"></path></g><path fill="#496E2D" d="M128 85.331h384v341.337H128z"></path><g fill="white"><path d="M361.909 298.793c-31.037 22.426-74.378 15.446-96.804-15.592-22.427-31.038-15.446-74.379 15.593-96.804 9.677-6.992 20.55-11.125 31.613-12.563-21.283-3.183-43.777 1.613-62.598 15.211-38.2 27.602-46.792 80.944-19.191 119.145 27.601 38.199 80.944 46.792 119.145 19.189 18.82-13.598 30.436-33.448 34.096-54.655-4.839 10.05-12.176 19.076-21.854 26.069zM360.58 172.889l17.484 18.842 23.322-10.802-12.519 22.447 17.483 18.844-25.219-4.968-12.519 22.45-3.067-25.521-25.22-4.969 23.323-10.802z"></path></g></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Pakistan +92</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="#338AF3" d="M0 85.331h512v341.337H0z"></path><circle fill="#FFDA44" cx="218.902" cy="255.994" r="74.207"></circle></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Palau +680</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="white" d="M0 85.337h512v341.326H0z"></path><path d="M0 85.337h512v113.775H0z"></path><path fill="#6DA544" d="M0 312.888h512v113.775H0z"></path><path fill="#D80027" d="M256 256.006L0 426.668V85.331z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Palestine +970</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path d="M0 85.333h512V426.67H0z"></path><path fill="#A2001D" d="M0 85.33h512v341.332"></path><g fill="white"><path d="M204.631 326.488l2.762 8.504h8.941l-7.233 5.255 2.763 8.502-7.233-5.254-7.233 5.254 2.762-8.502-7.233-5.255h8.94zM181.797 244.866l4.605 14.172h14.901l-12.056 8.757 4.605 14.172-12.055-8.759-12.055 8.759 4.606-14.172-12.056-8.757h14.901zM181.797 348.749l4.604 14.173h14.902l-12.057 8.757 4.606 14.173-12.055-8.759-12.055 8.759 4.604-14.173-12.054-8.757h14.899zM225.363 281.967l4.606 14.172h14.901l-12.056 8.758 4.605 14.172-12.056-8.759-12.054 8.759 4.606-14.172-12.056-8.758h14.901zM138.23 281.967l4.606 14.172h14.899l-12.054 8.758 4.603 14.172-12.054-8.759-12.055 8.759 4.605-14.172-12.055-8.758h14.9z"></path></g><path fill="#FFDA44" d="M376.526 204.163c-7.628-7.628-17.538-12.133-28.189-12.908l31.88-24.795c-12.698-12.698-29.714-18.431-46.319-17.218a44.31 44.31 0 00-11.396-19.511l-12.593 25.186a18.47 18.47 0 00-3.148-4.197c-7.245-7.245-18.991-7.244-26.234 0s-7.245 18.99 0 26.234a18.536 18.536 0 004.197 3.148l-25.186 12.593a44.303 44.303 0 0019.519 11.399c-1.217 16.606 4.511 33.619 17.209 46.317L324.12 214.6a11.053 11.053 0 017.807-3.202c2.973 0 5.768 1.158 7.87 3.26a11.055 11.055 0 013.26 7.87c0 2.974-1.158 5.768-3.26 7.87l10.494 10.494c4.905-4.905 7.607-11.428 7.607-18.364 0-5.675-1.81-11.071-5.153-15.534a29.492 29.492 0 0113.288 7.662c11.573 11.572 11.573 30.403 0 41.975l10.494 10.494c8.409-8.409 13.039-19.59 13.039-31.481-.001-11.892-4.632-23.072-13.04-31.481z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Papua New Guinea +675</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="white" d="M0 85.337h512v341.326H0z"></path><path fill="#D80027" d="M0 85.337h512v113.775H0z"></path><path fill="#0052B4" d="M0 312.888h512v113.775H0z"></path><path fill="#6DA544" d="M289.579 216.738l-12.592 12.592c5.37 5.372 8.693 12.792 8.693 20.988 0 16.392-13.289 29.68-29.68 29.68-16.392 0-29.68-13.289-29.68-29.68 0-8.195 3.322-15.616 8.693-20.988l-12.592-12.592c-8.594 8.594-13.91 20.466-13.91 33.579 0 26.228 21.261 47.489 47.489 47.489s47.489-21.261 47.489-47.489c0-13.112-5.316-24.985-13.91-33.579z"></path><path fill="#FFDA44" d="M256 232.51l4.421 13.605h14.304l-11.573 8.408 4.421 13.604L256 259.719l-11.573 8.408 4.421-13.604-11.573-8.408h14.304z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Paraguay +595</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="white" d="M0 85.331h512v341.326H0z"></path><g fill="#D80027"><path d="M0 85.331h170.663v341.337H0zM341.337 85.331H512v341.337H341.337z"></path></g></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Peru +51</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="white" d="M0 85.337h512v341.326H0z"></path><path fill="#0052B4" d="M512 85.337V256H256L0 85.337z"></path><path fill="#D80027" d="M512 256v170.663H0L256 256z"></path><g fill="#FFDA44"><path d="M161.908 256l-27.288-12.835 14.532-26.428-29.632 5.668-3.755-29.933-20.64 22.015-20.639-22.015-3.755 29.933-29.631-5.669 14.531 26.428L28.343 256l27.288 12.835L41.1 295.263l29.633-5.668 3.753 29.933 20.639-22.015 20.64 22.015 3.755-29.933 29.631 5.669-14.532-26.427zM21.789 117.607l9.081 12.696 14.879-4.714-9.268 12.56 9.081 12.694-14.809-4.932-9.268 12.559.117-15.608-14.809-4.934 14.88-4.712zM21.789 353.53l9.081 12.696 14.879-4.714-9.268 12.56 9.081 12.695-14.809-4.933-9.268 12.558.117-15.607-14.809-4.934 14.88-4.712zM210.395 235.569l-9.081 12.695-14.879-4.713 9.268 12.559-9.081 12.696 14.809-4.933 9.268 12.558-.117-15.607 14.809-4.934-14.88-4.713z"></path></g></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Philippines +63</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="#0052B4" d="M0 85.333h512V426.67H0z"></path><path fill="#ACABB1" d="M400.696 219.822L384 225.387l-16.696-5.565-5.565-13.913 5.565-13.913h33.392l-5.566 13.913z"></path><path fill="#338AF3" d="M345.043 219.822v61.217c0 29.821 38.957 38.957 38.957 38.957s38.957-9.137 38.957-38.957v-61.217h-77.914z"></path><path fill="#6DA544" d="M348.555 295.541C358.131 313.927 384 319.996 384 319.996s25.869-6.069 35.445-24.455L384 236.518l-35.445 59.023z"></path><path fill="#FFDA44" d="M422.957 280.421L384 219.822l-38.957 60.599v.618c0 5.518 1.337 10.328 3.512 14.503L384 240.405l35.445 55.137c2.175-4.175 3.512-8.983 3.512-14.503v-.618z"></path><path fill="white" d="M256 85.333v30.553l-45.167 25.099H256v59.359h-59.103L256 233.179v22.817h-26.68l-73.494-40.826v40.826h-55.652v-48.573l-87.43 48.573H0v-30.554l45.167-25.098H0v-59.359h59.103L0 108.139V85.333h26.68l73.494 40.825V85.333h55.652v48.572l87.43-48.572z"></path><path fill="#D80027" d="M144 85.33h-32v69.332H0v32h112v69.334h32v-69.334h112v-32H144z"></path><path fill="#0052B4" d="M155.826 200.344L256 255.996v-15.737l-71.847-39.915z"></path><path fill="white" d="M155.826 200.344L256 255.996v-15.737l-71.847-39.915z"></path><g fill="#D80027"><path d="M155.826 200.344L256 255.996v-15.737l-71.847-39.915zM71.846 200.344L0 240.259v15.737l100.174-55.652z"></path></g><path fill="#0052B4" d="M100.174 140.982L0 85.33v15.737l71.847 39.915z"></path><path fill="white" d="M100.174 140.982L0 85.33v15.737l71.847 39.915z"></path><g fill="#D80027"><path d="M100.174 140.982L0 85.33v15.737l71.847 39.915zM184.154 140.982L256 101.067V85.33l-100.174 55.652z"></path></g></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Pitcairn +872</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><g fill="white"><path d="M0 85.337h512v341.326H0z"></path><path d="M0 85.337h512V256H0z"></path></g><path fill="#D80027" d="M0 256h512v170.663H0z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Poland +48</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="#D80027" d="M0 85.337h512v341.326H0z"></path><path fill="#6DA544" d="M196.641 85.337v341.326H0V85.337z"></path><circle fill="#FFDA44" cx="196.641" cy="256" r="64"></circle><path fill="#D80027" d="M160.638 224v40.001c0 19.882 16.118 36 36 36s36-16.118 36-36V224h-72z"></path><path fill="white" d="M196.638 276c-6.617 0-12-5.383-12-12v-16h24.001v16c-.001 6.616-5.385 12-12.001 12z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Portugal +351</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="white" d="M0 85.337h512v341.326H0z"></path><g fill="#D80027"><path d="M0 85.337h512V153.6H0zM0 221.863h512v68.263H0zM0 358.4h512v68.263H0z"></path></g><path fill="#0052B4" d="M256 256.006L0 426.668V85.331z"></path><path fill="white" d="M83.477 195.132l15.107 46.498h48.894l-39.554 28.739 15.107 46.499-39.554-28.738-39.555 28.738 15.11-46.499-39.554-28.739H68.37z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Puerto Rico +1939</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="#751A46" d="M2.216 86.076H512v339.848H2.216z"></path><path fill="white" d="M209.455 154.969l-50.236 25.267 50.236 25.257-50.236 25.267 50.236 25.257-50.236 25.266 50.236 25.257-50.236 25.268 50.236 25.257-50.236 25.267 50.236 25.268-36.45 18.33H0V86.07h172.939l36.516 18.364-50.236 25.267z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Qatar +974</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 26.666 640 426.666"><g fill-rule="evenodd" stroke-width="1pt"><path fill="white" d="M0 0h640v480H0z"></path><path fill="#00267f" d="M0 0h213.3v480H0z"></path><path fill="#f31830" d="M426.7 0H640v480H426.7z"></path></g></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Reunion +262</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="#FFDA44" d="M0 85.331h512v341.326H0z"></path><path fill="#0052B4" d="M0 85.331h170.663v341.337H0z"></path><path fill="#D80027" d="M341.337 85.331H512v341.337H341.337z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Romania +40</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="white" d="M0 85.33v341.332h512V85.33z"></path><path fill="#0052B4" d="M0 85.333h512V426.67H0z"></path><path fill="white" d="M0 85.333h512v113.775H0z"></path><path fill="#D80027" d="M0 312.884h512v113.775H0z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Russia +7</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="#338AF3" d="M0 85.331h512v341.337H0z"></path><path fill="#FFDA44" d="M0 255.994h512v81.619H0z"></path><path fill="#496E2D" d="M0 337.614h512v89.043H0z"></path><path fill="#FFDA44" d="M278.261 185.209l20.844 9.804-11.099 20.186 22.632-4.33 2.868 22.865 15.765-16.816 15.766 16.816 2.867-22.865 22.633 4.33-11.099-20.186 20.843-9.804-20.844-9.805 11.1-20.185-22.633 4.329-2.868-22.864-15.765 16.816-15.766-16.816-2.867 22.864-22.634-4.329 11.1 20.187z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Rwanda +250</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 341.33"><path fill="white" d="M0 0h512v341.33H0z"></path><path fill="#E6BC00" d="M157.31 199.76s-9.04 43.93-19.31 40.39c-10.62-3.54-17.53-18.76-17.53-18.76l-14.52 21.24s38.18 8.48 41.01 5.47c1.22-1.14 8.21-15.1 10.34-26.05v-22.29zm-56.13 60.57s-2.48 20.18-1.06 22.66c1.24 2.3 39.48 11.33 39.48 11.33s-24.96 16.46-29.74 20.54L91.8 284.94l-.71-24.61h10.09zM112.51 94.64s39.65 41.6 40.36 45.5c.71 3.72-4.25 3.19-4.25 3.19s-44.79-37.53-49.92-41.07c-5.31-3.55 13.81-7.62 13.81-7.62z"></path><path fill="#ADADAD" d="M99.41 104.73s16.99-.71 16.64-11.51c-.35-10.62-11.15-14.87-19.12-12.39-7.97 2.3-23.01 13.45-13.63 35.05 9.38 21.42 23.37 29.39 26.2 47.8 0 0-5.46 9.86-19.12.35-16.9-11.77-6.2-38.24-10.44-44.96-4.25-7.08-40.95-38.92-40.95-38.92s-30.24 39.37-18 74.92c16.95 49.21 51.74 31.98 64.61 36.76 0 0-42.13 61.96-49.57 67.09 0 0 24.08 8.32 47.8-18.76 0 0 5.84 9.74 7.08 20.18h10.27c4.78-26.2 51.51-64.26 49.92-82.32-1.77-21.25-49.21-49.39-51.69-73.29z"></path><path fill="#E6BC00" d="M359.17 201.27s8.96 42.43 19.23 38.89c10.62-3.54 17.53-18.76 17.53-18.76l14.52 21.24s-37 8.48-39.83 5.47c-1.21-1.14-9.32-13.79-11.52-24.66l.07-22.18zm56.05 59.06s2.48 20.18 1.06 22.66c-1.24 2.3-39.48 11.33-39.48 11.33s24.96 16.46 29.74 20.54l18.06-29.92.71-24.61h-10.09zM403.89 94.64s-39.65 41.6-40.36 45.5c-.71 3.72 4.25 3.19 4.25 3.19s44.79-37.53 49.92-41.07c5.14-3.55-13.81-7.62-13.81-7.62z"></path><path fill="#125ECC" d="M157.31 87.06H359.1v145.46c0 16.06-9.69 21.39-21.91 31.85l-45.92 39.41c-18.25 15.62-47.91 15.57-66.07 0l-46.01-39.43c-12.08-10.35-21.88-15.71-21.88-31.82V87.06z"></path><path fill="#FFE600" d="M200.55 147.71c-7.96 0-14.41-6.45-14.41-14.41s6.45-14.41 14.41-14.41 14.41 6.45 14.41 14.41-6.45 14.41-14.41 14.41zm57.65-3c-7.96 0-14.41-6.45-14.41-14.41s6.45-14.41 14.41-14.41 14.41 6.45 14.41 14.41-6.45 14.41-14.41 14.41zm57.65 3c-7.96 0-14.41-6.45-14.41-14.41s6.45-14.41 14.41-14.41 14.41 6.45 14.41 14.41-6.45 14.41-14.41 14.41zM214.96 274.43c-7.96 0-14.41-6.45-14.41-14.41s6.45-14.41 14.41-14.41 14.41 6.45 14.41 14.41c.01 7.96-6.45 14.41-14.41 14.41zm43.24 14.42c-7.96 0-14.41-6.45-14.41-14.41s6.45-14.41 14.41-14.41 14.41 6.45 14.41 14.41c0 7.95-6.45 14.41-14.41 14.41zm43.24-14.42c-7.96 0-14.41-6.45-14.41-14.41s6.45-14.41 14.41-14.41 14.41 6.45 14.41 14.41-6.45 14.41-14.41 14.41z"></path><path fill="#D60537" d="M157.31 175.36H359.1v57.65H157.31v-57.65z"></path><path fill="#EACE00" d="M142.9 43.82s57.65-14.41 115.31-14.41 115.31 14.41 115.31 14.41l-14.41 57.65s-50.45-14.41-100.89-14.41-100.89 14.41-100.89 14.41L142.9 43.82z"></path><path fill="#7A6920" d="M258.2 72.65c-7.96 0-14.41-6.45-14.41-14.41s6.45-14.41 14.41-14.41 14.41 6.45 14.41 14.41-6.45 14.41-14.41 14.41zm57.65 5c-7.96 0-14.41-6.45-14.41-14.41s6.45-14.41 14.41-14.41 14.41 6.45 14.41 14.41-6.45 14.41-14.41 14.41zm-115.3 0c-7.96 0-14.41-6.45-14.41-14.41s6.45-14.41 14.41-14.41 14.41 6.45 14.41 14.41-6.45 14.41-14.41 14.41z"></path><path fill="#ADADAD" d="M365.08 178.02c-1.59 18.06 45.14 56.12 49.92 82.32h10.27c1.24-10.44 7.08-20.18 7.08-20.18 23.72 27.09 47.8 18.76 47.8 18.76-7.44-5.13-49.57-67.09-49.57-67.09 12.88-4.78 47.67 12.45 64.61-36.76 12.24-35.55-18-74.92-18-74.92s-36.7 31.84-40.95 38.92c-4.25 6.73 6.46 33.2-10.44 44.96-13.66 9.51-19.12-.35-19.12-.35 2.83-18.41 16.82-26.38 26.2-47.8 9.38-21.6-5.66-32.75-13.63-35.05-7.97-2.48-18.76 1.77-19.12 12.39-.35 10.8 16.64 11.51 16.64 11.51-2.48 23.9-49.92 52.04-51.69 73.29z"></path><circle fill="white" cx="258.2" cy="204.19" r="16.93"></circle></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Saint Barthelemy +590</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 341.3"><path fill="#0052B4" d="M0 0h512v341.3H0z"></path><path fill="white" d="M256 0v117.4h-46.1l46.1 30.7v22.6h-22.6L160 121.8v48.9H96v-48.9l-73.4 48.9H0v-22.6l46.1-30.7H0v-64h46.1L0 22.7V0h22.6L96 48.9V0h64v48.9L233.4 0z"></path><g fill="#D80027"><path d="M144 0h-32v69.4H0v32h112v69.3h32v-69.3h112v-32H144z"></path><path d="M0 0v15.1l57.4 38.3H80zM256 0v15.1l-57.4 38.3H176z"></path></g><path fill="#2E52B2" d="M256 22.7v30.7h-46.1z"></path><g fill="#D80027"><path d="M0 0v15.1l57.4 38.3H80zM256 0v15.1l-57.4 38.3H176z"></path></g><path fill="#2E52B2" d="M256 22.7v30.7h-46.1z"></path><g fill="#D80027"><path d="M0 170.7v-15.1l57.4-38.2H80zM256 170.7v-15.1l-57.4-38.2H176z"></path></g><path fill="#29DBFF" d="M449 139.7c-.1 44.4-7.2 92.1-65 114.9-57.8-22.8-64.9-70.5-65-114.9h130z"></path><path fill="#ffda44" d="M449 139.7c0-16.7-.9-32.9-.5-47.1C426.9 83 398.4 81 383.9 81s-42.9 2-64.6 11.6c.4 14.2-.5 30.4-.5 47.1H449z"></path><path fill="#BF521B" d="M369.5 204.5l.3 10.3-12.8.2 4.9 13.2h-17.3c-18-20.2-23.4-42.4-24.9-68.1l9.1-9.7 8.3 14.3 10.8-12.8 7 7.8.8 15.7 13.8 29.1z"></path><path fill="#474747" d="M436.6 192.5l-8.6 18.3h-47l-29.2-19.5 25.7 10.5h25.1l3.7-6.5 7.2.2 2-3z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Saint Helena, Ascension and Tristan Da Cunha +290</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 513 342"><path fill="#D80027" d="M0 0h513v342H0z"></path><path fill="#6DA544" d="M512 0H0v342"></path><path fill="#FFDA44" d="M307.7 0L0 194.5V342h206.9L513 148.5V0z"></path><path d="M513 0H385.2L0 249.4V341l126.2 1L513 91.6z"></path><g fill="white"><path d="M141.1 187l31.2 24 32.3-22.2-13.1 37 31.1 23.9-39.2-1.1-13.2 37-11.1-37.6-39.2-1.1 32.3-22.2zM310.6 70.8l31.2 23.9 32.3-22.2-13.1 37 31.1 23.9-39.2-1.1-13.2 37-11.1-37.6-39.2-1.1 32.4-22.2z"></path></g></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Saint Kitts and Nevis +1869</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 513 342"><path fill="#55B2FF" d="M0 0h513v342H0z"></path><path fill="#F3F3F3" d="M148.5 298.1h216l-108-254.2z"></path><path fill="#333" d="M186 272.7l70.5-160.3L327 272.7z"></path><path fill="#FFDA44" d="M148.5 298.1h216l-108-101.7z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Saint Lucia +1758</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 108 72"><path d="M0 0h108v72H0z" fill="#003787"></path><path d="M0 0h108L60 48v24H48V48z" fill="white"></path><circle cx="54" cy="30" r="8" fill="#f9d90f"></circle><path d="M44 30h20L54 48z" fill="white"></path><path d="M54 48L38 33h32z" fill="#cf142b"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Saint Martin +590</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 26.666 640 426.666"><g fill-rule="evenodd" stroke-width="1pt"><path fill="white" d="M0 0h640v480H0z"></path><path fill="#00267f" d="M0 0h213.3v480H0z"></path><path fill="#f31830" d="M426.7 0H640v480H426.7z"></path></g></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Saint Pierre and Miquelon +508</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="#FFDA44" d="M0 85.331h512v341.337H0z"></path><path fill="#338AF3" d="M0 85.331h170.663v341.337H0z"></path><g fill="#6DA544"><path d="M341.337 85.331H512v341.337H341.337zM214.261 283.82l-33.393-50.086 33.392-50.087 33.392 50.087zM297.739 283.82l-33.391-50.086 33.391-50.087 33.393 50.087zM256 350.603l-33.391-50.087L256 250.429l33.391 50.087z"></path></g></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Saint Vincent and the Grenadines +1784</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="#D80027" d="M0 85.331h512v341.337H0z"></path><path fill="#0052B4" d="M0 85.331h256v170.663H0z"></path><g fill="white"><path d="M165.483 181.79l2.764 8.504h8.939l-7.232 5.254 2.763 8.503-7.234-5.255-7.233 5.255 2.763-8.503-7.233-5.254h8.94zM120.579 115.007l4.606 14.173h14.9l-12.055 8.757 4.605 14.171-12.056-8.758-12.054 8.758 4.605-14.171-12.056-8.757h14.901zM165.101 129.848l4.606 14.172h14.9l-12.055 8.757 4.604 14.173-12.055-8.76-12.054 8.76 4.604-14.173-12.055-8.757h14.9zM129.909 189.211l4.606 14.172h14.9l-12.055 8.758 4.604 14.171-12.055-8.759-12.054 8.759 4.604-14.171-12.055-8.758h14.9zM90.899 152.108l4.605 14.173h14.9l-12.055 8.757 4.604 14.173-12.054-8.76-12.055 8.76 4.604-14.173-12.055-8.757h14.9z"></path></g></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Samoa +685</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="#338AF3" d="M0 85.34h512v341.326H0z"></path><path fill="white" d="M512 85.334v166.69L0 256.175V85.334z"></path><path fill="#6DA544" d="M323.744 203.099L256 270.843l-67.744-67.744a81.156 81.156 0 00-13.879 45.483v22.261c0 35.744 23.097 66.193 55.148 77.213-4.277 8.385-3.556 18.848 2.712 26.671l24.258-19.439 24.258 19.439c6.342-7.915 7.011-18.534 2.564-26.968 31.614-11.261 54.308-41.485 54.308-76.916v-22.261a81.174 81.174 0 00-13.881-45.483z"></path><path fill="#FFDA44" d="M256 330.206c-32.732 0-59.362-26.63-59.362-59.362v-22.261c0-32.733 26.63-59.363 59.362-59.363s59.362 26.63 59.362 59.362v22.261c0 32.733-26.63 59.363-59.362 59.363z"></path><path fill="#338AF3" d="M293.101 270.843v-22.261c0-20.458-16.643-37.101-37.101-37.101s-37.101 16.643-37.101 37.101v22.261L256 278.264l37.101-7.421z"></path><path fill="#6DA544" d="M218.899 270.843c0 20.458 16.643 37.101 37.101 37.101s37.101-16.643 37.101-37.101h-74.202z"></path><path fill="#FFDA44" d="M300.522 189.22c0-12.295-9.966-22.261-22.261-22.261a22.173 22.173 0 00-14.84 5.672v-13.093h7.421v-14.84h-7.421v-7.421h-14.84v7.421h-7.421v14.84h7.421v13.093a22.177 22.177 0 00-14.841-5.672c-12.295 0-22.261 9.966-22.261 22.261 0 6.591 2.867 12.512 7.421 16.589v13.093h74.203v-13.093c4.552-4.077 7.419-9.997 7.419-16.589z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">San Marino +378</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="#FFDA44" d="M0 85.337h512v341.326H0z"></path><g fill="#6DA544"><path d="M0 85.337h512v113.775H0zM0 312.888h512v113.775H0z"></path></g><path fill="#D80027" d="M256 256.006L0 426.668V85.331z"></path><path d="M302.049 226.318l7.368 22.674h23.842l-19.288 14.016 7.366 22.674-19.288-14.015-19.287 14.015 7.366-22.674-19.288-14.016h23.842zM376.252 226.318l7.367 22.674h23.842l-19.288 14.016 7.367 22.674-19.288-14.015-19.288 14.015 7.367-22.674-19.288-14.016h23.842z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Sao Tome and Principe +239</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="#6DA544" d="M0 85.331h512v341.337H0z"></path><g fill="white"><path d="M183.548 289.386c0 12.295 9.731 22.261 21.736 22.261h65.208c0 10.244 8.11 18.551 18.114 18.551h21.736c10.004 0 18.114-8.306 18.114-18.551v-22.261H183.548zM330.264 181.791v51.942c0 8.183-6.5 14.84-14.491 14.84v22.261c19.976 0 36.226-16.643 36.226-37.101v-51.942h-21.735zM174.491 233.734c0 8.183-6.5 14.84-14.491 14.84v22.261c19.976 0 36.226-16.643 36.226-37.101v-51.942H174.49v51.942z"></path><path d="M297.661 181.788h21.736v51.942h-21.736zM265.057 211.473c0 2.046-1.625 3.71-3.623 3.71-1.998 0-3.623-1.664-3.623-3.71v-29.682h-21.736v29.682c0 2.046-1.625 3.71-3.623 3.71s-3.623-1.664-3.623-3.71v-29.682h-21.736v29.682c0 14.32 11.376 25.971 25.358 25.971 5.385 0 10.38-1.733 14.491-4.677 4.11 2.944 9.106 4.677 14.491 4.677 1.084 0 2.15-.078 3.2-.215-1.54 6.499-7.255 11.345-14.068 11.345v22.261c19.976 0 36.226-16.643 36.226-37.101v-51.943h-21.736l.002 29.682z"></path><path d="M207.093 248.57h32.601v22.261h-32.601z"></path></g></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Saudi Arabia +966</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="#FFDA44" d="M0 85.331h512v341.326H0z"></path><path fill="#D80027" d="M330.207 85.331H512v341.337H330.207z"></path><g fill="#496E2D"><path d="M0 85.331h181.793v341.337H0zM255.999 196.632l14.733 45.347h47.685l-38.576 28.029 14.734 45.348-38.576-28.026-38.577 28.026 14.737-45.348-38.576-28.029h47.681z"></path></g></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Senegal +221</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="#0052B4" d="M0 85.331h512v341.337H0z"></path><path fill="#D80027" d="M0 85.331h512v113.775H0z"></path><path fill="white" d="M0 312.882h512v113.775H0z"></path><path fill="#D80027" d="M129.468 181.793v85.136c0 48.429 63.267 63.267 63.267 63.267S256 315.356 256 266.929v-85.136H129.468z"></path><g fill="#FFDA44"><path d="M155.634 196.634h74.201v-29.681l-14.841 7.42-22.261-22.26-22.259 22.26-14.84-7.42zM241.16 278.782l-48.231-48.231-48.231 48.231 15.741 15.74 32.49-32.49 32.49 32.49z"></path></g><path fill="white" d="M241.16 233.734h-22.504a14.74 14.74 0 002.001-7.418c0-8.196-6.645-14.84-14.84-14.84-5.663 0-10.581 3.172-13.083 7.836-2.502-4.663-7.421-7.836-13.083-7.836-8.195 0-14.84 6.644-14.84 14.84 0 2.706.736 5.235 2.001 7.418h-22.114c0 8.196 7.139 14.84 15.334 14.84h-.494c0 8.196 6.644 14.84 14.84 14.84 0 7.257 5.211 13.286 12.094 14.576l-11.694 26.401a48.075 48.075 0 0018.149 3.544 48.079 48.079 0 0018.149-3.544l-11.694-26.401c6.883-1.29 12.094-7.319 12.094-14.576 8.196 0 14.84-6.644 14.84-14.84h-.494c8.199 0 15.338-6.644 15.338-14.84z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Serbia +381</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="white" d="M0 85.337h512v341.326H0z"></path><path fill="#FFDA44" d="M235.454 85.337L0 426.663 427.345 85.337z"></path><path fill="#6DA544" d="M512 329.393L0 426.663h512z"></path><path fill="#D80027" d="M512 85.337h-84.655L0 426.663l512-204.512z"></path><path fill="#0052B4" d="M0 85.337v341.326L235.454 85.337z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Seychelles +248</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="white" d="M0 85.337h512v341.326H0z"></path><path fill="#6DA544" d="M0 85.337h512v113.775H0z"></path><path fill="#338AF3" d="M0 312.888h512v113.775H0z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Sierra Leone +232</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="#0052B4" d="M0 85.337h512v341.326H0z"></path><path fill="#D80027" d="M512 85.331v166.69L0 256.173V85.331z"></path><path fill="white" d="M256 256.006L0 426.668V85.331z"></path><g fill="#FFDA44"><path d="M59.621 256a59.546 59.546 0 00-.193 4.57c0 32.821 26.607 59.429 59.429 59.429s59.429-26.607 59.429-59.429c0-1.539-.078-3.061-.193-4.57H59.621z"></path><circle cx="118.862" cy="210.287" r="18.286"></circle></g><path fill="#D80027" d="M77.715 205.714v59.429c0 31.494 41.144 41.143 41.144 41.143s41.144-9.649 41.144-41.143v-59.429H77.715z"></path><path fill="#338AF3" d="M118.877 287.148c-7.632-2.746-22.876-9.767-22.876-22.006v-41.144h45.715v41.144c-.001 12.28-15.244 19.283-22.839 22.006z"></path><path fill="#F3F3F3" d="M128.001 246.856v-9.142l-9.144-4.571-9.142 4.571v9.142l-4.571 4.573v18.285h27.428v-18.285z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Sint Maarten +1721</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="white" d="M0 85.337h512v341.326H0z"></path><path fill="#0052B4" d="M0 196.641h512v118.717H0z"></path><path fill="#D80027" d="M0 315.359h512v111.304H0z"></path><path fill="white" d="M129.468 181.799v85.136c0 48.429 63.267 63.267 63.267 63.267S256 315.362 256 266.935v-85.136H129.468z"></path><path fill="#D80027" d="M146.126 184.294v81.941c0 5.472 1.215 10.64 3.623 15.485h85.97c2.408-4.844 3.623-10.012 3.623-15.485v-81.941h-93.216z"></path><path fill="white" d="M221.301 241.427h-21.425v-14.283h14.284v-14.283h-14.284v-14.284h-14.283v14.284h-14.282v14.283h14.282v14.283h-21.426v14.284h21.426v14.283h14.283v-14.283h21.425z"></path><path fill="#0052B4" d="M169.232 301.658c9.204 5.783 18.66 9.143 23.502 10.636 4.842-1.494 14.298-4.852 23.502-10.636 9.282-5.833 15.79-12.506 19.484-19.939a24.878 24.878 0 00-14.418-4.583c-1.956 0-3.856.232-5.682.657-3.871-8.796-12.658-14.94-22.884-14.94-10.227 0-19.013 6.144-22.884 14.94a25.048 25.048 0 00-5.682-.657 24.88 24.88 0 00-14.418 4.583c3.691 7.433 10.198 14.106 19.48 19.939z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Slovakia +421</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="white" d="M0 85.337h512v341.326H0z"></path><path fill="#0052B4" d="M0 199.112h512v113.775H0z"></path><path fill="#D80027" d="M0 312.888h512v113.775H0z"></path><path fill="white" d="M233.606 196.639v14.837c0 34.081-44.522 44.522-44.522 44.522s-44.522-10.44-44.522-44.522v-14.837l-.145-44.188 89.043-.266.146 44.454z"></path><path fill="#0052B4" d="M233.606 196.639v14.837c0 34.081-44.522 44.522-44.522 44.522s-44.522-10.44-44.522-44.522v-14.837l-.145-44.188 89.043-.266.146 44.454z"></path><path fill="white" d="M233.606 196.639v14.837c0 34.081-44.522 44.522-44.522 44.522s-44.522-10.44-44.522-44.522v-14.837l14.848 14.837 29.674-22.261 29.685 22.261 14.837-14.837z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Slovenia +386</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="#496E2D" d="M0 85.334h512v341.337H0z"></path><path fill="#0052B4" d="M0 426.663V85.329h512"></path><path fill="#FFDA44" d="M0 396.494v30.169h45.255L512 115.499v-30.17h-45.255z"></path><g fill="white"><path d="M85.688 108.787l5.12 15.756h16.566l-13.403 9.737 5.12 15.757-13.403-9.738-13.405 9.738 5.12-15.757L64 124.543h16.567zM170.312 108.787l5.121 15.756H192l-13.403 9.737 5.12 15.757-13.405-9.738-13.403 9.738 5.12-15.757-13.403-9.737h16.566zM85.688 191.289l5.12 15.756h16.566l-13.403 9.738 5.12 15.757-13.403-9.739-13.405 9.739 5.12-15.757L64 207.045h16.567zM170.312 191.289l5.121 15.756H192l-13.403 9.738 5.12 15.757-13.405-9.739-13.403 9.739 5.12-15.757-13.403-9.738h16.566zM128 150.037l5.12 15.756h16.568l-13.405 9.738 5.12 15.758L128 181.55l-13.403 9.739 5.12-15.758-13.405-9.738h16.568z"></path></g></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Solomon Islands +677</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="#338AF3" d="M0 85.331h512v341.337H0z"></path><path fill="white" d="M256 157.273l22.663 69.748H352l-59.332 43.106 22.664 69.749L256 296.769l-59.332 43.107 22.664-69.749L160 227.021h73.337z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Somalia +252</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="white" d="M0 85.337h512v341.326H0z"></path><path d="M114.024 256.001L0 141.926v228.17z"></path><path fill="#FFDA44" d="M161.192 256L0 94.7v47.226l114.024 114.075L0 370.096v47.138z"></path><path fill="#6DA544" d="M509.833 289.391c.058-.44.804-.878 2.167-1.318v-65.464H222.602L85.33 85.337H0V94.7L161.192 256 0 417.234v9.429h85.33l137.272-137.272h287.231z"></path><path fill="#0052B4" d="M503.181 322.783H236.433l-103.881 103.88H512v-103.88z"></path><path fill="#D80027" d="M503.181 189.217H512V85.337H132.552l103.881 103.88z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">South Africa +27</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 341.3"><path fill="#0052B4" d="M0 0h512v341.3H0z"></path><path fill="white" d="M256 0v117.4h-46.1l46.1 30.7v22.6h-22.6L160 121.8v48.9H96v-48.9l-73.4 48.9H0v-22.6l46.1-30.7H0v-64h46.1L0 22.7V0h22.6L96 48.9V0h64v48.9L233.4 0z"></path><path fill="#D80027" d="M144 0h-32v69.4H0v32h112v69.3h32v-69.3h112v-32H144z"></path><path fill="#2E52B2" d="M256 22.7v30.7h-46.1z"></path><path fill="#D80027" d="M0 170.7v-11l62.5-42.3h22.6L7.3 170.7zM7.3.1l77.8 53.2H62.5L0 11.1V.1zM256 .1v11l-62.5 42.3h-22.6L248.7.1zM248.7 170.7l-77.8-53.3h22.6l62.5 42.3v11z"></path><g><ellipse fill="white" cx="443.4" cy="233.6" rx="29" ry="43.5"></ellipse><ellipse fill="#FFCE00" cx="406.9" cy="317.7" rx="22" ry="9.3"></ellipse><ellipse fill="#FFCE00" cx="364" cy="317.7" rx="22" ry="9.3"></ellipse><path fill="#39B200" d="M342 190.1l43.4 86.9 43.5-86.9z"></path><ellipse fill="#9B9B9B" cx="327.5" cy="233.6" rx="29" ry="43.5"></ellipse><path fill="#757575" d="M371 175.6l-14.5 14.5h57.9l-14.5-14.5 14.5-43.5s-13-29-29-29-29 29-29 29l14.6 43.5z"></path><circle fill="#C6B56F" cx="385.4" cy="67" r="29"></circle><circle fill="#A54A00" cx="386" cy="88.7" r="29"></circle><circle fill="white" cx="443.4" cy="117.7" r="29"></circle><circle fill="#0049FF" cx="342.2" cy="146.7" r="29"></circle><circle fill="#0041F9" cx="429.8" cy="146.7" r="29"></circle><circle fill="#F7D71E" cx="386" cy="233.6" r="29"></circle><circle fill="#CEC851" cx="457.9" cy="190.1" r="29"></circle><circle fill="white" cx="385.4" cy="289.5" r="29"></circle><path fill="#7C0B29" d="M371 135.7l14.5-3.5 14.5 3.5c0 7.5-14.5 11-14.5 11s-14.5-3.5-14.5-11z"></path><circle fill="white" cx="327.5" cy="117.4" r="29"></circle></g></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">South Georgia and the South Sandwich Islands +500</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="white" d="M0 85.337h512v341.326H0z"></path><path fill="#496E2D" d="M0 322.783h512v103.88H0z"></path><path d="M0 85.337h512v104.515H0z"></path><path fill="#A2001D" d="M0 210.877h512v89.656H0z"></path><path fill="#0052B4" d="M256 256.006L0 426.668V85.331z"></path><path fill="#FFDA44" d="M73.178 209.188l20.831 29.067 34.084-10.83-21.207 28.795 20.83 29.069-33.939-11.271-21.208 28.794.234-35.762-33.94-11.273 34.083-10.83z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">South Sudan +211</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="#FFDA44" d="M0 85.331h512v341.337H0z"></path><g fill="#D80027"><path d="M0 85.331h512v113.775H0zM0 312.882h512v113.775H0z"></path></g></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Spain +34</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="#FFDA44" d="M0 85.329v341.337h512V85.329H0zm489.739 319.076h-267.13V107.59h267.13v296.815z"></path><path fill="#A2001D" d="M222.609 107.595h267.13V404.41h-267.13z"></path><path fill="#D80027" d="M22.261 107.595h200.348V404.41H22.261z"></path><path fill="#FFDA44" d="M200.348 85.334h22.261v341.337h-22.261z"></path><path fill="#6DA544" d="M22.261 107.595h89.043V404.41H22.261z"></path><path fill="#FF9811" d="M111.304 107.595h89.043V404.41h-89.043z"></path><g fill="#FFDA44"><path d="M358.675 250.438v-44.522c0-7.424-11.13-14.848-11.13-14.848s-11.13 7.424-11.13 14.848h-44.522v44.522h22.261v22.261c0 4.875.979 9.539 2.76 13.768l-10.184 8.493h-29.674V157.677c-12.299 0-22.261 9.973-22.261 22.261v96.467a22.19 22.19 0 007.413 16.584v35.361h14.848v-18.554h66.783v29.685H328.99v14.837h29.685v-29.685l13.601-14.837h44.288v29.685h-14.848v14.837h29.685v-29.685l13.601-14.837 12.552-40.259-11.038-19.1h-38.945c-14.169-.122-40.637.09-48.896.001z"></path><path d="M370.551 211.844v25.229h71.513v13.365h4.452v-17.817h-71.513v-16.325h75.965v-4.452zM222.609 107.595h22.261v22.261h-22.261zM467.478 107.595h22.261v22.261h-22.261zM222.609 382.138h22.261v22.261h-22.261zM467.478 382.138h22.261v22.261h-22.261z"></path></g></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Sri Lanka +94</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="white" d="M0 85.337h512v341.326H0z"></path><path fill="#D80027" d="M0 85.337h512v113.775H0z"></path><path d="M0 312.888h512v113.775H0z"></path><path fill="#496E2D" d="M0 426.668V85.331l256 170.675z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Sudan +249</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="white" d="M0 85.331h512v341.337H0z"></path><path fill="#A2001D" d="M0 196.636h512v118.728H0z"></path><g fill="#6DA544"><path d="M0 352.462h512v74.207H0zM0 85.331h512v74.207H0z"></path></g><path fill="#FFDA44" d="M256.742 218.003l9.43 29.021h30.518L272 264.963l9.431 29.023-24.689-17.937-24.689 17.937 9.431-29.023-24.69-17.939h30.518z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Suriname +597</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="#D80027" d="M0 85.334h512v341.337H0z"></path><path fill="white" d="M512 295.883H202.195v130.783H122.435V295.883H0V216.111h122.435V85.329H202.195v130.782H512V277.329z"></path><path fill="#2E52B2" d="M512 234.666v42.663H183.652v149.337h-42.674V277.329H0v-42.663h140.978V85.329h42.674v149.337z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Svalbard and Jan Mayen +47</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="#0052B4" d="M0 85.333h512V426.67H0z"></path><path fill="#FFDA44" d="M192 85.33h-64v138.666H0v64h128v138.666h64V287.996h320v-64H192z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Sweden +46</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="#D80027" d="M0 85.337h512v341.326H0z"></path><path fill="white" d="M356.174 222.609h-66.783v-66.783h-66.782v66.783h-66.783v66.782h66.783v66.783h66.782v-66.783h66.783z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Switzerland +41</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="white" d="M0 85.331h512v341.337H0z"></path><path fill="#D80027" d="M0 85.331h512v113.775H0z"></path><path d="M0 312.882h512v113.775H0z"></path><g fill="#6DA544"><path d="M187.31 215.184l9.208 28.341h29.802l-24.11 17.518 9.209 28.342-24.109-17.516-24.11 17.516 9.209-28.342-24.109-17.518h29.801zM324.69 215.184l9.209 28.341H363.7l-24.109 17.518 9.209 28.342-24.11-17.516-24.109 17.516 9.209-28.342-24.11-17.518h29.802z"></path></g></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Syrian Arab Republic +963</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="#D80027" d="M0 85.337h512v341.326H0z"></path><path fill="#0052B4" d="M0 85.337h256V256H0z"></path><path fill="white" d="M186.435 170.669L162.558 181.9l12.714 23.125-25.927-4.961-3.286 26.192L128 206.993l-18.06 19.263-3.285-26.192-25.927 4.96 12.714-23.125-23.877-11.23 23.877-11.231-12.714-23.125 25.927 4.96 3.286-26.192L128 134.344l18.06-19.263 3.285 26.192 25.928-4.96-12.715 23.125z"></path><circle fill="#0052B4" cx="128" cy="170.674" r="29.006"></circle><path fill="white" d="M128 190.06c-10.692 0-19.391-8.7-19.391-19.391 0-10.692 8.7-19.391 19.391-19.391 10.692 0 19.391 8.7 19.391 19.391 0 10.691-8.699 19.391-19.391 19.391z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Taiwan +886</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="white" d="M0 85.337h512v341.326H0z"></path><path fill="#D80027" d="M0 85.337h512v113.775H0z"></path><path fill="#6DA544" d="M0 312.888h512v113.775H0z"></path><g fill="#FFDA44"><path d="M226.318 300.522h59.364v-25.23l-11.873 5.937L256 263.421l-17.809 17.808-11.873-5.937zM192.355 270.84l2.763 8.504h8.94l-7.233 5.255 2.763 8.502-7.233-5.255-7.234 5.255 2.763-8.502-7.233-5.255h8.94zM200.921 241.16l2.763 8.502h8.94l-7.233 5.255 2.763 8.504-7.233-5.256-7.234 5.256 2.763-8.504-7.233-5.255h8.94zM225.409 218.899l2.763 8.502h8.94l-7.233 5.255 2.763 8.504-7.233-5.256-7.234 5.256 2.763-8.504-7.233-5.255h8.94zM319.645 270.84l-2.763 8.504h-8.94l7.233 5.255-2.763 8.502 7.233-5.255 7.234 5.255-2.763-8.502 7.233-5.255h-8.94zM311.079 241.16l-2.763 8.502h-8.94l7.233 5.255-2.763 8.504 7.233-5.256 7.234 5.256-2.763-8.504 7.233-5.255h-8.94zM286.591 218.899l-2.763 8.502h-8.94l7.233 5.255-2.763 8.504 7.233-5.256 7.234 5.256-2.763-8.504 7.233-5.255h-8.94zM256 207.767l2.763 8.503h8.941l-7.234 5.256 2.763 8.502-7.233-5.254-7.233 5.254 2.763-8.502-7.234-5.256h8.941z"></path></g></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Tajikistan +992</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="#338AF3" d="M0 85.337h512v341.326H0z"></path><path fill="#6DA544" d="M0 426.663V85.337h512"></path><path fill="#FFDA44" d="M512 152.222V85.337H411.67L0 359.778v66.885h100.33z"></path><path d="M512 85.337v40.125L60.193 426.663H0v-40.125L451.807 85.337z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Tanzania, United Republic of Tanzania +255</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="white" d="M0 85.334h512V426.66H0z"></path><path fill="#0052B4" d="M0 194.056h512v123.882H0z"></path><g fill="#D80027"><path d="M0 85.334h512v54.522H0zM0 372.143h512v54.522H0z"></path></g></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Thailand +66</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="#D80027" d="M0 85.337h512v341.326H0z"></path><path fill="#FFDA44" d="M256 256L0 90.691v44.242L155.826 256 0 377.067v44.242z"></path><path d="M0 90.691v330.618L189.217 256z"></path><path fill="white" d="M44.184 213.36l24.912 23.577 30.121-16.41-14.723 30.98 24.911 23.575-34.012-4.43L60.67 301.63l-6.296-33.716-34.012-4.43 30.119-16.408z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Timor-Leste +670</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="#FFDA44" d="M0 85.337h512v341.326H0z"></path><g fill="#496E2D"><path d="M0 85.337h512V153.6H0zM0 358.4h512v68.263H0zM0 221.863h512v68.263H0z"></path></g><path fill="#D80027" d="M0 85.337h204.054v204.054H0z"></path><path fill="white" d="M102.026 133.938l13.26 40.812h42.916l-34.718 25.226 13.26 40.814-34.718-25.224-34.719 25.224 13.263-40.814-34.718-25.226h42.913z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Togo +228</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="#0052B4" d="M0 85.337h512v341.326H0z"></path><g fill="white"><path d="M210.715 174.377l3.684 11.338h11.919l-9.643 7.006 3.684 11.337-9.644-7.007-9.644 7.007 3.684-11.337-9.645-7.006h11.921zM116.816 281.971l4.605 14.172h14.9l-12.055 8.757 4.606 14.173-12.056-8.76-12.055 8.76 4.604-14.173-12.054-8.757h14.899zM144.696 119.679l4.604 14.172h14.901l-12.056 8.758 4.606 14.171-12.055-8.759-12.056 8.759 4.606-14.171-12.055-8.758h14.9zM69.539 175.331l4.604 14.172h14.9l-12.055 8.758 4.606 14.171-12.055-8.758-12.056 8.758 4.606-14.171-12.055-8.758h14.9z"></path></g><g fill="#FFDA44"><path d="M483.386 354.503H117.801s109.234-88.562 310.593-220.938c.001 0-88.443 128.935 54.992 220.938zM117.801 366.089c-11.177 0-11.195 17.37 0 17.37h365.585c11.177 0 11.195-17.37 0-17.37H117.801z"></path></g></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Tokelau +690</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="#D80027" d="M0 85.331h512v341.337H0z"></path><path fill="white" d="M0 85.331h256v170.663H0z"></path><path fill="#D80027" d="M141.357 157.303V130.59h-26.714v26.713H87.93v26.713h26.713v26.713h26.714v-26.713h26.713v-26.713z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Tonga +676</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="#D80027" d="M0 85.337h512v341.326H0z"></path><path fill="white" d="M6.066 85.337l207.961 212.636 131.584 128.69h160.323L297.973 214.027 166.389 85.337z"></path><path d="M43.364 85.337L384.69 426.663h83.946L127.31 85.337z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Trinidad and Tobago +1868</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="#D80027" d="M0 85.331h512v341.337H0z"></path><circle fill="white" cx="256" cy="255.994" r="96"></circle><g fill="#D80027"><path d="M267.826 219.291l16.47 22.695 26.673-8.649-16.496 22.676 16.468 22.695-26.664-8.681-16.495 22.676.017-28.04-26.664-8.682 26.674-8.648z"></path><path d="M277.818 312.724c-31.33 0-56.727-25.397-56.727-56.727s25.397-56.727 56.727-56.727c9.769 0 18.96 2.47 26.985 6.819-12.589-12.31-29.804-19.909-48.803-19.909-38.558 0-69.818 31.259-69.818 69.818s31.26 69.818 69.818 69.818c18.999 0 36.215-7.599 48.803-19.909-8.026 4.347-17.216 6.817-26.985 6.817z"></path></g></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Tunisia +216</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 450 300"><path fill="#d80027" d="M0 150V0h450v300H0V150z"></path><path fill="white" d="M247.3 118.3l35.2 5.8L307.4 99l5.1 32.8L344 150l-31.5 18.2-4.9 33.5-25.1-25.9-35.2 5.8L263 150z"></path><path fill="white" d="M240.6 228.6c-43.3 0-78.3-35.1-78.3-78.3S197.4 72 240.6 72c8.1 0 15.8 1.2 23.2 3.5-17.3-15-39.8-24-64.5-24-54.4 0-98.6 44.1-98.6 98.6s44.1 98.6 98.6 98.6c24.2 0 46.3-8.7 63.4-23.1-7 1.9-14.4 3-22.1 3z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Turkey +90</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="#496E2D" d="M0 85.337h512v341.326H0z"></path><g fill="white"><path d="M357.208 183.679c8.397-23.404-1.036-48.858-21.281-61.536a52.131 52.131 0 0110.884 2.621c27.002 9.688 41.038 39.428 31.35 66.431s-39.428 41.038-66.431 31.35a52.182 52.182 0 01-10.069-4.895c23.686 3.084 47.15-10.566 55.547-33.971zM310.637 115.729l-7.297 9.427-11.22-4.026 6.712 9.852-7.296 9.427 11.443-3.338 6.712 9.852.361-11.914 11.444-3.339-11.221-4.025z"></path><path d="M330.338 146.448l-7.296 9.427-11.221-4.026 6.712 9.852-7.296 9.427 11.443-3.339 6.712 9.853.36-11.915 11.445-3.34-11.221-4.024zM275.9 126.916l-7.296 9.427-11.219-4.024 6.711 9.851-7.296 9.426 11.443-3.338 6.712 9.852.361-11.915 11.444-3.337-11.221-4.027zM275.101 162.105l-7.296 9.427-11.221-4.026 6.712 9.852-7.296 9.427 11.444-3.338 6.711 9.852.362-11.915 11.443-3.338-11.22-4.026zM308.585 174.118l-7.296 9.427-11.22-4.026 6.712 9.853-7.297 9.426 11.444-3.338 6.712 9.852.36-11.915 11.443-3.338-11.219-4.025z"></path></g><path fill="#D80027" d="M83.478 85.337h89.043v341.326H83.478z"></path><path fill="white" d="M117.458 175.191l-14.908-11.105v-15.705l14.908-11.105h21.084l14.908 11.105v15.705l-14.908 11.105z"></path><g fill="#FF9811"><path d="M128 137.276h-10.542l-14.908 11.105v7.678H128zM128 175.191h10.542l14.908-11.105v-8.012H128z"></path></g><path fill="white" d="M117.458 374.725l-14.908-11.106v-15.704l14.908-11.105h21.084l14.908 11.105v15.704l-14.908 11.106z"></path><g fill="#FF9811"><path d="M128 336.81h-10.542l-14.908 11.105v7.678H128zM128 374.725h10.542l14.908-11.106v-8.011H128z"></path></g><g fill="#496E2D"><path d="M117.458 274.957l-14.908-11.105v-15.703l14.908-11.106h21.084l14.908 11.106v15.703l-14.908 11.105zM153.971 299.391h-6.493v-6.493h-11.411l-8.068-8.068-8.067 8.068h-11.41v6.493h-6.493v12.986h6.493v6.492h11.41l8.068 8.069 8.068-8.069h11.41v-6.492h6.493zM153.971 199.623h-6.493v-6.492h-11.411l-8.068-8.069-8.067 8.069h-11.41v6.492h-6.493v12.986h6.493v6.492h11.41l8.068 8.07 8.068-8.07h11.41v-6.492h6.493z"></path></g><g fill="#D80027"><path d="M120.576 248.576h14.84v14.84h-14.84z"></path><circle cx="128" cy="206.113" r="7.421"></circle><circle cx="128" cy="305.887" r="7.421"></circle></g></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Turkmenistan +993</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="#0052B4" d="M0 85.333h512V426.67H0z"></path><path fill="#FFDA44" d="M332.058 191.996v78.221c0 38.103 51.942 49.779 51.942 49.779s51.942-11.675 51.942-49.779v-78.221H332.058z"></path><path fill="#FF9811" d="M376.579 220.44c0 7.855-6.644 28.445-14.84 28.445s-14.84-20.589-14.84-28.445c0-7.856 14.84-14.222 14.84-14.222s14.84 6.367 14.84 14.222z"></path><path fill="#A2001D" d="M415.961 235.93c2.394-5.6 4.257-13.785 4.257-17.86 0-6.546-8.904-11.852-8.904-11.852s-8.904 5.306-8.904 11.852c0 4.075 1.862 12.26 4.257 17.86l-5.141 11.123a26.898 26.898 0 009.788 1.831c3.463 0 6.766-.654 9.788-1.831l-5.141-11.123z"></path><path fill="#6DA544" d="M372.87 270.217s-7.421 14.222-7.421 28.445h37.101c0-14.222-7.421-28.445-7.421-28.445l-11.13-7.111-11.129 7.111z"></path><path fill="#D80027" d="M395.13 270.217v-3.555c0-5.891-4.983-10.666-11.13-10.666-6.147 0-11.13 4.776-11.13 10.666v3.555h22.26z"></path><path fill="white" d="M256 85.333v30.553l-45.167 25.099H256v59.359h-59.103L256 233.179v22.817h-26.68l-73.494-40.826v40.826h-55.652v-48.573l-87.43 48.573H0v-30.554l45.167-25.098H0v-59.359h59.103L0 108.139V85.333h26.68l73.494 40.825V85.333h55.652v48.572l87.43-48.572z"></path><path fill="#D80027" d="M144 85.33h-32v69.332H0v32h112v69.334h32v-69.334h112v-32H144z"></path><path fill="#0052B4" d="M155.826 200.344L256 255.996v-15.737l-71.847-39.915z"></path><path fill="white" d="M155.826 200.344L256 255.996v-15.737l-71.847-39.915z"></path><g fill="#D80027"><path d="M155.826 200.344L256 255.996v-15.737l-71.847-39.915zM71.846 200.344L0 240.259v15.737l100.174-55.652z"></path></g><path fill="#0052B4" d="M100.174 140.982L0 85.33v15.737l71.847 39.915z"></path><path fill="white" d="M100.174 140.982L0 85.33v15.737l71.847 39.915z"></path><g fill="#D80027"><path d="M100.174 140.982L0 85.33v15.737l71.847 39.915zM184.154 140.982L256 101.067V85.33l-100.174 55.652z"></path></g></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Turks and Caicos Islands +1649</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 900 600"><path fill="#0052B4" d="M0 0h900v600H0z"></path><path fill="#00B2EE" d="M0 300h450V0h450v600H0V300z"></path><path fill="#FFDA44" d="M345.3 480.9l29.4 90.6-77.1-56H393l-77.1 56 29.4-90.6zM706.4 340l29.4 90.6-77.1-56H754l-77.1 56 29.5-90.6zM812.8 261.5l29.4 90.6-77.1-56h95.3l-77.1 56 29.5-90.6zM812.8 37.4l29.4 90.6-77.1-56h95.3l-77.1 56 29.5-90.6z"></path><path fill="white" d="M449.9 0v206.3h-81l81 54V300h-39.7l-129-85.9V300H168.7v-85.9L39.7 300H0v-39.7l81-54H0V93.8h81L0 39.9V0h39.7l129 85.9V0h112.5v85.9L410.2 0z"></path><path fill="#D80027" d="M253.1 0h-56.3v122H0v56.2h196.8V300h56.3V178.2h196.8V122H253.1z"></path><path fill="#2E52B2" d="M449.9 39.9v53.9h-81z"></path><path fill="#D80027" d="M0 300v-19.3l109.9-74.4h39.7L12.8 300zM12.8.1l136.8 93.7h-39.7L0 19.4V.1zM449.9.2v19.3L340 93.8h-39.7L437.1.2zM437.1 300l-136.8-93.7H340l109.9 74.4V300z"></path><path fill="#FFDA44" d="M719.9 131.6l29.4 90.6-77.1-56h95.3l-77.1 56 29.5-90.6zM584 187.7l29.4 90.6-77.1-56h95.3l-77.1 56 29.5-90.6zM614 430.6l29.4 90.6-77.1-56h95.3l-77.1 56 29.5-90.6zM488 332l29.4 90.6-77.1-56h95.3l-77.1 56L488 332zM488 464l29.4 90.6-77.1-56h95.3l-77.1 56L488 464z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Tuvalu +688</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 341.3"><path fill="#232323" d="M0 0h512v341.3H0z"></path><path fill="#FFDA44" d="M0 56.9h512v56.9H0z"></path><path fill="#D32300" d="M0 113.8h512v56.9H0z"></path><path fill="#FFDA44" d="M0 227.6h512v56.9H0z"></path><path fill="#D32300" d="M0 284.4h512v56.9H0z"></path><circle fill="white" cx="256" cy="170.7" r="80.7"></circle><path d="M234.5 127.5c.9-1.4-19.6-2-19.6-2 1.7-2.5 18.4-10.5 18.4-10.5s-.9-6 2.7-9.8l-4.5-9.8s7-3.4 18.4-3.4 19.9 7 21 13.1l-6.4 3.4c-.1 4.7 1.7 11.6-4.3 17.3-5.9 5.7-8.3 6.9-8.5 18.8 0 3.9 2.3 8.2 8.8 11.7 17.4 9.3 38.6 28.2 44.6 33.9 6.1 5.7 5.1 19.2 2.6 25.2s-12.1 14.3-14.3 13.6c-2.2-.6 1.2-9.2-3.5-11.6 0 0-8.9-7.6-16.8.6s-.2 25.2 3.9 28c4.1 2.8 1.7 5-1.9 5H247c-3.8 0-5.4-2.3-1.9-5 7.6-3.8 12.4-15.3 7.4-20.3-4.9-4.9-18.3 1.5-21.5 6.3-2.8 2.8-8.8 3.6-12.9-1.4s-4.1-10.4-1.1-12.5c7-4.8 0 0 .1-.1 0 0 11.9-8.6 29.9-9 3.9 0 4.8-2.2 2.2-4.8 0 0-30.9-27.4-28.1-44.2 3-18.3 20-26.3 13.4-32.5-1.3-1.8 0 0 0 0z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Uganda +256</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="#FFDA44" d="M0 85.337h512v341.326H0z"></path><path fill="#338AF3" d="M0 85.337h512V256H0z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Ukraine +380</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="white" d="M0 85.333h512V426.67H0z"></path><path fill="#D80027" d="M288 85.33h-64v138.666H0v64h224v138.666h64V287.996h224v-64H288z"></path><g fill="#0052B4"><path d="M393.785 315.358L512 381.034v-65.676zM311.652 315.358L512 426.662v-31.474l-143.693-79.83zM458.634 426.662l-146.982-81.664v81.664z"></path></g><path fill="white" d="M311.652 315.358L512 426.662v-31.474l-143.693-79.83z"></path><path fill="#D80027" d="M311.652 315.358L512 426.662v-31.474l-143.693-79.83z"></path><g fill="#0052B4"><path d="M90.341 315.356L0 365.546v-50.19zM200.348 329.51v97.151H25.491z"></path></g><path fill="#D80027" d="M143.693 315.358L0 395.188v31.474l200.348-111.304z"></path><g fill="#0052B4"><path d="M118.215 196.634L0 130.958v65.676zM200.348 196.634L0 85.33v31.474l143.693 79.83zM53.366 85.33l146.982 81.664V85.33z"></path></g><path fill="white" d="M200.348 196.634L0 85.33v31.474l143.693 79.83z"></path><path fill="#D80027" d="M200.348 196.634L0 85.33v31.474l143.693 79.83z"></path><g fill="#0052B4"><path d="M421.659 196.636L512 146.446v50.19zM311.652 182.482V85.331h174.857z"></path></g><path fill="#D80027" d="M368.307 196.634L512 116.804V85.33L311.652 196.634z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">United Kingdom +44</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 513 342"><path fill="white" d="M0 0h513v342H0z"></path><g fill="#338AF3"><path d="M0 38h513v38H0zM0 114h513v38H0zM0 190h513v38H0zM0 266h513v38H0z"></path></g><path fill="white" d="M0 0h256.5v190H0z"></path><path fill="#FFDA44" d="M192 95l-26.2 12.3 14 25.3-28.4-5.4-3.6 28.7-19.8-21.1-19.8 21.1-3.6-28.7-28.4 5.4 14-25.3L64 95l26.2-12.3-14-25.3 28.4 5.4 3.6-28.7L128 55.2l19.8-21.1 3.6 28.7 28.4-5.4-14 25.3z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Uruguay +598</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="#D80027" d="M0 85.337h512v341.326H0z"></path><path fill="#6DA544" d="M0 322.783h512v103.88H0z"></path><path fill="#338AF3" d="M0 85.337h512v104.515H0z"></path><path fill="white" d="M0 210.877h512v89.656H0z"></path><path fill="#338AF3" d="M0 85.337h512v104.515H0z"></path><g fill="white"><path d="M188.688 137.589c0-15.984 11.234-29.339 26.236-32.614a33.531 33.531 0 00-7.155-.777c-18.442 0-33.391 14.949-33.391 33.391s14.949 33.391 33.391 33.391c2.458 0 4.85-.273 7.155-.777-15.002-3.275-26.236-16.63-26.236-32.614zM234.658 152.766l2.261 6.957h7.315l-5.918 4.301 2.261 6.956-5.919-4.3-5.918 4.3 2.261-6.956-5.918-4.301h7.315zM258.006 152.766l2.26 6.957h7.315l-5.918 4.301 2.261 6.956-5.918-4.3-5.918 4.3 2.26-6.956-5.917-4.301h7.314zM281.353 152.766l2.26 6.957h7.315l-5.917 4.301 2.26 6.956-5.918-4.3-5.918 4.3 2.26-6.956-5.918-4.301h7.315zM304.7 152.766l2.262 6.957h7.315l-5.919 4.301 2.261 6.956-5.919-4.3-5.918 4.3 2.262-6.956-5.919-4.301h7.314zM328.048 152.766l2.26 6.957h7.315l-5.918 4.301 2.261 6.956-5.918-4.3-5.918 4.3 2.26-6.956-5.917-4.301h7.314zM258.006 128.482l2.26 6.956h7.315l-5.918 4.3 2.261 6.957-5.918-4.299-5.918 4.299 2.26-6.957-5.917-4.3h7.314zM281.353 128.482l2.26 6.956h7.315l-5.917 4.3 2.26 6.957-5.918-4.299-5.918 4.299 2.26-6.957-5.918-4.3h7.315zM304.7 128.482l2.262 6.956h7.315l-5.919 4.3 2.261 6.957-5.919-4.299-5.918 4.299 2.262-6.957-5.919-4.3h7.314zM328.048 128.482l2.26 6.956h7.315l-5.918 4.3 2.261 6.957-5.918-4.299-5.918 4.299 2.26-6.957-5.917-4.3h7.314zM281.353 104.198l2.26 6.956h7.315l-5.917 4.3 2.26 6.957-5.918-4.3-5.918 4.3 2.26-6.957-5.918-4.3h7.315zM304.7 104.198l2.262 6.956h7.315l-5.919 4.3 2.261 6.957-5.919-4.3-5.918 4.3 2.262-6.957-5.919-4.3h7.314zM328.048 104.198l2.26 6.956h7.315l-5.918 4.3 2.261 6.957-5.918-4.3-5.918 4.3 2.26-6.957-5.917-4.3h7.314z"></path></g></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Uzbekistan +998</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path d="M0 85.337h512v341.326H0z"></path><path fill="#6DA544" d="M512 256v170.663H0L215.185 256z"></path><path fill="#D80027" d="M512 85.337V256H215.185L0 85.337z"></path><path d="M221.001 239.304L26.868 85.337H8.956l208.168 165.098H512v-11.131zM8.956 426.663h17.912l194.133-153.967H512v-11.131H217.124zM0 92.44v14.206L188.317 256 0 405.354v14.205L206.229 256z"></path><g fill="#FFDA44"><path d="M8.956 85.337H0v7.103L206.229 256 0 419.559v7.104h8.956l208.168-165.098H512v-11.13H217.124z"></path><path d="M63.718 292.382v-14.295c14.265 0 25.87-11.606 25.87-25.869 0-10.092-8.211-18.303-18.304-18.303-6.875 0-12.469 5.593-12.469 12.469 0 4.397 3.577 7.974 7.974 7.974a4.514 4.514 0 004.508-4.508h14.295c0 10.368-8.435 18.804-18.802 18.804-12.279-.002-22.269-9.993-22.269-22.271 0-14.758 12.006-26.764 26.764-26.764 17.975 0 32.599 14.623 32.599 32.599 0 22.145-18.018 40.164-40.166 40.164z"></path></g></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Vanuatu +678</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 22.5 15"><path fill="#FFCE00" d="M0 0h22.5v5H0z"></path><path fill="#203899" d="M0 5h22.5v5H0z"></path><path fill="#D82B2B" d="M0 10h22.5v5H0z"></path><path fill="white" d="M12.13 5.38l.14.46.45.14-.39.27.01.48-.38-.29-.45.15.15-.44-.28-.38h.47zM10.36 5.38l.27.39h.47l-.28.38.15.45-.45-.16-.38.28.01-.47-.39-.28.45-.13zM13.8 5.94l-.01.48.39.27-.46.14-.14.45-.27-.38h-.48l.29-.38-.15-.45.45.16zM8.69 5.96l.4.27.44-.18-.13.46.3.36-.47.02-.26.4-.16-.44-.46-.12.37-.3zM15.24 7.13l-.2.44.25.4-.47-.05-.31.36-.1-.46-.43-.18.41-.24.03-.47.35.31zM15.43 8.25l.21.43.47.07-.34.33.08.46-.42-.22-.42.22.08-.46-.34-.33.47-.07zM7 8.2l.21.43.47.06-.34.33.08.47L7 9.27l-.42.22.08-.47-.34-.33.47-.06zM7.31 7.05l.45.14.38-.29v.48l.39.26-.45.15-.13.46-.28-.38-.47.01.27-.38z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Venezuela, Bolivarian Republic of Venezuela +58</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="#D80027" d="M196.641 85.337H0v341.326h512V85.337z"></path><path fill="#FFDA44" d="M256 157.279l22.663 69.747H352l-59.332 43.106 22.664 69.749L256 296.774l-59.332 43.107 22.664-69.749L160 227.026h73.337z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Vietnam +84</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="#0052B4" d="M0 85.334h512v341.337H0z"></path><path fill="white" d="M256 85.334V202.66h-46.069L256 233.38v22.617h-22.628L160 207.078v48.919H96v-48.919l-73.372 48.919H0V233.38l46.069-30.72H0v-64h46.069L0 107.951V85.334h22.628L96 134.241V85.334h64v48.907l73.372-48.907z"></path><g fill="#D80027"><path d="M144 85.33h-32v69.333H0v32h112v69.334h32v-69.334h112v-32H144z"></path><path d="M0 85.329v15.083l57.377 38.251H80zM256 85.329v15.083l-57.377 38.251H176z"></path></g><path fill="#2E52B2" d="M256 107.951v30.712h-46.069z"></path><g fill="#D80027"><path d="M0 85.329v15.083l57.377 38.251H80zM256 85.329v15.083l-57.377 38.251H176z"></path></g><path fill="#2E52B2" d="M256 107.951v30.712h-46.069z"></path><g fill="#D80027"><path d="M0 255.997v-15.082l57.377-38.252H80zM256 255.997v-15.082l-57.377-38.252H176z"></path></g><path fill="#FFDA44" d="M384 259.706l-46.129 46.129c8.645 16.675 26.051 28.074 46.129 28.074s37.484-11.4 46.129-28.074L384 259.706z"></path><path fill="#6DA544" d="M332.058 178.084V259.708c.001 39.759 51.942 51.941 51.942 51.941s51.941-12.182 51.942-51.942v-81.623H332.058z"></path><path fill="white" d="M372.87 215.181h22.261v59.359H372.87z"></path><circle fill="#A2001D" cx="384" cy="215.181" r="11.13"></circle><g fill="#FFDA44"><path d="M346.902 192.92h14.84v14.84h-14.84zM346.902 226.312h14.84v14.84h-14.84zM346.902 259.703h14.84v14.84h-14.84zM406.261 192.92h14.84v14.84h-14.84zM406.261 226.312h14.84v14.84h-14.84zM406.261 259.703h14.84v14.84h-14.84z"></path></g></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Virgin Islands, British +1284</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 341.3"><path fill="white" d="M0 0h512v341.3H0z"></path><path fill="#1583C4" d="M397.7 166.3l-51 97.7c-1.1 2-.3 4.5 1.8 5.6 2 1.1 4.5.3 5.6-1.8l51-97.7c1-2.1.1-4.6-2-5.5-2-.9-4.3-.2-5.4 1.7z"></path><path fill="#1583C4" d="M404.9 188l-57.8 75.4c-1.3 1.9-.8 4.5 1.1 5.8 1.7 1.2 4.1.9 5.5-.7l57.8-75.4c1.4-1.8 1.1-4.4-.8-5.8-1.8-1.5-4.4-1.1-5.8.7z"></path><path fill="#1583C4" d="M379 181.3l-32.5 83.1c-.8 2.1.2 4.6 2.4 5.4 2.1.8 4.6-.2 5.4-2.4l32.5-83.1c.7-2.2-.4-4.5-2.6-5.3-2.1-.6-4.3.4-5.2 2.3z"></path><path fill="#409347" d="M122.1 171.9c.4 1.7 1.2 4.7 2.2 8.5 1.7 6.4 3.6 12.8 5.6 18.7 2.3 6.9 14.7 31.4 20.2 39.1 6.9 9.7 14.1 19.3 21.5 28.6 1.6 1.9 4.5 2.1 6.4.5 1.8-1.6 2.1-4.3.7-6.2-7.3-9.2-14.4-18.6-21.2-28.2-4.2-5.8-17.2-31.1-19-36.7-2.9-8.7-5.4-17.6-7.6-26.5-.5-2.4-2.9-4-5.3-3.5s-4 2.9-3.5 5.3c-.1.2 0 .3 0 .4z"></path><g fill="#FFD836" stroke="#231F20" stroke-miterlimit="10"><path d="M297.1 114.9S279.5 42.8 261 42.8c-6.9 0-11.9-.6-15.4 6.4-.9 1.7-20.7-1.6-19.1 20.8.5 6.9 1.1-9.8 14.9-3.4 6.3 3-16.4 48.2-16.4 48.2h72.1z"></path><path d="M466.1 48.4l-90.9 22c-75.3 18.3-42.1 44.4-42.1 44.4l-72.1 12-72.1-12s33.2-26.1-42.1-44.4l-90.9-22C43.1 45.3 38.1 51.8 45.3 63c0 0 106.6 104 126.8 112 20.2 8.1 40.8 0 40.8 0s-14.9 8.7-24 24c-9.2 15.3-4.6 34.7-38.9 40.2-5.5 6.6-5 14 2.9 19.9 7.9 5.8 72.1-48.1 72.1-48.1s-24 24.4-24 36.1c0 5.1 44.1 53.8 60.1 53.8s60.1-48.7 60.1-53.8c0-11.7-24-36.1-24-36.1s64.2 53.9 72.1 48.1 11.4-19.3 2.8-19.9c-28-1.8-29.7-24.9-38.9-40.2-9.2-15.3-24-24-24-24s20.6 8.1 40.8 0S476.7 63 476.7 63c7.2-11.2 2.3-17.7-10.6-14.6z"></path></g><path fill="white" stroke="#231F20" stroke-miterlimit="10" d="M201.3 111.8v80.3c0 45.7 59.7 59.7 59.7 59.7s59.7-14 59.7-59.7v-80.3H201.3h0z"></path><g fill="#D80027"><path d="M225.2 137.7V235c8.2 6 17 10.2 23.9 12.9V137.7h-23.9zM296.8 137.7V235c-8.2 6-17 10.2-23.9 12.9V137.7h23.9z"></path></g><path fill="#0052B4" d="M201.3 111.8h119.4v37.9H201.3z"></path><path fill="#1583C4" d="M60.1 210.5l-21.9-58.1H15.7l31.8 80.8h25.2l31.5-80.8H81.7zM451.5 151.9h18.9v81.7h-18.9z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Virgin Islands, U.S. +1340</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 150 100"><path fill="#ED2939" d="M0 0h150v100H0z"></path><path fill="#002395" d="M0 0h20v44.33H0z"></path><path fill="white" d="M20 0h20v44.33H20z"></path><path fill="none" stroke="white" stroke-width="3" d="M0 44.33h62.75V0"></path><path fill="white" d="M108.08 43.29L87.96 23.17h40.25l-20.13 20.12zm-6.7 6.71L81.25 29.88v40.25L101.38 50zm6.7 6.71L87.96 76.83h40.25l-20.13-20.12zm6.71-6.71l20.13-20.13v40.25L114.79 50z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Wallis and Futuna +681</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="white" d="M0 85.337h512v341.326H0z"></path><path fill="#D80027" d="M0 85.337h512v113.775H0z"></path><path d="M0 312.888h512v113.775H0z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Yemen +967</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path fill="#496E2D" d="M0 85.331h512v341.337H0z"></path><path fill="#FF9811" d="M490.668 195.476h-48c0-8.836-7.164-16-16-16s-16 7.164-16 16h-48c0 8.836 7.697 16 16.533 16h-.533c0 8.836 7.162 16 16 16 0 8.836 7.162 16 16 16h32c8.836 0 16-7.164 16-16 8.836 0 16-7.164 16-16h-.533c8.837 0 16.533-7.164 16.533-16z"></path><path fill="#D80027" d="M341.337 255.994h56.888v170.663h-56.888z"></path><path fill="#FF9811" d="M455.112 255.994H512v170.663h-56.888z"></path><path d="M398.225 255.994h56.888v170.663h-56.888z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Zambia +260</div></div></div><div class="bg-white pr-spacing10 pl-spacing16 pt-spacing10 pb-spacing10 w-full font-normal text-xs text-gray cursor-pointer border-1 border-white hover:border-neutral-400"><div class="flex items-center font-Inter"><div class="w-5 h-5 flex items-center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 85.333 512 341.333"><path d="M0 85.333h512V426.67H0z"></path><g fill="#FFDA44"><path d="M0 134.196h512v48.868H0zM0 329.668h512v48.868H0z"></path></g><path fill="#6DA544" d="M0 85.333h512v48.868H0z"></path><g fill="#D80027"><path d="M0 183.069h512v48.868H0zM0 280.806h512v48.868H0z"></path></g><path fill="#6DA544" d="M0 378.542h512v48.128H0z"></path><path fill="white" d="M276.992 255.996L106.329 426.659H0V85.333h106.329z"></path><path d="M256 255.996L85.334 426.662h20.987l170.667-170.666L106.321 85.33H85.334z"></path><path fill="#D80027" d="M102.465 202.57l13.259 40.812h42.917l-34.718 25.226 13.26 40.814-34.718-25.224-34.72 25.224 13.262-40.814-34.718-25.226h42.915z"></path><path fill="#FFDA44" d="M138.94 259.335l-34.559-12.243s-2.553-23.955-2.708-24.766c-1.173-6.18-6.603-10.851-13.123-10.851-7.376 0-13.357 5.98-13.357 13.357 0 1.223.178 2.402.486 3.528l-9.689 9.755h17.229c0 17.882-13.344 17.882-13.344 35.691l7.402 17.809h44.522l7.422-17.809h-.004a17.782 17.782 0 001.381-5.231c6.397-2.589 8.342-9.24 8.342-9.24z"></path></svg></div><div class="pl-spacing4 w-6 items-center text-neutral-700 font-semibold md:!w-45 !w-auto pl-spacing8 text-sm">Zimbabwe +263</div></div></div></div></div></div><div class="flex flex-col justify-start items-start self-stretch flex-grow-0 flex-shrink-0 relative mb-spacing16"><p class="text-xs leading-4.5"><span class="text-xs text-neutral-600 self-stretch flex-grow-0 flex-shrink-0 text-left mr-1">By Signing up, you agree to our</span><a href="terms-conditions" target="_blank" class="text-xs"><span class="text-xs text-neutral-600 underline underline-offset-3 font-medium self-stretch flex-grow-0 flex-shrink-0">Terms &amp; Conditions</span></a><span class="text-xs text-neutral-600 self-stretch flex-grow-0 flex-shrink-0 text-left mx-1">and our</span><a href="privacy-policy" target="_blank" class="text-xs"><span class="text-xs leading-4.5 text-neutral-600 underline underline-offset-3 font-medium self-stretch flex-grow-0 flex-shrink-0">Privacy and Policy</span></a></p></div><button tabindex="-1" type="submit" class="bg-transparent text-mono-black border-neutral-700 hover:bg-mono-black/4 transition duration-300 ease-in-out border-2 font-bold text-base rounded px-spacing16 md:h-11 md:min-w-24 !w-full flex items-center justify-center"><div class="flex justify-center items-center">Talk to our advisor</div></button></form></div><div class="relative 
   w-full mt-spacing28 h-auto 
     h-33  bg-white overflow-hidden rounded-12 -z-0"><div class="w-6.5 h-8 bg-white rounded-xl border border-bootcamp-green-700 absolute -right-3.5 top-12.5 z-10"></div><div class="w-6.5 h-8 bg-white rounded-xl border border-bootcamp-green-700 absolute -left-3.5 top-12.5 z-10"></div><div class="border rounded-12 border-bootcamp-green-700 bg-bootcamp-green-200 w-full h-full py-spacing10 px-spacing16 shadow-elevation relative overflow-hidden"><div class="absolute -top-1 -right-1"><img alt="pattern" loading="lazy" width="95" height="153" decoding="async"  style="color:transparent" src="infinity_images/Pattern.svg"></div><div class="flex items-center h-full justify-between relative z-1"><div class="flex flex-col gap-spacing8"><div class="flex gap-spacing4 items-center"><i class="icon-percentage-filled md:text-2xl xs:text-md text-bootcamp-green-900 "></i><h5 class="text-xl text-bootcamp-green-900 font-bold">10% OFF</h5></div><div class="flex flex-col "><div><span class="text-bootcamp-green-900 font-normal text-sm">Coupon Code</span><span class="text-sm leading-4 text-bootcamp-green-900 font-bold">&nbsp;"LEVEL10"</span></div><div><span class="text-bootcamp-green-900 font-normal text-sm">Coupon Expires</span><span class="text-sm leading-4 text-bootcamp-green-900 font-bold">&nbsp; 13/04</span></div></div></div><div class="bg-bootcamp-green-500 rounded-full px-spacing12 h-8 flex items-center shadow-elevation gap-spacing6 cursor-pointer"><i class="text-white text-sm icon-copy"></i><div class="text-xs text-white font-normal text-right cursor-pointer">Copy</div></div></div></div></div></div></div></div></div></div></div></section></div><div><div><div></div><div class="transition-all duration-1000 z-[20] md:block hidden"></div></div><!--$--><div><section class="py-spacing44 sm:py-spacing48 xl:px-spacing80 sm:px-spacing112 px-0 bg-interview-white-1 py-spacing48 xs:!mt-spacing48"><div class="px-spacing20 md:px-0 w-full 2xl:max-w-7xl mx-auto"><div class="row g-4"><div class="col-12 md:flex-col"><h3 class="text-interview-black-1 font-[700] md:text-title2 xs:text-title3 pb-spacing10">Description</h3><div class="relative "><div class="text-neutral7 font-normal md:text-bodyNormal xs:text-bannerPoints pb-spacing24"><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><span>Java is a high-level </span><a href="blog/programming/best-programming-languages" class="CertTheme__link"><span>programming language</span></a><span> used for creating web applications. It runs on many different operating systems, including android. It is still one of the most in-demand programming languages, and there is a high demand for skilled </span><a href="blog/programming/how-to-become-java-developer" class="CertTheme__link"><span>Java developers</span></a><span> in various industries, such as finance, healthcare, and e-commerce. To upskill your career, enroll in our </span><a href="programming/java-deep-dive-training" class="CertTheme__link"><span>Java Course</span></a><span> and be a part of this trending career path.</span></p><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><span>Prepare better with the best java interview questions and answers, and walk away with top interview tips. These java interview questions and answers will boost your core interview skills and help you perform better.</span></p><p class="CertTheme__paragraph" dir="ltr" data-mode="standard"><span>We have compiled a set of frequently asked java interview questions to help you crack your interview with conviction. These java interview questions for experienced as well as freshers roles will enable you to face the toughest of interviews confidently. Prepare yourself well with these Java interview questions and open new doors to your dream job. To learn more about different software programming, join us in our </span><a href="programming-certification" class="CertTheme__link"><span>software programming course</span></a><span> to upskill yourself.</span></p></div></div></div></div></div></section></div><!--/$--><!--$--><div><section class="py-spacing44 sm:py-spacing48 xl:px-spacing80 sm:px-spacing112 px-0 z-[21] relative bg-white"><div class="px-spacing20 md:px-0 w-full 2xl:max-w-7xl mx-auto"><div><div class="max-w-133"><h2 class="text-sm uppercase font-semibold text-neutral-500">Recommended Courses</h2><div class="text-3xl leading-9.75 font-bold text-mono-black mt-spacing6">Learners Enrolled For</div></div><div class="relative"><div><div class="absolute flex gap-spacing16  right-0 -top-10 "><button class="border-2 rounded-full h-8 w-8 flex items-center justify-center border-solid border-neutral-700 pr-spacing2 disabled:border-neutral-200 transition duration-300 ease-in-out hover:bg-neutral-100 text-neutral-800 disabled:text-neutral-300 disabled:bg-transparent recommendedCourses-sliderprev-button undefined"><i class="icon-chevron-right text-2xl leading-6 rotate-180 pointer-events-none"></i></button><button class="border-2 rounded-full h-8 w-8 flex items-center justify-center border-solid pl-spacing2 border-neutral-700 disabled:border-neutral-200 text-neutral-800 disabled:text-neutral-300 transition duration-300 ease-in-out hover:bg-neutral-100 disabled:bg-transparent recommendedCourses-slidernext-button undefined"><i class="icon-chevron-right text-2xl leading-6 pointer-events-none"></i></button></div><div class="arrow-slider-wrapper pt-spacing40"><div class="swiper !-m-3 !p-3"><div class="swiper-wrapper"></div></div></div></div></div></div></div></section></div><!--/$--><!--$--><div class="md:pt-spacing48 pt-spacing44"><div><section data-id="ow-cta1-1" id="ow-cta1-1" class="py-spacing44 sm:py-spacing48 xl:px-spacing80 sm:px-spacing112 px-0 bg-home-cta !p-0"><div class="px-spacing20 md:px-0 w-full 2xl:max-w-7xl mx-auto"><div class="row g-4"><div class="col-12 md:flex-col"><div class="flex md:flex-row flex-col gap-spacing32 justify-center md:p-0 py-spacing24 px-spacing4 md:gap-spacing80"><img alt="CTA" loading="lazy" width="100" height="100" decoding="async"  class="self-end w-80 h-54" style="color:transparent" src="https://d2o2utebsixu4k.cloudfront.net/IllustrationCTA-5a461054ff2a4b0daa61b1369df49999.svg"><div class="flex justify-center md:w-140  items-center flex-col gap-spacing8"><div class="text-sm font-semibold uppercase text-secondary-700">Got more questions? We've got answers.</div><div class="text-2xl text-mono-black text-center font-bold">Book Your Free Counselling Session Today.</div></div><div class="flex justify-center items-center"><div class="group flex justify-center md:pb-0 m-0"><button class="transition duration-300 ease-in-out bg-mono-black md:hover:bg-primary-main active:bg-primary-main rounded text-white px-6 py-4 flex items-center justify-center md:w-auto w-fit h-11 md:h-14 whitespace-nowrap !bg-home-red-main text-sm md:text-base font-bold md:!pl-spacing28 md:!pr-spacing20 !pl-spacing16 !pr-spacing12 !py-0" tabindex="-1"><p class="">Connect With Us</p><i class="icon-chevron-right leading-5 ml-spacing8 md:ml-spacing12 text-xl text-white"></i></button><div class="relati"></div></div></div></div></div></div></div></section></div></div><!--/$--></div><div id="chatContainer" class="hidden fixed right-2.5 bottom-20 z-50 items-end"><div class="hidden md:flex items-end"><div id="chatToolTip" class="hidden relative tooltip-bottom chatToolTipDiv"><span class="font-bold">Hello! Ready to elevate your career? Explore 500+ future-ready courses with SureCertificate  🚀</span><span id="toolTipClose" class="cursor-pointer absolute top-0 right-1.5">x</span></div><div id="chatButton" class="cursor-pointer relative"><div class="h-15 w-15 flex items-center justify-center rounded-128 bg-primary-main text-mono-white"><i class="icon-message-filled text-1.75xl"></i></div><div id="notificationCounter" class="hidden absolute top-0 right-0 md:top-1 md:right-1 w-3.5 h-3.5 bg-red-600 rounded-full outline outline-1 outline-white text-center text-white text-xs leading-3 font-bold">1</div></div></div><div class="flex items-center gap-spacing4 md:hidden"><div id="chatButtonMobile" class="flex justify-center items-center h-12 w-12 bg-mono-white shadow-elevation rounded-128"><i class="icon-message-filled text-2xl text-mono-black"></i></div></div></div>
<?php include __DIR__ . '/../../footer.php'; ?>
