tag:blogger.com,1999:blog-83525401031620954892024-02-19T17:11:45.790+05:30Java program codesBagadhi Sateeshhttp://www.blogger.com/profile/16786636572407672825noreply@blogger.comBlogger489125tag:blogger.com,1999:blog-8352540103162095489.post-4063585078575543252019-04-26T16:35:00.000+05:302019-04-26T16:35:31.190+05:30Java Interview Questions and Answers<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; color: #ff6600; margin: 0px; padding: 0px;"><span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Q #1) What is JAVA?</span></span></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Ans:</span> Java is a high-level programming language and is platform independent.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
Java is a collection of objects. It was developed by Sun Microsystems. There are a lot of applications, websites and Games that are developed using Java.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; color: #ff6600; margin: 0px; padding: 0px;"><span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Q #2) What are the features in JAVA?</span></span></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Ans: Features of Java:</span></div>
<ul style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; list-style-image: initial; list-style-position: initial; margin: 0px 0px 1.5em 3em; padding: 0px;">
<li style="border: 0px; margin: 0px; padding: 0px;"><span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Oops concepts</span><ul style="border: 0px; list-style: disc; margin: 0px 0px 0px 1.5em; padding: 0px;">
<li style="border: 0px; margin: 0px; padding: 0px;">Object-oriented</li>
<li style="border: 0px; margin: 0px; padding: 0px;">Inheritance</li>
<li style="border: 0px; margin: 0px; padding: 0px;">Encapsulation</li>
<li style="border: 0px; margin: 0px; padding: 0px;">Polymorphism</li>
<li style="border: 0px; margin: 0px; padding: 0px;">Abstraction</li>
</ul>
</li>
</ul>
<ul style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; list-style-image: initial; list-style-position: initial; margin: 0px 0px 1.5em 3em; padding: 0px;">
<li style="border: 0px; margin: 0px; padding: 0px;"><span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Platform independent:</span> A single program works on different platforms without any modification.</li>
<li style="border: 0px; margin: 0px; padding: 0px;"><span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">High Performance:</span> JIT (Just In Time compiler) enables high performance in Java. JIT converts the bytecode into machine language and then JVM starts the execution.</li>
<li style="border: 0px; margin: 0px; padding: 0px;"><span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Multi-threaded:</span> A flow of execution is known as a Thread. JVM creates a thread which is called main thread. The user can create multiple threads by extending the thread class or by implementing Runnable interface.</li>
</ul>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; color: #ff6600; margin: 0px; padding: 0px;"><span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Q #3) How does Java enable high performance?</span></span></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Ans:</span> Java uses Just In Time compiler to enable high performance. JIT is used to convert the instructions into bytecodes.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; color: #ff6600; margin: 0px; padding: 0px;"><span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Q #4) What are the Java IDE’s?</span></span></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Ans:</span> Eclipse and NetBeans are the IDE's of JAVA.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; color: #ff6600; margin: 0px; padding: 0px;"><span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Q #5) What do you mean by Constructor?</span></span></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Ans: The points given below explain what a Constructor is in detail:</span></div>
<ul style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; list-style-image: initial; list-style-position: initial; margin: 0px 0px 1.5em 3em; padding: 0px;">
<li style="border: 0px; margin: 0px; padding: 0px;">When a new object is created in a program a constructor gets invoked corresponding to the class.</li>
<li style="border: 0px; margin: 0px; padding: 0px;">The constructor is a method which has the same name as class name.</li>
<li style="border: 0px; margin: 0px; padding: 0px;">If a user doesn’t create a constructor implicitly a default constructor will be created.</li>
<li style="border: 0px; margin: 0px; padding: 0px;">The constructor can be overloaded.</li>
<li style="border: 0px; margin: 0px; padding: 0px;">If the user created a constructor with a parameter then he should create another constructor explicitly without a parameter.</li>
</ul>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; color: #ff6600; margin: 0px; padding: 0px;"><span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Q #6) What is meant by Local variable and Instance variable?</span></span></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Ans: Local variables</span> are defined in the method and scope of the variables that have existed inside the method itself.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">An instance variable</span> is defined inside the class and outside the method and scope of the variables exist throughout the class.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; color: #ff6600; margin: 0px; padding: 0px;"><span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Q #7) What is a Class?</span></span></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Ans:</span> All Java codes are defined in a class. A Class has variables and methods.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Variables </span>are attributes which define the state of a class.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Methods</span> are the place where the exact business logic has to be done. It contains a set of statements (or) instructions to satisfy the particular requirement.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; color: #ff6600; margin: 0px; padding: 0px; text-decoration-line: underline;"><span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Example:</span></span></div>
<div class="syntaxhighlighter " id="highlighter_96426" style="background: none rgb(255, 255, 255) !important; border: 1px solid rgb(224, 224, 224) !important; bottom: auto !important; color: #3a3a3a; direction: ltr !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 15px; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 1em 0px !important; outline: 0px !important; padding: 0px !important; position: relative !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: 751.094px;">
<div class="lines" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<div class="line alt1" style="background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">1</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">public</code> <code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">class</code> <code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">Addition{ </code><code class="comments" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 130, 0) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">//Class name declaration</code></td></tr>
</tbody></table>
</div>
<div class="line alt2" style="background: none rgb(248, 248, 248) !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">2</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">int</code> <code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">a = </code><code class="value" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 153, 0) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">5</code><code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">; </code><code class="comments" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 130, 0) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">//Variable declaration</code></td></tr>
</tbody></table>
</div>
<div class="line alt1" style="background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">3</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">int</code> <code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">b= </code><code class="value" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 153, 0) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">5</code><code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">;</code></td></tr>
</tbody></table>
</div>
<div class="line alt2" style="background: none rgb(248, 248, 248) !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">4</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">public</code> <code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">void</code> <code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">add(){ </code><code class="comments" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 130, 0) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">//Method declaration</code></td></tr>
</tbody></table>
</div>
<div class="line alt1" style="background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">5</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">int</code> <code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">c = a+b;</code></td></tr>
</tbody></table>
</div>
<div class="line alt2" style="background: none rgb(248, 248, 248) !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">6</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">}</code></td></tr>
</tbody></table>
</div>
<div class="line alt1" style="background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">7</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">}</code></td></tr>
</tbody></table>
</div>
</div>
</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; color: #ff6600; margin: 0px; padding: 0px;"><span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Q #8) What is an Object?</span></span></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Ans:</span> An instance of a class is called object. The object has state and behavior.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
Whenever the JVM reads the “new()” keyword then it will create an instance of that class.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; color: #ff6600; margin: 0px; padding: 0px; text-decoration-line: underline;"><span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Example:</span></span></div>
<div class="syntaxhighlighter " id="highlighter_641327" style="background: none rgb(255, 255, 255) !important; border: 1px solid rgb(224, 224, 224) !important; bottom: auto !important; color: #3a3a3a; direction: ltr !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 15px; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 1em 0px !important; outline: 0px !important; padding: 0px !important; position: relative !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: 751.094px;">
<div class="lines" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<div class="line alt1" style="background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">1</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">public</code> <code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">class</code> <code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">Addition{</code></td></tr>
</tbody></table>
</div>
<div class="line alt2" style="background: none rgb(248, 248, 248) !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">2</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">public</code> <code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">static</code> <code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">void</code> <code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">main(String[] args){</code></td></tr>
</tbody></table>
</div>
<div class="line alt1" style="background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">3</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">Addion add = </code><code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">new</code> <code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">Addition();</code><code class="comments" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 130, 0) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">//Object creation</code></td></tr>
</tbody></table>
</div>
<div class="line alt2" style="background: none rgb(248, 248, 248) !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">4</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">}</code></td></tr>
</tbody></table>
</div>
<div class="line alt1" style="background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">5</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">}</code></td></tr>
</tbody></table>
</div>
</div>
</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
The above code creates the object for the Addition class.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; color: #ff6600; margin: 0px; padding: 0px;"><span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Q #9)What are the Oops concepts?</span></span></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Ans: Oops concepts include:</span></div>
<ul style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; list-style-image: initial; list-style-position: initial; margin: 0px 0px 1.5em 3em; padding: 0px;">
<li style="border: 0px; margin: 0px; padding: 0px;">Inheritance</li>
<li style="border: 0px; margin: 0px; padding: 0px;">Encapsulation</li>
<li style="border: 0px; margin: 0px; padding: 0px;">Polymorphism</li>
<li style="border: 0px; margin: 0px; padding: 0px;">Abstraction</li>
<li style="border: 0px; margin: 0px; padding: 0px;">Interface</li>
</ul>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; color: #ff6600; margin: 0px; padding: 0px;"><span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Q #10) What is Inheritance?</span></span></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Ans:</span> Inheritance means one class can <span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">extend </span>to another class. So that the codes can be reused from one class to another class.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
Existing class is known as Super class whereas the derived class is known as a sub class.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; color: #ff6600; margin: 0px; padding: 0px; text-decoration-line: underline;"><span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Example:</span></span></div>
<div class="syntaxhighlighter " id="highlighter_460435" style="background: none rgb(255, 255, 255) !important; border: 1px solid rgb(224, 224, 224) !important; bottom: auto !important; color: #3a3a3a; direction: ltr !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 15px; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 1em 0px !important; outline: 0px !important; padding: 0px !important; position: relative !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: 751.094px;">
<div class="lines" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<div class="line alt1" style="background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">1</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">Super </code><code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">class</code><code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">:</code></td></tr>
</tbody></table>
</div>
<div class="line alt2" style="background: none rgb(248, 248, 248) !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">2</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">public</code> <code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">class</code> <code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">Manupulation(){</code></td></tr>
</tbody></table>
</div>
<div class="line alt1" style="background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">3</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">}</code></td></tr>
</tbody></table>
</div>
<div class="line alt2" style="background: none rgb(248, 248, 248) !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">4</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">Sub </code><code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">class</code><code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">:</code></td></tr>
</tbody></table>
</div>
<div class="line alt1" style="background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">5</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">public</code> <code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">class</code> <code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">Addition </code><code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">extends</code> <code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">Manipulation(){</code></td></tr>
</tbody></table>
</div>
<div class="line alt2" style="background: none rgb(248, 248, 248) !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">6</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">}</code></td></tr>
</tbody></table>
</div>
</div>
</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
Inheritance is applicable for public and protected members only. Private members can’t be inherited.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; color: #ff6600; margin: 0px; padding: 0px;"><span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Q #11) What is Encapsulation?</span></span></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Ans: Purpose of Encapsulation:</span></div>
<ul style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; list-style-image: initial; list-style-position: initial; margin: 0px 0px 1.5em 3em; padding: 0px;">
<li style="border: 0px; margin: 0px; padding: 0px;">Protects the code from others.</li>
<li style="border: 0px; margin: 0px; padding: 0px;">Code maintainability.</li>
</ul>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; color: #ff6600; margin: 0px; padding: 0px; text-decoration-line: underline;"><span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Example:</span></span></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
We are declaring ‘a' as an integer variable and it should not be negative.</div>
<div class="syntaxhighlighter " id="highlighter_968529" style="background: none rgb(255, 255, 255) !important; border: 1px solid rgb(224, 224, 224) !important; bottom: auto !important; color: #3a3a3a; direction: ltr !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 15px; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 1em 0px !important; outline: 0px !important; padding: 0px !important; position: relative !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: 751.094px;">
<div class="lines" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<div class="line alt1" style="background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">1</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">public</code> <code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">class</code> <code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">Addition(){</code></td></tr>
</tbody></table>
</div>
<div class="line alt2" style="background: none rgb(248, 248, 248) !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">2</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">int</code> <code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">a=</code><code class="value" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 153, 0) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">5</code><code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">;</code></td></tr>
</tbody></table>
</div>
<div class="line alt1" style="background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">3</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">}</code></td></tr>
</tbody></table>
</div>
</div>
</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
If someone changes the exact variable as “<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;"><em style="border: 0px; margin: 0px; padding: 0px;">a = -5” </em></span>then it is bad.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; color: #ff6600; margin: 0px; padding: 0px;"><span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">In order to overcome the problem we need to follow the below steps:</span></span></div>
<ul style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; list-style-image: initial; list-style-position: initial; margin: 0px 0px 1.5em 3em; padding: 0px;">
<li style="border: 0px; margin: 0px; padding: 0px;">We can make the variable as private or protected one.</li>
<li style="border: 0px; margin: 0px; padding: 0px;">Use public accessor methods such as set<property> and get<property>.</li>
</ul>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">So that the above code can be modified as:</span></div>
<div class="syntaxhighlighter " id="highlighter_985257" style="background: none rgb(255, 255, 255) !important; border: 1px solid rgb(224, 224, 224) !important; bottom: auto !important; color: #3a3a3a; direction: ltr !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 15px; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 1em 0px !important; outline: 0px !important; padding: 0px !important; position: relative !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: 751.094px;">
<div class="lines" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<div class="line alt1" style="background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">1</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">public</code> <code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">class</code> <code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">Addition(){</code></td></tr>
</tbody></table>
</div>
<div class="line alt2" style="background: none rgb(248, 248, 248) !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">2</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">private</code> <code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">int</code> <code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">a = </code><code class="value" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 153, 0) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">5</code><code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">; </code><code class="comments" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 130, 0) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">//Here the variable is marked as private</code></td></tr>
</tbody></table>
</div>
<div class="line alt1" style="background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">3</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">}</code></td></tr>
</tbody></table>
</div>
</div>
</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Below code shows the getter and setter.</span></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
Conditions can be provided while setting the variable.</div>
<pre style="background: rgba(0, 0, 0, 0.05); border: 0px; color: #3a3a3a; font-family: inherit; font-size: 15px; line-height: normal; margin-bottom: 1.5em; max-width: 100%; overflow: auto; padding: 20px;">get A(){
}
set A(int a){
if(a>0){// Here condition is applied
.........
}
}</pre>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
For encapsulation, we need to make all the instance variables as private and create setter and getter for those variables. Which in turn will force others to call the setters rather than access the data directly.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; color: #ff6600; margin: 0px; padding: 0px;"><span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Q #12) What is Polymorphism?</span></span></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Ans:</span> Polymorphism means many forms.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
A single object can refer the super class or sub-class depending on the reference type which is called polymorphism.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; color: #ff6600; margin: 0px; padding: 0px; text-decoration-line: underline;"><span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Example:</span></span></div>
<div class="syntaxhighlighter " id="highlighter_994797" style="background: none rgb(255, 255, 255) !important; border: 1px solid rgb(224, 224, 224) !important; bottom: auto !important; color: #3a3a3a; direction: ltr !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 15px; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 1em 0px !important; outline: 0px !important; padding: 0px !important; position: relative !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: 751.094px;">
<div class="lines" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<div class="line alt1" style="background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">1</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">Public </code><code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">class</code> <code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">Manipulation(){ </code><code class="comments" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 130, 0) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">//Super class</code></td></tr>
</tbody></table>
</div>
<div class="line alt2" style="background: none rgb(248, 248, 248) !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">2</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">public</code> <code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">void</code> <code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">add(){</code></td></tr>
</tbody></table>
</div>
<div class="line alt1" style="background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">3</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">}</code></td></tr>
</tbody></table>
</div>
<div class="line alt2" style="background: none rgb(248, 248, 248) !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">4</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">}</code></td></tr>
</tbody></table>
</div>
<div class="line alt1" style="background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">5</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">public</code> <code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">class</code> <code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">Addition </code><code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">extends</code> <code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">Manipulation(){ </code><code class="comments" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 130, 0) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">// Sub class</code></td></tr>
</tbody></table>
</div>
<div class="line alt2" style="background: none rgb(248, 248, 248) !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">6</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">public</code> <code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">void</code> <code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">add(){</code></td></tr>
</tbody></table>
</div>
<div class="line alt1" style="background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">7</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">}</code></td></tr>
</tbody></table>
</div>
<div class="line alt2" style="background: none rgb(248, 248, 248) !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">8</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">public</code> <code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">static</code> <code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">void</code> <code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">main(String args[]){</code></td></tr>
</tbody></table>
</div>
<div class="line alt1" style="background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">9</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">Manipulation addition = </code><code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">new</code> <code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">Addition();</code><code class="comments" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 130, 0) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">//Manipulation is reference type and Addition is reference type</code></td></tr>
</tbody></table>
</div>
<div class="line alt2" style="background: none rgb(248, 248, 248) !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">10</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">addition.add();</code></td></tr>
</tbody></table>
</div>
<div class="line alt1" style="background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">11</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">}</code></td></tr>
</tbody></table>
</div>
<div class="line alt2" style="background: none rgb(248, 248, 248) !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">12</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">}</code></td></tr>
</tbody></table>
</div>
</div>
</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
Using Manipulation reference type we can call the Addition class “add()” method. This ability is known as Polymorphism.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
Polymorphism is applicable for <span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">overriding </span>and not for <span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">overloading</span>.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; color: #ff6600; margin: 0px; padding: 0px;"><span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Q #13) What is meant by Method Overriding?</span></span></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Ans: Method overriding happens if the sub class method satisfies the below conditions with the Super class method:</span></div>
<ul style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; list-style-image: initial; list-style-position: initial; margin: 0px 0px 1.5em 3em; padding: 0px;">
<li style="border: 0px; margin: 0px; padding: 0px;">Method name should be same</li>
<li style="border: 0px; margin: 0px; padding: 0px;">Argument should be same</li>
<li style="border: 0px; margin: 0px; padding: 0px;">Return type also should be same</li>
</ul>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
The key benefit of overriding is that the Sub class can provide some specific information about that sub class type than the super class.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; color: #ff6600; margin: 0px; padding: 0px; text-decoration-line: underline;"><span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Example:</span></span></div>
<pre style="background: rgba(0, 0, 0, 0.05); border: 0px; color: #3a3a3a; font-family: inherit; font-size: 15px; line-height: normal; margin-bottom: 1.5em; max-width: 100%; overflow: auto; padding: 20px;">public class Manipulation{ //Super class
public void add(){
………………
}
}
Public class Addition extends Manipulation(){
Public void add(){
………..
}
Public static void main(String args[]){
Manipulation addition = new Addition(); //Polimorphism is applied
addition.add(); // It calls the Sub class add() method
}
}</pre>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">addition.add() </span>method calls the add() method in the Sub class and not the parent class. So it overrides the Super class method and is known as Method Overriding.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; color: #ff6600; margin: 0px; padding: 0px;"><span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Q #14) What is meant by Overloading?</span></span></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Ans:</span> Method overloading happens for different classes or within the same class.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">For method overloading, subclass method should satisfy the below conditions with the Super class method (or) methods in the same class itself:</span></div>
<ul style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; list-style-image: initial; list-style-position: initial; margin: 0px 0px 1.5em 3em; padding: 0px;">
<li style="border: 0px; margin: 0px; padding: 0px;">Same method name</li>
<li style="border: 0px; margin: 0px; padding: 0px;">Different argument type</li>
<li style="border: 0px; margin: 0px; padding: 0px;">May have different return types</li>
</ul>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; color: #ff6600; margin: 0px; padding: 0px; text-decoration-line: underline;"><span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Example:</span></span></div>
<pre style="background: rgba(0, 0, 0, 0.05); border: 0px; color: #3a3a3a; font-family: inherit; font-size: 15px; line-height: normal; margin-bottom: 1.5em; max-width: 100%; overflow: auto; padding: 20px;">public class Manipulation{ //Super class
public void add(String name){ //String parameter
………………
}
}
Public class Addition extends Manipulation(){
Public void add(){//No Parameter
………..
}
Public void add(int a){ //integer parameter
}
Public static void main(String args[]){
Addition addition = new Addition();
addition.add();
}
}</pre>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
Here the add() method having different parameters in the Addition class is overloaded in the same class as well as with the super class.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; margin: 0px; padding: 0px; text-decoration-line: underline;"><span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Note:</span></span> Polymorphism is not applicable for method overloading.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; color: #ff6600; margin: 0px; padding: 0px;"><span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Q #15) What is meant by Interface?</span></span></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Ans:</span> Multiple inheritance cannot be achieved in java. To overcome this problem Interface concept is introduced.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
An interface is a template which has only method declarations and not the method implementation.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; color: #ff6600; margin: 0px; padding: 0px; text-decoration-line: underline;"><span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Example:</span></span></div>
<div class="syntaxhighlighter " id="highlighter_925871" style="background: none rgb(255, 255, 255) !important; border: 1px solid rgb(224, 224, 224) !important; bottom: auto !important; color: #3a3a3a; direction: ltr !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 15px; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 1em 0px !important; outline: 0px !important; padding: 0px !important; position: relative !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: 751.094px;">
<div class="lines" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<div class="line alt1" style="background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">1</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">Public </code><code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">abstract</code> <code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">interface</code> <code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">IManupulation{ </code><code class="comments" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 130, 0) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">//Interface declaration</code></td></tr>
</tbody></table>
</div>
<div class="line alt2" style="background: none rgb(248, 248, 248) !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">2</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">Public </code><code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">abstract</code> <code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">void</code> <code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">add();</code><code class="comments" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 130, 0) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">//method declaration</code></td></tr>
</tbody></table>
</div>
<div class="line alt1" style="background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">3</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">public</code> <code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">abstract</code> <code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">void</code> <code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">subtract();</code></td></tr>
</tbody></table>
</div>
<div class="line alt2" style="background: none rgb(248, 248, 248) !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">4</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">}</code></td></tr>
</tbody></table>
</div>
</div>
</div>
<ul style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; list-style-image: initial; list-style-position: initial; margin: 0px 0px 1.5em 3em; padding: 0px;">
<li style="border: 0px; margin: 0px; padding: 0px;">All the methods in the interface are internally <span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">public abstract void</span>.</li>
<li style="border: 0px; margin: 0px; padding: 0px;">All the variables in the interface are internally <span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">public static final</span> that is constants.</li>
<li style="border: 0px; margin: 0px; padding: 0px;">Classes can implement the interface and not extends.</li>
<li style="border: 0px; margin: 0px; padding: 0px;">The class which implements the interface should provide an implementation for all the methods declared in the interface.</li>
</ul>
<div class="syntaxhighlighter " id="highlighter_401817" style="background: none rgb(255, 255, 255) !important; border: 1px solid rgb(224, 224, 224) !important; bottom: auto !important; color: #3a3a3a; direction: ltr !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 15px; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 1em 0px !important; outline: 0px !important; padding: 0px !important; position: relative !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: 751.094px;">
<div class="lines" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<div class="line alt1" style="background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">1</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">public</code> <code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">class</code> <code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">Manupulation </code><code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">implements</code> <code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">IManupulation{ </code><code class="comments" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 130, 0) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">//Manupulation class uses the interface</code></td></tr>
</tbody></table>
</div>
<div class="line alt2" style="background: none rgb(248, 248, 248) !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">2</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">Public </code><code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">void</code> <code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">add(){</code></td></tr>
</tbody></table>
</div>
<div class="line alt1" style="background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">3</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">……………</code></td></tr>
</tbody></table>
</div>
<div class="line alt2" style="background: none rgb(248, 248, 248) !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">4</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">}</code></td></tr>
</tbody></table>
</div>
<div class="line alt1" style="background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">5</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">Public </code><code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">void</code> <code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">subtract(){</code></td></tr>
</tbody></table>
</div>
<div class="line alt2" style="background: none rgb(248, 248, 248) !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">6</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">…………….</code></td></tr>
</tbody></table>
</div>
<div class="line alt1" style="background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">7</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">}</code></td></tr>
</tbody></table>
</div>
<div class="line alt2" style="background: none rgb(248, 248, 248) !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">8</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">}</code></td></tr>
</tbody></table>
</div>
</div>
</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; color: #ff6600; margin: 0px; padding: 0px;"><span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Q #16) What is meant by Abstract class?</span></span></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Ans:</span> We can create the Abstract class by using “Abstract” keyword before the class name. An abstract class can have both “Abstract” methods and “Non-abstract” methods that are a concrete class.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Abstract method:</span></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
The method which has only the declaration and not the implementation is called the abstract method and it has the keyword called “abstract”. Declarations are the ends with a semicolon.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; color: #ff6600; margin: 0px; padding: 0px; text-decoration-line: underline;"><span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Example:</span></span></div>
<div class="syntaxhighlighter " id="highlighter_558250" style="background: none rgb(255, 255, 255) !important; border: 1px solid rgb(224, 224, 224) !important; bottom: auto !important; color: #3a3a3a; direction: ltr !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 15px; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 1em 0px !important; outline: 0px !important; padding: 0px !important; position: relative !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: 751.094px;">
<div class="lines" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<div class="line alt1" style="background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">1</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">public</code> <code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">abstract</code> <code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">class</code> <code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">Manupulation{</code></td></tr>
</tbody></table>
</div>
<div class="line alt2" style="background: none rgb(248, 248, 248) !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">2</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">public</code> <code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">abstract</code> <code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">void</code> <code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">add();</code><code class="comments" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 130, 0) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">//Abstract method declaration</code></td></tr>
</tbody></table>
</div>
<div class="line alt1" style="background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">3</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">Public </code><code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">void</code> <code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">subtract(){</code></td></tr>
</tbody></table>
</div>
<div class="line alt2" style="background: none rgb(248, 248, 248) !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">4</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">}</code></td></tr>
</tbody></table>
</div>
<div class="line alt1" style="background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">5</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">}</code></td></tr>
</tbody></table>
</div>
</div>
</div>
<ul style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; list-style-image: initial; list-style-position: initial; margin: 0px 0px 1.5em 3em; padding: 0px;">
<li style="border: 0px; margin: 0px; padding: 0px;">An abstract class may have a Non- abstract method also.</li>
<li style="border: 0px; margin: 0px; padding: 0px;">The concrete Subclass which extends the Abstract class should provide the implementation for abstract methods.</li>
</ul>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; color: #ff6600; margin: 0px; padding: 0px;"><span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Q #17) Difference between Array and Array List.</span></span></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Ans:</span> <span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">The Difference between Array and Array List can be understood from the below table:</span></div>
<table class="tablepress tablepress-id-147" id="tablepress-147" style="background-color: white; border-collapse: collapse; border-spacing: 0px; border: none; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin: 0px 0px 1em; padding: 0px; width: 758px;"><thead style="border: 0px; margin: 0px; padding: 0px;">
<tr class="row-1 odd" style="border: 0px; margin: 0px; padding: 0px;"><th class="column-1" style="background: 0px 0px rgb(217, 237, 247); border-bottom: 1px solid rgb(221, 221, 221); border-image: initial; border-left: none; border-right: none; border-top: none; float: none !important; margin: 0px; padding: 8px; text-align: left; vertical-align: middle;"> Array <br /></th><th class="column-2" style="background: 0px 0px rgb(217, 237, 247); border-bottom: 1px solid rgb(221, 221, 221); border-image: initial; border-left: none; border-right: none; border-top: none; float: none !important; margin: 0px; padding: 8px; text-align: left; vertical-align: middle;"> Array List </th></tr>
</thead><tbody class="row-hover" style="border: 0px; margin: 0px; padding: 0px;">
<tr class="row-2 even" style="border: 0px; margin: 0px; padding: 0px;"><td class="column-1" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px 0px; background-repeat: initial; background-size: initial; border-bottom: none; border-image: initial; border-left: none; border-right: none; border-top: 0px; float: none !important; margin: 0px; padding: 8px; vertical-align: top;">Size should be given at the time of array declaration.<br /><br />String[] name = new String[2]</td><td class="column-2" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px 0px; background-repeat: initial; background-size: initial; border-bottom: none; border-image: initial; border-left: none; border-right: none; border-top: 0px; float: none !important; margin: 0px; padding: 8px; vertical-align: top;">Size may not be required. It changes the size dynamically.<br /><br />ArrayList <string>name = new ArrayList<string></string></string></td></tr>
<tr class="row-3 odd" style="border: 0px; margin: 0px; padding: 0px;"><td class="column-1" style="background: 0px 0px rgb(249, 249, 249); border-bottom: none; border-image: initial; border-left: none; border-right: none; border-top: 1px solid rgb(221, 221, 221); float: none !important; margin: 0px; padding: 8px; vertical-align: top;">To put an object into array we need to specify the index.<br /><br />name[1] = “book”</td><td class="column-2" style="background: 0px 0px rgb(249, 249, 249); border-bottom: none; border-image: initial; border-left: none; border-right: none; border-top: 1px solid rgb(221, 221, 221); float: none !important; margin: 0px; padding: 8px; vertical-align: top;">No index required.<br /><br />name.add(“book”)</td></tr>
<tr class="row-4 even" style="border: 0px; margin: 0px; padding: 0px;"><td class="column-1" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px 0px; background-repeat: initial; background-size: initial; border-bottom: none; border-image: initial; border-left: none; border-right: none; border-top: 1px solid rgb(221, 221, 221); float: none !important; margin: 0px; padding: 8px; vertical-align: top;">Array is not type parameterized</td><td class="column-2" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px 0px; background-repeat: initial; background-size: initial; border-bottom: none; border-image: initial; border-left: none; border-right: none; border-top: 1px solid rgb(221, 221, 221); float: none !important; margin: 0px; padding: 8px; vertical-align: top;">ArrayList in java 5.0 are parameterized.<br /><br />Eg: <string>This angle bracket is a type parameter which means a list of String.</string></td></tr>
</tbody></table>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; color: #ff6600; margin: 0px; padding: 0px;"><span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Q #18) Difference between String, String Builder, and String Buffer.</span></span></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Ans: String:</span> String variables are stored in “constant string pool”. Once the string reference changes the old value that exists in the “constant string pool”, it cannot be erased.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; color: #ff6600; margin: 0px; padding: 0px; text-decoration-line: underline;"><span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Example:</span></span></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
String name = “book”;</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Constant string pool</span></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<img alt="Constant string pool" class="alignnone size-full wp-image-16573 lazyloaded" data-lazy-src="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2017/10/Constant-string-pool.jpg" data-was-processed="true" height="97" src="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2017/10/Constant-string-pool.jpg" style="height: auto; max-width: 100%;" width="240" />.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
If the name value has changed from “book” to “pen”.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Constant string pool</span></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<img alt="Constant string pools" class="alignnone size-full wp-image-16574 lazyloaded" data-lazy-src="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2017/10/Constant-string-pools.jpg" data-was-processed="true" height="113" src="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2017/10/Constant-string-pools.jpg" style="height: auto; max-width: 100%;" width="238" /></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
Then the older value retains in the constant string pool.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">String Buffer:</span></div>
<ul style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; list-style-image: initial; list-style-position: initial; margin: 0px 0px 1.5em 3em; padding: 0px;">
<li style="border: 0px; margin: 0px; padding: 0px;">Here string values are stored in a stack. If the values are changed then the new value replaces the older value.</li>
<li style="border: 0px; margin: 0px; padding: 0px;">The string buffer is synchronized which is thread-safe.</li>
<li style="border: 0px; margin: 0px; padding: 0px;">Performance is slower than the String Builder.</li>
</ul>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; color: #ff6600; margin: 0px; padding: 0px; text-decoration-line: underline;"><span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Example:</span></span></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
String Buffer name =”book”;</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<img alt="Stack" class="alignnone size-full wp-image-16580 lazyloaded" data-lazy-src="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2017/10/Stack.jpg" data-was-processed="true" height="76" src="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2017/10/Stack.jpg" style="height: auto; max-width: 100%;" width="98" /></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
Once the name value has been changed to “pen” then the “book” is erased in the stack.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<img alt="Stack1" class="alignnone size-full wp-image-16581 lazyloaded" data-lazy-src="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2017/10/Stack1.jpg" data-was-processed="true" height="88" src="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2017/10/Stack1.jpg" style="height: auto; max-width: 100%;" width="105" /></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">String Builder:</span></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
This is same as String Buffer except for the String Builder which is not threaded safety that is not synchronized. So obviously performance is fast.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; color: #ff6600; margin: 0px; padding: 0px;"><span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Q #19) Explain about Public and Private access specifiers.</span></span></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Ans:</span> Methods and instance variables are known as members.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Public:</span></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
Public members are visible in the same package as well as the outside package that is for other packages.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<img alt="Public" class="alignnone size-full wp-image-16578 lazyloaded" data-lazy-sizes="(max-width: 549px) 100vw, 549px" data-lazy-src="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2017/10/Public.jpg" data-lazy-srcset="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2017/10/Public.jpg 549w, https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2017/10/Public-300x92.jpg 300w" data-was-processed="true" height="169" sizes="(max-width: 549px) 100vw, 549px" src="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2017/10/Public.jpg" srcset="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2017/10/Public.jpg 549w, https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2017/10/Public-300x92.jpg 300w" style="height: auto; max-width: 100%;" width="549" /></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
Public members in Class A are visible to Class B (Same package) as well as Class C (Different package).</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Private:</span></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
Private members are visible in the same class only and not for the other classes in the same package as well as classes in the outside packages.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<img alt="Private" class="alignnone size-full wp-image-16576 lazyloaded" data-lazy-sizes="(max-width: 592px) 100vw, 592px" data-lazy-src="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2017/10/Private.jpg" data-lazy-srcset="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2017/10/Private.jpg 592w, https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2017/10/Private-300x98.jpg 300w" data-was-processed="true" height="193" sizes="(max-width: 592px) 100vw, 592px" src="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2017/10/Private.jpg" srcset="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2017/10/Private.jpg 592w, https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2017/10/Private-300x98.jpg 300w" style="height: auto; max-width: 100%;" width="592" /></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
Private members in class A is visible only in that class. It is invisible for class B as well as class C.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; color: #ff6600; margin: 0px; padding: 0px;"><span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Q #20) Difference between Default and Protected access specifiers.</span></span></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Ans: <span style="border: 0px; color: #ff6600; margin: 0px; padding: 0px;">Default: </span></span>Methods and variables declared in a class without any access specifiers are called default.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<img alt="Default" class="alignnone size-full wp-image-16575 lazyloaded" data-lazy-sizes="(max-width: 563px) 100vw, 563px" data-lazy-src="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2017/10/Default.jpg" data-lazy-srcset="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2017/10/Default.jpg 563w, https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2017/10/Default-300x93.jpg 300w" data-was-processed="true" height="175" sizes="(max-width: 563px) 100vw, 563px" src="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2017/10/Default.jpg" srcset="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2017/10/Default.jpg 563w, https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2017/10/Default-300x93.jpg 300w" style="height: auto; max-width: 100%;" width="563" /></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
Default members in Class A are visible to the other classes which are inside the package and invisible to the classes which are outside the package.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
So Class A members are visible to the Class B and invisible to the Class C.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; color: #ff6600; margin: 0px; padding: 0px;"><span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Protected:</span></span></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;"><img alt="Protected" class="alignnone size-full wp-image-16577 lazyloaded" data-lazy-sizes="(max-width: 493px) 100vw, 493px" data-lazy-src="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2017/10/Protected.jpg" data-lazy-srcset="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2017/10/Protected.jpg 493w, https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2017/10/Protected-300x108.jpg 300w" data-was-processed="true" height="177" sizes="(max-width: 493px) 100vw, 493px" src="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2017/10/Protected.jpg" srcset="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2017/10/Protected.jpg 493w, https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2017/10/Protected-300x108.jpg 300w" style="height: auto; max-width: 100%;" width="493" /> .</span></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
Protected is same as Default but if a class extends then it is visible even if it is outside the package.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
Class A members are visible to Class B because it is inside the package. For Class C it is invisible but if Class C extends Class A then the members are visible to the Class C even if it is outside the package.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; color: #ff6600; margin: 0px; padding: 0px;"><span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Q #21) Difference between HashMap and HashTable.</span></span></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Ans:</span> <span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Difference between HashMap and HashTable can be seen below:</span></div>
<table class="tablepress tablepress-id-148" id="tablepress-148" style="background-color: white; border-collapse: collapse; border-spacing: 0px; border: none; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin: 0px 0px 1em; padding: 0px; width: 758px;"><thead style="border: 0px; margin: 0px; padding: 0px;">
<tr class="row-1 odd" style="border: 0px; margin: 0px; padding: 0px;"><th class="column-1" style="background: 0px 0px rgb(217, 237, 247); border-bottom: 1px solid rgb(221, 221, 221); border-image: initial; border-left: none; border-right: none; border-top: none; float: none !important; margin: 0px; padding: 8px; text-align: left; vertical-align: middle;">HashMap</th><th class="column-2" style="background: 0px 0px rgb(217, 237, 247); border-bottom: 1px solid rgb(221, 221, 221); border-image: initial; border-left: none; border-right: none; border-top: none; float: none !important; margin: 0px; padding: 8px; text-align: left; vertical-align: middle;">HashTable</th></tr>
</thead><tbody class="row-hover" style="border: 0px; margin: 0px; padding: 0px;">
<tr class="row-2 even" style="border: 0px; margin: 0px; padding: 0px;"><td class="column-1" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px 0px; background-repeat: initial; background-size: initial; border-bottom: none; border-image: initial; border-left: none; border-right: none; border-top: 0px; float: none !important; margin: 0px; padding: 8px; vertical-align: top;">Methods are not synchronized</td><td class="column-2" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px 0px; background-repeat: initial; background-size: initial; border-bottom: none; border-image: initial; border-left: none; border-right: none; border-top: 0px; float: none !important; margin: 0px; padding: 8px; vertical-align: top;">Key methods are synchronized</td></tr>
<tr class="row-3 odd" style="border: 0px; margin: 0px; padding: 0px;"><td class="column-1" style="background: 0px 0px rgb(249, 249, 249); border-bottom: none; border-image: initial; border-left: none; border-right: none; border-top: 1px solid rgb(221, 221, 221); float: none !important; margin: 0px; padding: 8px; vertical-align: top;">Not thread safety</td><td class="column-2" style="background: 0px 0px rgb(249, 249, 249); border-bottom: none; border-image: initial; border-left: none; border-right: none; border-top: 1px solid rgb(221, 221, 221); float: none !important; margin: 0px; padding: 8px; vertical-align: top;">Thread safety</td></tr>
<tr class="row-4 even" style="border: 0px; margin: 0px; padding: 0px;"><td class="column-1" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px 0px; background-repeat: initial; background-size: initial; border-bottom: none; border-image: initial; border-left: none; border-right: none; border-top: 1px solid rgb(221, 221, 221); float: none !important; margin: 0px; padding: 8px; vertical-align: top;">Iterator is used to iterate the values</td><td class="column-2" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px 0px; background-repeat: initial; background-size: initial; border-bottom: none; border-image: initial; border-left: none; border-right: none; border-top: 1px solid rgb(221, 221, 221); float: none !important; margin: 0px; padding: 8px; vertical-align: top;">Enumerator is used to iterate the values</td></tr>
<tr class="row-5 odd" style="border: 0px; margin: 0px; padding: 0px;"><td class="column-1" style="background: 0px 0px rgb(249, 249, 249); border-bottom: none; border-image: initial; border-left: none; border-right: none; border-top: 1px solid rgb(221, 221, 221); float: none !important; margin: 0px; padding: 8px; vertical-align: top;">Allows one null key and multiple null values</td><td class="column-2" style="background: 0px 0px rgb(249, 249, 249); border-bottom: none; border-image: initial; border-left: none; border-right: none; border-top: 1px solid rgb(221, 221, 221); float: none !important; margin: 0px; padding: 8px; vertical-align: top;">Doesn’t allow anything that is null</td></tr>
<tr class="row-6 even" style="border: 0px; margin: 0px; padding: 0px;"><td class="column-1" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px 0px; background-repeat: initial; background-size: initial; border-bottom: none; border-image: initial; border-left: none; border-right: none; border-top: 1px solid rgb(221, 221, 221); float: none !important; margin: 0px; padding: 8px; vertical-align: top;">Performance is high than HashTable</td><td class="column-2" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px 0px; background-repeat: initial; background-size: initial; border-bottom: none; border-image: initial; border-left: none; border-right: none; border-top: 1px solid rgb(221, 221, 221); float: none !important; margin: 0px; padding: 8px; vertical-align: top;">Performance is slow</td></tr>
</tbody></table>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; color: #ff6600; margin: 0px; padding: 0px;"><span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Q #22) Difference between HashSet and TreeSet.</span></span></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Ans:</span> <span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Difference between HashSet and TreeSet can be seen below:</span></div>
<table class="tablepress tablepress-id-149" id="tablepress-149" style="background-color: white; border-collapse: collapse; border-spacing: 0px; border: none; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin: 0px 0px 1em; padding: 0px; width: 758px;"><thead style="border: 0px; margin: 0px; padding: 0px;">
<tr class="row-1 odd" style="border: 0px; margin: 0px; padding: 0px;"><th class="column-1" style="background: 0px 0px rgb(217, 237, 247); border-bottom: 1px solid rgb(221, 221, 221); border-image: initial; border-left: none; border-right: none; border-top: none; float: none !important; margin: 0px; padding: 8px; text-align: left; vertical-align: middle;">HashSet</th><th class="column-2" style="background: 0px 0px rgb(217, 237, 247); border-bottom: 1px solid rgb(221, 221, 221); border-image: initial; border-left: none; border-right: none; border-top: none; float: none !important; margin: 0px; padding: 8px; text-align: left; vertical-align: middle;">TreeSet</th></tr>
</thead><tbody class="row-hover" style="border: 0px; margin: 0px; padding: 0px;">
<tr class="row-2 even" style="border: 0px; margin: 0px; padding: 0px;"><td class="column-1" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px 0px; background-repeat: initial; background-size: initial; border-bottom: none; border-image: initial; border-left: none; border-right: none; border-top: 0px; float: none !important; margin: 0px; padding: 8px; vertical-align: top;">Inserted elements are in random order</td><td class="column-2" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px 0px; background-repeat: initial; background-size: initial; border-bottom: none; border-image: initial; border-left: none; border-right: none; border-top: 0px; float: none !important; margin: 0px; padding: 8px; vertical-align: top;">Maintains the elements in the sorted order</td></tr>
<tr class="row-3 odd" style="border: 0px; margin: 0px; padding: 0px;"><td class="column-1" style="background: 0px 0px rgb(249, 249, 249); border-bottom: none; border-image: initial; border-left: none; border-right: none; border-top: 1px solid rgb(221, 221, 221); float: none !important; margin: 0px; padding: 8px; vertical-align: top;">Can able to store null objects</td><td class="column-2" style="background: 0px 0px rgb(249, 249, 249); border-bottom: none; border-image: initial; border-left: none; border-right: none; border-top: 1px solid rgb(221, 221, 221); float: none !important; margin: 0px; padding: 8px; vertical-align: top;">Couldn’t store null objects</td></tr>
<tr class="row-4 even" style="border: 0px; margin: 0px; padding: 0px;"><td class="column-1" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px 0px; background-repeat: initial; background-size: initial; border-bottom: none; border-image: initial; border-left: none; border-right: none; border-top: 1px solid rgb(221, 221, 221); float: none !important; margin: 0px; padding: 8px; vertical-align: top;">Performance is fast</td><td class="column-2" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px 0px; background-repeat: initial; background-size: initial; border-bottom: none; border-image: initial; border-left: none; border-right: none; border-top: 1px solid rgb(221, 221, 221); float: none !important; margin: 0px; padding: 8px; vertical-align: top;">Performance is slow</td></tr>
</tbody></table>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; color: #ff6600; margin: 0px; padding: 0px;"><span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Q #23) Difference between Abstract class and Interface.</span></span></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Ans: Difference between Abstract Class and Interface are as follows:</span></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;"><span style="border: 0px; color: #ff6600; margin: 0px; padding: 0px;">Abstract Class:</span></span></div>
<ul style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; list-style-image: initial; list-style-position: initial; margin: 0px 0px 1.5em 3em; padding: 0px;">
<li style="border: 0px; margin: 0px; padding: 0px;">Abstract classes have a default constructor and it is called whenever the concrete subclass is instantiated.</li>
<li style="border: 0px; margin: 0px; padding: 0px;">Contains Abstract methods as well as Non-Abstract methods.</li>
<li style="border: 0px; margin: 0px; padding: 0px;">The class which extends the Abstract class shouldn’t require implementing all the methods, only Abstract methods need to be implemented in the concrete sub-class.</li>
<li style="border: 0px; margin: 0px; padding: 0px;">Abstract Class contains instance variables.</li>
</ul>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; color: #ff6600; margin: 0px; padding: 0px;"><span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Interface:</span></span></div>
<ul style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; list-style-image: initial; list-style-position: initial; margin: 0px 0px 1.5em 3em; padding: 0px;">
<li style="border: 0px; margin: 0px; padding: 0px;">Doesn’t have any constructor and couldn’t be instantiated.</li>
<li style="border: 0px; margin: 0px; padding: 0px;">Abstract method alone should be declared.</li>
<li style="border: 0px; margin: 0px; padding: 0px;">Classes which implement the interface should provide the implementation for all the methods.</li>
<li style="border: 0px; margin: 0px; padding: 0px;">The interface contains only constants.</li>
</ul>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; color: #ff6600; margin: 0px; padding: 0px;"><span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Q</span> <span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">#24) What is mean by Collections in Java?</span></span></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Ans:</span> Collection is a framework that is designed to store the objects and manipulate the design to store the objects.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Collections are used to perform the following operations:</span></div>
<ul style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; list-style-image: initial; list-style-position: initial; margin: 0px 0px 1.5em 3em; padding: 0px;">
<li style="border: 0px; margin: 0px; padding: 0px;">Searching</li>
<li style="border: 0px; margin: 0px; padding: 0px;">Sorting</li>
<li style="border: 0px; margin: 0px; padding: 0px;">Manipulation</li>
<li style="border: 0px; margin: 0px; padding: 0px;">Insertion</li>
<li style="border: 0px; margin: 0px; padding: 0px;">Deletion</li>
</ul>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
A group of objects is known as collections. All the classes and interfaces for collecting are available in Java utile package.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; color: #ff6600; margin: 0px; padding: 0px;"><span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Q #25) What are all the Classes and Interfaces that are available in the collections?</span></span></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Ans:</span> <span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Given below are the Classes and Interfaces that are available in Collections:</span></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Interfaces:</span></div>
<ul style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; list-style-image: initial; list-style-position: initial; margin: 0px 0px 1.5em 3em; padding: 0px;">
<li style="border: 0px; margin: 0px; padding: 0px;">Collection</li>
<li style="border: 0px; margin: 0px; padding: 0px;">List</li>
<li style="border: 0px; margin: 0px; padding: 0px;">Set</li>
<li style="border: 0px; margin: 0px; padding: 0px;">Map</li>
<li style="border: 0px; margin: 0px; padding: 0px;">Sorted Set</li>
<li style="border: 0px; margin: 0px; padding: 0px;">Sorted Map</li>
<li style="border: 0px; margin: 0px; padding: 0px;">Queue</li>
</ul>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Classes:</span></div>
<ul style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; list-style-image: initial; list-style-position: initial; margin: 0px 0px 1.5em 3em; padding: 0px;">
<li style="border: 0px; margin: 0px; padding: 0px;">Lists:</li>
<li style="border: 0px; margin: 0px; padding: 0px;">Array List</li>
<li style="border: 0px; margin: 0px; padding: 0px;">Vector</li>
<li style="border: 0px; margin: 0px; padding: 0px;">Linked List</li>
</ul>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Sets:</span></div>
<ul style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; list-style-image: initial; list-style-position: initial; margin: 0px 0px 1.5em 3em; padding: 0px;">
<li style="border: 0px; margin: 0px; padding: 0px;">Hash set</li>
<li style="border: 0px; margin: 0px; padding: 0px;">Linked Hash Set</li>
<li style="border: 0px; margin: 0px; padding: 0px;">Tree Set</li>
</ul>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Maps:</span></div>
<ul style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; list-style-image: initial; list-style-position: initial; margin: 0px 0px 1.5em 3em; padding: 0px;">
<li style="border: 0px; margin: 0px; padding: 0px;">Hash Map</li>
<li style="border: 0px; margin: 0px; padding: 0px;">Hash Table</li>
<li style="border: 0px; margin: 0px; padding: 0px;">Tree Map</li>
<li style="border: 0px; margin: 0px; padding: 0px;">Linked Hashed Map</li>
</ul>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Queue:</span></div>
<ul style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; list-style-image: initial; list-style-position: initial; margin: 0px 0px 1.5em 3em; padding: 0px;">
<li style="border: 0px; margin: 0px; padding: 0px;">Priority Queue</li>
</ul>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; color: #ff6600; margin: 0px; padding: 0px;"><span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Q #26) What is meant by Ordered and Sorted in collections?</span></span></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Ans:</span></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Ordered:</span></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
It means the values that are stored in a collection is based on the values that are added to the collection. So we can iterate the values from the collection in a specific order.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Sorted:</span></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
Sorting mechanism can be applied internally or externally so that the group of objects sorted in a particular collection is based on properties of the objects.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; color: #ff6600; margin: 0px; padding: 0px;"><span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Q #27) Explain about the different lists available in the collection.</span></span></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Ans: </span>Values added to the list is based on the index position and it is ordered by index position. Duplicates are allowed.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;"><span style="border: 0px; color: #ff6600; margin: 0px; padding: 0px;">Types of Lists are:</span></span></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Array List:</span></div>
<ul style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; list-style-image: initial; list-style-position: initial; margin: 0px 0px 1.5em 3em; padding: 0px;">
<li style="border: 0px; margin: 0px; padding: 0px;">Fast iteration and fast Random Access.</li>
<li style="border: 0px; margin: 0px; padding: 0px;">It is an ordered collection (by index) and not sorted.</li>
<li style="border: 0px; margin: 0px; padding: 0px;">It implements Random Access Interface.</li>
</ul>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; color: #ff6600; margin: 0px; padding: 0px; text-decoration-line: underline;"><span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Example:</span></span></div>
<pre style="background: rgba(0, 0, 0, 0.05); border: 0px; color: #3a3a3a; font-family: inherit; font-size: 15px; line-height: normal; margin-bottom: 1.5em; max-width: 100%; overflow: auto; padding: 20px;">public class Fruits{
public static void main (String [ ] args){
ArrayList <String>names=new ArrayList <String>();
names.add (“apple”);
names.add (“cherry”);
names.add (“kiwi”);
names.add (“banana”);
names.add (“cherry”);
System.out.println (names);
}
}</pre>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Output:</span></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
[Apple, cherry, kiwi, banana, cherry]</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
From the output, Array List maintains the insertion order and it accepts the duplicates. But not sorted.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Vector:</span></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
It is same as Array List.</div>
<ul style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; list-style-image: initial; list-style-position: initial; margin: 0px 0px 1.5em 3em; padding: 0px;">
<li style="border: 0px; margin: 0px; padding: 0px;">Vector methods are synchronized.</li>
<li style="border: 0px; margin: 0px; padding: 0px;">Thread safety.</li>
<li style="border: 0px; margin: 0px; padding: 0px;">It also implements the Random Access.</li>
<li style="border: 0px; margin: 0px; padding: 0px;">Thread safety usually causes a performance hit.</li>
</ul>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; color: #ff6600; margin: 0px; padding: 0px; text-decoration-line: underline;"><span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Example:</span></span></div>
<pre style="background: rgba(0, 0, 0, 0.05); border: 0px; color: #3a3a3a; font-family: inherit; font-size: 15px; line-height: normal; margin-bottom: 1.5em; max-width: 100%; overflow: auto; padding: 20px;">public class Fruit {
public static void main (String [ ] args){
Vector <String> names = new Vector <String> ( );
names.add (“cherry”);
names.add (“apple”);
names.add (“banana”);
names.add (“kiwi”);
names.add (“apple”);
System.out.println (“names”);
}
}</pre>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Output:</span></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
[cherry,apple,banana,kiwi,apple]</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
Vector also maintains the insertion order and accepts the duplicates.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Linked List:</span></div>
<ul style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; list-style-image: initial; list-style-position: initial; margin: 0px 0px 1.5em 3em; padding: 0px;">
<li style="border: 0px; margin: 0px; padding: 0px;">Elements are doubly linked to one another.</li>
<li style="border: 0px; margin: 0px; padding: 0px;">Performance is slow than Array list.</li>
<li style="border: 0px; margin: 0px; padding: 0px;">Good choice for insertion and deletion.</li>
<li style="border: 0px; margin: 0px; padding: 0px;">In Java 5.0 it supports common queue methods peek( ), Pool ( ), Offer ( ) etc.</li>
</ul>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; color: #ff6600; margin: 0px; padding: 0px; text-decoration-line: underline;"><span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Example:</span></span></div>
<pre style="background: rgba(0, 0, 0, 0.05); border: 0px; color: #3a3a3a; font-family: inherit; font-size: 15px; line-height: normal; margin-bottom: 1.5em; max-width: 100%; overflow: auto; padding: 20px;">public class Fruit {
public static void main (String [ ] args){
Linkedlist <String> names = new linkedlist <String> ( ) ;
names.add(“banana”);
names.add(“cherry”);
names.add(“apple”);
names.add(“kiwi”);
names.add(“banana”);
System.out.println (names);
}
}</pre>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Output</span></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
[ banana,cherry,apple,kiwi,banana]</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
Maintains the insertion order and accepts the duplicates.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; color: #ff6600; margin: 0px; padding: 0px;"><span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Q #28) Explain about Set and their types in a collection?</span></span></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Ans: Set c</span>ares about uniqueness. It doesn’t allow duplications. Here “equals ( )” method is used to determine whether two objects are identical or not.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Hash Set:</span></div>
<ul style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; list-style-image: initial; list-style-position: initial; margin: 0px 0px 1.5em 3em; padding: 0px;">
<li style="border: 0px; margin: 0px; padding: 0px;">Unordered and unsorted.</li>
<li style="border: 0px; margin: 0px; padding: 0px;">Uses the hash code of the object to insert the values.</li>
<li style="border: 0px; margin: 0px; padding: 0px;">Use this when the requirement is “no duplicates and don’t care about the order”.</li>
</ul>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; color: #ff6600; margin: 0px; padding: 0px; text-decoration-line: underline;"><span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Example:</span></span></div>
<pre style="background: rgba(0, 0, 0, 0.05); border: 0px; color: #3a3a3a; font-family: inherit; font-size: 15px; line-height: normal; margin-bottom: 1.5em; max-width: 100%; overflow: auto; padding: 20px;">public class Fruit {
public static void main (String[ ] args){
HashSet<String> names = new HashSet <=String>( ) ;
names.add(“banana”);
names.add(“cherry”);
names.add(“apple”);
names.add(“kiwi”);
names.add(“banana”);
System.out.println (names);
}
}</pre>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Output:</span></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
[banana, cherry, kiwi, apple]</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
Doesn’t follow any insertion order. Duplicates are not allowed.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Linked Hash set:</span></div>
<ul style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; list-style-image: initial; list-style-position: initial; margin: 0px 0px 1.5em 3em; padding: 0px;">
<li style="border: 0px; margin: 0px; padding: 0px;">An ordered version of the hash set is known as Linked Hash Set.</li>
<li style="border: 0px; margin: 0px; padding: 0px;">Maintains a doubly-Linked list of all the elements.</li>
<li style="border: 0px; margin: 0px; padding: 0px;">Use this when the iteration order is required.</li>
</ul>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; color: #ff6600; margin: 0px; padding: 0px; text-decoration-line: underline;"><span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Example:</span></span></div>
<pre style="background: rgba(0, 0, 0, 0.05); border: 0px; color: #3a3a3a; font-family: inherit; font-size: 15px; line-height: normal; margin-bottom: 1.5em; max-width: 100%; overflow: auto; padding: 20px;">public class Fruit {
public static void main (String[ ] args){
LinkedHashSet<String> names = new LinkedHashSet <String>( ) ;
names.add(“banana”);
names.add(“cherry”);
names.add(“apple”);
names.add(“kiwi”);
names.add(“banana”);
System.out.println (names);
}
}</pre>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Output:</span></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
[banana, cherry, apple, kiwi]</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
Maintains the insertion order in which they have been added to the Set. Duplicates are not allowed.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Tree Set:</span></div>
<ul style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; list-style-image: initial; list-style-position: initial; margin: 0px 0px 1.5em 3em; padding: 0px;">
<li style="border: 0px; margin: 0px; padding: 0px;">It is one of the two sorted collections.</li>
<li style="border: 0px; margin: 0px; padding: 0px;">Uses “Read-Black” tree structure and guarantees that the elements will be in an ascending order.</li>
<li style="border: 0px; margin: 0px; padding: 0px;">We can construct a tree set with the constructor by using comparable (or) comparator.</li>
</ul>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; color: #ff6600; margin: 0px; padding: 0px; text-decoration-line: underline;"><span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Example:</span></span></div>
<pre style="background: rgba(0, 0, 0, 0.05); border: 0px; color: #3a3a3a; font-family: inherit; font-size: 15px; line-height: normal; margin-bottom: 1.5em; max-width: 100%; overflow: auto; padding: 20px;">public class Fruits{
public static void main (String[ ]args) {
Treeset<String> names= new TreeSet<String>( ) ;
names.add(“cherry”);
names.add(“banana”);
names.add(“apple”);
names.add(“kiwi”);
names.add(“cherry”);
System.out.println(names);
}
}</pre>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Output:</span></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
[apple, banana, cherry, kiwi]</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
TreeSet sorts the elements in an ascending order. And duplicates are not allowed.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; color: #ff6600; margin: 0px; padding: 0px;"><span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Q #29). Explain about Map and their types.</span></span></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Ans: Map</span> cares about unique identifier. We can map a unique key to a specific value. It is a key/value pair. We can search a value, based on the key. Like set, Map also uses “equals ( )” method to determine whether two keys are same or different.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Hash Map:</span></div>
<ul style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; list-style-image: initial; list-style-position: initial; margin: 0px 0px 1.5em 3em; padding: 0px;">
<li style="border: 0px; margin: 0px; padding: 0px;">Unordered and unsorted map.</li>
<li style="border: 0px; margin: 0px; padding: 0px;">Hashmap is a good choice when we don’t care about the order.</li>
<li style="border: 0px; margin: 0px; padding: 0px;">It allows one null key and multiple null values.</li>
</ul>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; color: #ff6600; margin: 0px; padding: 0px; text-decoration-line: underline;"><span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Example:</span></span></div>
<pre style="background: rgba(0, 0, 0, 0.05); border: 0px; color: #3a3a3a; font-family: inherit; font-size: 15px; line-height: normal; margin-bottom: 1.5em; max-width: 100%; overflow: auto; padding: 20px;">Public class Fruit{
Public static void main(String[ ] args){
HashMap<Sting,String> names =new HashMap<String,String>( );
names.put(“key1”,“cherry”);
names.put (“key2”,“banana”);
names.put (“key3”,“apple”);
names.put (“key4”,“kiwi”);
names.put (“key1”,“cherry”);
System.out.println(names);
}
}
</pre>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Output:</span></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
{key2 =banana, key1=cherry, key4 =kiwi, key3= apple}</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
Duplicate keys are not allowed in Map.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
Doesn’t maintain any insertion order and is unsorted.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Hash Table:</span></div>
<ul style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; list-style-image: initial; list-style-position: initial; margin: 0px 0px 1.5em 3em; padding: 0px;">
<li style="border: 0px; margin: 0px; padding: 0px;">Like vector key, methods of the class are synchronized.</li>
<li style="border: 0px; margin: 0px; padding: 0px;">Thread safety and therefore slows the performance.</li>
<li style="border: 0px; margin: 0px; padding: 0px;">Doesn’t allow anything that is null.</li>
</ul>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; color: #ff6600; margin: 0px; padding: 0px; text-decoration-line: underline;"><span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Example:</span></span></div>
<pre style="background: rgba(0, 0, 0, 0.05); border: 0px; color: #3a3a3a; font-family: inherit; font-size: 15px; line-height: normal; margin-bottom: 1.5em; max-width: 100%; overflow: auto; padding: 20px;">public class Fruit{
public static void main(String[ ]args){
Hashtable<Sting,String> names =new Hashtable<String,String>( );
names.put(“key1”,“cherry”);
names.put(“key2”,“apple”);
names.put(“key3”,“banana”);
names.put(“key4”,“kiwi”);
names.put(“key2”,“orange”);
System.out.println(names);
}
}</pre>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Output:</span></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
{key2=apple, key1=cherry,key4=kiwi, key3=banana}</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
Duplicate keys are not allowed.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;"> </span><span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Linked Hash Map:</span></div>
<ul style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; list-style-image: initial; list-style-position: initial; margin: 0px 0px 1.5em 3em; padding: 0px;">
<li style="border: 0px; margin: 0px; padding: 0px;">Maintains insertion order.</li>
<li style="border: 0px; margin: 0px; padding: 0px;">Slower than Hash map.</li>
<li style="border: 0px; margin: 0px; padding: 0px;">Can expect a faster iteration.</li>
</ul>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; color: #ff6600; margin: 0px; padding: 0px; text-decoration-line: underline;"><span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Example:</span></span></div>
<pre style="background: rgba(0, 0, 0, 0.05); border: 0px; color: #3a3a3a; font-family: inherit; font-size: 15px; line-height: normal; margin-bottom: 1.5em; max-width: 100%; overflow: auto; padding: 20px;">public class Fruit{
public static void main(String[ ] args){
LinkedHashMap<Sting,String> names =new LinkedHashMap<String,String>( );
names.put(“key1”,“cherry”);
names.put(“key2”,“apple”);
names.put(“key3”,“banana”);
names.put(“key4”,“kiwi”);
names.put(“key2”,“orange”);
System.out.println(names);
}
}</pre>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Output:</span></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
{key2=apple, key1=cherry,key4=kiwi, key3=banana}</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
Duplicate keys are not allowed.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">TreeMap:</span></div>
<ul style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; list-style-image: initial; list-style-position: initial; margin: 0px 0px 1.5em 3em; padding: 0px;">
<li style="border: 0px; margin: 0px; padding: 0px;">Sorted Map.</li>
<li style="border: 0px; margin: 0px; padding: 0px;">Like Tree set, we can construct a sort order with the constructor.</li>
</ul>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; color: #ff6600; margin: 0px; padding: 0px; text-decoration-line: underline;"><span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Example:</span></span></div>
<pre style="background: rgba(0, 0, 0, 0.05); border: 0px; color: #3a3a3a; font-family: inherit; font-size: 15px; line-height: normal; margin-bottom: 1.5em; max-width: 100%; overflow: auto; padding: 20px;">public class Fruit{
public static void main(String[ ]args){
TreeMap<Sting,String> names =new TreeMap<String,String>( );
names.put(“key1”,“cherry”);
names.put(“key2”,“banana”);
names.put(“key3”,“apple”);
names.put(“key4”,“kiwi”);
names.put(“key2”,“orange”);
System.out.println(names);
}
}</pre>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Output:</span></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
{key1=cherry, key2=banana, key3 =apple, key4=kiwi}</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
It is sorted in ascending order based on the key. Duplicate keys are not allowed.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; color: #ff6600; margin: 0px; padding: 0px;"><span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Q #30) Explain the Priority Queue.</span></span></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Ans: Queue Interface</span></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Priority Queue: </span>Linked list class has been enhanced to implement the queue interface. Queues can be handled with a linked list. Purpose of a queue is “Priority-in, Priority-out”.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
Hence elements are ordered either naturally or according to the comparator. The elements ordering represents their relative priority.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; color: #ff6600; margin: 0px; padding: 0px;"><span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Q #31) What is mean by Exception?</span></span></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Ans:</span> An Exception is a problem that can occur during the normal flow of an execution. A method can throw an exception when something wails at runtime. If that exception couldn’t be handled, then the execution gets terminated before it completes the task.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
If we handled the exception, then the normal flow gets continued. Exceptions are a subclass of java.lang.Exception.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; color: #ff6600; margin: 0px; padding: 0px; text-decoration-line: underline;"><span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Example for handling Exception:</span></span></div>
<div class="syntaxhighlighter " id="highlighter_718749" style="background: none rgb(255, 255, 255) !important; border: 1px solid rgb(224, 224, 224) !important; bottom: auto !important; color: #3a3a3a; direction: ltr !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 15px; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 1em 0px !important; outline: 0px !important; padding: 0px !important; position: relative !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: 751.094px;">
<div class="lines" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<div class="line alt1" style="background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">1</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">try</code><code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">{</code></td></tr>
</tbody></table>
</div>
<div class="line alt2" style="background: none rgb(248, 248, 248) !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">2</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="comments" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 130, 0) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">//Risky codes are surrounded by this block</code></td></tr>
</tbody></table>
</div>
<div class="line alt1" style="background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">3</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">}</code><code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">catch</code><code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">(Exception e){</code></td></tr>
</tbody></table>
</div>
<div class="line alt2" style="background: none rgb(248, 248, 248) !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">4</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="comments" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 130, 0) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">//Exceptions are caught in catch block</code></td></tr>
</tbody></table>
</div>
<div class="line alt1" style="background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">5</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">}</code></td></tr>
</tbody></table>
</div>
</div>
</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; color: #ff6600; margin: 0px; padding: 0px;"><span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Q #32) What are the types of Exceptions?</span></span></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Ans:</span> Two types of Exceptions are explained below in detail.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Checked Exception:</span></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
These exceptions are checked by the compiler at the time of compilation. Classes that extend Throwable class except Runtime exception and Error are called checked Exception.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
Checked Exceptions must either declare the exception using throes keyword (or) surrounded by appropriate try/catch.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; margin: 0px; padding: 0px; text-decoration-line: underline;"><em style="border: 0px; margin: 0px; padding: 0px;"><span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">E.g.</span></em></span> ClassNotFound Exception</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Unchecked Exception:</span></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
These exceptions are not checked during the compile time by the compiler. The compiler doesn’t force to handle these exceptions.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">It includes:</span></div>
<ul style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; list-style-image: initial; list-style-position: initial; margin: 0px 0px 1.5em 3em; padding: 0px;">
<li style="border: 0px; margin: 0px; padding: 0px;">Arithmetic Exception</li>
<li style="border: 0px; margin: 0px; padding: 0px;">ArrayIndexOutOfBounds Exception</li>
</ul>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; color: #ff6600; margin: 0px; padding: 0px;"><span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Q #33) What are the different ways to handle exceptions?</span></span></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Ans:</span> <span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Two different ways to handle exception are explained below:</span></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">#1) Using try/catch:</span></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
A risky code is surrounded by try block. If an exception occurs, then it is caught by the catch block which is followed by the try block.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; color: #ff6600; margin: 0px; padding: 0px; text-decoration-line: underline;"><span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Example:</span></span></div>
<div class="syntaxhighlighter " id="highlighter_643700" style="background: none rgb(255, 255, 255) !important; border: 1px solid rgb(224, 224, 224) !important; bottom: auto !important; color: #3a3a3a; direction: ltr !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 15px; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 1em 0px !important; outline: 0px !important; padding: 0px !important; position: relative !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: 751.094px;">
<div class="lines" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<div class="line alt1" style="background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">1</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">class</code> <code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">Manipulation{</code></td></tr>
</tbody></table>
</div>
<div class="line alt2" style="background: none rgb(248, 248, 248) !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">2</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">public</code> <code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">static</code> <code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">void</code> <code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">main(String[] args){</code></td></tr>
</tbody></table>
</div>
<div class="line alt1" style="background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">3</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">add();</code></td></tr>
</tbody></table>
</div>
<div class="line alt2" style="background: none rgb(248, 248, 248) !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">4</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">}</code></td></tr>
</tbody></table>
</div>
<div class="line alt1" style="background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">5</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">Public </code><code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">void</code> <code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">add(){</code></td></tr>
</tbody></table>
</div>
<div class="line alt2" style="background: none rgb(248, 248, 248) !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">6</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">try</code><code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">{</code></td></tr>
</tbody></table>
</div>
<div class="line alt1" style="background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">7</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">addition();</code></td></tr>
</tbody></table>
</div>
<div class="line alt2" style="background: none rgb(248, 248, 248) !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">8</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">}</code><code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">catch</code><code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">(Exception e){</code></td></tr>
</tbody></table>
</div>
<div class="line alt1" style="background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">9</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">e.printStacktrace();</code></td></tr>
</tbody></table>
</div>
<div class="line alt2" style="background: none rgb(248, 248, 248) !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">10</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">}</code></td></tr>
</tbody></table>
</div>
<div class="line alt1" style="background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">11</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">}</code></td></tr>
</tbody></table>
</div>
<div class="line alt2" style="background: none rgb(248, 248, 248) !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">12</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">}</code></td></tr>
</tbody></table>
</div>
</div>
</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">#2) By declaring throws keyword:</span></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
At the end of the method, we can declare the exception using throws keyword.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; color: #ff6600; margin: 0px; padding: 0px; text-decoration-line: underline;"><span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Example:</span></span></div>
<div class="syntaxhighlighter " id="highlighter_974170" style="background: none rgb(255, 255, 255) !important; border: 1px solid rgb(224, 224, 224) !important; bottom: auto !important; color: #3a3a3a; direction: ltr !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 15px; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 1em 0px !important; outline: 0px !important; padding: 0px !important; position: relative !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: 751.094px;">
<div class="lines" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<div class="line alt1" style="background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">1</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">class</code> <code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">Manipulation{</code></td></tr>
</tbody></table>
</div>
<div class="line alt2" style="background: none rgb(248, 248, 248) !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">2</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">public</code> <code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">static</code> <code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">void</code> <code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">main(String[] args){</code></td></tr>
</tbody></table>
</div>
<div class="line alt1" style="background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">3</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">add();</code></td></tr>
</tbody></table>
</div>
<div class="line alt2" style="background: none rgb(248, 248, 248) !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">4</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">}</code></td></tr>
</tbody></table>
</div>
<div class="line alt1" style="background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">5</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">public</code> <code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">void</code> <code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">add() </code><code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">throws</code> <code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">Exception{</code></td></tr>
</tbody></table>
</div>
<div class="line alt2" style="background: none rgb(248, 248, 248) !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">6</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">addition();</code></td></tr>
</tbody></table>
</div>
<div class="line alt1" style="background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">7</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">}</code></td></tr>
</tbody></table>
</div>
<div class="line alt2" style="background: none rgb(248, 248, 248) !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">8</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">}</code></td></tr>
</tbody></table>
</div>
</div>
</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; color: #ff6600; margin: 0px; padding: 0px;"><span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Q #34) What are the Advantages of Exception handling?</span></span></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Ans: Given below are the advantages:</span></div>
<ul style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; list-style-image: initial; list-style-position: initial; margin: 0px 0px 1.5em 3em; padding: 0px;">
<li style="border: 0px; margin: 0px; padding: 0px;">The normal flow of the execution won’t be terminated if exception got handled</li>
<li style="border: 0px; margin: 0px; padding: 0px;">We can identify the problem by using catch declaration</li>
</ul>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; color: #ff6600; margin: 0px; padding: 0px;"><span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;"> </span><span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Q #35) What are Exception handling keywords in Java?</span></span></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Ans: Given below are the two Exception Handling Keywords:</span></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">try:</span></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
When a risky code is surrounded by a try block. An exception occurring in the try block is caught by a catch block. Try can be followed either by catch (or) finally (or) both. But any one of the blocks is mandatory.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">catch:</span></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
This is followed by try block. Exceptions are caught here.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">finally:</span></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
This is followed either by try block (or) catch block. This block gets executed regardless of an exception. So generally clean up codes are provided here.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; color: #ff6600; margin: 0px; padding: 0px;"><span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Q #36) Explain about Exception Propagation.</span></span></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Ans:</span> Exception is first thrown from the method which is at the top of the stack. If it doesn’t catch, then it pops up the method and moves to the previous method and so on until they are got.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
This is called Exception propagation.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; margin: 0px; padding: 0px; text-decoration-line: underline;"><span style="border: 0px; color: #ff6600; margin: 0px; padding: 0px;"><span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Example:</span></span></span></div>
<div class="syntaxhighlighter " id="highlighter_904155" style="background: none rgb(255, 255, 255) !important; border: 1px solid rgb(224, 224, 224) !important; bottom: auto !important; color: #3a3a3a; direction: ltr !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 15px; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 1em 0px !important; outline: 0px !important; padding: 0px !important; position: relative !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: 751.094px;">
<div class="lines" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<div class="line alt1" style="background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">1</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">public</code> <code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">class</code> <code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">Manipulation{</code></td></tr>
</tbody></table>
</div>
<div class="line alt2" style="background: none rgb(248, 248, 248) !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">2</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">public</code> <code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">static</code> <code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">void</code> <code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">main(String[] args){</code></td></tr>
</tbody></table>
</div>
<div class="line alt1" style="background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">3</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">add();</code></td></tr>
</tbody></table>
</div>
<div class="line alt2" style="background: none rgb(248, 248, 248) !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">4</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">}</code></td></tr>
</tbody></table>
</div>
<div class="line alt1" style="background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">5</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">public</code> <code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">void</code> <code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">add(){</code></td></tr>
</tbody></table>
</div>
<div class="line alt2" style="background: none rgb(248, 248, 248) !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">6</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">addition();</code></td></tr>
</tbody></table>
</div>
<div class="line alt1" style="background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">7</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">}</code></td></tr>
</tbody></table>
</div>
</div>
</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; color: #ff6600; margin: 0px; padding: 0px; text-decoration-line: underline;"><span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">From the above example, the stack looks like as shown below:</span></span></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;"><img alt="Stack Example" class="alignnone size-full wp-image-16579 lazyloaded" data-lazy-src="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2017/10/Stack-Example.jpg" data-was-processed="true" height="74" src="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2017/10/Stack-Example.jpg" style="height: auto; max-width: 100%;" width="112" /> </span></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
If an exception occurred in the <span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">addition()</span> method is not caught, then it moves to the method <span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">add()</span>. Then it is moved to the <span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">main()</span> method and then it will stop the flow of execution. It is called Exception Propagation.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; color: #ff6600; margin: 0px; padding: 0px;"><span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Q #37) What is the final keyword in Java?</span></span></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Ans:</span></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Final variable:</span></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
Once a variable is declared as final, then the value of the variable could not be changed. It is like a constant.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; color: #ff6600; margin: 0px; padding: 0px; text-decoration-line: underline;"><span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Example:</span></span></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
final int = 12;</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Final method:</span></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
A final keyword in a method that couldn’t be overridden. If a method is marked as a final, then it can’t be overridden by the subclass.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Final class:</span></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
If a class is declared as final, then the class couldn’t be subclassed. No class can extend the final class.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; color: #ff6600; margin: 0px; padding: 0px;"><span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Q #38) What is a Thread?</span></span></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Ans: </span>In Java, the flow of a execution is called Thread. Every java program has at least one thread called main thread, the Main thread is created by JVM. The user can define their own threads by extending Thread class (or) by implementing Runnable interface. Threads are executed concurrently.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; color: #ff6600; margin: 0px; padding: 0px; text-decoration-line: underline;"><span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Example:</span></span></div>
<div class="syntaxhighlighter " id="highlighter_410706" style="background: none rgb(255, 255, 255) !important; border: 1px solid rgb(224, 224, 224) !important; bottom: auto !important; color: #3a3a3a; direction: ltr !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 15px; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 1em 0px !important; outline: 0px !important; padding: 0px !important; position: relative !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: 751.094px;">
<div class="lines" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<div class="line alt1" style="background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">1</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">public</code> <code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">static</code> <code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">void</code> <code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">main(String[] args){</code><code class="comments" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 130, 0) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">//main thread starts here</code></td></tr>
</tbody></table>
</div>
<div class="line alt2" style="background: none rgb(248, 248, 248) !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">2</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">}</code></td></tr>
</tbody></table>
</div>
</div>
</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; color: #ff6600; margin: 0px; padding: 0px;"><span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Q #39) How do you make a thread in Java?</span></span></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Ans: </span>There are two ways available in order to make a thread.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">#1) Extend Thread class:</span></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
Extending a Thread class and override the run method. The thread is available in java.lang.thread.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; color: #ff6600; margin: 0px; padding: 0px; text-decoration-line: underline;"><span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Example:</span></span></div>
<div class="syntaxhighlighter " id="highlighter_682780" style="background: none rgb(255, 255, 255) !important; border: 1px solid rgb(224, 224, 224) !important; bottom: auto !important; color: #3a3a3a; direction: ltr !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 15px; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 1em 0px !important; outline: 0px !important; padding: 0px !important; position: relative !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: 751.094px;">
<div class="lines" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<div class="line alt1" style="background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">1</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">Public </code><code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">class</code> <code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">Addition </code><code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">extends</code> <code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">Thread {</code></td></tr>
</tbody></table>
</div>
<div class="line alt2" style="background: none rgb(248, 248, 248) !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">2</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">public</code> <code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">void</code> <code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">run () {</code></td></tr>
</tbody></table>
</div>
<div class="line alt1" style="background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">3</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">}</code></td></tr>
</tbody></table>
</div>
<div class="line alt2" style="background: none rgb(248, 248, 248) !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">4</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">}</code></td></tr>
</tbody></table>
</div>
</div>
</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
The disadvantage of using a thread class is that we cannot extend any other classes because we have already extend the thread class. We can overload the run () method in our class.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">#2) Implement Runnable interface:</span></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
Another way is implementing the runnable interface. For that we should provide the implementation for run () method which is defined in the interface.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; color: #ff6600; margin: 0px; padding: 0px; text-decoration-line: underline;"><span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Example:</span></span></div>
<div class="syntaxhighlighter " id="highlighter_126718" style="background: none rgb(255, 255, 255) !important; border: 1px solid rgb(224, 224, 224) !important; bottom: auto !important; color: #3a3a3a; direction: ltr !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 15px; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 1em 0px !important; outline: 0px !important; padding: 0px !important; position: relative !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: 751.094px;">
<div class="lines" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<div class="line alt1" style="background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">1</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">Public </code><code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">class</code> <code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">Addition </code><code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">implements</code> <code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">Runnable {</code></td></tr>
</tbody></table>
</div>
<div class="line alt2" style="background: none rgb(248, 248, 248) !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">2</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">public</code> <code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">void</code> <code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">run () {</code></td></tr>
</tbody></table>
</div>
<div class="line alt1" style="background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">3</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">}</code></td></tr>
</tbody></table>
</div>
<div class="line alt2" style="background: none rgb(248, 248, 248) !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">4</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">}</code></td></tr>
</tbody></table>
</div>
</div>
</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; color: #ff6600; margin: 0px; padding: 0px;"><span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Q #40) Explain about join () method.</span></span></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Ans:</span> Join () method is used to join one thread with the end of the currently running thread.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; color: #ff6600; margin: 0px; padding: 0px;"><span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Example:</span></span></div>
<div class="syntaxhighlighter " id="highlighter_691021" style="background: none rgb(255, 255, 255) !important; border: 1px solid rgb(224, 224, 224) !important; bottom: auto !important; color: #3a3a3a; direction: ltr !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 15px; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 1em 0px !important; outline: 0px !important; padding: 0px !important; position: relative !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: 751.094px;">
<div class="lines" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<div class="line alt1" style="background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">1</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">public</code> <code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">static</code> <code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">void</code> <code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">main (String[] args){</code></td></tr>
</tbody></table>
</div>
<div class="line alt2" style="background: none rgb(248, 248, 248) !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">2</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">Thread t = </code><code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">new</code> <code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">Thread ();</code></td></tr>
</tbody></table>
</div>
<div class="line alt1" style="background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">3</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">t.start ();</code></td></tr>
</tbody></table>
</div>
<div class="line alt2" style="background: none rgb(248, 248, 248) !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">4</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">t.join ();</code></td></tr>
</tbody></table>
</div>
<div class="line alt1" style="background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">5</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">}</code></td></tr>
</tbody></table>
</div>
</div>
</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
From the above code, the main thread started the execution. When it reaches the code <span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;"><em style="border: 0px; margin: 0px; padding: 0px;">t.start()</em></span> then ‘thread t’ starts the own stack for the execution. JVM switches between the main thread and ‘thread t’.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
Once it reaches the code <span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;"><em style="border: 0px; margin: 0px; padding: 0px;">t.join()</em></span> then ‘thread t’ alone is executed and completes its task, then only main thread started the execution.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
It is a non-static method. Join () method has overloaded version. So we can mention the time duration in join () method also “.s”.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; color: #ff6600; margin: 0px; padding: 0px;"><span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Q #41) What does yield method of the Thread class do?</span></span></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Ans:</span> A yield () method moves the currently running thread to a runnable state and allows the other threads for execution. So that equal priority threads have a chance to run. It is a static method. It doesn’t release any lock.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
Yield () method moves the thread back to the Runnable state only, and not the thread to sleep (), wait () (or) block.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; color: #ff6600; margin: 0px; padding: 0px; text-decoration-line: underline;"><span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Example:</span></span></div>
<div class="syntaxhighlighter " id="highlighter_775888" style="background: none rgb(255, 255, 255) !important; border: 1px solid rgb(224, 224, 224) !important; bottom: auto !important; color: #3a3a3a; direction: ltr !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 15px; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 1em 0px !important; outline: 0px !important; padding: 0px !important; position: relative !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: 751.094px;">
<div class="lines" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<div class="line alt1" style="background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">1</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">public</code> <code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">static</code> <code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">void</code> <code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">main (String[] args){</code></td></tr>
</tbody></table>
</div>
<div class="line alt2" style="background: none rgb(248, 248, 248) !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">2</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">Thread t = </code><code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">new</code> <code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">Thread ();</code></td></tr>
</tbody></table>
</div>
<div class="line alt1" style="background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">3</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">t.start ();</code></td></tr>
</tbody></table>
</div>
<div class="line alt2" style="background: none rgb(248, 248, 248) !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">4</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">}</code></td></tr>
</tbody></table>
</div>
<div class="line alt1" style="background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">5</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">public</code> <code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">void</code> <code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">run(){</code></td></tr>
</tbody></table>
</div>
<div class="line alt2" style="background: none rgb(248, 248, 248) !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">6</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">Thread.yield();</code></td></tr>
</tbody></table>
</div>
<div class="line alt1" style="background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">7</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">}</code></td></tr>
</tbody></table>
</div>
<div class="line alt2" style="background: none rgb(248, 248, 248) !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">8</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">}</code></td></tr>
</tbody></table>
</div>
</div>
</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; color: #ff6600; margin: 0px; padding: 0px;"><span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Q #42) Explain about wait () method.</span></span></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Ans: wait ()</span> method is used to make the thread to wait in the waiting pool. When a wait () method is executed during a thread execution then immediately the thread gives up the lock on the object and goes to the waiting pool. Wait () method tells the thread to wait for a given amount of time.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
Then the thread will wake up after notify () (or) notify all () method is called.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
Wait() and the other above-mentioned methods do not give the lock on the object immediately until the currently executing thread completes the synchronized code. It is mostly used in synchronization.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; color: #ff6600; margin: 0px; padding: 0px; text-decoration-line: underline;"><span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Example:</span></span></div>
<div class="syntaxhighlighter " id="highlighter_357254" style="background: none rgb(255, 255, 255) !important; border: 1px solid rgb(224, 224, 224) !important; bottom: auto !important; color: #3a3a3a; direction: ltr !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 15px; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 1em 0px !important; outline: 0px !important; padding: 0px !important; position: relative !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: 751.094px;">
<div class="lines" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<div class="line alt1" style="background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">1</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">public</code> <code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">static</code> <code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">void</code> <code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">main (String[] args){</code></td></tr>
</tbody></table>
</div>
<div class="line alt2" style="background: none rgb(248, 248, 248) !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">2</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">Thread t = </code><code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">new</code> <code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">Thread ();</code></td></tr>
</tbody></table>
</div>
<div class="line alt1" style="background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">3</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">t.start ();</code></td></tr>
</tbody></table>
</div>
<div class="line alt2" style="background: none rgb(248, 248, 248) !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">4</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">Synchronized (t) {</code></td></tr>
</tbody></table>
</div>
<div class="line alt1" style="background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">5</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">Wait();</code></td></tr>
</tbody></table>
</div>
<div class="line alt2" style="background: none rgb(248, 248, 248) !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">6</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">}</code></td></tr>
</tbody></table>
</div>
<div class="line alt1" style="background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">7</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">}</code></td></tr>
</tbody></table>
</div>
</div>
</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; color: #ff6600; margin: 0px; padding: 0px;"><span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Q #43) Difference between notify() method and notifyAll() method in Java.</span></span></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Ans: Given below are few differences between notify() method and notifyAll() method</span></div>
<table class="tablepress tablepress-id-150" id="tablepress-150" style="background-color: white; border-collapse: collapse; border-spacing: 0px; border: none; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin: 0px 0px 1em; padding: 0px; width: 758px;"><thead style="border: 0px; margin: 0px; padding: 0px;">
<tr class="row-1 odd" style="border: 0px; margin: 0px; padding: 0px;"><th class="column-1" style="background: 0px 0px rgb(217, 237, 247); border-bottom: 1px solid rgb(221, 221, 221); border-image: initial; border-left: none; border-right: none; border-top: none; float: none !important; margin: 0px; padding: 8px; text-align: left; vertical-align: middle;">notify()</th><th class="column-2" style="background: 0px 0px rgb(217, 237, 247); border-bottom: 1px solid rgb(221, 221, 221); border-image: initial; border-left: none; border-right: none; border-top: none; float: none !important; margin: 0px; padding: 8px; text-align: left; vertical-align: middle;">notifyAll()</th></tr>
</thead><tbody class="row-hover" style="border: 0px; margin: 0px; padding: 0px;">
<tr class="row-2 even" style="border: 0px; margin: 0px; padding: 0px;"><td class="column-1" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px 0px; background-repeat: initial; background-size: initial; border-bottom: none; border-image: initial; border-left: none; border-right: none; border-top: 0px; float: none !important; margin: 0px; padding: 8px; vertical-align: top;">This method is used to send a signal to wake up a single thread in the waiting pool.</td><td class="column-2" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px 0px; background-repeat: initial; background-size: initial; border-bottom: none; border-image: initial; border-left: none; border-right: none; border-top: 0px; float: none !important; margin: 0px; padding: 8px; vertical-align: top;">This method sends the signal to wake up all the threads in a waiting spool.</td></tr>
</tbody></table>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; color: #ff6600; margin: 0px; padding: 0px;"><span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Q #44) How to stop a thread in java? Explain about sleep () method in a thread?</span></span></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Ans:</span> We can stop a thread by using the following thread methods.</div>
<ul style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; list-style-image: initial; list-style-position: initial; margin: 0px 0px 1.5em 3em; padding: 0px;">
<li style="border: 0px; margin: 0px; padding: 0px;">Sleeping</li>
<li style="border: 0px; margin: 0px; padding: 0px;">Waiting</li>
<li style="border: 0px; margin: 0px; padding: 0px;">Blocked</li>
</ul>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Sleep:</span></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
Sleep () method is used to sleep the currently executing thread for the given amount of time. Once the thread is wake up it can move to the runnable state. So sleep () method is used to delay the execution for some period.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
It is a static method.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; color: #ff6600; margin: 0px; padding: 0px; text-decoration-line: underline;"><span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Example:</span></span></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Thread. Sleep (2000)</span></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
So it delays the thread to sleep 2 milliseconds. Sleep () method throws an uninterrupted exception, hence we need to surround the block with try/catch.</div>
<div class="syntaxhighlighter " id="highlighter_85574" style="background: none rgb(255, 255, 255) !important; border: 1px solid rgb(224, 224, 224) !important; bottom: auto !important; color: #3a3a3a; direction: ltr !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 15px; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 1em 0px !important; outline: 0px !important; padding: 0px !important; position: relative !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: 751.094px;">
<div class="lines" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<div class="line alt1" style="background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">1</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">public</code> <code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">class</code> <code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">ExampleThread </code><code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">implements</code> <code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">Runnable{</code></td></tr>
</tbody></table>
</div>
<div class="line alt2" style="background: none rgb(248, 248, 248) !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">2</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">public</code> <code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">static</code> <code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">void</code> <code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">main (String[] args){</code></td></tr>
</tbody></table>
</div>
<div class="line alt1" style="background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">3</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">Thread t = </code><code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">new</code> <code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">Thread ();</code></td></tr>
</tbody></table>
</div>
<div class="line alt2" style="background: none rgb(248, 248, 248) !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">4</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">t.start ();</code></td></tr>
</tbody></table>
</div>
<div class="line alt1" style="background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">5</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">}</code></td></tr>
</tbody></table>
</div>
<div class="line alt2" style="background: none rgb(248, 248, 248) !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">6</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">public</code> <code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">void</code> <code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">run(){</code></td></tr>
</tbody></table>
</div>
<div class="line alt1" style="background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">7</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">try</code><code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">{</code></td></tr>
</tbody></table>
</div>
<div class="line alt2" style="background: none rgb(248, 248, 248) !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">8</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">Thread.sleep(</code><code class="value" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 153, 0) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">2000</code><code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">);</code></td></tr>
</tbody></table>
</div>
<div class="line alt1" style="background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">9</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">}</code><code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">catch</code><code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">(InterruptedException e){</code></td></tr>
</tbody></table>
</div>
<div class="line alt2" style="background: none rgb(248, 248, 248) !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">10</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">}</code></td></tr>
</tbody></table>
</div>
<div class="line alt1" style="background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">11</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">}</code></td></tr>
</tbody></table>
</div>
</div>
</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; color: #ff6600; margin: 0px; padding: 0px;"><span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Q #45) When to use Runnable interface Vs Thread class in Java?</span></span></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Ans:</span> If we need our class to extend some other classes other than the thread then we can go with the runnable interface because in java we can extend only one class.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
If we are not going to extend any class then we can extend the thread class.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; color: #ff6600; margin: 0px; padding: 0px;"><span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Q #46) Difference between start() and run() method of thread class.</span></span></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Ans:</span> Start() method creates new thread and the code inside the run () method is executed in the new thread. If we directly called the run() method then a new thread is not created and the currently executing thread will continue to execute the run() method.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; color: #ff6600; margin: 0px; padding: 0px;"><span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Q #47) What is Multi-threading?</span></span></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Ans:</span> Multiple threads are executed simultaneously. Each thread starts their own stack based on the flow (or) priority of the threads.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; color: #ff6600; margin: 0px; padding: 0px; text-decoration-line: underline;"><span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Example Program:</span></span></div>
<div class="syntaxhighlighter " id="highlighter_363681" style="background: none rgb(255, 255, 255) !important; border: 1px solid rgb(224, 224, 224) !important; bottom: auto !important; color: #3a3a3a; direction: ltr !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 15px; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 1em 0px !important; outline: 0px !important; padding: 0px !important; position: relative !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: 751.094px;">
<div class="lines" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<div class="line alt1" style="background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">1</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">public</code> <code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">class</code> <code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">MultipleThreads </code><code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">implements</code> <code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">Runnable</code></td></tr>
</tbody></table>
</div>
<div class="line alt2" style="background: none rgb(248, 248, 248) !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">2</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">{</code></td></tr>
</tbody></table>
</div>
<div class="line alt1" style="background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">3</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">public</code> <code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">static</code> <code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">void</code> <code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">main (String[] args){</code><code class="comments" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 130, 0) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">//Main thread starts here</code></td></tr>
</tbody></table>
</div>
<div class="line alt2" style="background: none rgb(248, 248, 248) !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">4</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">Runnable r = </code><code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">new</code> <code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">runnable ();</code></td></tr>
</tbody></table>
</div>
<div class="line alt1" style="background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">5</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">Thread t=</code><code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">new</code> <code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">thread ();</code></td></tr>
</tbody></table>
</div>
<div class="line alt2" style="background: none rgb(248, 248, 248) !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">6</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">t.start ();</code><code class="comments" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 130, 0) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">//User thread starts here</code></td></tr>
</tbody></table>
</div>
<div class="line alt1" style="background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">7</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">Addition add=</code><code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">new</code> <code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">addition ();</code></td></tr>
</tbody></table>
</div>
<div class="line alt2" style="background: none rgb(248, 248, 248) !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">8</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">}</code></td></tr>
</tbody></table>
</div>
<div class="line alt1" style="background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">9</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">public</code> <code class="keyword" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">void</code> <code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">run(){</code></td></tr>
</tbody></table>
</div>
<div class="line alt2" style="background: none rgb(248, 248, 248) !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">10</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">go();</code></td></tr>
</tbody></table>
</div>
<div class="line alt1" style="background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">11</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">}</code><code class="comments" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(0, 130, 0) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">//User thread ends here</code></td></tr>
</tbody></table>
</div>
<div class="line alt2" style="background: none rgb(248, 248, 248) !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background: none !important; border-collapse: collapse !important; border-spacing: 0px; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background: none !important; border: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">12</code></td><td class="content" style="background: none !important; border-bottom-color: initial !important; border-bottom-style: initial !important; border-image: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-right-color: initial !important; border-right-style: initial !important; border-top-color: initial !important; border-top-style: initial !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="plain" style="background: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">}</code></td></tr>
</tbody></table>
</div>
</div>
</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
On the 1st line execution, JVM calls the main method and the main thread stack looks as shown below.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<img alt="Thread1" class="alignnone size-full wp-image-16583 lazyloaded" data-lazy-src="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2017/10/Thread1.jpg" data-was-processed="true" height="91" src="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2017/10/Thread1.jpg" style="height: auto; max-width: 100%;" width="110" /></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
Once the execution reaches, <span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">t.start () </span>line then a new thread is created and the new stack for the thread is also created. Now JVM switches to the new thread and the main thread are back to the runnable state.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
The two stacks look as shown below.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<img alt="Thread2" class="alignnone size-full wp-image-16584 lazyloaded" data-lazy-src="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2017/10/Thread2.jpg" data-was-processed="true" height="90" src="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2017/10/Thread2.jpg" style="height: auto; max-width: 100%;" width="274" /></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
Now, the user thread executed the code inside the run() method.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<img alt="Thread3" class="alignnone size-full wp-image-16585 lazyloaded" data-lazy-src="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2017/10/Thread3.jpg" data-was-processed="true" height="100" src="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2017/10/Thread3.jpg" style="height: auto; max-width: 100%;" width="276" /></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
Once the run() method has completed, then JVM switches back to the main thread and the User thread has completed the task and the stack was disappeared.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
JVM switches between each thread until both the threads are completed. This is called Multi-threading.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; color: #ff6600; margin: 0px; padding: 0px;"><span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Q #48) Explain thread life cycle in Java.</span></span></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Ans:</span> <span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Thread has the following states:</span></div>
<ul style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; list-style-image: initial; list-style-position: initial; margin: 0px 0px 1.5em 3em; padding: 0px;">
<li style="border: 0px; margin: 0px; padding: 0px;">New</li>
<li style="border: 0px; margin: 0px; padding: 0px;">Runnable</li>
<li style="border: 0px; margin: 0px; padding: 0px;">Running</li>
<li style="border: 0px; margin: 0px; padding: 0px;">Non-runnable (Blocked)</li>
<li style="border: 0px; margin: 0px; padding: 0px;">Terminated</li>
</ul>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<a href="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2018/01/Thread-Life-Cycle-in-Java.jpg" style="background-color: transparent; border: 0px; color: #ce0000; margin: 0px; padding: 0px; text-decoration-line: none; transition: color 0.1s ease-in-out 0s, background-color 0.1s ease-in-out 0s;"><img alt="Thread Life Cycle in JAVA" class="alignnone size-full wp-image-22068 lazyloaded" data-lazy-sizes="(max-width: 531px) 100vw, 531px" data-lazy-src="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2018/01/Thread-Life-Cycle-in-Java.jpg" data-lazy-srcset="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2018/01/Thread-Life-Cycle-in-Java.jpg 531w, https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2018/01/Thread-Life-Cycle-in-Java-300x82.jpg 300w" data-was-processed="true" height="146" sizes="(max-width: 531px) 100vw, 531px" src="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2018/01/Thread-Life-Cycle-in-Java.jpg" srcset="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2018/01/Thread-Life-Cycle-in-Java.jpg 531w, https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2018/01/Thread-Life-Cycle-in-Java-300x82.jpg 300w" style="border: 0px; height: auto; max-width: 100%;" width="531" /></a></div>
<ul style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; list-style-image: initial; list-style-position: initial; margin: 0px 0px 1.5em 3em; padding: 0px;">
<li style="border: 0px; margin: 0px; padding: 0px;"><span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">New:</span></li>
</ul>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
In New state, Thread instance has been created but start () method is not yet invoked. Now the thread is not considered alive.</div>
<ul style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; list-style-image: initial; list-style-position: initial; margin: 0px 0px 1.5em 3em; padding: 0px;">
<li style="border: 0px; margin: 0px; padding: 0px;"><span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Runnable</span>:</li>
</ul>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
The Thread is in runnable state after invocation of the start () method, but before the run () method is invoked. But a thread can also return to the runnable state from waiting/sleeping. In this state the thread is considered alive.</div>
<ul style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; list-style-image: initial; list-style-position: initial; margin: 0px 0px 1.5em 3em; padding: 0px;">
<li style="border: 0px; margin: 0px; padding: 0px;"><span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Running</span>:</li>
</ul>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
The thread is in running state after it calls the run () method. Now the thread begins the execution.</div>
<ul style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; list-style-image: initial; list-style-position: initial; margin: 0px 0px 1.5em 3em; padding: 0px;">
<li style="border: 0px; margin: 0px; padding: 0px;"><span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Non-Runnable</span>(Blocked):</li>
</ul>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
The thread is alive but it is not eligible to run. It is not in runnable state but also, it will return to runnable state after some time.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; color: #ff6600; margin: 0px; padding: 0px;"><span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;"><span style="border: 0px; margin: 0px; padding: 0px; text-decoration-line: underline;">Example:</span></span></span> wait, sleep, block.</div>
<ul style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; list-style-image: initial; list-style-position: initial; margin: 0px 0px 1.5em 3em; padding: 0px;">
<li style="border: 0px; margin: 0px; padding: 0px;"><span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Terminated </span>:</li>
</ul>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
Once the run method is completed then it is terminated. Now the thread is not alive.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; color: #ff6600; margin: 0px; padding: 0px;"><span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Q #49) What is Synchronization?</span></span></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Ans:</span> Synchronization makes only one thread to access a block of code at a time. If multiple thread accesses the block of code, then there is a chance for inaccurate results at the end. To avoid this issue, we can provide synchronization for the sensitive block of codes.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
The synchronized keyword means that a thread needs a key in order to access the synchronized code.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
Locks are per objects. Every Java object has a lock. A lock has only one key. A thread can access a synchronized method only if the thread can get the key to the objects lock.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
For this, we use “Synchronized” keyword.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; color: #ff6600; margin: 0px; padding: 0px; text-decoration-line: underline;"><span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Example:</span></span></div>
<pre style="background: rgba(0, 0, 0, 0.05); border: 0px; color: #3a3a3a; font-family: inherit; font-size: 15px; line-height: normal; margin-bottom: 1.5em; max-width: 100%; overflow: auto; padding: 20px;">public class ExampleThread implements Runnable{
public static void main (String[] args){
Thread t = new Thread ();
t.start ();
}
public void run(){
synchronized(object){
{
}
}</pre>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; color: #ff6600; margin: 0px; padding: 0px;"><span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Q #50) What is the disadvantage of Synchronization?</span></span></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Ans:</span> Synchronization is not recommended to implement all the methods. Because if one thread accesses the synchronized code then the next thread should have to wait. So it makes slow performance on the other end.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; color: #ff6600; margin: 0px; padding: 0px;"><span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Q #51) What is meant by Serialization?</span></span></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Ans:</span> Converting a file into a byte stream is known as Serialization. The objects in the file is converted to the bytes for security purposes. For this, we need to implement java.io.Serializable interface. It has no method to define.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
Variables that are marked as transient will not be a part of the serialization. So we can skip the serialization for the variables in the file by using a transient keyword.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; color: #ff6600; margin: 0px; padding: 0px;"><span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Q #52) What is the purpose of a transient variable?</span></span></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Ans:</span> Transient variables are not part of the serialization process. During deserialization, the transient variables values are set to default value. It is not used with static variables.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; color: #ff6600; margin: 0px; padding: 0px; text-decoration-line: underline;"><span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Example:</span></span></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
transient int numbers;</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; color: #ff6600; margin: 0px; padding: 0px;"><span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Q #53) Which methods are used during Serialization and Deserialization process?</span></span></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Ans:</span> ObjectOutputStream and ObjectInputStream classes are higher level java.io. package. We will use them with lower level classes FileOutputStream and FileInputStream.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
ObjectOutputStream.writeObject<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;"> —-></span>Serialize the object and write the serialized object to a file.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
ObjectInputStream.readObject <span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">—></span> Reads the file and deserializes the object.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
To be serialized, an object must implement the serializable interface. If superclass implements Serializable, then the subclass will automatically be serializable.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; color: #ff6600; margin: 0px; padding: 0px;"><span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Q #54) What is the purpose of a Volatile Variable?</span></span></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Ans:</span> Volatile variable values are always read from the main memory and not from thread's cache memory. This is used mainly during synchronization. It is applicable only for variables.</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; color: #ff6600; margin: 0px; padding: 0px; text-decoration-line: underline;"><span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Example:</span></span></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
volatile int number;</div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; color: #ff6600; margin: 0px; padding: 0px;"><span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Q #55) Difference between Serialization and Deserialization in Java.</span></span></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Ans:</span> <span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">These are the difference between serialization and deserialization in java:</span></div>
<table class="tablepress tablepress-id-151" id="tablepress-151" style="background-color: white; border-collapse: collapse; border-spacing: 0px; border: none; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin: 0px 0px 1em; padding: 0px; width: 758px;"><thead style="border: 0px; margin: 0px; padding: 0px;">
<tr class="row-1 odd" style="border: 0px; margin: 0px; padding: 0px;"><th class="column-1" style="background: 0px 0px rgb(217, 237, 247); border-bottom: 1px solid rgb(221, 221, 221); border-image: initial; border-left: none; border-right: none; border-top: none; float: none !important; margin: 0px; padding: 8px; text-align: left; vertical-align: middle;">Serialization</th><th class="column-2" style="background: 0px 0px rgb(217, 237, 247); border-bottom: 1px solid rgb(221, 221, 221); border-image: initial; border-left: none; border-right: none; border-top: none; float: none !important; margin: 0px; padding: 8px; text-align: left; vertical-align: middle;">Deserialization</th></tr>
</thead><tbody class="row-hover" style="border: 0px; margin: 0px; padding: 0px;">
<tr class="row-2 even" style="border: 0px; margin: 0px; padding: 0px;"><td class="column-1" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px 0px; background-repeat: initial; background-size: initial; border-bottom: none; border-image: initial; border-left: none; border-right: none; border-top: 0px; float: none !important; margin: 0px; padding: 8px; vertical-align: top;">Serialization is the process which is used to convert the objects into byte stream</td><td class="column-2" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px 0px; background-repeat: initial; background-size: initial; border-bottom: none; border-image: initial; border-left: none; border-right: none; border-top: 0px; float: none !important; margin: 0px; padding: 8px; vertical-align: top;">Deserialization is the opposite process of serialization where we can get the objects back from the byte stream.</td></tr>
<tr class="row-3 odd" style="border: 0px; margin: 0px; padding: 0px;"><td class="column-1" style="background: 0px 0px rgb(249, 249, 249); border-bottom: none; border-image: initial; border-left: none; border-right: none; border-top: 1px solid rgb(221, 221, 221); float: none !important; margin: 0px; padding: 8px; vertical-align: top;">An object is serialized by writing it an ObjectOutputStream.</td><td class="column-2" style="background: 0px 0px rgb(249, 249, 249); border-bottom: none; border-image: initial; border-left: none; border-right: none; border-top: 1px solid rgb(221, 221, 221); float: none !important; margin: 0px; padding: 8px; vertical-align: top;">An object is deserialized by reading it from an ObjectInputStream.</td></tr>
</tbody></table>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; color: #ff6600; margin: 0px; padding: 0px;"><span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Q #56) What is SerialVersionUID?</span></span></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;"></span></div>
<div style="background-color: white; border: 0px; color: #3a3a3a; font-family: "Work Sans", sans-serif; font-size: 15px; margin-bottom: 1.4em; padding: 0px;">
<span style="border: 0px; font-weight: 700; margin: 0px; padding: 0px;">Ans:</span> Whenever an object is Serialized, the object is stamped with a version ID number for the object class. This ID is called the SerialVersionUID. This is used during deserialization to verify that the sender and receiver that are compatible with the Serialization.</div>
</div>
Bagadhi Sateeshhttp://www.blogger.com/profile/16786636572407672825noreply@blogger.com1tag:blogger.com,1999:blog-8352540103162095489.post-23693062091927897132018-09-29T14:15:00.003+05:302018-09-29T14:15:36.183+05:30Java program to WRITE A CSV FILE<div dir="ltr" style="text-align: left;" trbidi="on">
import java.io.File;<br />
import java.io.FileNotFoundException;<br />
import java.io.PrintWriter;<br />
<br />
<br />
public class CSVwrite {<br />
public static void main(String[]args) throws FileNotFoundException{<br />
PrintWriter pw = new PrintWriter(new File("abc.csv"));<br />
StringBuilder sb = new StringBuilder();<br />
sb.append("id");<br />
sb.append(',');<br />
sb.append("Name");<br />
sb.append('\n');<br />
<br />
sb.append("1");<br />
sb.append(',');<br />
sb.append("sateesh bagadhi");<br />
sb.append('\n');<br />
<br />
pw.write(sb.toString());<br />
pw.close();<br />
System.out.println("done!");<br />
}<br />
}<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjXyhFAioeW1YDJTw7tkqvjaNdSyhe2OQ-gKeeYWxam0WczLmfmxJSyj72ixV6IAbK2Vlr1nC0LyA9i5K4Xq0LIRzuPnjha4vbx-iE76rxmDh6ghx-Gdwp6IPPzO7mHJ4hk-z2xrfiwz1Q/s1600/Untitled.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="379" data-original-width="676" height="223" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjXyhFAioeW1YDJTw7tkqvjaNdSyhe2OQ-gKeeYWxam0WczLmfmxJSyj72ixV6IAbK2Vlr1nC0LyA9i5K4Xq0LIRzuPnjha4vbx-iE76rxmDh6ghx-Gdwp6IPPzO7mHJ4hk-z2xrfiwz1Q/s400/Untitled.png" width="400" /></a></div>
<br /></div>
Bagadhi Sateeshhttp://www.blogger.com/profile/16786636572407672825noreply@blogger.com0tag:blogger.com,1999:blog-8352540103162095489.post-30491744665270205872018-09-29T13:59:00.000+05:302018-09-29T13:59:05.315+05:30Java program to read CSV FILE<div dir="ltr" style="text-align: left;" trbidi="on">
import java.io.*;<br />
<br />
public class readfile {<br />
public static void main(String x[]) throws IOException{<br />
int i=0;<br />
BufferedReader b=new BufferedReader(new FileReader("cs.csv"));<br />
String[] user=new String[50000];<br />
String line="";<br />
while ((line = b.readLine()) != null)<br />
{<br />
user[i]=line;<br />
System.out.println(user[i]); <br />
i++; <br />
}<br />
}<br />
}<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhMWjWjqcU94Q1TCR3CMeh-ixgg_6oCLJoaACpPsaF5K-5k_72XmfplzLadbdkFk1IzRMFe9am0_h2PObgR43qP_8Du4IMyqijzsoBTS_SxmTdXK7xRXIAn08Rt1GocYt1B-YQLpfTKxZg/s1600/Untitled.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="727" data-original-width="891" height="261" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhMWjWjqcU94Q1TCR3CMeh-ixgg_6oCLJoaACpPsaF5K-5k_72XmfplzLadbdkFk1IzRMFe9am0_h2PObgR43qP_8Du4IMyqijzsoBTS_SxmTdXK7xRXIAn08Rt1GocYt1B-YQLpfTKxZg/s320/Untitled.png" width="320" /></a></div>
<br /></div>
Bagadhi Sateeshhttp://www.blogger.com/profile/16786636572407672825noreply@blogger.com0tag:blogger.com,1999:blog-8352540103162095489.post-31588197104935821792018-09-28T13:04:00.000+05:302018-09-28T13:58:21.642+05:30JAVA FILES<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<div class="MsoNormal" style="background: white; line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;">
</div>
<div class="MsoNormal" style="background: white; line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;">
<b><span style="color: darkslategrey; font-family: "verdana" , "sans-serif"; font-size: large;">Java I/O</span></b><span style="color: black; font-family: "verdana" , "sans-serif";"><span style="font-size: large;"><b> </b></span>(Input and Output) is used <i>to
process the input</i> and <i>produce the output</i>.<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;">
<span style="color: black; font-family: "verdana" , "sans-serif";">Java uses the concept
of a stream to make I/O operation fast. The java.io package contains all the
classes required for input and output operations.<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;">
<span style="color: black; font-family: "verdana" , "sans-serif";">We can perform </span><b><span style="color: darkslategrey; font-family: "verdana" , "sans-serif";">file handling in Java</span></b><span style="color: black; font-family: "verdana" , "sans-serif";"> by Java I/O API.<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 15.6pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 2;">
<span style="color: #610b38; font-family: "helvetica" , "sans-serif";"><br /></span>
<span style="color: #610b38; font-family: "helvetica" , "sans-serif";"><span style="font-size: large;"><b>Stream</b></span><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;">
<span style="color: black; font-family: "verdana" , "sans-serif";">A stream is a
sequence of data. In Java, a stream is composed of bytes. It's called a stream
because it is like a stream of water that continues to flow.<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;">
<span style="color: black; font-family: "verdana" , "sans-serif";">In Java, 3 streams
are created for us automatically. All these streams are attached with the
console.<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;">
<b><span style="color: darkslategrey; font-family: "verdana" , "sans-serif";">1) System.out: </span></b><span style="color: black; font-family: "verdana" , "sans-serif";">standard output
stream<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;">
<b><span style="color: darkslategrey; font-family: "verdana" , "sans-serif";">2) System.in: </span></b><span style="color: black; font-family: "verdana" , "sans-serif";">standard input stream<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;">
<b><span style="color: darkslategrey; font-family: "verdana" , "sans-serif";">3) System.err: </span></b><span style="color: black; font-family: "verdana" , "sans-serif";">standard error stream<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;">
<span style="color: black; font-family: "verdana" , "sans-serif";">Let's see the code to
print </span><b><span style="color: darkslategrey; font-family: "verdana" , "sans-serif";">output and an error</span></b><span style="color: black; font-family: "verdana" , "sans-serif";"> message to the console.<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 26.05pt; margin-bottom: .0001pt; margin: 0cm; mso-list: l5 level1 lfo1; tab-stops: list 36.0pt; text-indent: -18.0pt;">
<!--[if !supportLists]--><span style="color: black; font-family: "verdana" , "sans-serif";"><span style="mso-list: Ignore;">1.<span style="font-family: "times new roman"; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"> </span></span></span><!--[endif]--><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;">System.out.println(</span><span style="color: blue; font-family: "verdana" , "sans-serif";">"simple message"</span><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;">); </span><span style="color: black; font-family: "verdana" , "sans-serif";"><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 26.05pt; margin-bottom: 9.95pt; margin-left: 0cm; margin-right: 0cm; margin-top: 0cm; mso-list: l5 level1 lfo1; tab-stops: list 36.0pt; text-indent: -18.0pt;">
<!--[if !supportLists]--><span style="color: black; font-family: "verdana" , "sans-serif";"><span style="mso-list: Ignore;">2.<span style="font-family: "times new roman"; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"> </span></span></span><!--[endif]--><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;">System.err.println(</span><span style="color: blue; font-family: "verdana" , "sans-serif";">"error message"</span><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;">); </span><span style="color: black; font-family: "verdana" , "sans-serif";"><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;">
<span style="color: black; font-family: "verdana" , "sans-serif";">Let's see the code to
get </span><b><span style="color: darkslategrey; font-family: "verdana" , "sans-serif";">input</span></b><span style="color: black; font-family: "verdana" , "sans-serif";"> from console.<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 26.05pt; margin-bottom: .0001pt; margin: 0cm; mso-list: l4 level1 lfo2; tab-stops: list 36.0pt; text-indent: -18.0pt;">
<!--[if !supportLists]--><span style="color: black; font-family: "verdana" , "sans-serif";"><span style="mso-list: Ignore;">1.<span style="font-family: "times new roman"; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"> </span></span></span><!--[endif]--><b><span style="color: #006699; font-family: "verdana" , "sans-serif";">int</span></b><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;"> i=System.in.read();</span><span style="color: #008200; font-family: "verdana" , "sans-serif";">//returns ASCII code of 1st character</span><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;"> </span><span style="color: black; font-family: "verdana" , "sans-serif";"><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 26.05pt; margin-bottom: 9.95pt; margin-left: 0cm; margin-right: 0cm; margin-top: 0cm; mso-list: l4 level1 lfo2; tab-stops: list 36.0pt; text-indent: -18.0pt;">
<!--[if !supportLists]--><span style="color: black; font-family: "verdana" , "sans-serif";"><span style="mso-list: Ignore;">2.<span style="font-family: "times new roman"; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"> </span></span></span><!--[endif]--><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;">System.out.println((</span><b><span style="color: #006699; font-family: "verdana" , "sans-serif";">char</span></b><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;">)i);</span><span style="color: #008200; font-family: "verdana" , "sans-serif";">//will print the character</span><span style="color: black; font-family: "verdana" , "sans-serif";"><o:p></o:p></span></div>
<h2 style="background: white; line-height: 15.6pt;">
<span style="color: #610b38; font-family: "helvetica" , "sans-serif"; font-size: small; font-weight: normal;">OutputStream vs InputStream<o:p></o:p></span></h2>
<div style="background: white;">
<span style="color: black; font-family: "verdana" , "sans-serif";">The explanation of OutputStream and InputStream classes are given
below:<o:p></o:p></span></div>
<h3 style="background: white; line-height: 15.6pt;">
<span style="color: #610b4b; font-family: "helvetica" , "sans-serif"; font-size: small; font-weight: normal;">OutputStream<o:p></o:p></span></h3>
<div style="background: white;">
<span style="color: black; font-family: "verdana" , "sans-serif";">Java application uses an output stream to write data to a
destination; it may be a file, an array, peripheral device or socket.<o:p></o:p></span></div>
<h3 style="background: white; line-height: 15.6pt;">
<span style="color: #610b4b; font-family: "helvetica" , "sans-serif"; font-size: small; font-weight: normal;">InputStream<o:p></o:p></span></h3>
<div style="background: white;">
<span style="color: black; font-family: "verdana" , "sans-serif";">Java application uses an input stream to read data from a source;
it may be a file, an array, peripheral device or socket.<o:p></o:p></span></div>
<div style="background: white;">
<span style="color: black; font-family: "verdana" , "sans-serif";">Let's understand the working of Java OutputStream and InputStream
by the figure given below.<o:p></o:p></span><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiKW9DccW6HUbqnqFWimx6J1xozFpAPkjplSwII9S0MCCWOJSm99O0LsktIUfuHggbVjlGMNdfo6xYCu9Tj9Gkdrs8s5fUqH5YmoJT_olptHUbHPzN6KWSWHokYlr4HXTxbfXjq0ri0Up8/s1600/Untitled.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="223" data-original-width="690" height="127" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiKW9DccW6HUbqnqFWimx6J1xozFpAPkjplSwII9S0MCCWOJSm99O0LsktIUfuHggbVjlGMNdfo6xYCu9Tj9Gkdrs8s5fUqH5YmoJT_olptHUbHPzN6KWSWHokYlr4HXTxbfXjq0ri0Up8/s400/Untitled.png" width="400" /></a></div>
<span style="color: black; font-family: "verdana" , "sans-serif";"><br /></span></div>
<div class="MsoNormal">
<span style="line-height: 115%;"><!--[if gte vml 1]><v:shapetype id="_x0000_t75"
coordsize="21600,21600" o:spt="75" o:preferrelative="t" path="m@4@5l@4@11@9@11@9@5xe"
filled="f" stroked="f">
<v:stroke joinstyle="miter"/>
<v:formulas>
<v:f eqn="if lineDrawn pixelLineWidth 0"/>
<v:f eqn="sum @0 1 0"/>
<v:f eqn="sum 0 0 @1"/>
<v:f eqn="prod @2 1 2"/>
<v:f eqn="prod @3 21600 pixelWidth"/>
<v:f eqn="prod @3 21600 pixelHeight"/>
<v:f eqn="sum @0 0 1"/>
<v:f eqn="prod @6 1 2"/>
<v:f eqn="prod @7 21600 pixelWidth"/>
<v:f eqn="sum @8 21600 0"/>
<v:f eqn="prod @7 21600 pixelHeight"/>
<v:f eqn="sum @10 21600 0"/>
</v:formulas>
<v:path o:extrusionok="f" gradientshapeok="t" o:connecttype="rect"/>
<o:lock v:ext="edit" aspectratio="t"/>
</v:shapetype><v:shape id="Picture_x0020_1" o:spid="_x0000_i1029" type="#_x0000_t75"
alt="Java IO" style='width:514.5pt;height:163.5pt;visibility:visible;
mso-wrap-style:square'>
<v:imagedata src="file:///C:\Users\Student\AppData\Local\Temp\msohtmlclip1\01\clip_image001.png"
o:title="Java IO"/>
</v:shape><![endif]--><!--[if !vml]--><!--[endif]--></span><span style="font-family: "times new roman" , "serif"; line-height: 115%;"><o:p></o:p></span></div>
<div align="center" class="MsoNormal" style="text-align: center;">
<span style="line-height: 115%;">
</span><br />
<hr align="center" noshade="" size="2" style="color: #d4d4d4;" width="100%" />
<span style="line-height: 115%;">
</span></div>
<h2 style="background: white; line-height: 15.6pt;">
<span style="color: #610b38; font-family: "helvetica" , "sans-serif"; font-size: small; font-weight: normal;"><o:p> </o:p></span>OutputStream class</h2>
<div style="background: white;">
<span style="color: black; font-family: "verdana" , "sans-serif";">OutputStream class is an abstract class. It is the superclass of
all classes representing an output stream of bytes. An output stream accepts
output bytes and sends them to some sink.<o:p></o:p></span></div>
<h2 style="background: white; line-height: 15.6pt;">
<span style="color: #610b38; font-family: "helvetica" , "sans-serif"; font-size: small; font-weight: normal;">InputStream class<o:p></o:p></span></h2>
<div style="background: white;">
<span style="color: black; font-family: "verdana" , "sans-serif";">InputStream class is an abstract class. It is the superclass of
all classes representing an input stream of bytes.<o:p></o:p></span></div>
<h1 style="background: white; line-height: 15.6pt; margin-top: 6.2pt;">
<span style="color: #610b38; font-family: "helvetica" , "sans-serif"; font-size: small; font-weight: normal;">Java
ByteArrayOutputStream Class<o:p></o:p></span></h1>
<div style="background: white;">
<span style="color: black; font-family: "verdana" , "sans-serif";">Java ByteArrayOutputStream class is used to </span><strong><span style="color: darkslategrey; font-family: "verdana" , "sans-serif";">write
common data</span></strong><span style="color: black; font-family: "verdana" , "sans-serif";"> into multiple files. In this stream, the data is written
into a byte </span><a href="https://www.javatpoint.com/array-in-java"><span style="color: green; font-family: "verdana" , "sans-serif";">array</span></a><span style="color: black; font-family: "verdana" , "sans-serif";"> which can be written to multiple
streams later.<o:p></o:p></span></div>
<div style="background: white;">
<span style="color: black; font-family: "verdana" , "sans-serif";">The ByteArrayOutputStream holds a copy of data and forwards it to
multiple streams.<o:p></o:p></span></div>
<div style="background: white;">
<span style="color: black; font-family: "verdana" , "sans-serif";">The buffer of ByteArrayOutputStream automatically grows according
to data.<o:p></o:p></span></div>
<div align="center" class="MsoNormal" style="text-align: center;">
<span style="line-height: 115%;">
</span><br />
<hr align="center" noshade="" size="2" style="color: #d4d4d4;" width="100%" />
<span style="line-height: 115%;">
</span></div>
<h2 style="background: white; line-height: 15.6pt;">
<span style="color: #610b38; font-family: "helvetica" , "sans-serif"; font-size: small; font-weight: normal;">Java ByteArrayOutputStream class declaration<o:p></o:p></span></h2>
<div style="background: white;">
<span style="color: black; font-family: "verdana" , "sans-serif";">Let's see the declaration for Java.io.ByteArrayOutputStream class:<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 26.05pt; margin-bottom: .0001pt; margin: 0cm; mso-list: l2 level1 lfo3; tab-stops: list 36.0pt; text-indent: -18.0pt;">
<!--[if !supportLists]--><span style="color: black; font-family: "verdana" , "sans-serif";"><span style="mso-list: Ignore;">1.<span style="font-family: "times new roman"; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"> </span></span></span><!--[endif]--><span class="keyword"><b><span style="border: 1pt none; color: #006699; font-family: "verdana" , "sans-serif"; padding: 0cm;">public</span></b></span><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;"> </span><span class="keyword"><b><span style="border: 1pt none; color: #006699; font-family: "verdana" , "sans-serif"; padding: 0cm;">class</span></b></span><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;"> ByteArrayOutputStream </span><span class="keyword"><b><span style="border: 1pt none; color: #006699; font-family: "verdana" , "sans-serif"; padding: 0cm;">extends</span></b></span><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;"> OutputStream </span><span style="color: black; font-family: "verdana" , "sans-serif";"><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 15.6pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 2;">
<span style="color: #610b38; font-family: "helvetica" , "sans-serif";">Example of Java ByteArrayOutputStream<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;">
<span style="color: black; font-family: "verdana" , "sans-serif";">Let's see a simple
example of </span><a href="https://www.javatpoint.com/java-tutorial"><span style="color: green; font-family: "verdana" , "sans-serif"; text-decoration: none;">java</span></a><span style="color: black; font-family: "verdana" , "sans-serif";"> ByteArrayOutputStream class to
write common data into 2 files: f1.txt and f2.txt.<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 26.05pt; margin-bottom: .0001pt; margin: 0cm; mso-list: l0 level1 lfo4; tab-stops: list 36.0pt; text-indent: -18.0pt;">
<!--[if !supportLists]--><span style="color: black; font-family: "verdana" , "sans-serif";"><span style="mso-list: Ignore;">1.<span style="font-family: "times new roman"; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"> </span></span></span><!--[endif]--><b><span style="color: #006699; font-family: "verdana" , "sans-serif";">package</span></b><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;"> Mypack; </span><span style="color: black; font-family: "verdana" , "sans-serif";"><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 26.05pt; margin-bottom: .0001pt; margin: 0cm; mso-list: l0 level1 lfo4; tab-stops: list 36.0pt; text-indent: -18.0pt;">
<!--[if !supportLists]--><span style="color: black; font-family: "verdana" , "sans-serif";"><span style="mso-list: Ignore;">2.<span style="font-family: "times new roman"; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"> </span></span></span><!--[endif]--><b><span style="color: #006699; font-family: "verdana" , "sans-serif";">import</span></b><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;"> java.io.*; </span><span style="color: black; font-family: "verdana" , "sans-serif";"><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 26.05pt; margin-bottom: .0001pt; margin: 0cm; mso-list: l0 level1 lfo4; tab-stops: list 36.0pt; text-indent: -18.0pt;">
<!--[if !supportLists]--><span style="color: black; font-family: "verdana" , "sans-serif";"><span style="mso-list: Ignore;">3.<span style="font-family: "times new roman"; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"> </span></span></span><!--[endif]--><b><span style="color: #006699; font-family: "verdana" , "sans-serif";">public</span></b><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;"> </span><b><span style="color: #006699; font-family: "verdana" , "sans-serif";">class</span></b><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;"> DataStreamExample { </span><span style="color: black; font-family: "verdana" , "sans-serif";"><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 26.05pt; margin-bottom: .0001pt; margin: 0cm; mso-list: l0 level1 lfo4; tab-stops: list 36.0pt; text-indent: -18.0pt;">
<!--[if !supportLists]--><span style="color: black; font-family: "verdana" , "sans-serif";"><span style="mso-list: Ignore;">4.<span style="font-family: "times new roman"; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"> </span></span></span><!--[endif]--><b><span style="color: #006699; font-family: "verdana" , "sans-serif";">public</span></b><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;"> </span><b><span style="color: #006699; font-family: "verdana" , "sans-serif";">static</span></b><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;"> </span><b><span style="color: #006699; font-family: "verdana" , "sans-serif";">void</span></b><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;"> main(String args[])</span><b><span style="color: #006699; font-family: "verdana" , "sans-serif";">throws</span></b><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;"> Exception{ </span><span style="color: black; font-family: "verdana" , "sans-serif";"><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 26.05pt; margin-bottom: .0001pt; margin: 0cm; mso-list: l0 level1 lfo4; tab-stops: list 36.0pt; text-indent: -18.0pt;">
<!--[if !supportLists]--><span style="color: black; font-family: "verdana" , "sans-serif";"><span style="mso-list: Ignore;">5.<span style="font-family: "times new roman"; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"> </span></span></span><!--[endif]--><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;"> FileOutputStream fout1=</span><b><span style="color: #006699; font-family: "verdana" , "sans-serif";">new</span></b><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;"> FileOutputStream(</span><span style="color: blue; font-family: "verdana" , "sans-serif";">"D:\\f1.txt"</span><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;">); </span><span style="color: black; font-family: "verdana" , "sans-serif";"><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 26.05pt; margin-bottom: .0001pt; margin: 0cm; mso-list: l0 level1 lfo4; tab-stops: list 36.0pt; text-indent: -18.0pt;">
<!--[if !supportLists]--><span style="color: black; font-family: "verdana" , "sans-serif";"><span style="mso-list: Ignore;">6.<span style="font-family: "times new roman"; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"> </span></span></span><!--[endif]--><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;"> FileOutputStream fout2=</span><b><span style="color: #006699; font-family: "verdana" , "sans-serif";">new</span></b><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;"> FileOutputStream(</span><span style="color: blue; font-family: "verdana" , "sans-serif";">"D:\\f2.txt"</span><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;">); </span><span style="color: black; font-family: "verdana" , "sans-serif";"><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 26.05pt; margin-bottom: .0001pt; margin: 0cm; mso-list: l0 level1 lfo4; tab-stops: list 36.0pt; text-indent: -18.0pt;">
<!--[if !supportLists]--><span style="color: black; font-family: "verdana" , "sans-serif";"><span style="mso-list: Ignore;">7.<span style="font-family: "times new roman"; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"> </span></span></span><!--[endif]--><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;"> </span><span style="color: black; font-family: "verdana" , "sans-serif";"><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 26.05pt; margin-bottom: .0001pt; margin: 0cm; mso-list: l0 level1 lfo4; tab-stops: list 36.0pt; text-indent: -18.0pt;">
<!--[if !supportLists]--><span style="color: black; font-family: "verdana" , "sans-serif";"><span style="mso-list: Ignore;">8.<span style="font-family: "times new roman"; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"> </span></span></span><!--[endif]--><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;"> ByteArrayOutputStream bout=</span><b><span style="color: #006699; font-family: "verdana" , "sans-serif";">new</span></b><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;"> ByteArrayOutputStream(); </span><span style="color: black; font-family: "verdana" , "sans-serif";"><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 26.05pt; margin-bottom: .0001pt; margin: 0cm; mso-list: l0 level1 lfo4; tab-stops: list 36.0pt; text-indent: -18.0pt;">
<!--[if !supportLists]--><span style="color: black; font-family: "verdana" , "sans-serif";"><span style="mso-list: Ignore;">9.<span style="font-family: "times new roman"; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"> </span></span></span><!--[endif]--><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;"> bout.write(</span><span style="color: #c00000; font-family: "verdana" , "sans-serif";">65</span><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;">); </span><span style="color: black; font-family: "verdana" , "sans-serif";"><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 26.05pt; margin-bottom: .0001pt; margin: 0cm; mso-list: l0 level1 lfo4; tab-stops: list 36.0pt; text-indent: -18.0pt;">
<!--[if !supportLists]--><span style="color: black; font-family: "verdana" , "sans-serif";"><span style="mso-list: Ignore;">10.<span style="font-family: "times new roman"; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;">
</span></span></span><!--[endif]--><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;"> bout.writeTo(fout1); </span><span style="color: black; font-family: "verdana" , "sans-serif";"><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 26.05pt; margin-bottom: .0001pt; margin: 0cm; mso-list: l0 level1 lfo4; tab-stops: list 36.0pt; text-indent: -18.0pt;">
<!--[if !supportLists]--><span style="color: black; font-family: "verdana" , "sans-serif";"><span style="mso-list: Ignore;">11.<span style="font-family: "times new roman"; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;">
</span></span></span><!--[endif]--><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;"> bout.writeTo(fout2); </span><span style="color: black; font-family: "verdana" , "sans-serif";"><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 26.05pt; margin-bottom: .0001pt; margin: 0cm; mso-list: l0 level1 lfo4; tab-stops: list 36.0pt; text-indent: -18.0pt;">
<!--[if !supportLists]--><span style="color: black; font-family: "verdana" , "sans-serif";"><span style="mso-list: Ignore;">12.<span style="font-family: "times new roman"; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;">
</span></span></span><!--[endif]--><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;"> </span><span style="color: black; font-family: "verdana" , "sans-serif";"><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 26.05pt; margin-bottom: .0001pt; margin: 0cm; mso-list: l0 level1 lfo4; tab-stops: list 36.0pt; text-indent: -18.0pt;">
<!--[if !supportLists]--><span style="color: black; font-family: "verdana" , "sans-serif";"><span style="mso-list: Ignore;">13.<span style="font-family: "times new roman"; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;">
</span></span></span><!--[endif]--><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;"> bout.flush(); </span><span style="color: black; font-family: "verdana" , "sans-serif";"><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 26.05pt; margin-bottom: .0001pt; margin: 0cm; mso-list: l0 level1 lfo4; tab-stops: list 36.0pt; text-indent: -18.0pt;">
<!--[if !supportLists]--><span style="color: black; font-family: "verdana" , "sans-serif";"><span style="mso-list: Ignore;">14.<span style="font-family: "times new roman"; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;">
</span></span></span><!--[endif]--><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;"> bout.close();</span><span style="color: #008200; font-family: "verdana" , "sans-serif";">//has no effect </span><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;"> </span><span style="color: black; font-family: "verdana" , "sans-serif";"><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 26.05pt; margin-bottom: .0001pt; margin: 0cm; mso-list: l0 level1 lfo4; tab-stops: list 36.0pt; text-indent: -18.0pt;">
<!--[if !supportLists]--><span style="color: black; font-family: "verdana" , "sans-serif";"><span style="mso-list: Ignore;">15.<span style="font-family: "times new roman"; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;">
</span></span></span><!--[endif]--><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;"> System.out.println(</span><span style="color: blue; font-family: "verdana" , "sans-serif";">"Success..."</span><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;">); </span><span style="color: black; font-family: "verdana" , "sans-serif";"><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 26.05pt; margin-bottom: .0001pt; margin: 0cm; mso-list: l0 level1 lfo4; tab-stops: list 36.0pt; text-indent: -18.0pt;">
<!--[if !supportLists]--><span style="color: black; font-family: "verdana" , "sans-serif";"><span style="mso-list: Ignore;">16.<span style="font-family: "times new roman"; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;">
</span></span></span><!--[endif]--><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;"> } </span><span style="color: black; font-family: "verdana" , "sans-serif";"><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 26.05pt; margin-bottom: 9.95pt; margin-left: 0cm; margin-right: 0cm; margin-top: 0cm; mso-list: l0 level1 lfo4; tab-stops: list 36.0pt; text-indent: -18.0pt;">
<!--[if !supportLists]--><span style="color: black; font-family: "verdana" , "sans-serif";"><span style="mso-list: Ignore;">17.<span style="font-family: "times new roman"; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;">
</span></span></span><!--[endif]--><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;"> } </span><span style="color: black; font-family: "verdana" , "sans-serif";"><o:p></o:p></span></div>
<h1 style="background: white; line-height: 15.6pt; margin-top: 3.65pt;">
<span style="color: #610b38; font-family: "helvetica" , "sans-serif"; font-size: small; font-weight: normal;">Java Writer<o:p></o:p></span></h1>
<div style="background: white;">
<span style="color: black; font-family: "verdana" , "sans-serif";">It is an </span><a href="https://www.javatpoint.com/abstract-class-in-java"><span style="color: green; font-family: "verdana" , "sans-serif";">abstract</span></a><span style="color: black; font-family: "verdana" , "sans-serif";"> class
for writing to character streams. The methods that a subclass must implement
are write(char[], int, int), flush(), and close(). Most subclasses will
override some of the methods defined here to provide higher efficiency,
functionality or both.<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-left: -14.2pt; tab-stops: 14.2pt; text-indent: 14.2pt;">
<br /></div>
<div class="MsoNormal" style="background: white; line-height: 15.6pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 2;">
<span style="color: #610b38; font-family: "helvetica" , "sans-serif";">Java Writer Example<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 26.05pt; margin-bottom: .0001pt; margin: 0cm; mso-list: l1 level1 lfo5; tab-stops: list 36.0pt; text-indent: -18.0pt;">
<!--[if !supportLists]--><span style="color: black; font-family: "verdana" , "sans-serif";"><span style="mso-list: Ignore;">1.<span style="font-family: "times new roman"; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"> </span></span></span><!--[endif]--><b><span style="color: #006699; font-family: "verdana" , "sans-serif";">import</span></b><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;"> java.io.*; </span><span style="color: black; font-family: "verdana" , "sans-serif";"><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 26.05pt; margin-bottom: .0001pt; margin: 0cm; mso-list: l1 level1 lfo5; tab-stops: list 36.0pt; text-indent: -18.0pt;">
<!--[if !supportLists]--><span style="color: black; font-family: "verdana" , "sans-serif";"><span style="mso-list: Ignore;">2.<span style="font-family: "times new roman"; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"> </span></span></span><!--[endif]--><b><span style="color: #006699; font-family: "verdana" , "sans-serif";">public</span></b><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;"> </span><b><span style="color: #006699; font-family: "verdana" , "sans-serif";">class</span></b><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;"> WriterExample { </span><span style="color: black; font-family: "verdana" , "sans-serif";"><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 26.05pt; margin-bottom: .0001pt; margin: 0cm; mso-list: l1 level1 lfo5; tab-stops: list 36.0pt; text-indent: -18.0pt;">
<!--[if !supportLists]--><span style="color: black; font-family: "verdana" , "sans-serif";"><span style="mso-list: Ignore;">3.<span style="font-family: "times new roman"; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"> </span></span></span><!--[endif]--><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;"> </span><b><span style="color: #006699; font-family: "verdana" , "sans-serif";">public</span></b><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;"> </span><b><span style="color: #006699; font-family: "verdana" , "sans-serif";">static</span></b><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;"> </span><b><span style="color: #006699; font-family: "verdana" , "sans-serif";">void</span></b><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;"> main(String[] args) { </span><span style="color: black; font-family: "verdana" , "sans-serif";"><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 26.05pt; margin-bottom: .0001pt; margin: 0cm; mso-list: l1 level1 lfo5; tab-stops: list 36.0pt; text-indent: -18.0pt;">
<!--[if !supportLists]--><span style="color: black; font-family: "verdana" , "sans-serif";"><span style="mso-list: Ignore;">4.<span style="font-family: "times new roman"; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"> </span></span></span><!--[endif]--><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;"> </span><b><span style="color: #006699; font-family: "verdana" , "sans-serif";">try</span></b><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;"> { </span><span style="color: black; font-family: "verdana" , "sans-serif";"><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 26.05pt; margin-bottom: .0001pt; margin: 0cm; mso-list: l1 level1 lfo5; tab-stops: list 36.0pt; text-indent: -18.0pt;">
<!--[if !supportLists]--><span style="color: black; font-family: "verdana" , "sans-serif";"><span style="mso-list: Ignore;">5.<span style="font-family: "times new roman"; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"> </span></span></span><!--[endif]--><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;"> Writer w = </span><b><span style="color: #006699; font-family: "verdana" , "sans-serif";">new</span></b><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;"> FileWriter(</span><span style="color: blue; font-family: "verdana" , "sans-serif";">"output.txt"</span><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;">); </span><span style="color: black; font-family: "verdana" , "sans-serif";"><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 26.05pt; margin-bottom: .0001pt; margin: 0cm; mso-list: l1 level1 lfo5; tab-stops: list 36.0pt; text-indent: -18.0pt;">
<!--[if !supportLists]--><span style="color: black; font-family: "verdana" , "sans-serif";"><span style="mso-list: Ignore;">6.<span style="font-family: "times new roman"; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"> </span></span></span><!--[endif]--><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;"> String content = </span><span style="color: blue; font-family: "verdana" , "sans-serif";">"I love my country"</span><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;">; </span><span style="color: black; font-family: "verdana" , "sans-serif";"><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 26.05pt; margin-bottom: .0001pt; margin: 0cm; mso-list: l1 level1 lfo5; tab-stops: list 36.0pt; text-indent: -18.0pt;">
<!--[if !supportLists]--><span style="color: black; font-family: "verdana" , "sans-serif";"><span style="mso-list: Ignore;">7.<span style="font-family: "times new roman"; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"> </span></span></span><!--[endif]--><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;"> w.write(content); </span><span style="color: black; font-family: "verdana" , "sans-serif";"><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 26.05pt; margin-bottom: .0001pt; margin: 0cm; mso-list: l1 level1 lfo5; tab-stops: list 36.0pt; text-indent: -18.0pt;">
<!--[if !supportLists]--><span style="color: black; font-family: "verdana" , "sans-serif";"><span style="mso-list: Ignore;">8.<span style="font-family: "times new roman"; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"> </span></span></span><!--[endif]--><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;"> w.close(); </span><span style="color: black; font-family: "verdana" , "sans-serif";"><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 26.05pt; margin-bottom: .0001pt; margin: 0cm; mso-list: l1 level1 lfo5; tab-stops: list 36.0pt; text-indent: -18.0pt;">
<!--[if !supportLists]--><span style="color: black; font-family: "verdana" , "sans-serif";"><span style="mso-list: Ignore;">9.<span style="font-family: "times new roman"; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"> </span></span></span><!--[endif]--><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;"> System.out.println(</span><span style="color: blue; font-family: "verdana" , "sans-serif";">"Done"</span><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;">); </span><span style="color: black; font-family: "verdana" , "sans-serif";"><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 26.05pt; margin-bottom: .0001pt; margin: 0cm; mso-list: l1 level1 lfo5; tab-stops: list 36.0pt; text-indent: -18.0pt;">
<!--[if !supportLists]--><span style="color: black; font-family: "verdana" , "sans-serif";"><span style="mso-list: Ignore;">10.<span style="font-family: "times new roman"; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;">
</span></span></span><!--[endif]--><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;"> } </span><b><span style="color: #006699; font-family: "verdana" , "sans-serif";">catch</span></b><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;"> (IOException e) { </span><span style="color: black; font-family: "verdana" , "sans-serif";"><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 26.05pt; margin-bottom: .0001pt; margin: 0cm; mso-list: l1 level1 lfo5; tab-stops: list 36.0pt; text-indent: -18.0pt;">
<!--[if !supportLists]--><span style="color: black; font-family: "verdana" , "sans-serif";"><span style="mso-list: Ignore;">11.<span style="font-family: "times new roman"; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;">
</span></span></span><!--[endif]--><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;"> e.printStackTrace(); </span><span style="color: black; font-family: "verdana" , "sans-serif";"><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 26.05pt; margin-bottom: .0001pt; margin: 0cm; mso-list: l1 level1 lfo5; tab-stops: list 36.0pt; text-indent: -18.0pt;">
<!--[if !supportLists]--><span style="color: black; font-family: "verdana" , "sans-serif";"><span style="mso-list: Ignore;">12.<span style="font-family: "times new roman"; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;">
</span></span></span><!--[endif]--><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;"> } </span><span style="color: black; font-family: "verdana" , "sans-serif";"><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 26.05pt; margin-bottom: .0001pt; margin: 0cm; mso-list: l1 level1 lfo5; tab-stops: list 36.0pt; text-indent: -18.0pt;">
<!--[if !supportLists]--><span style="color: black; font-family: "verdana" , "sans-serif";"><span style="mso-list: Ignore;">13.<span style="font-family: "times new roman"; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;">
</span></span></span><!--[endif]--><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;"> } </span><span style="color: black; font-family: "verdana" , "sans-serif";"><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 26.05pt; margin-bottom: 9.95pt; margin-left: 0cm; margin-right: 0cm; margin-top: 0cm; mso-list: l1 level1 lfo5; tab-stops: list 36.0pt; text-indent: -18.0pt;">
<!--[if !supportLists]--><span style="color: black; font-family: "verdana" , "sans-serif";"><span style="mso-list: Ignore;">14.<span style="font-family: "times new roman"; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;">
</span></span></span><!--[endif]--><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;">} </span><span style="color: black; font-family: "verdana" , "sans-serif";"><o:p></o:p></span></div>
<h1 style="background: white; line-height: 15.6pt; margin-top: 6.2pt;">
<span style="color: #610b38; font-family: "helvetica" , "sans-serif"; font-size: small; font-weight: normal;">Java Reader<o:p></o:p></span></h1>
<div style="background: white;">
<a href="https://www.javatpoint.com/java-tutorial"><span style="color: green; font-family: "verdana" , "sans-serif";">Java</span></a><span style="color: black; font-family: "verdana" , "sans-serif";"> Reader is an </span><a href="https://www.javatpoint.com/abstract-class-in-java"><span style="color: green; font-family: "verdana" , "sans-serif";">abstract class</span></a><span style="color: black; font-family: "verdana" , "sans-serif";"> for
reading character </span><a href="https://www.javatpoint.com/java-8-stream"><span style="color: green; font-family: "verdana" , "sans-serif";">streams</span></a><span style="color: black; font-family: "verdana" , "sans-serif";">. The only methods that a subclass must
implement are read(char[], int, int) and close(). Most subclasses, however,
will <a href="https://www.javatpoint.com/method-overriding-in-java"><span style="color: green;">override</span></a>some of the methods to provide higher
efficiency, additional functionality, or both.<o:p></o:p></span></div>
<div style="background: white;">
<span style="color: black; font-family: "verdana" , "sans-serif";">Some of the implementation </span><a href="https://www.javatpoint.com/object-class"><span style="color: green; font-family: "verdana" , "sans-serif";">class</span></a><span style="color: black; font-family: "verdana" , "sans-serif";"> are </span><a href="https://www.javatpoint.com/java-bufferedreader-class"><span style="color: green; font-family: "verdana" , "sans-serif";">BufferedReader</span></a><span style="color: black; font-family: "verdana" , "sans-serif";">, </span><a href="https://www.javatpoint.com/java-chararrayreader-class"><span style="color: green; font-family: "verdana" , "sans-serif";">CharArrayReader</span></a><span style="color: black; font-family: "verdana" , "sans-serif";">, </span><a href="https://www.javatpoint.com/java-filterreader-class"><span style="color: green; font-family: "verdana" , "sans-serif";">FilterReader</span></a><span style="color: black; font-family: "verdana" , "sans-serif";">, </span><a href="https://www.javatpoint.com/Input-from-keyboard-by-InputStreamReader"><span style="color: green; font-family: "verdana" , "sans-serif";">InputStreamReader</span></a><span style="color: black; font-family: "verdana" , "sans-serif";">,
PipedReader, <a href="https://www.javatpoint.com/java-stringreader-class"><span style="color: green;">StringReader</span></a><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 26.05pt; margin-bottom: .0001pt; margin: 0cm; mso-list: l8 level1 lfo6; tab-stops: list 36.0pt; text-indent: -18.0pt;">
<!--[if !supportLists]--><span style="color: black; font-family: "verdana" , "sans-serif";"><span style="mso-list: Ignore;">1.<span style="font-family: "times new roman"; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"> </span></span></span><!--[endif]--><b><span style="color: #006699; font-family: "verdana" , "sans-serif";">import</span></b><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;"> java.io.*; </span><span style="color: black; font-family: "verdana" , "sans-serif";"><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 26.05pt; margin-bottom: .0001pt; margin: 0cm; mso-list: l8 level1 lfo6; tab-stops: list 36.0pt; text-indent: -18.0pt;">
<!--[if !supportLists]--><span style="color: black; font-family: "verdana" , "sans-serif";"><span style="mso-list: Ignore;">2.<span style="font-family: "times new roman"; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"> </span></span></span><!--[endif]--><b><span style="color: #006699; font-family: "verdana" , "sans-serif";">public</span></b><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;"> </span><b><span style="color: #006699; font-family: "verdana" , "sans-serif";">class</span></b><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;"> ReaderExample { </span><span style="color: black; font-family: "verdana" , "sans-serif";"><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 26.05pt; margin-bottom: .0001pt; margin: 0cm; mso-list: l8 level1 lfo6; tab-stops: list 36.0pt; text-indent: -18.0pt;">
<!--[if !supportLists]--><span style="color: black; font-family: "verdana" , "sans-serif";"><span style="mso-list: Ignore;">3.<span style="font-family: "times new roman"; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"> </span></span></span><!--[endif]--><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;"> </span><b><span style="color: #006699; font-family: "verdana" , "sans-serif";">public</span></b><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;"> </span><b><span style="color: #006699; font-family: "verdana" , "sans-serif";">static</span></b><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;"> </span><b><span style="color: #006699; font-family: "verdana" , "sans-serif";">void</span></b><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;"> main(String[] args) { </span><span style="color: black; font-family: "verdana" , "sans-serif";"><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 26.05pt; margin-bottom: .0001pt; margin: 0cm; mso-list: l8 level1 lfo6; tab-stops: list 36.0pt; text-indent: -18.0pt;">
<!--[if !supportLists]--><span style="color: black; font-family: "verdana" , "sans-serif";"><span style="mso-list: Ignore;">4.<span style="font-family: "times new roman"; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"> </span></span></span><!--[endif]--><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;"> </span><b><span style="color: #006699; font-family: "verdana" , "sans-serif";">try</span></b><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;"> { </span><span style="color: black; font-family: "verdana" , "sans-serif";"><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 26.05pt; margin-bottom: .0001pt; margin: 0cm; mso-list: l8 level1 lfo6; tab-stops: list 36.0pt; text-indent: -18.0pt;">
<!--[if !supportLists]--><span style="color: black; font-family: "verdana" , "sans-serif";"><span style="mso-list: Ignore;">5.<span style="font-family: "times new roman"; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"> </span></span></span><!--[endif]--><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;"> Reader reader = </span><b><span style="color: #006699; font-family: "verdana" , "sans-serif";">new</span></b><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;"> FileReader(</span><span style="color: blue; font-family: "verdana" , "sans-serif";">"file.txt"</span><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;">); </span><span style="color: black; font-family: "verdana" , "sans-serif";"><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 26.05pt; margin-bottom: .0001pt; margin: 0cm; mso-list: l8 level1 lfo6; tab-stops: list 36.0pt; text-indent: -18.0pt;">
<!--[if !supportLists]--><span style="color: black; font-family: "verdana" , "sans-serif";"><span style="mso-list: Ignore;">6.<span style="font-family: "times new roman"; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"> </span></span></span><!--[endif]--><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;"> </span><b><span style="color: #006699; font-family: "verdana" , "sans-serif";">int</span></b><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;"> data = reader.read(); </span><span style="color: black; font-family: "verdana" , "sans-serif";"><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 26.05pt; margin-bottom: .0001pt; margin: 0cm; mso-list: l8 level1 lfo6; tab-stops: list 36.0pt; text-indent: -18.0pt;">
<!--[if !supportLists]--><span style="color: black; font-family: "verdana" , "sans-serif";"><span style="mso-list: Ignore;">7.<span style="font-family: "times new roman"; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"> </span></span></span><!--[endif]--><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;"> </span><b><span style="color: #006699; font-family: "verdana" , "sans-serif";">while</span></b><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;"> (data != -</span><span style="color: #c00000; font-family: "verdana" , "sans-serif";">1</span><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;">) { </span><span style="color: black; font-family: "verdana" , "sans-serif";"><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 26.05pt; margin-bottom: .0001pt; margin: 0cm; mso-list: l8 level1 lfo6; tab-stops: list 36.0pt; text-indent: -18.0pt;">
<!--[if !supportLists]--><span style="color: black; font-family: "verdana" , "sans-serif";"><span style="mso-list: Ignore;">8.<span style="font-family: "times new roman"; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"> </span></span></span><!--[endif]--><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;"> System.out.print((</span><b><span style="color: #006699; font-family: "verdana" , "sans-serif";">char</span></b><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;">) data); </span><span style="color: black; font-family: "verdana" , "sans-serif";"><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 26.05pt; margin-bottom: .0001pt; margin: 0cm; mso-list: l8 level1 lfo6; tab-stops: list 36.0pt; text-indent: -18.0pt;">
<!--[if !supportLists]--><span style="color: black; font-family: "verdana" , "sans-serif";"><span style="mso-list: Ignore;">9.<span style="font-family: "times new roman"; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"> </span></span></span><!--[endif]--><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;"> data = reader.read(); </span><span style="color: black; font-family: "verdana" , "sans-serif";"><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 26.05pt; margin-bottom: .0001pt; margin: 0cm; mso-list: l8 level1 lfo6; tab-stops: list 36.0pt; text-indent: -18.0pt;">
<!--[if !supportLists]--><span style="color: black; font-family: "verdana" , "sans-serif";"><span style="mso-list: Ignore;">10.<span style="font-family: "times new roman"; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;">
</span></span></span><!--[endif]--><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;"> } </span><span style="color: black; font-family: "verdana" , "sans-serif";"><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 26.05pt; margin-bottom: .0001pt; margin: 0cm; mso-list: l8 level1 lfo6; tab-stops: list 36.0pt; text-indent: -18.0pt;">
<!--[if !supportLists]--><span style="color: black; font-family: "verdana" , "sans-serif";"><span style="mso-list: Ignore;">11.<span style="font-family: "times new roman"; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;">
</span></span></span><!--[endif]--><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;"> reader.close(); </span><span style="color: black; font-family: "verdana" , "sans-serif";"><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 26.05pt; margin-bottom: .0001pt; margin: 0cm; mso-list: l8 level1 lfo6; tab-stops: list 36.0pt; text-indent: -18.0pt;">
<!--[if !supportLists]--><span style="color: black; font-family: "verdana" , "sans-serif";"><span style="mso-list: Ignore;">12.<span style="font-family: "times new roman"; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;">
</span></span></span><!--[endif]--><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;"> } </span><b><span style="color: #006699; font-family: "verdana" , "sans-serif";">catch</span></b><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;"> (Exception ex) { </span><span style="color: black; font-family: "verdana" , "sans-serif";"><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 26.05pt; margin-bottom: .0001pt; margin: 0cm; mso-list: l8 level1 lfo6; tab-stops: list 36.0pt; text-indent: -18.0pt;">
<!--[if !supportLists]--><span style="color: black; font-family: "verdana" , "sans-serif";"><span style="mso-list: Ignore;">13.<span style="font-family: "times new roman"; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;">
</span></span></span><!--[endif]--><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;"> System.out.println(ex.getMessage()); </span><span style="color: black; font-family: "verdana" , "sans-serif";"><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 26.05pt; margin-bottom: .0001pt; margin: 0cm; mso-list: l8 level1 lfo6; tab-stops: list 36.0pt; text-indent: -18.0pt;">
<!--[if !supportLists]--><span style="color: black; font-family: "verdana" , "sans-serif";"><span style="mso-list: Ignore;">14.<span style="font-family: "times new roman"; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;">
</span></span></span><!--[endif]--><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;"> } </span><span style="color: black; font-family: "verdana" , "sans-serif";"><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 26.05pt; margin-bottom: .0001pt; margin: 0cm; mso-list: l8 level1 lfo6; tab-stops: list 36.0pt; text-indent: -18.0pt;">
<!--[if !supportLists]--><span style="color: black; font-family: "verdana" , "sans-serif";"><span style="mso-list: Ignore;">15.<span style="font-family: "times new roman"; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;">
</span></span></span><!--[endif]--><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;"> } </span><span style="color: black; font-family: "verdana" , "sans-serif";"><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 26.05pt; margin-bottom: .0001pt; margin: 0cm; mso-list: l8 level1 lfo6; tab-stops: list 36.0pt; text-indent: -18.0pt;">
<!--[if !supportLists]--><span style="color: black; font-family: "verdana" , "sans-serif";"><span style="mso-list: Ignore;">16.<span style="font-family: "times new roman"; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;">
</span></span></span><!--[endif]--><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;">} </span><span style="color: black; font-family: "verdana" , "sans-serif";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-left: -14.2pt; tab-stops: 14.2pt; text-indent: 14.2pt;">
<br /></div>
<h1 style="background: white; line-height: 15.6pt; margin-top: 6.2pt;">
<span style="color: #610b38; font-family: "helvetica" , "sans-serif"; font-size: small; font-weight: normal;">Java
FileWriter Class<o:p></o:p></span></h1>
<div style="background: white;">
<span style="color: black; font-family: "verdana" , "sans-serif";">Java FileWriter class is used to write character-oriented data to
a </span><a href="https://www.javatpoint.com/java-file-class"><span style="color: green; font-family: "verdana" , "sans-serif";">file</span></a><span style="color: black; font-family: "verdana" , "sans-serif";">. It is
character-oriented class which is used for file handling in </span><a href="https://www.javatpoint.com/java-tutorial"><span style="color: green; font-family: "verdana" , "sans-serif";">java</span></a><span style="color: black; font-family: "verdana" , "sans-serif";">.<o:p></o:p></span></div>
<div style="background: white;">
<a href="https://www.blogger.com/blogger.g?rinli=1&pli=1&blogID=8352540103162095489" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"></a><span style="color: black; font-family: "verdana" , "sans-serif";">Unlike FileOutputStream class, you don't need to convert string
into byte </span><a href="https://www.javatpoint.com/array-in-java"><span style="color: green; font-family: "verdana" , "sans-serif";">array</span></a><span style="color: black; font-family: "verdana" , "sans-serif";"> because it provides method to write
string directly.<o:p></o:p></span></div>
<div align="center" class="MsoNormal" style="text-align: center;">
<span style="line-height: 115%;">
</span><br />
<hr align="center" noshade="" size="2" style="color: #d4d4d4;" width="100%" />
<span style="line-height: 115%;">
</span></div>
<h2 style="background: white; line-height: 15.6pt;">
<span style="color: #610b38; font-family: "helvetica" , "sans-serif"; font-size: small; font-weight: normal;">Java FileWriter class declaration<o:p></o:p></span></h2>
<div style="background: white;">
<span style="color: black; font-family: "verdana" , "sans-serif";">Let's see the declaration for Java.io.FileWriter class:<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 26.05pt; margin-bottom: .0001pt; margin: 0cm; mso-list: l7 level1 lfo7; tab-stops: list 36.0pt; text-indent: -18.0pt;">
<!--[if !supportLists]--><span style="color: black; font-family: "verdana" , "sans-serif";"><span style="mso-list: Ignore;">1.<span style="font-family: "times new roman"; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"> </span></span></span><!--[endif]--><span class="keyword"><b><span style="border: 1pt none; color: #006699; font-family: "verdana" , "sans-serif"; padding: 0cm;">public</span></b></span><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;"> </span><span class="keyword"><b><span style="border: 1pt none; color: #006699; font-family: "verdana" , "sans-serif"; padding: 0cm;">class</span></b></span><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;"> FileWriter </span><span class="keyword"><b><span style="border: 1pt none; color: #006699; font-family: "verdana" , "sans-serif"; padding: 0cm;">extends</span></b></span><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;"> OutputStreamWriter </span><span style="color: black; font-family: "verdana" , "sans-serif";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-left: -14.2pt; tab-stops: 14.2pt; text-indent: 14.2pt;">
<br /></div>
<div class="MsoNormal" style="background: white; line-height: 15.6pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 2;">
<span style="color: #610b38; font-family: "helvetica" , "sans-serif";">Java FileWriter Example<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;">
<span style="color: black; font-family: "verdana" , "sans-serif";">In this example, we
are writing the data in the file test.txt using Java FileWriter class.<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 15.25pt; margin-bottom: .0001pt; margin: 0cm; mso-list: l3 level1 lfo8; tab-stops: list 36.0pt; text-indent: -18.0pt;">
<!--[if !supportLists]--><span style="color: black; font-family: "verdana" , "sans-serif";"><span style="mso-list: Ignore;">1.<span style="font-family: "times new roman"; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"> </span></span></span><!--[endif]--><b><span style="color: #006699; font-family: "verdana" , "sans-serif";">package</span></b><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;"> <span style="font-family: verdana, sans-serif;">Mypack</span>; </span><span style="color: black; font-family: "verdana" , "sans-serif";"><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 15.25pt; margin-bottom: .0001pt; margin: 0cm; mso-list: l3 level1 lfo8; tab-stops: list 36.0pt; text-indent: -18.0pt;">
<!--[if !supportLists]--><span style="color: black; font-family: "verdana" , "sans-serif";"><span style="mso-list: Ignore;">2.<span style="font-family: "times new roman"; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"> </span></span></span><!--[endif]--><b><span style="color: #006699; font-family: "verdana" , "sans-serif";">import</span></b><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;"> java.io.FileWriter; </span><span style="color: black; font-family: "verdana" , "sans-serif";"><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 15.25pt; margin-bottom: .0001pt; margin: 0cm; mso-list: l3 level1 lfo8; tab-stops: list 36.0pt; text-indent: -18.0pt;">
<!--[if !supportLists]--><span style="color: black; font-family: "verdana" , "sans-serif";"><span style="mso-list: Ignore;">3.<span style="font-family: "times new roman"; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"> </span></span></span><!--[endif]--><b><span style="color: #006699; font-family: "verdana" , "sans-serif";">public</span></b><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;"> </span><b><span style="color: #006699; font-family: "verdana" , "sans-serif";">class</span></b><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;"> FileWriterExample { </span><span style="color: black; font-family: "verdana" , "sans-serif";"><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 15.25pt; margin-bottom: .0001pt; margin: 0cm; mso-list: l3 level1 lfo8; tab-stops: list 36.0pt; text-indent: -18.0pt;">
<!--[if !supportLists]--><span style="color: black; font-family: "verdana" , "sans-serif";"><span style="mso-list: Ignore;">4.<span style="font-family: "times new roman"; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"> </span></span></span><!--[endif]--><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;"> </span><b><span style="color: #006699; font-family: "verdana" , "sans-serif";">public</span></b><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;"> </span><b><span style="color: #006699; font-family: "verdana" , "sans-serif";">static</span></b><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;"> </span><b><span style="color: #006699; font-family: "verdana" , "sans-serif";">void</span></b><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;"> main(String args[]){ </span><span style="color: black; font-family: "verdana" , "sans-serif";"><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 15.25pt; margin-bottom: .0001pt; margin: 0cm; mso-list: l3 level1 lfo8; tab-stops: list 36.0pt; text-indent: -18.0pt;">
<!--[if !supportLists]--><span style="color: black; font-family: "verdana" , "sans-serif";"><span style="mso-list: Ignore;">5.<span style="font-family: "times new roman"; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"> </span></span></span><!--[endif]--><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;"> </span><b><span style="color: #006699; font-family: "verdana" , "sans-serif";">try</span></b><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;">{ </span><span style="color: black; font-family: "verdana" , "sans-serif";"><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 15.25pt; margin-bottom: .0001pt; margin: 0cm; mso-list: l3 level1 lfo8; tab-stops: list 36.0pt; text-indent: -18.0pt;">
<!--[if !supportLists]--><span style="color: black; font-family: "verdana" , "sans-serif";"><span style="mso-list: Ignore;">6.<span style="font-family: "times new roman"; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"> </span></span></span><!--[endif]--><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;"> FileWriter fw=</span><b><span style="color: #006699; font-family: "verdana" , "sans-serif";">new</span></b><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;"> FileWriter(</span><span style="color: blue; font-family: "verdana" , "sans-serif";">"D:\\test.txt"</span><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;">); </span><span style="color: black; font-family: "verdana" , "sans-serif";"><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 15.25pt; margin-bottom: .0001pt; margin: 0cm; mso-list: l3 level1 lfo8; tab-stops: list 36.0pt; text-indent: -18.0pt;">
<!--[if !supportLists]--><span style="color: black; font-family: "verdana" , "sans-serif";"><span style="mso-list: Ignore;">7.<span style="font-family: "times new roman"; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"> </span></span></span><!--[endif]--><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;"> fw.write(</span><span style="color: blue; font-family: "verdana" , "sans-serif";">"Welcome to java"</span><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;">); </span><span style="color: black; font-family: "verdana" , "sans-serif";"><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 15.25pt; margin-bottom: .0001pt; margin: 0cm; mso-list: l3 level1 lfo8; tab-stops: list 36.0pt; text-indent: -18.0pt;">
<!--[if !supportLists]--><span style="color: black; font-family: "verdana" , "sans-serif";"><span style="mso-list: Ignore;">8.<span style="font-family: "times new roman"; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"> </span></span></span><!--[endif]--><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;"> fw.close(); </span><span style="color: black; font-family: "verdana" , "sans-serif";"><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 15.25pt; margin-bottom: .0001pt; margin: 0cm; mso-list: l3 level1 lfo8; tab-stops: list 36.0pt; text-indent: -18.0pt;">
<!--[if !supportLists]--><span style="color: black; font-family: "verdana" , "sans-serif";"><span style="mso-list: Ignore;">9.<span style="font-family: "times new roman"; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"> </span></span></span><!--[endif]--><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;"> }</span><b><span style="color: #006699; font-family: "verdana" , "sans-serif";">catch</span></b><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;">(Exception e){System.out.println(e);} </span><span style="color: black; font-family: "verdana" , "sans-serif";"><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 15.25pt; margin-bottom: .0001pt; margin: 0cm; mso-list: l3 level1 lfo8; tab-stops: list 36.0pt; text-indent: -18.0pt;">
<!--[if !supportLists]--><span style="color: black; font-family: "verdana" , "sans-serif";"><span style="mso-list: Ignore;">10.<span style="font-family: "times new roman"; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;">
</span></span></span><!--[endif]--><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;"> System.out.println(</span><span style="color: blue; font-family: "verdana" , "sans-serif";">"Success..."</span><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;">); </span><span style="color: black; font-family: "verdana" , "sans-serif";"><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 15.25pt; margin-bottom: .0001pt; margin: 0cm; mso-list: l3 level1 lfo8; tab-stops: list 36.0pt; text-indent: -18.0pt;">
<!--[if !supportLists]--><span style="color: black; font-family: "verdana" , "sans-serif";"><span style="mso-list: Ignore;">11.<span style="font-family: "times new roman"; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;">
</span></span></span><!--[endif]--><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;"> } </span><span style="color: black; font-family: "verdana" , "sans-serif";"><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 15.25pt; margin-bottom: 5.8pt; margin-left: 0cm; margin-right: 0cm; margin-top: 0cm; mso-list: l3 level1 lfo8; tab-stops: list 36.0pt; text-indent: -18.0pt;">
<!--[if !supportLists]--><span style="color: black; font-family: "verdana" , "sans-serif";"><span style="mso-list: Ignore;">12.<span style="font-family: "times new roman"; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;">
</span></span></span><!--[endif]--><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;">} </span><span style="color: black; font-family: "verdana" , "sans-serif";"><o:p></o:p></span></div>
<h1 style="background: white; line-height: 15.6pt; margin-top: 6.2pt;">
<span style="color: #610b38; font-family: "helvetica" , "sans-serif"; font-size: small; font-weight: normal;">Java
FileReader Class<o:p></o:p></span></h1>
<div style="background: white;">
<span style="color: black; font-family: "verdana" , "sans-serif";">Java FileReader class is used to read data from the file. It
returns data in byte format like <a href="https://www.javatpoint.com/java-fileinputstream-class"><span style="color: green;">FileInputStream</span></a> class.<o:p></o:p></span></div>
<div style="background: white;">
<span style="color: black; font-family: "verdana" , "sans-serif";">It is character-oriented class which is used for </span><a href="https://www.javatpoint.com/java-file-class"><span style="color: green; font-family: "verdana" , "sans-serif";">file</span></a><span style="color: black; font-family: "verdana" , "sans-serif";"> handling
in </span><a href="https://www.javatpoint.com/java-tutorial"><span style="color: green; font-family: "verdana" , "sans-serif";">java</span></a><span style="color: black; font-family: "verdana" , "sans-serif";">.<o:p></o:p></span></div>
<div align="center" class="MsoNormal" style="text-align: center;">
<span style="line-height: 115%;">
</span><br />
<hr align="center" noshade="" size="2" style="color: #d4d4d4;" width="100%" />
<span style="line-height: 115%;">
</span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://www.blogger.com/blogger.g?rinli=1&pli=1&blogID=8352540103162095489" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"></a></div>
<h2 style="background: white; line-height: 15.6pt;">
<span style="color: #610b38; font-family: "helvetica" , "sans-serif"; font-size: small; font-weight: normal;">Java FileReader class declaration<o:p></o:p></span></h2>
<div style="background: white;">
<span style="color: black; font-family: "verdana" , "sans-serif";">Let's see the declaration for Java.io.FileReader class:<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 26.05pt; margin-bottom: .0001pt; margin: 0cm; mso-list: l9 level1 lfo9; tab-stops: list 36.0pt; text-indent: -18.0pt;">
<!--[if !supportLists]--><a href="https://www.blogger.com/blogger.g?rinli=1&pli=1&blogID=8352540103162095489" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"></a><span style="color: black; font-family: "verdana" , "sans-serif";"><span style="mso-list: Ignore;">1.<span style="font-family: "times new roman"; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"> </span></span></span><!--[endif]--><span class="keyword"><b><span style="border: 1pt none; color: #006699; font-family: "verdana" , "sans-serif"; padding: 0cm;">public</span></b></span><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;"> </span><span class="keyword"><b><span style="border: 1pt none; color: #006699; font-family: "verdana" , "sans-serif"; padding: 0cm;">class</span></b></span><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;"> FileReader </span><span class="keyword"><b><span style="border: 1pt none; color: #006699; font-family: "verdana" , "sans-serif"; padding: 0cm;">extends</span></b></span><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;"> InputStreamReader </span><span style="color: black; font-family: "verdana" , "sans-serif";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-left: -14.2pt; tab-stops: 14.2pt; text-indent: 14.2pt;">
<br /></div>
<div class="MsoNormal" style="background: white; line-height: 15.6pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 2;">
<span style="color: #610b38; font-family: "helvetica" , "sans-serif";">Java FileReader Example<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;">
<span style="color: black; font-family: "verdana" , "sans-serif";">In this example, we
are reading the data from the text file </span><b><span style="color: darkslategrey; font-family: "verdana" , "sans-serif";">test.txt</span></b><span style="color: black; font-family: "verdana" , "sans-serif";"> using Java FileReader class.<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 15.25pt; margin-bottom: .0001pt; margin: 0cm; mso-list: l6 level1 lfo10; tab-stops: list 36.0pt; text-indent: -18.0pt;">
<!--[if !supportLists]--><span style="color: black; font-family: "verdana" , "sans-serif";"><span style="mso-list: Ignore;">1.<span style="font-family: "times new roman"; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"> </span></span></span><!--[endif]--><b><span style="color: #006699; font-family: "verdana" , "sans-serif";">package</span></b><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;"> <span style="font-family: verdana, sans-serif;">Mypack</span>; </span><span style="color: black; font-family: "verdana" , "sans-serif";"><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 15.25pt; margin-bottom: .0001pt; margin: 0cm; mso-list: l6 level1 lfo10; tab-stops: list 36.0pt; text-indent: -18.0pt;">
<!--[if !supportLists]--><span style="color: black; font-family: "verdana" , "sans-serif";"><span style="mso-list: Ignore;">2.<span style="font-family: "times new roman"; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"> </span></span></span><!--[endif]--><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;"> </span><span style="color: black; font-family: "verdana" , "sans-serif";"><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 15.25pt; margin-bottom: .0001pt; margin: 0cm; mso-list: l6 level1 lfo10; tab-stops: list 36.0pt; text-indent: -18.0pt;">
<!--[if !supportLists]--><span style="color: black; font-family: "verdana" , "sans-serif";"><span style="mso-list: Ignore;">3.<span style="font-family: "times new roman"; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"> </span></span></span><!--[endif]--><b><span style="color: #006699; font-family: "verdana" , "sans-serif";">import</span></b><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;"> java.io.FileReader; </span><span style="color: black; font-family: "verdana" , "sans-serif";"><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 15.25pt; margin-bottom: .0001pt; margin: 0cm; mso-list: l6 level1 lfo10; tab-stops: list 36.0pt; text-indent: -18.0pt;">
<!--[if !supportLists]--><span style="color: black; font-family: "verdana" , "sans-serif";"><span style="mso-list: Ignore;">4.<span style="font-family: "times new roman"; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"> </span></span></span><!--[endif]--><b><span style="color: #006699; font-family: "verdana" , "sans-serif";">public</span></b><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;"> </span><b><span style="color: #006699; font-family: "verdana" , "sans-serif";">class</span></b><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;"> FileReaderExample { </span><span style="color: black; font-family: "verdana" , "sans-serif";"><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 15.25pt; margin-bottom: .0001pt; margin: 0cm; mso-list: l6 level1 lfo10; tab-stops: list 36.0pt; text-indent: -18.0pt;">
<!--[if !supportLists]--><span style="color: black; font-family: "verdana" , "sans-serif";"><span style="mso-list: Ignore;">5.<span style="font-family: "times new roman"; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"> </span></span></span><!--[endif]--><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;"> </span><b><span style="color: #006699; font-family: "verdana" , "sans-serif";">public</span></b><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;"> </span><b><span style="color: #006699; font-family: "verdana" , "sans-serif";">static</span></b><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;"> </span><b><span style="color: #006699; font-family: "verdana" , "sans-serif";">void</span></b><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;"> main(String args[])</span><b><span style="color: #006699; font-family: "verdana" , "sans-serif";">throws</span></b><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;"> Exception{ </span><span style="color: black; font-family: "verdana" , "sans-serif";"><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 15.25pt; margin-bottom: .0001pt; margin: 0cm; mso-list: l6 level1 lfo10; tab-stops: list 36.0pt; text-indent: -18.0pt;">
<!--[if !supportLists]--><span style="color: black; font-family: "verdana" , "sans-serif";"><span style="mso-list: Ignore;">6.<span style="font-family: "times new roman"; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"> </span></span></span><!--[endif]--><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;"> FileReader fr=</span><b><span style="color: #006699; font-family: "verdana" , "sans-serif";">new</span></b><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;"> FileReader(</span><span style="color: blue; font-family: "verdana" , "sans-serif";">"D:\\test.txt"</span><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;">); </span><span style="color: black; font-family: "verdana" , "sans-serif";"><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 15.25pt; margin-bottom: .0001pt; margin: 0cm; mso-list: l6 level1 lfo10; tab-stops: list 36.0pt; text-indent: -18.0pt;">
<!--[if !supportLists]--><span style="color: black; font-family: "verdana" , "sans-serif";"><span style="mso-list: Ignore;">7.<span style="font-family: "times new roman"; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"> </span></span></span><!--[endif]--><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;"> </span><b><span style="color: #006699; font-family: "verdana" , "sans-serif";">int</span></b><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;"> i; </span><span style="color: black; font-family: "verdana" , "sans-serif";"><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 15.25pt; margin-bottom: .0001pt; margin: 0cm; mso-list: l6 level1 lfo10; tab-stops: list 36.0pt; text-indent: -18.0pt;">
<!--[if !supportLists]--><span style="color: black; font-family: "verdana" , "sans-serif";"><span style="mso-list: Ignore;">8.<span style="font-family: "times new roman"; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"> </span></span></span><!--[endif]--><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;"> </span><b><span style="color: #006699; font-family: "verdana" , "sans-serif";">while</span></b><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;">((i=fr.read())!=-</span><span style="color: #c00000; font-family: "verdana" , "sans-serif";">1</span><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;">) </span><span style="color: black; font-family: "verdana" , "sans-serif";"><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 15.25pt; margin-bottom: .0001pt; margin: 0cm; mso-list: l6 level1 lfo10; tab-stops: list 36.0pt; text-indent: -18.0pt;">
<!--[if !supportLists]--><span style="color: black; font-family: "verdana" , "sans-serif";"><span style="mso-list: Ignore;">9.<span style="font-family: "times new roman"; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"> </span></span></span><!--[endif]--><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;"> System.out.print((</span><b><span style="color: #006699; font-family: "verdana" , "sans-serif";">char</span></b><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;">)i); </span><span style="color: black; font-family: "verdana" , "sans-serif";"><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 15.25pt; margin-bottom: .0001pt; margin: 0cm; mso-list: l6 level1 lfo10; tab-stops: list 36.0pt; text-indent: -18.0pt;">
<!--[if !supportLists]--><span style="color: black; font-family: "verdana" , "sans-serif";"><span style="mso-list: Ignore;">10.<span style="font-family: "times new roman"; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;">
</span></span></span><!--[endif]--><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;"> fr.close(); </span><span style="color: black; font-family: "verdana" , "sans-serif";"><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 15.25pt; margin-bottom: .0001pt; margin: 0cm; mso-list: l6 level1 lfo10; tab-stops: list 36.0pt; text-indent: -18.0pt;">
<!--[if !supportLists]--><span style="color: black; font-family: "verdana" , "sans-serif";"><span style="mso-list: Ignore;">11.<span style="font-family: "times new roman"; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;">
</span></span></span><!--[endif]--><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;"> } </span><span style="color: black; font-family: "verdana" , "sans-serif";"><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 15.25pt; margin-bottom: 5.8pt; margin-left: 0cm; margin-right: 0cm; margin-top: 0cm; mso-list: l6 level1 lfo10; tab-stops: list 36.0pt; text-indent: -18.0pt;">
<!--[if !supportLists]--><span style="color: black; font-family: "verdana" , "sans-serif";"><span style="mso-list: Ignore;">12.<span style="font-family: "times new roman"; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;">
</span></span></span><!--[endif]--><span style="border: 1pt none; color: black; font-family: "verdana" , "sans-serif"; padding: 0cm;">} </span><span style="color: black; font-family: "verdana" , "sans-serif";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-left: -14.2pt; tab-stops: 14.2pt; text-indent: 14.2pt;">
<br /></div>
<br />
<br /></div>
Bagadhi Sateeshhttp://www.blogger.com/profile/16786636572407672825noreply@blogger.com1tag:blogger.com,1999:blog-8352540103162095489.post-89360192235544009282018-09-28T12:59:00.001+05:302018-09-28T12:59:07.757+05:30JAVA RECORD PROGRAMS<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<div class="MsoNormal">
<span style="background: yellow; mso-highlight: yellow;">// 1.
JAVA PROGRAM FOR COMMANDLINE ARGUMENTS</span></div>
<div class="MsoNormal">
class CommandLine{<span style="mso-spacerun: yes;"> </span></div>
<div class="MsoNormal">
public static void main(String args[]){<span style="mso-spacerun: yes;"> </span></div>
<div class="MsoNormal">
int a=Integer.parseInt(args[0]);</div>
<div class="MsoNormal">
int b=Integer.parseInt(args[1]);</div>
<div class="MsoNormal">
int c=a+b;</div>
<div class="MsoNormal">
System.out.println("Sum of a and b is: "+c); </div>
<div class="MsoNormal">
<span style="mso-spacerun: yes;"> </span>}<span style="mso-spacerun: yes;"> </span></div>
<div class="MsoNormal">
}<span style="mso-spacerun: yes;"> </span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="background: yellow; mso-highlight: yellow;">// 2.<span style="mso-spacerun: yes;"> </span>java program used to caliculate the Compound
Interest</span></div>
<div class="MsoNormal">
import java.lang.*;</div>
<div class="MsoNormal">
class compound</div>
<div class="MsoNormal">
{</div>
<div class="MsoNormal">
<span style="mso-tab-count: 1;"> </span>public
static void main(String []args)</div>
<div class="MsoNormal">
<span style="mso-tab-count: 1;"> </span>{</div>
<div class="MsoNormal">
<span style="mso-tab-count: 2;"> </span>int
roa=Integer.parseInt(args[0]);</div>
<div class="MsoNormal">
<span style="mso-tab-count: 2;"> </span>int
noy=Integer.parseInt(args[1]);</div>
<div class="MsoNormal">
<span style="mso-tab-count: 2;"> </span>int
amt=Integer.parseInt(args[2]);</div>
<div class="MsoNormal">
<span style="mso-tab-count: 2;"> </span>float
pamt=(float)(amt*Math.pow((1+(float)roa/100),noy));</div>
<div class="MsoNormal">
<span style="mso-tab-count: 2;"> </span>System.out.println("Compound
Interest is.."+pamt);</div>
<div class="MsoNormal">
<span style="mso-tab-count: 1;"> </span>}</div>
<div class="MsoNormal">
}</div>
<div class="MsoNormal">
<span style="background: yellow; mso-highlight: yellow;">// 3.<span style="mso-spacerun: yes;"> </span>Java program to demonstrate primitive data
types in Java</span></div>
<div class="MsoNormal">
class Datatypes</div>
<div class="MsoNormal">
{</div>
<div class="MsoNormal">
<span style="mso-spacerun: yes;"> </span>public static void
main(String args[]) </div>
<div class="MsoNormal">
<span style="mso-spacerun: yes;"> </span>{</div>
<div class="MsoNormal">
<span style="mso-spacerun: yes;"> </span>// declaring
character</div>
<div class="MsoNormal">
<span style="mso-spacerun: yes;"> </span>char a = 'G';</div>
<div class="MsoNormal">
<span style="mso-spacerun: yes;"> </span>// Integer
data type is generally </div>
<div class="MsoNormal">
<span style="mso-spacerun: yes;"> </span>// used for
numeric values</div>
<div class="MsoNormal">
<span style="mso-spacerun: yes;"> </span>int i=89;</div>
<div class="MsoNormal">
<span style="mso-spacerun: yes;"> </span>// use byte
and short if memory is a constraint </div>
<div class="MsoNormal">
<span style="mso-spacerun: yes;"> </span>byte b = 4;</div>
<div class="MsoNormal">
<span style="mso-spacerun: yes;"> </span>short s = 56;</div>
<div class="MsoNormal">
<span style="mso-spacerun: yes;"> </span>// by default
fraction value is double in java</div>
<div class="MsoNormal">
<span style="mso-spacerun: yes;"> </span>double d =
4.355453532;</div>
<div class="MsoNormal">
<span style="mso-spacerun: yes;"> </span>// for float
use 'f' as suffix</div>
<div class="MsoNormal">
<span style="mso-spacerun: yes;"> </span>float f =
4.7333434f;</div>
<div class="MsoNormal">
<span style="mso-spacerun: yes;">
</span>System.out.println("char: " + a); </div>
<div class="MsoNormal">
<span style="mso-spacerun: yes;">
</span>System.out.println("integer: " + i); </div>
<div class="MsoNormal">
<span style="mso-spacerun: yes;"> </span>System.out.println("byte:
" + b); </div>
<div class="MsoNormal">
<span style="mso-spacerun: yes;">
</span>System.out.println("short: " + s); </div>
<div class="MsoNormal">
<span style="mso-spacerun: yes;">
</span>System.out.println("float: " + f); </div>
<div class="MsoNormal">
<span style="mso-spacerun: yes;">
</span>System.out.println("double: " + d); </div>
<div class="MsoNormal">
<span style="mso-spacerun: yes;"> </span>}<span style="mso-spacerun: yes;"> </span></div>
<div class="MsoNormal">
}</div>
<div class="MsoNormal">
<span style="background: yellow; mso-highlight: yellow;">// 4.<span style="mso-spacerun: yes;"> </span>Float data type example in java</span></div>
<div class="MsoNormal">
class Exp</div>
<div class="MsoNormal">
<span style="mso-spacerun: yes;"> </span>{</div>
<div class="MsoNormal">
<span style="mso-spacerun: yes;"> </span>public static void
main(String args[])</div>
<div class="MsoNormal">
<span style="mso-spacerun: yes;"> </span>{</div>
<div class="MsoNormal">
<span style="mso-spacerun: yes;"> </span>float
c=17.2f,d=2;</div>
<div class="MsoNormal">
<span style="mso-spacerun: yes;"> </span>float z;</div>
<div class="MsoNormal">
<span style="mso-spacerun: yes;"> </span>z = c / d;</div>
<div class="MsoNormal">
<span style="mso-spacerun: yes;">
</span>System.out.println("C="+z);</div>
<div class="MsoNormal">
<span style="mso-spacerun: yes;"> </span>}</div>
<div class="MsoNormal">
}</div>
<div class="MsoNormal">
<span style="background: yellow; mso-highlight: yellow;">// 5.
SIMPLE IF EXAMPLE</span></div>
<div class="MsoNormal">
class testif{</div>
<div class="MsoNormal">
public static void main(String args[]){</div>
<div class="MsoNormal">
float marks=29;</div>
<div class="MsoNormal">
if(marks>=35){</div>
<div class="MsoNormal">
System.out.println("PASS");</div>
<div class="MsoNormal">
}</div>
<div class="MsoNormal">
}</div>
<div class="MsoNormal">
}</div>
<div class="MsoNormal">
<span style="background: yellow; mso-highlight: yellow;">// 6.<span style="mso-spacerun: yes;"> </span>BANK TRANSACTION EXAMPLE</span></div>
<div class="MsoNormal">
interface bank</div>
<div class="MsoNormal">
{</div>
<div class="MsoNormal">
<span style="mso-tab-count: 1;"> </span>int
accno=101;</div>
<div class="MsoNormal">
<span style="mso-tab-count: 1;"> </span>String
accname="GVP";</div>
<div class="MsoNormal">
<span style="mso-tab-count: 1;"> </span>int
amt=10000;</div>
<div class="MsoNormal">
}</div>
<div class="MsoNormal">
interface acctype extends bank</div>
<div class="MsoNormal">
{</div>
<div class="MsoNormal">
<span style="mso-tab-count: 1;"> </span>void
calc_interest(int rof);</div>
<div class="MsoNormal">
<span style="mso-tab-count: 1;"> </span>void
put_details();</div>
<div class="MsoNormal">
}</div>
<div class="MsoNormal">
abstract class members implements acctype</div>
<div class="MsoNormal">
{</div>
<div class="MsoNormal">
<span style="mso-tab-count: 1;"> </span>float
interest=0.0f;</div>
<div class="MsoNormal">
<span style="mso-tab-count: 1;"> </span>float
bal=0.0f;</div>
<div class="MsoNormal">
<span style="mso-tab-count: 1;"> </span>public
void put_details()</div>
<div class="MsoNormal">
<span style="mso-tab-count: 1;"> </span>{</div>
<div class="MsoNormal">
<span style="mso-tab-count: 2;"> </span>System.out.println("Account
Number="+accno);</div>
<div class="MsoNormal">
<span style="mso-tab-count: 2;"> </span>System.out.println("Account
Name="+accname);</div>
<div class="MsoNormal">
<span style="mso-tab-count: 2;"> </span>System.out.println("Amount
="+amt);</div>
<div class="MsoNormal">
<span style="mso-tab-count: 2;"> </span>System.out.println("Interest="+interest);</div>
<div class="MsoNormal">
<span style="mso-tab-count: 2;"> </span>System.out.println("Balance="+bal);</div>
<div class="MsoNormal">
<span style="mso-tab-count: 1;"> </span>}</div>
<div class="MsoNormal">
}</div>
<div class="MsoNormal">
class current_accnt<span style="mso-spacerun: yes;">
</span>extends members implements acctype</div>
<div class="MsoNormal">
{<span style="mso-tab-count: 1;"> </span></div>
<div class="MsoNormal">
<span style="mso-tab-count: 1;"> </span>public
void calc_interest(int rof)</div>
<div class="MsoNormal">
<span style="mso-tab-count: 1;"> </span>{</div>
<div class="MsoNormal">
<span style="mso-tab-count: 2;"> </span>interest=(rof*amt)/100;</div>
<div class="MsoNormal">
<span style="mso-tab-count: 2;"> </span>bal=amt+interest;</div>
<div class="MsoNormal">
<span style="mso-tab-count: 1;"> </span>}</div>
<div class="MsoNormal">
}</div>
<div class="MsoNormal">
class savings_accnt extends members implements acctype </div>
<div class="MsoNormal">
{</div>
<div class="MsoNormal">
<span style="mso-tab-count: 1;"> </span>public
void calc_interest(int rof)</div>
<div class="MsoNormal">
<span style="mso-tab-count: 1;"> </span>{</div>
<div class="MsoNormal">
<span style="mso-tab-count: 2;"> </span>interest=(rof*amt)/100;</div>
<div class="MsoNormal">
<span style="mso-tab-count: 2;"> </span>bal=amt+interest;</div>
<div class="MsoNormal">
<span style="mso-tab-count: 1;"> </span>}</div>
<div class="MsoNormal">
}</div>
<div class="MsoNormal">
class interest</div>
<div class="MsoNormal">
{</div>
<div class="MsoNormal">
<span style="mso-tab-count: 1;"> </span>public
static void main(String []args)</div>
<div class="MsoNormal">
<span style="mso-tab-count: 1;"> </span>{</div>
<div class="MsoNormal">
<span style="mso-tab-count: 2;"> </span>current_accnt
ca=new current_accnt(); </div>
<div class="MsoNormal">
<span style="mso-tab-count: 2;"> </span>savings_accnt
sa=new savings_accnt();</div>
<div class="MsoNormal">
<span style="mso-tab-count: 2;"> </span>if(args[0].equals("current"))</div>
<div class="MsoNormal">
<span style="mso-tab-count: 2;"> </span>{</div>
<div class="MsoNormal">
<span style="mso-tab-count: 3;"> </span>ca.calc_interest(10);</div>
<div class="MsoNormal">
<span style="mso-tab-count: 3;"> </span>ca.put_details();</div>
<div class="MsoNormal">
<span style="mso-tab-count: 2;"> </span>}</div>
<div class="MsoNormal">
<span style="mso-tab-count: 2;"> </span>else
if(args[0].equals("savings"))</div>
<div class="MsoNormal">
<span style="mso-spacerun: yes;">
</span>{</div>
<div class="MsoNormal">
<span style="mso-tab-count: 3;"> </span>sa.calc_interest(5);</div>
<div class="MsoNormal">
<span style="mso-tab-count: 3;"> </span>sa.put_details();</div>
<div class="MsoNormal">
<span style="mso-tab-count: 2;"> </span>}<span style="mso-tab-count: 1;"> </span></div>
<div class="MsoNormal">
<span style="mso-tab-count: 2;"> </span>else</div>
<div class="MsoNormal">
<span style="mso-tab-count: 3;"> </span>System.exit(0);</div>
<div class="MsoNormal">
<span style="mso-tab-count: 1;"> </span>}</div>
<div class="MsoNormal">
}</div>
<div class="MsoNormal">
<span style="background: yellow; mso-highlight: yellow;">// <span style="mso-spacerun: yes;"> </span>7. LOOPS IN JAVA</span></div>
<div class="MsoNormal">
class loop{</div>
<div class="MsoNormal">
public static void main(String args[]){</div>
<div class="MsoNormal">
<span style="mso-spacerun: yes;">
</span>System.out.println("URSING FOR LOOP:");</div>
<div class="MsoNormal">
<span style="mso-spacerun: yes;"> </span>for(int
i=1;i<11;i++){</div>
<div class="MsoNormal">
<span style="mso-spacerun: yes;">
</span>System.out.println(i);</div>
<div class="MsoNormal">
<span style="mso-spacerun: yes;"> </span>}</div>
<div class="MsoNormal">
<span style="mso-spacerun: yes;">
</span>System.out.println("URSING WHILE LOOP:");</div>
<div class="MsoNormal">
<span style="mso-spacerun: yes;"> </span>int j=0;</div>
<div class="MsoNormal">
<span style="mso-spacerun: yes;"> </span>while(j<10){</div>
<div class="MsoNormal">
<span style="mso-spacerun: yes;"> </span>j=j+1;</div>
<div class="MsoNormal">
<span style="mso-spacerun: yes;">
</span>System.out.println(j);</div>
<div class="MsoNormal">
<span style="mso-spacerun: yes;"> </span>}</div>
<div class="MsoNormal">
<span style="mso-spacerun: yes;"> </span>System.out.println("URSING
do WHILE LOOP:");</div>
<div class="MsoNormal">
<span style="mso-spacerun: yes;"> </span>int k=0;</div>
<div class="MsoNormal">
<span style="mso-spacerun: yes;"> </span>do{</div>
<div class="MsoNormal">
<span style="mso-spacerun: yes;"> </span>k=k+1;</div>
<div class="MsoNormal">
<span style="mso-spacerun: yes;">
</span>System.out.println(k);</div>
<div class="MsoNormal">
<span style="mso-spacerun: yes;"> </span>}while(k<10);</div>
<div class="MsoNormal">
<span style="mso-spacerun: yes;"> </span>}</div>
<div class="MsoNormal">
}</div>
<div class="MsoNormal">
<span style="background: yellow; mso-highlight: yellow;">// 8.
IF ELSE IN JAVA</span></div>
<div class="MsoNormal">
class nestedif{</div>
<div class="MsoNormal">
public static void main(String args[]){</div>
<div class="MsoNormal">
int a=30,b=45,c=65;</div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
if(a>b && a>c)</div>
<div class="MsoNormal">
{</div>
<div class="MsoNormal">
System.out.println("A IS BIG");</div>
<div class="MsoNormal">
}</div>
<div class="MsoNormal">
<span style="mso-spacerun: yes;"> </span>else if(b>a
&& b>c)</div>
<div class="MsoNormal">
{</div>
<div class="MsoNormal">
System.out.println("B IS BIG");</div>
<div class="MsoNormal">
}</div>
<div class="MsoNormal">
else </div>
<div class="MsoNormal">
{</div>
<div class="MsoNormal">
System.out.println("C IS BIG");</div>
<div class="MsoNormal">
}</div>
<div class="MsoNormal">
}</div>
<div class="MsoNormal">
}</div>
<div class="MsoNormal">
<span style="background: yellow; mso-highlight: yellow;">// 9.
NUMBER NAME IN JAVA</span></div>
<div class="MsoNormal">
class NumberName</div>
<div class="MsoNormal">
{</div>
<div class="MsoNormal">
static void PrintName(char c)</div>
<div class="MsoNormal">
{</div>
<div class="MsoNormal">
switch(c)</div>
<div class="MsoNormal">
{</div>
<div class="MsoNormal">
case '0' :</div>
<div class="MsoNormal">
System.out.print(" Zero ");</div>
<div class="MsoNormal">
break;</div>
<div class="MsoNormal">
case '1' :</div>
<div class="MsoNormal">
System.out.print(" One ");</div>
<div class="MsoNormal">
break;</div>
<div class="MsoNormal">
case '2' :</div>
<div class="MsoNormal">
System.out.print(" Two ");</div>
<div class="MsoNormal">
break;</div>
<div class="MsoNormal">
case '3' :</div>
<div class="MsoNormal">
System.out.print(" Three ");</div>
<div class="MsoNormal">
break;</div>
<div class="MsoNormal">
case '4' :</div>
<div class="MsoNormal">
System.out.print(" Four ");</div>
<div class="MsoNormal">
break;</div>
<div class="MsoNormal">
case '5' :</div>
<div class="MsoNormal">
System.out.print(" Five ");</div>
<div class="MsoNormal">
break;</div>
<div class="MsoNormal">
case '6' :</div>
<div class="MsoNormal">
System.out.print(" Six ");</div>
<div class="MsoNormal">
break;</div>
<div class="MsoNormal">
case '7' :</div>
<div class="MsoNormal">
System.out.print(" Seven ");</div>
<div class="MsoNormal">
break;</div>
<div class="MsoNormal">
case '8' :</div>
<div class="MsoNormal">
System.out.print(" Eight ");</div>
<div class="MsoNormal">
break;</div>
<div class="MsoNormal">
case '9' :</div>
<div class="MsoNormal">
System.out.print(" nine ");</div>
<div class="MsoNormal">
break;</div>
<div class="MsoNormal">
default : </div>
<div class="MsoNormal">
System.out.print(" Not a Valid Number ");</div>
<div class="MsoNormal">
}</div>
<div class="MsoNormal">
}</div>
<div class="MsoNormal">
<span style="mso-spacerun: yes;"> </span>public static
void main(String args[])</div>
<div class="MsoNormal">
<span style="mso-spacerun: yes;"> </span>{</div>
<div class="MsoNormal">
<span style="mso-spacerun: yes;"> </span>String
str;</div>
<div class="MsoNormal">
<span style="mso-spacerun: yes;"> </span>str =
args[0];</div>
<div class="MsoNormal">
<span style="mso-spacerun: yes;"> </span>int l =
str.length();</div>
<div class="MsoNormal">
<span style="mso-spacerun: yes;"> </span>for(int
i=0; i < l ; i++)</div>
<div class="MsoNormal">
<span style="mso-spacerun: yes;"> </span>{</div>
<div class="MsoNormal">
<span style="mso-spacerun: yes;">
</span>PrintName(str.charAt(i));</div>
<div class="MsoNormal">
<span style="mso-spacerun: yes;"> </span>}</div>
<div class="MsoNormal">
<span style="mso-spacerun: yes;"> </span>}</div>
<div class="MsoNormal">
}<span style="mso-spacerun: yes;"> </span></div>
<div class="MsoNormal">
<span style="background: yellow; mso-highlight: yellow;">// 10.
Multithreading using java</span></div>
<div class="MsoNormal">
class odd extends Thread </div>
<div class="MsoNormal">
{</div>
<div class="MsoNormal">
<span style="mso-tab-count: 1;"> </span>int
n=20;</div>
<div class="MsoNormal">
<span style="mso-tab-count: 1;"> </span>public
void<span style="mso-spacerun: yes;"> </span>run()</div>
<div class="MsoNormal">
<span style="mso-tab-count: 1;"> </span>{</div>
<div class="MsoNormal">
<span style="mso-tab-count: 2;"> </span>for(int
i=1;i<=n;i++)</div>
<div class="MsoNormal">
<span style="mso-tab-count: 2;"> </span>{</div>
<div class="MsoNormal">
<span style="mso-tab-count: 2;"> </span>if
(i%2!=0)</div>
<div class="MsoNormal">
<span style="mso-tab-count: 2;"> </span>System.out.println("Odd
nos:"+i);</div>
<div class="MsoNormal">
<span style="mso-tab-count: 2;"> </span>try
</div>
<div class="MsoNormal">
<span style="mso-tab-count: 2;"> </span>{</div>
<div class="MsoNormal">
<span style="mso-tab-count: 3;"> </span>Thread.sleep(1000);</div>
<div class="MsoNormal">
<span style="mso-tab-count: 2;"> </span>}
</div>
<div class="MsoNormal">
<span style="mso-tab-count: 2;"> </span>catch(InterruptedException
e) {}</div>
<div class="MsoNormal">
<span style="mso-tab-count: 2;"> </span>}</div>
<div class="MsoNormal">
<span style="mso-tab-count: 1;"> </span>}</div>
<div class="MsoNormal">
}</div>
<div class="MsoNormal">
class even extends Thread</div>
<div class="MsoNormal">
{</div>
<div class="MsoNormal">
<span style="mso-tab-count: 1;"> </span>int
n=20;</div>
<div class="MsoNormal">
<span style="mso-tab-count: 1;"> </span>public
void run()</div>
<div class="MsoNormal">
<span style="mso-tab-count: 1;"> </span>{</div>
<div class="MsoNormal">
<span style="mso-tab-count: 1;"> </span>for(int
i=1;i<=n;i++)</div>
<div class="MsoNormal">
<span style="mso-tab-count: 1;"> </span>{</div>
<div class="MsoNormal">
<span style="mso-tab-count: 2;"> </span>if(i%2==0)</div>
<div class="MsoNormal">
<span style="mso-tab-count: 2;"> </span>System.out.println("Even
nos:"+i);</div>
<div class="MsoNormal">
<span style="mso-tab-count: 2;"> </span>try
</div>
<div class="MsoNormal">
<span style="mso-tab-count: 2;"> </span>{</div>
<div class="MsoNormal">
<span style="mso-tab-count: 3;"> </span>Thread.sleep(1000);</div>
<div class="MsoNormal">
<span style="mso-tab-count: 2;"> </span>}
</div>
<div class="MsoNormal">
<span style="mso-tab-count: 2;"> </span>catch(InterruptedException
e) {}</div>
<div class="MsoNormal">
<span style="mso-tab-count: 1;"> </span>}</div>
<div class="MsoNormal">
<span style="mso-tab-count: 1;"> </span>}</div>
<div class="MsoNormal">
<span style="mso-tab-count: 1;"> </span></div>
<div class="MsoNormal">
}</div>
<div class="MsoNormal">
class oddeven </div>
<div class="MsoNormal">
{</div>
<div class="MsoNormal">
public static void main(String args[])</div>
<div class="MsoNormal">
{</div>
<div class="MsoNormal">
<span style="mso-tab-count: 1;"> </span>odd
t1=new odd();</div>
<div class="MsoNormal">
<span style="mso-tab-count: 1;"> </span>even
t2=new even();</div>
<div class="MsoNormal">
<span style="mso-tab-count: 1;"> </span>t1.start();</div>
<div class="MsoNormal">
<span style="mso-tab-count: 1;"> </span>t2.start();</div>
<div class="MsoNormal">
}</div>
<div class="MsoNormal">
}</div>
<div class="MsoNormal">
<span style="background: yellow; mso-highlight: yellow;">// 11.
Java Program to print Prime Numbers up to N</span></div>
<div class="MsoNormal">
class prime</div>
<div class="MsoNormal">
{</div>
<div class="MsoNormal">
<span style="mso-tab-count: 1;"> </span>public
static void main(String args[])</div>
<div class="MsoNormal">
<span style="mso-tab-count: 1;"> </span>{</div>
<div class="MsoNormal">
<span style="mso-tab-count: 2;"> </span>int
num=Integer.parseInt(args[0]);</div>
<div class="MsoNormal">
<span style="mso-tab-count: 2;"> </span></div>
<div class="MsoNormal">
<span style="mso-tab-count: 2;"> </span>for(int
n=2;n<=num;n++)</div>
<div class="MsoNormal">
<span style="mso-tab-count: 2;"> </span>{</div>
<div class="MsoNormal">
<span style="mso-tab-count: 3;"> </span>int
count=0;</div>
<div class="MsoNormal">
<span style="mso-tab-count: 3;"> </span>for(int
i=1;i<=n;i++)</div>
<div class="MsoNormal">
<span style="mso-tab-count: 3;"> </span>{</div>
<div class="MsoNormal">
<span style="mso-tab-count: 4;"> </span>if((n%i)==0)</div>
<div class="MsoNormal">
<span style="mso-tab-count: 5;"> </span>count++;</div>
<div class="MsoNormal">
<span style="mso-tab-count: 3;"> </span>}</div>
<div class="MsoNormal">
<span style="mso-tab-count: 3;"> </span>if(count==2)</div>
<div class="MsoNormal">
<span style="mso-tab-count: 4;"> </span>System.out.println(n);</div>
<div class="MsoNormal">
<span style="mso-tab-count: 2;"> </span>}</div>
<div class="MsoNormal">
<span style="mso-tab-count: 1;"> </span>}</div>
<div class="MsoNormal">
}</div>
<div class="MsoNormal">
<span style="background: yellow; mso-highlight: yellow;">// 12.
java program to calculate sum of series 1 + ½ + 1/3 + ¼ + ……..+1/n</span><span style="mso-spacerun: yes;"> </span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
class series</div>
<div class="MsoNormal">
{</div>
<div class="MsoNormal">
<span style="mso-tab-count: 1;"> </span>public
static void main(String args[])</div>
<div class="MsoNormal">
<span style="mso-tab-count: 1;"> </span>{</div>
<div class="MsoNormal">
<span style="mso-tab-count: 2;"> </span>int
n=Integer.parseInt(args[0]);</div>
<div class="MsoNormal">
<span style="mso-tab-count: 2;"> </span>float
sum = 1.0f;</div>
<div class="MsoNormal">
<span style="mso-tab-count: 3;"> </span>for(int
i=1; i<n; i++)</div>
<div class="MsoNormal">
<span style="mso-tab-count: 3;"> </span>{
</div>
<div class="MsoNormal">
<span style="mso-tab-count: 3;"> </span><span style="mso-spacerun: yes;"> </span>sum += (float) 1 / (i+1);</div>
<div class="MsoNormal">
<span style="mso-tab-count: 3;"> </span>}</div>
<div class="MsoNormal">
<span style="mso-tab-count: 2;"> </span>System.out.println("Sum
of the series<span style="mso-spacerun: yes;"> </span>is.."+ sum);</div>
<div class="MsoNormal">
<span style="mso-tab-count: 1;"> </span>}</div>
<div class="MsoNormal">
}</div>
<div class="MsoNormal">
<span style="background: yellow; mso-highlight: yellow;">// 13.
Single Inheritance in Java</span></div>
<div class="MsoNormal">
class Dept</div>
<div class="MsoNormal">
{</div>
<div class="MsoNormal">
<span style="mso-tab-count: 1;"> </span>int
dno;</div>
<div class="MsoNormal">
<span style="mso-tab-count: 1;"> </span>String
dname;</div>
<div class="MsoNormal">
<span style="mso-tab-count: 1;"> </span>String
loc;</div>
<div class="MsoNormal">
<span style="mso-tab-count: 1;"> </span>void
setDetails(int x,String y,String z)</div>
<div class="MsoNormal">
<span style="mso-tab-count: 1;"> </span>{</div>
<div class="MsoNormal">
<span style="mso-tab-count: 2;"> </span>dno=x;</div>
<div class="MsoNormal">
<span style="mso-tab-count: 2;"> </span>dname=y;</div>
<div class="MsoNormal">
<span style="mso-tab-count: 2;"> </span>loc=z;</div>
<div class="MsoNormal">
<span style="mso-tab-count: 1;"> </span>}</div>
<div class="MsoNormal">
}</div>
<div class="MsoNormal">
class emp extends Dept</div>
<div class="MsoNormal">
{</div>
<div class="MsoNormal">
<span style="mso-tab-count: 1;"> </span>int
eno;</div>
<div class="MsoNormal">
<span style="mso-tab-count: 1;"> </span>String
ename;</div>
<div class="MsoNormal">
<span style="mso-tab-count: 1;"> </span>String
job;</div>
<div class="MsoNormal">
<span style="mso-tab-count: 1;"> </span>void
setemp(int x,String y,String z)</div>
<div class="MsoNormal">
<span style="mso-tab-count: 1;"> </span>{</div>
<div class="MsoNormal">
<span style="mso-tab-count: 2;"> </span>eno=x;</div>
<div class="MsoNormal">
<span style="mso-tab-count: 2;"> </span>ename=y;</div>
<div class="MsoNormal">
<span style="mso-tab-count: 2;"> </span>job=z;</div>
<div class="MsoNormal">
<span style="mso-tab-count: 1;"> </span>}</div>
<div class="MsoNormal">
<span style="mso-tab-count: 1;"> </span>void
showdetails()</div>
<div class="MsoNormal">
<span style="mso-tab-count: 1;"> </span>{</div>
<div class="MsoNormal">
<span style="mso-tab-count: 2;"> </span>System.out.println("Dept
Details="+dno+"\t\t"+dname+"\t\t"+loc);</div>
<div class="MsoNormal">
<span style="mso-tab-count: 2;"> </span>System.out.println("Emp
Details="+eno+"\t\t"+ename+"\t\t"+job);</div>
<div class="MsoNormal">
<span style="mso-tab-count: 1;"> </span>}</div>
<div class="MsoNormal">
}</div>
<div class="MsoNormal">
class single</div>
<div class="MsoNormal">
{</div>
<div class="MsoNormal">
<span style="mso-tab-count: 1;"> </span>public
static void main(String []args)</div>
<div class="MsoNormal">
<span style="mso-tab-count: 1;"> </span>{</div>
<div class="MsoNormal">
<span style="mso-tab-count: 2;"> </span>emp
e=new emp();</div>
<div class="MsoNormal">
<span style="mso-tab-count: 2;"> </span>e.setDetails(10,"sales","vizag");</div>
<div class="MsoNormal">
<span style="mso-tab-count: 2;"> </span>e.setemp(101,"Smith","manager");</div>
<div class="MsoNormal">
<span style="mso-tab-count: 2;"> </span>e.showdetails();</div>
<div class="MsoNormal">
<span style="mso-tab-count: 1;"> </span>}</div>
<div class="MsoNormal">
}</div>
<div class="MsoNormal">
<span style="background: yellow; mso-highlight: yellow;">// 14.
String manipulations in java</span></div>
<div class="MsoNormal">
class StringManip</div>
<div class="MsoNormal">
{</div>
<div class="MsoNormal">
<span style="mso-spacerun: yes;"> </span>public static
void main(String args[])</div>
<div class="MsoNormal">
<span style="mso-spacerun: yes;"> </span>{</div>
<div class="MsoNormal">
<span style="mso-spacerun: yes;"> </span>String s1 =
"I am a student of B.Sc Final year.";</div>
<div class="MsoNormal">
<span style="mso-spacerun: yes;"> </span>String s2 =
" ";</div>
<div class="MsoNormal">
<span style="mso-spacerun: yes;"> </span>s2 =
s1.replace('a','z');</div>
<div class="MsoNormal">
<span style="mso-spacerun: yes;">
</span>System.out.println(s1);</div>
<div class="MsoNormal">
<span style="mso-spacerun: yes;">
</span>System.out.println(s2);</div>
<div class="MsoNormal">
<span style="mso-spacerun: yes;"> </span>int
n1,n2,n3;</div>
<div class="MsoNormal">
<span style="mso-spacerun: yes;"> </span>n1 =
s1.indexOf('a');</div>
<div class="MsoNormal">
<span style="mso-spacerun: yes;"> </span>n2 =
s1.indexOf('a',5);</div>
<div class="MsoNormal">
<span style="mso-spacerun: yes;"> </span>n3 = s1.indexOf("stud");</div>
<div class="MsoNormal">
<span style="mso-spacerun: yes;">
</span>System.out.println(n1);</div>
<div class="MsoNormal">
<span style="mso-spacerun: yes;">
</span>System.out.println(n2);</div>
<div class="MsoNormal">
<span style="mso-spacerun: yes;">
</span>System.out.println(n3);</div>
<div class="MsoNormal">
<span style="mso-spacerun: yes;"> </span>String s3 =
"";</div>
<div class="MsoNormal">
<span style="mso-spacerun: yes;"> </span>String s4 =
"";</div>
<div class="MsoNormal">
<span style="mso-spacerun: yes;"> </span>s3 =
s1.substring(4);</div>
<div class="MsoNormal">
<span style="mso-spacerun: yes;"> </span>s4 =
s1.substring(4,12);</div>
<div class="MsoNormal">
<span style="mso-spacerun: yes;"> </span>System.out.println(s3);</div>
<div class="MsoNormal">
<span style="mso-spacerun: yes;">
</span>System.out.println(s4);</div>
<div class="MsoNormal">
<span style="mso-spacerun: yes;"> </span>}</div>
<div class="MsoNormal">
}</div>
<div class="MsoNormal">
<span style="background: yellow; mso-highlight: yellow;">// 15.
Ternary operator in java(?:)</span></div>
<div class="MsoNormal">
class testif{</div>
<div class="MsoNormal">
public static void main(String args[]){</div>
<div class="MsoNormal">
int c=34;</div>
<div class="MsoNormal">
String d=(c>34)?"PASS":"FAIL";</div>
<div class="MsoNormal">
System.out.println(d);</div>
<div class="MsoNormal">
}</div>
<div class="MsoNormal">
}</div>
<div class="MsoNormal">
<span style="background: yellow; mso-highlight: yellow;">// 16.
Switch case in java</span></div>
<div class="MsoNormal">
class testswitch{</div>
<div class="MsoNormal">
public static void main(String args[]){</div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
int day=7;</div>
<div class="MsoNormal">
switch(day)</div>
<div class="MsoNormal">
{</div>
<div class="MsoNormal">
case 1: System.out.println("Sunday");</div>
<div class="MsoNormal">
break;</div>
<div class="MsoNormal">
case 2: System.out.println("Monday");</div>
<div class="MsoNormal">
break;</div>
<div class="MsoNormal">
case 3: System.out.println("Tuesday");</div>
<div class="MsoNormal">
break;</div>
<div class="MsoNormal">
case 4: System.out.println("wednesday");</div>
<div class="MsoNormal">
break;</div>
<div class="MsoNormal">
case 5: System.out.println("Thursday");</div>
<div class="MsoNormal">
break;</div>
<div class="MsoNormal">
case 6: System.out.println("Friday");</div>
<div class="MsoNormal">
break;</div>
<div class="MsoNormal">
case 7:System.out.println("Saturday");</div>
<div class="MsoNormal">
break;</div>
<div class="MsoNormal">
default: System.out.println("Sorry! Invalid
choice!");</div>
<div class="MsoNormal">
break;</div>
<div class="MsoNormal">
}</div>
<div class="MsoNormal">
}</div>
<div class="MsoNormal">
}</div>
<div class="MsoNormal">
<span style="background: yellow; mso-highlight: yellow;">// 17.
Java Applet program</span></div>
<div class="MsoNormal">
import java.awt.*;</div>
<div class="MsoNormal">
import java.awt.event.*;</div>
<div class="MsoNormal">
import java.applet.*;</div>
<div class="MsoNormal">
public class textinput extends Applet implements
ActionListener</div>
<div class="MsoNormal">
{</div>
<div class="MsoNormal">
<span style="mso-tab-count: 1;"> </span>Font
f=new Font("TimesRoman",Font.BOLD,30);</div>
<div class="MsoNormal">
<span style="mso-tab-count: 1;"> </span>TextField
t1,t2;</div>
<div class="MsoNormal">
<span style="mso-tab-count: 1;"> </span>Button
b1;</div>
<div class="MsoNormal">
<span style="mso-tab-count: 1;"> </span>Label
l1;</div>
<div class="MsoNormal">
<span style="mso-tab-count: 1;"> </span>public
void init()</div>
<div class="MsoNormal">
<span style="mso-tab-count: 1;"> </span>{</div>
<div class="MsoNormal">
<span style="mso-tab-count: 2;"> </span>setBackground(Color.pink);</div>
<div class="MsoNormal">
<span style="mso-tab-count: 2;"> </span>setForeground(Color.black);</div>
<div class="MsoNormal">
<span style="mso-tab-count: 2;"> </span>t1=new
TextField(8);</div>
<div class="MsoNormal">
<span style="mso-tab-count: 2;"> </span>t2=new
TextField(8);</div>
<div class="MsoNormal">
<span style="mso-tab-count: 2;"> </span>b1=new
Button("Ok");</div>
<div class="MsoNormal">
<span style="mso-tab-count: 2;"> </span>setFont(f);</div>
<div class="MsoNormal">
<span style="mso-tab-count: 2;"> </span>l1=new
Label("Enter a Number");</div>
<div class="MsoNormal">
<span style="mso-tab-count: 2;"> </span>add(l1);</div>
<div class="MsoNormal">
<span style="mso-tab-count: 2;"> </span>add(t1);</div>
<div class="MsoNormal">
<span style="mso-tab-count: 2;"> </span>add(t2);</div>
<div class="MsoNormal">
<span style="mso-tab-count: 2;"> </span>add(b1);</div>
<div class="MsoNormal">
<span style="mso-tab-count: 2;"> </span>b1.addActionListener(this);</div>
<div class="MsoNormal">
<span style="mso-tab-count: 1;"> </span>}</div>
<div class="MsoNormal">
<span style="mso-tab-count: 1;"> </span>public
void actionPerformed(ActionEvent e)</div>
<div class="MsoNormal">
<span style="mso-tab-count: 1;"> </span>{</div>
<div class="MsoNormal">
<span style="mso-tab-count: 2;"> </span>if(e.getSource()==b1)</div>
<div class="MsoNormal">
<span style="mso-tab-count: 2;"> </span>{</div>
<div class="MsoNormal">
<span style="mso-tab-count: 3;"> </span>int
n, r,rev=0;</div>
<div class="MsoNormal">
<span style="mso-tab-count: 3;"> </span>String
s1;</div>
<div class="MsoNormal">
<span style="mso-tab-count: 3;"> </span>s1=t1.getText();</div>
<div class="MsoNormal">
<span style="mso-tab-count: 3;"> </span>n=Integer.parseInt(s1);</div>
<div class="MsoNormal">
<span style="mso-tab-count: 3;"> </span>while(n!=0)</div>
<div class="MsoNormal">
<span style="mso-tab-count: 3;"> </span>{</div>
<div class="MsoNormal">
<span style="mso-tab-count: 4;"> </span>r=n%10;</div>
<div class="MsoNormal">
<span style="mso-tab-count: 4;"> </span>rev=rev*10+r;</div>
<div class="MsoNormal">
<span style="mso-tab-count: 4;"> </span>n=n/10;</div>
<div class="MsoNormal">
<span style="mso-tab-count: 3;"> </span>}</div>
<div class="MsoNormal">
<span style="mso-tab-count: 3;"> </span>String
x=String.valueOf(rev);</div>
<div class="MsoNormal">
<span style="mso-tab-count: 3;"> </span>t2.setText(x);</div>
<div class="MsoNormal">
<span style="mso-tab-count: 2;"> </span>}</div>
<div class="MsoNormal">
<span style="mso-tab-count: 1;"> </span>}</div>
<div class="MsoNormal">
}</div>
<div class="MsoNormal">
<span style="background: yellow; mso-highlight: yellow;">// 18. Vector
Demo</span></div>
<div class="MsoNormal">
import java.io.*;</div>
<div class="MsoNormal">
import java.util.*; </div>
<div class="MsoNormal">
class VectorDemo1</div>
<div class="MsoNormal">
{ </div>
<div class="MsoNormal">
public static void main(String args[]) throws IOException</div>
<div class="MsoNormal">
{ </div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
Vector v = new Vector( ); </div>
<div class="MsoNormal">
BufferedReader br=new BufferedReader(new
InputStreamReader(System.in));</div>
<div class="MsoNormal">
while(true)</div>
<div class="MsoNormal">
{</div>
<div class="MsoNormal">
System.out.println("1.Creation");</div>
<div class="MsoNormal">
System.out.println("2.Insertion");</div>
<div class="MsoNormal">
System.out.println("3.Deletion");</div>
<div class="MsoNormal">
System.out.println("4.Display");</div>
<div class="MsoNormal">
System.out.println("5.exit");</div>
<div class="MsoNormal">
System.out.println("Enter Ur Choice:");</div>
<div class="MsoNormal">
int n=Integer.parseInt(br.readLine());</div>
<div class="MsoNormal">
switch(n)</div>
<div class="MsoNormal">
{</div>
<div class="MsoNormal">
<span style="mso-tab-count: 1;"> </span>case 1:
<span style="mso-tab-count: 1;"> </span></div>
<div class="MsoNormal">
<span style="mso-tab-count: 2;"> </span>System.out.println("Enter
the Element:");</div>
<div class="MsoNormal">
<span style="mso-tab-count: 2;"> </span>v.addElement(new
Integer(br.readLine())); </div>
<div class="MsoNormal">
<span style="mso-tab-count: 2;"> </span>break;</div>
<div class="MsoNormal">
<span style="mso-tab-count: 1;"> </span>case 2:<span style="mso-tab-count: 1;"> </span>System.out.println("Enter the position to
be inserted:");</div>
<div class="MsoNormal">
<span style="mso-tab-count: 2;"> </span>int
x=Integer.parseInt(br.readLine());</div>
<div class="MsoNormal">
<span style="mso-tab-count: 2;"> </span>v.insertElementAt(new
Integer(br.readLine()),x); </div>
<div class="MsoNormal">
<span style="mso-tab-count: 2;"> </span>break;</div>
<div class="MsoNormal">
<span style="mso-tab-count: 1;"> </span>case 3:<span style="mso-tab-count: 1;"> </span>System.out.println("Enter the position to
be deleted:");</div>
<div class="MsoNormal">
<span style="mso-tab-count: 2;"> </span>int
y=Integer.parseInt(br.readLine());</div>
<div class="MsoNormal">
<span style="mso-tab-count: 2;"> </span>v.removeElementAt(y);
</div>
<div class="MsoNormal">
<span style="mso-tab-count: 2;"> </span>break;</div>
<div class="MsoNormal">
<span style="mso-tab-count: 1;"> </span>case 4:
System.out.println("Elements are:");</div>
<div class="MsoNormal">
<span style="mso-tab-count: 2;"> </span>for(int
i=0;i<v.size();i++)</div>
<div class="MsoNormal">
<span style="mso-tab-count: 2;"> </span>System.out.println(v.get(i)+"
");<span style="mso-tab-count: 2;"> </span></div>
<div class="MsoNormal">
<span style="mso-tab-count: 2;"> </span>break;</div>
<div class="MsoNormal">
<span style="mso-tab-count: 1;"> </span>case 5:<span style="mso-tab-count: 1;"> </span>System.exit(0);</div>
<div class="MsoNormal">
<span style="mso-spacerun: yes;"> </span>} </div>
<div class="MsoNormal">
<span style="mso-spacerun: yes;"> </span>}</div>
<div class="MsoNormal">
<span style="mso-spacerun: yes;"> </span>}</div>
<div class="MsoNormal">
}</div>
<div class="MsoNormal">
<span style="background: yellow; mso-highlight: yellow;">// 19.
PACKAGE PROGRAM IN JAVA</span></div>
<div class="MsoNormal">
// 1. CREATE A FOLDER arithmetic and save the following file
calculations.java</div>
<div class="MsoNormal">
package arithmetic;</div>
<div class="MsoNormal">
public class calculations</div>
<div class="MsoNormal">
{</div>
<div class="MsoNormal">
<span style="mso-tab-count: 1;"> </span>public
int add(int a,int b)</div>
<div class="MsoNormal">
<span style="mso-tab-count: 1;"> </span>{</div>
<div class="MsoNormal">
<span style="mso-tab-count: 2;"> </span>return
a+b;</div>
<div class="MsoNormal">
<span style="mso-tab-count: 1;"> </span>}</div>
<div class="MsoNormal">
<span style="mso-tab-count: 1;"> </span>public
int sub(int a,int b)</div>
<div class="MsoNormal">
<span style="mso-tab-count: 1;"> </span>{</div>
<div class="MsoNormal">
<span style="mso-tab-count: 2;"> </span>return
a-b;</div>
<div class="MsoNormal">
<span style="mso-tab-count: 1;"> </span>}</div>
<div class="MsoNormal">
<span style="mso-tab-count: 1;"> </span>public
int mul(int a,int b)</div>
<div class="MsoNormal">
<span style="mso-tab-count: 1;"> </span>{</div>
<div class="MsoNormal">
<span style="mso-tab-count: 2;"> </span>return
a*b;</div>
<div class="MsoNormal">
<span style="mso-tab-count: 1;"> </span>}</div>
<div class="MsoNormal">
<span style="mso-tab-count: 1;"> </span>public
int div(int a,int b)</div>
<div class="MsoNormal">
<span style="mso-tab-count: 1;"> </span>{</div>
<div class="MsoNormal">
<span style="mso-tab-count: 2;"> </span>return
a/b;</div>
<div class="MsoNormal">
<span style="mso-tab-count: 1;"> </span>}</div>
<div class="MsoNormal">
}</div>
<div class="MsoNormal">
/*2. Create another file outside arithmetic folder with the
name performoperations.java and run the file */</div>
<div class="MsoNormal">
//importing package</div>
<div class="MsoNormal">
import arithmetic.calculations;</div>
<div class="MsoNormal">
class performoperations</div>
<div class="MsoNormal">
{</div>
<div class="MsoNormal">
<span style="mso-tab-count: 1;"> </span>public
static void main(String []args)</div>
<div class="MsoNormal">
<span style="mso-tab-count: 1;"> </span>{</div>
<div class="MsoNormal">
<span style="mso-tab-count: 2;"> </span>calculations
c=new calculations();</div>
<div class="MsoNormal">
<span style="mso-tab-count: 2;"> </span>int
a=Integer.parseInt(args[0]);</div>
<div class="MsoNormal">
<span style="mso-tab-count: 2;"> </span>int
b=Integer.parseInt(args[1]);</div>
<div class="MsoNormal">
<span style="mso-tab-count: 2;"> </span>int
z=c.mul(a,b);</div>
<div class="MsoNormal">
<span style="mso-tab-count: 2;"> </span>int
v=c.sub(a,b);</div>
<div class="MsoNormal">
<span style="mso-tab-count: 2;"> </span>System.out.println("Addition
is:"+c.add(a,b));</div>
<div class="MsoNormal">
<span style="mso-tab-count: 2;"> </span>System.out.println("Division
is:"+c.div(a,b));</div>
<div class="MsoNormal">
<span style="mso-tab-count: 2;"> </span>System.out.println("Multiplication
is:"+z);</div>
<div class="MsoNormal">
<span style="mso-tab-count: 2;"> </span>System.out.println("Subtraction
is:"+v);<span style="mso-tab-count: 1;"> </span></div>
<div class="MsoNormal">
<span style="mso-tab-count: 1;"> </span>}</div>
<div class="MsoNormal">
}</div>
<br /></div>
Bagadhi Sateeshhttp://www.blogger.com/profile/16786636572407672825noreply@blogger.com0tag:blogger.com,1999:blog-8352540103162095489.post-69199349428484997252018-09-18T13:46:00.002+05:302018-09-18T13:46:32.744+05:30Applet Programming<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<div class="MsoTitle">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">Applet
Programming<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">Applets
are small java programs that are primarily used in Internet Computing. An
applet is an GUI Interface that provides look and feel as compare to console
application.<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">Applets
are not directly executable instead they should run inside a browser either
embedding with HTML pages or by using applet viewer.<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">Applets
can draw pictures on a web pages, play sounds, arithmetic calculations etc.,<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b style="mso-bidi-font-weight: normal;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">Local Applets: </span></b><span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-bidi-font-weight: bold;">An applet developed locally and stored in a local system is known as a
local applet.<o:p></o:p></span></div>
<div class="MsoNormal">
<b><span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">Remote Applets:</span></b><span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"> An applet that's stored on another
computer and which must be downloaded to your computer over the Internet.<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b style="mso-bidi-font-weight: normal;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">How Applets differ from
Applications <o:p></o:p></span></b></div>
<div class="MsoNormal">
<br /></div>
<table border="1" cellpadding="0" cellspacing="0" class="MsoNormalTable" style="border-collapse: collapse; border: none; mso-border-alt: solid windowtext .5pt; mso-border-insideh: .5pt solid windowtext; mso-border-insidev: .5pt solid windowtext; mso-padding-alt: 0cm 5.4pt 0cm 5.4pt; mso-yfti-tbllook: 480;">
<tbody>
<tr style="height: 18.85pt; mso-yfti-firstrow: yes; mso-yfti-irow: 0;">
<td style="border: solid windowtext 1.0pt; height: 18.85pt; mso-border-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 230.4pt;" valign="top" width="307">
<div align="center" class="MsoNormal" style="text-align: center;">
<b style="mso-bidi-font-weight: normal;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">Java
Application Program</span></b><b style="mso-bidi-font-weight: normal;"><span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 10.0pt; mso-bidi-font-size: 11.0pt;"><o:p></o:p></span></b></div>
</td>
<td style="border-left: none; border: solid windowtext 1.0pt; height: 18.85pt; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt;" valign="top">
<div align="center" class="MsoNormal" style="text-align: center;">
<b style="mso-bidi-font-weight: normal;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">Java
Applet Program<o:p></o:p></span></b></div>
</td>
</tr>
<tr style="mso-yfti-irow: 1;">
<td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 230.4pt;" valign="top" width="307">
<ul style="margin-top: 0cm;" type="disc">
<li class="MsoNormal" style="mso-list: l2 level1 lfo1; tab-stops: list 36.0pt; text-align: left;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">These
programs can be executed independently<o:p></o:p></span></li>
</ul>
</td>
<td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt;" valign="top">
<ul style="margin-top: 0cm;" type="disc">
<li class="MsoNormal" style="mso-list: l2 level1 lfo1; tab-stops: list 36.0pt; text-align: left;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">Applets
cannot be executed independently<o:p></o:p></span></li>
</ul>
</td>
</tr>
<tr style="mso-yfti-irow: 2;">
<td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 230.4pt;" valign="top" width="307">
<ul style="margin-top: 0cm;" type="disc">
<li class="MsoNormal" style="mso-list: l2 level1 lfo1; tab-stops: list 36.0pt; text-align: left;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">It
contains main() method for initiating the execution of a code<o:p></o:p></span></li>
</ul>
</td>
<td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt;" valign="top">
<ul style="margin-top: 0cm;" type="disc">
<li class="MsoNormal" style="mso-list: l2 level1 lfo1; tab-stops: list 36.0pt; text-align: left;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">It
does not contain main() method<o:p></o:p></span></li>
</ul>
</td>
</tr>
<tr style="mso-yfti-irow: 3;">
<td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 230.4pt;" valign="top" width="307">
<ul style="margin-top: 0cm;" type="disc">
<li class="MsoNormal" style="mso-list: l2 level1 lfo1; tab-stops: list 36.0pt; text-align: left;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">Applications
have no inherent security restrictions & can perform read/write to
files in local system<o:p></o:p></span></li>
</ul>
</td>
<td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt;" valign="top">
<ul style="margin-top: 0cm;" type="disc">
<li class="MsoNormal" style="mso-list: l2 level1 lfo1; tab-stops: list 36.0pt; text-align: left;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">Applets
cannot read or write to the files in the local computer<o:p></o:p></span></li>
</ul>
</td>
</tr>
<tr style="mso-yfti-irow: 4;">
<td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 230.4pt;" valign="top" width="307">
<ul style="margin-top: 0cm;" type="disc">
<li class="MsoNormal" style="mso-list: l2 level1 lfo1; tab-stops: list 36.0pt; text-align: left;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">Have
no special support in HTML<o:p></o:p></span></li>
</ul>
</td>
<td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt;" valign="top">
<ul style="margin-top: 0cm;" type="disc">
<li class="MsoNormal" style="mso-list: l2 level1 lfo1; tab-stops: list 36.0pt; text-align: left;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">Can
be embedded in HTML pages<o:p></o:p></span></li>
</ul>
</td>
</tr>
<tr style="mso-yfti-irow: 5; mso-yfti-lastrow: yes;">
<td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 230.4pt;" valign="top" width="307">
<ul style="margin-top: 0cm;" type="disc">
<li class="MsoNormal" style="mso-list: l2 level1 lfo1; tab-stops: list 36.0pt; text-align: left;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">These
are not restricted from using libraries from other languages such as C
or C++ through native methods<o:p></o:p></span></li>
</ul>
</td>
<td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt;" valign="top">
<ul style="margin-top: 0cm;" type="disc">
<li class="MsoNormal" style="mso-list: l2 level1 lfo1; tab-stops: list 36.0pt; text-align: left;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">Applets
are restricted from using libraries from other languages such as C or
C++<o:p></o:p></span></li>
</ul>
</td>
</tr>
</tbody></table>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b style="mso-bidi-font-weight: normal;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">Preparing to write Applets <o:p></o:p></span></b></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">The
steps involved in developing and testing an applet are:<o:p></o:p></span></div>
<ul style="margin-top: 0cm;" type="disc">
<li class="MsoNormal" style="mso-list: l6 level1 lfo2; tab-stops: list 36.0pt; text-align: left;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">Building
an applet code<o:p></o:p></span></li>
<li class="MsoNormal" style="mso-list: l6 level1 lfo2; tab-stops: list 36.0pt; text-align: left;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">Creating
an executable applet<o:p></o:p></span></li>
<li class="MsoNormal" style="mso-list: l6 level1 lfo2; tab-stops: list 36.0pt; text-align: left;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">Designing
a Web Page using HTML tags<o:p></o:p></span></li>
<li class="MsoNormal" style="mso-list: l6 level1 lfo2; tab-stops: list 36.0pt; text-align: left;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">Preparing
< Applet >Tag <o:p></o:p></span></li>
<li class="MsoNormal" style="mso-list: l6 level1 lfo2; tab-stops: list 36.0pt; text-align: left;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">Incorporating
<Applet> tag into the web page <o:p></o:p></span></li>
<li class="MsoNormal" style="mso-list: l6 level1 lfo2; tab-stops: list 36.0pt; text-align: left;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">Creating
HTML file<o:p></o:p></span></li>
<li class="MsoNormal" style="mso-list: l6 level1 lfo2; tab-stops: list 36.0pt; text-align: left;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">Testing
the applet code.<o:p></o:p></span></li>
</ul>
<div class="MsoNormal">
<b><span lang="EN-US" style="font-family: "Times New Roman","serif";">Building Applet Code</span></b></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">The
applet class which is contained in the java.applet package provides life and
behaviour to the applet through its methods. When an applet is loaded, java
automatically calls a series of Applet class methods for starting, running and
stopping the applet code.<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">Applet
code imports java.awt package that contains the Graphic class.<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b style="mso-bidi-font-weight: normal;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">Format of an applet code:<o:p></o:p></span></b></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">import
java.awt.*;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">import
java.applet.*;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">----------<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">----------<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">public
class <appletclassname> extends Applet<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>………..<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>………..<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>public void paint(Graphics g)<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span>………….<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span>………… // applet code<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span>…………<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>……….<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>……….<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">}<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b style="mso-bidi-font-weight: normal;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">Applet Life Cycle<o:p></o:p></span></b></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">When
an applet is loaded, it undergoes a series of changes in its state. The applet
states include:<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<ul style="margin-top: 0cm;" type="disc">
<li class="MsoNormal" style="mso-list: l3 level1 lfo3; tab-stops: list 36.0pt;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">Born or
initialization state<o:p></o:p></span></li>
<li class="MsoNormal" style="mso-list: l3 level1 lfo3; tab-stops: list 36.0pt;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">Running State<o:p></o:p></span></li>
<li class="MsoNormal" style="mso-list: l3 level1 lfo3; tab-stops: list 36.0pt;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">Idle state<o:p></o:p></span></li>
<li class="MsoNormal" style="mso-list: l3 level1 lfo3; tab-stops: list 36.0pt;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">Dead or destroyed
state<o:p></o:p></span></li>
</ul>
<div class="MsoNormal">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEijZLqfyeLzlN7MAvlheh0aATjHiKfsSmFZhGb125FqLmCvm60wB8jBCT40jeQxQMbOFS8dBDfp-hIHEIw4KCJMesae5pFupT6b3d7JoRFW_QU_7XbHWiR5hV3NC44fRr3iEjUYNBTjHfo/s1600/Untitled.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="313" data-original-width="526" height="237" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEijZLqfyeLzlN7MAvlheh0aATjHiKfsSmFZhGb125FqLmCvm60wB8jBCT40jeQxQMbOFS8dBDfp-hIHEIw4KCJMesae5pFupT6b3d7JoRFW_QU_7XbHWiR5hV3NC44fRr3iEjUYNBTjHfo/s400/Untitled.png" width="400" /></a></div>
<br />
<div class="MsoNormal">
<!--[if mso & !supportInlineShapes & supportFields]><span
lang=EN-US style='font-family:"Times New Roman","serif"'><span
style='mso-element:field-begin;mso-field-lock:yes'></span><span
style='mso-spacerun:yes'> </span>SHAPE <span
style='mso-spacerun:yes'> </span>\* MERGEFORMAT <span style='mso-element:field-separator'></span></span><![endif]--><span lang="EN-US" style="font-family: "Times New Roman","serif";"><!--[if gte vml 1]><v:group
id="_x0000_s1026" editas="canvas" style='width:387pt;height:269.95pt;
mso-position-horizontal-relative:char;mso-position-vertical-relative:line'
coordorigin="3577,2122" coordsize="6450,4628">
<o:lock v:ext="edit" aspectratio="t"/>
<v:shapetype id="_x0000_t75" coordsize="21600,21600" o:spt="75"
o:preferrelative="t" path="m@4@5l@4@11@9@11@9@5xe" filled="f" stroked="f">
<v:stroke joinstyle="miter"/>
<v:formulas>
<v:f eqn="if lineDrawn pixelLineWidth 0"/>
<v:f eqn="sum @0 1 0"/>
<v:f eqn="sum 0 0 @1"/>
<v:f eqn="prod @2 1 2"/>
<v:f eqn="prod @3 21600 pixelWidth"/>
<v:f eqn="prod @3 21600 pixelHeight"/>
<v:f eqn="sum @0 0 1"/>
<v:f eqn="prod @6 1 2"/>
<v:f eqn="prod @7 21600 pixelWidth"/>
<v:f eqn="sum @8 21600 0"/>
<v:f eqn="prod @7 21600 pixelHeight"/>
<v:f eqn="sum @10 21600 0"/>
</v:formulas>
<v:path o:extrusionok="f" gradientshapeok="t" o:connecttype="rect"/>
<o:lock v:ext="edit" aspectratio="t"/>
</v:shapetype><v:shape id="_x0000_s1027" type="#_x0000_t75" style='position:absolute;
left:3577;top:2122;width:6450;height:4628' o:preferrelative="f">
<v:fill o:detectmouseclick="t"/>
<v:path o:extrusionok="t" o:connecttype="none"/>
<o:lock v:ext="edit" text="t"/>
</v:shape><v:group id="_x0000_s1028" style='position:absolute;left:3577;top:2431;
width:6450;height:4319' coordorigin="3577,2431" coordsize="6450,4319">
<v:oval id="_x0000_s1029" style='position:absolute;left:5527;top:2431;
width:900;height:771'>
<v:textbox>
<![if !mso]>
<table cellpadding=0 cellspacing=0 width="100%">
<tr>
<td><![endif]>
<div>
<p class=MsoNormal>
<span lang=EN-US>Born</span></p>
</div>
<![if !mso]></td>
</tr>
</table>
<![endif]></v:textbox>
</v:oval><v:oval id="_x0000_s1030" style='position:absolute;left:5377;top:4436;
width:1350;height:617'>
<v:textbox>
<![if !mso]>
<table cellpadding=0 cellspacing=0 width="100%">
<tr>
<td><![endif]>
<div>
<p class=MsoNormal align=center style='text-align:center'>
<span
lang=EN-US>Running</span></p>
</div>
<![if !mso]></td>
</tr>
</table>
<![endif]></v:textbox>
</v:oval><v:oval id="_x0000_s1031" style='position:absolute;left:7927;top:4282;
width:900;height:771'>
<v:textbox>
<![if !mso]>
<table cellpadding=0 cellspacing=0 width="100%">
<tr>
<td><![endif]>
<div>
<p class=MsoNormal align=center style='text-align:center'>
<span
lang=EN-US>Idle</span></p>
</div>
<![if !mso]></td>
</tr>
</table>
<![endif]></v:textbox>
</v:oval><v:oval id="_x0000_s1032" style='position:absolute;left:7927;top:5979;
width:900;height:771'>
<v:textbox>
<![if !mso]>
<table cellpadding=0 cellspacing=0 width="100%">
<tr>
<td><![endif]>
<div>
<p class=MsoNormal align=center style='text-align:center'>
<span
lang=EN-US>Dead</span></p>
</div>
<![if !mso]></td>
</tr>
</table>
<![endif]></v:textbox>
</v:oval><v:line id="_x0000_s1033" style='position:absolute' from="8377,5053"
to="8377,5979">
<v:stroke endarrow="block"/>
</v:line><v:line id="_x0000_s1034" style='position:absolute' from="8827,6287"
to="9127,6287">
<v:stroke endarrow="block"/>
</v:line><v:shapetype id="_x0000_t202" coordsize="21600,21600" o:spt="202"
path="m,l,21600r21600,l21600,xe">
<v:stroke joinstyle="miter"/>
<v:path gradientshapeok="t" o:connecttype="rect"/>
</v:shapetype><v:shape id="_x0000_s1035" type="#_x0000_t202" style='position:absolute;
left:9127;top:6155;width:900;height:331' stroked="f">
<v:textbox>
<![if !mso]>
<table cellpadding=0 cellspacing=0 width="100%">
<tr>
<td><![endif]>
<div>
<p class=MsoNormal>
<span lang=EN-US>End</span></p>
</div>
<![if !mso]></td>
</tr>
</table>
<![endif]></v:textbox>
</v:shape><v:shape id="_x0000_s1036" type="#_x0000_t202" style='position:absolute;
left:6577;top:6133;width:1200;height:331' stroked="f">
<v:textbox>
<![if !mso]>
<table cellpadding=0 cellspacing=0 width="100%">
<tr>
<td><![endif]>
<div>
<p class=MsoNormal>
<span lang=EN-US>Destroyed</span></p>
</div>
<![if !mso]></td>
</tr>
</table>
<![endif]></v:textbox>
</v:shape><v:shape id="_x0000_s1037" type="#_x0000_t202" style='position:absolute;
left:8527;top:5362;width:1200;height:331' stroked="f">
<v:textbox>
<![if !mso]>
<table cellpadding=0 cellspacing=0 width="100%">
<tr>
<td><![endif]>
<div>
<p class=MsoNormal>
<span lang=EN-US>destroy( )</span></p>
</div>
<![if !mso]></td>
</tr>
</table>
<![endif]></v:textbox>
</v:shape><v:shape id="_x0000_s1038" type="#_x0000_t202" style='position:absolute;
left:8977;top:4436;width:1050;height:332' stroked="f">
<v:textbox>
<![if !mso]>
<table cellpadding=0 cellspacing=0 width="100%">
<tr>
<td><![endif]>
<div>
<p class=MsoNormal>
<span lang=EN-US>stopped</span></p>
</div>
<![if !mso]></td>
</tr>
</table>
<![endif]></v:textbox>
</v:shape><v:shape id="_x0000_s1039" type="#_x0000_t202" style='position:absolute;
left:6877;top:2585;width:1350;height:332' stroked="f">
<v:textbox>
<![if !mso]>
<table cellpadding=0 cellspacing=0 width="100%">
<tr>
<td><![endif]>
<div>
<p class=MsoNormal>
<span lang=EN-US>Initialization</span></p>
</div>
<![if !mso]></td>
</tr>
</table>
<![endif]></v:textbox>
</v:shape><v:shape id="_x0000_s1040" type="#_x0000_t202" style='position:absolute;
left:4327;top:2585;width:750;height:332' stroked="f">
<v:textbox>
<![if !mso]>
<table cellpadding=0 cellspacing=0 width="100%">
<tr>
<td><![endif]>
<div>
<p class=MsoNormal>
<span lang=EN-US>Begin</span></p>
</div>
<![if !mso]></td>
</tr>
</table>
<![endif]></v:textbox>
</v:shape><v:line id="_x0000_s1041" style='position:absolute' from="5077,2739"
to="5527,2739">
<v:stroke endarrow="block"/>
</v:line><v:line id="_x0000_s1042" style='position:absolute' from="5977,3202"
to="5977,4436">
<v:stroke endarrow="block"/>
</v:line><v:shape id="_x0000_s1043" type="#_x0000_t202" style='position:absolute;
left:4927;top:3510;width:900;height:333' stroked="f">
<v:textbox>
<![if !mso]>
<table cellpadding=0 cellspacing=0 width="100%">
<tr>
<td><![endif]>
<div>
<p class=MsoNormal>
<span lang=EN-US>Start( )</span></p>
</div>
<![if !mso]></td>
</tr>
</table>
<![endif]></v:textbox>
</v:shape><v:shape id="_x0000_s1044" style='position:absolute;left:4602;
top:4590;width:1075;height:463' coordsize="1290,720" path="m1290,720c675,690,60,660,30,540,,420,870,150,1110,e"
filled="f">
<v:path arrowok="t"/>
</v:shape><v:shape id="_x0000_s1045" type="#_x0000_t202" style='position:absolute;
left:3577;top:4745;width:900;height:333' stroked="f">
<v:textbox>
<![if !mso]>
<table cellpadding=0 cellspacing=0 width="100%">
<tr>
<td><![endif]>
<div>
<p class=MsoNormal>
<span lang=EN-US>Display</span></p>
</div>
<![if !mso]></td>
</tr>
</table>
<![endif]></v:textbox>
</v:shape><v:shape id="_x0000_s1046" type="#_x0000_t202" style='position:absolute;
left:4477;top:5207;width:900;height:334' stroked="f">
<v:textbox>
<![if !mso]>
<table cellpadding=0 cellspacing=0 width="100%">
<tr>
<td><![endif]>
<div>
<p class=MsoNormal>
<span lang=EN-US>paint( )</span></p>
</div>
<![if !mso]></td>
</tr>
</table>
<![endif]></v:textbox>
</v:shape><v:line id="_x0000_s1047" style='position:absolute;flip:x' from="6577,4899"
to="8077,4900">
<v:stroke endarrow="block"/>
</v:line><v:line id="_x0000_s1048" style='position:absolute' from="6427,4436"
to="7927,4436">
<v:stroke endarrow="block"/>
</v:line><v:shape id="_x0000_s1049" type="#_x0000_t202" style='position:absolute;
left:6877;top:3973;width:1050;height:332' stroked="f">
<v:textbox>
<![if !mso]>
<table cellpadding=0 cellspacing=0 width="100%">
<tr>
<td><![endif]>
<div>
<p class=MsoNormal>
<span lang=EN-US>Stop( )</span></p>
</div>
<![if !mso]></td>
</tr>
</table>
<![endif]></v:textbox>
</v:shape><v:shape id="_x0000_s1050" type="#_x0000_t202" style='position:absolute;
left:6877;top:5053;width:1050;height:332' stroked="f">
<v:textbox>
<![if !mso]>
<table cellpadding=0 cellspacing=0 width="100%">
<tr>
<td><![endif]>
<div>
<p class=MsoNormal>
<span lang=EN-US>Start( )</span></p>
</div>
<![if !mso]></td>
</tr>
</table>
<![endif]></v:textbox>
</v:shape></v:group><w:wrap type="none"/>
<w:anchorlock/>
</v:group><![endif]--><!--[if !vml]--><!--[endif]--></span><!--[if mso & !supportInlineShapes & supportFields]><span
lang=EN-US style='font-family:"Times New Roman","serif"'><v:shape id="_x0000_i1025"
type="#_x0000_t75" style='width:387pt;height:269.95pt'>
<v:imagedata croptop="-65520f" cropbottom="65520f"/>
</v:shape><span style='mso-element:field-end'></span></span><![endif]--><span lang="EN-US" style="font-family: "Times New Roman","serif";"><o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div align="center" class="MsoNormal" style="tab-stops: 284.25pt; text-align: center;">
<b style="mso-bidi-font-weight: normal;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">Applets’
Life Cycle<o:p></o:p></span></b></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b style="mso-bidi-font-weight: normal;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">Initialization State<o:p></o:p></span></b></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">This
is achieved by calling init( ) method of Applet Class. At this stage, applet is
born. In this method we may do the following such as<o:p></o:p></span></div>
<ul style="margin-top: 0cm;" type="disc">
<li class="MsoNormal" style="mso-list: l1 level1 lfo4; tab-stops: list 36.0pt;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">Set up initial
values<o:p></o:p></span></li>
<li class="MsoNormal" style="mso-list: l1 level1 lfo4; tab-stops: list 36.0pt;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">Changing fonts<o:p></o:p></span></li>
<li class="MsoNormal" style="mso-list: l1 level1 lfo4; tab-stops: list 36.0pt;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">Setting up the
colors<o:p></o:p></span></li>
<li class="MsoNormal" style="mso-list: l1 level1 lfo4; tab-stops: list 36.0pt;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">Loading images<o:p></o:p></span></li>
</ul>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">This
stage occurs only once in the applet’s life cycle.<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b style="mso-bidi-font-weight: normal;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">Running State<o:p></o:p></span></b></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">This
occurs automatically after the applet is initialized by calling the start ( )
method. Starting can also occur if the applet is already in “stopped” state.
For example, we may leave the web page containing the applet temporarily to
another page and return back to the page. This again starts the applet running.
Start ( ) method may be called more than once.<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b style="mso-bidi-font-weight: normal;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">Idle or Stopped State<o:p></o:p></span></b></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">An
applet becomes idle when its stopped from running. Stopping occurs
automatically when we leave the page containing running applet. We can also do
so by calling the stop() method explicitly. <o:p></o:p></span></div>
<div class="MsoNormal">
<b style="mso-bidi-font-weight: normal;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">Dead State<o:p></o:p></span></b></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">An
applet is said to be dead when it is removed from memory. This occurs
automatically by invoking the destroy () method when we quit the applet. This
state occurs only once in the applets life cycle. <o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b style="mso-bidi-font-weight: normal;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">Display State<o:p></o:p></span></b></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">Applet
moves to the display state whenever it has to perform some output operations on
the screen. This happens immediately after the applet enters into the running
state. <o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b style="mso-bidi-font-weight: normal;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">Creating an Executable Applet<o:p></o:p></span></b></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">import
java.awt.*;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">import
java.applet.*;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">/*
<applet code=”hellojava” height=400 width=300> </applet> */<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">public
class hellojava extends Applet<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>public void paint(Graphics g)<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span>g.drawString(“Hello
welcome to applets”,10,100);<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt;"><o:p> </o:p></span><span style="font-family: "Times New Roman", serif; font-size: 9pt;"> </span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">The
first imports the Abstract Window Toolkit(AWT) classes. Applets interact with
the users through the AWT. The second import statement imports the applet
package, which contains the class Applet. <o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">The
next line in the program declares the class hellojava. This class must be
declared as public because it will be accessed by code that is outside the
program. Paint( ) is defined by AWT and must be overridden by the applet.
Inside paint() there is a call to drawstring( ) which is a member of the
Graphics class. This method outputs a string beginning at the specified X,Y
location. It has the following general form: <o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">void
drawstring(String message, int x,int y)<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">After
we enter the source code for hellojava, compile in the same way that you have
been compiling programs. Then it produces a hellojava. class file. However
running a hellojava involves a different process. Infact there are 2 ways in
which you can run an applet:<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<ul style="margin-top: 0cm;" type="disc">
<li class="MsoNormal" style="mso-list: l4 level1 lfo5; tab-stops: list 36.0pt;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">Executing the
applet within a browser<o:p></o:p></span></li>
<li class="MsoNormal" style="mso-list: l4 level1 lfo5; tab-stops: list 36.0pt;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">Using an
appletviewer<o:p></o:p></span></li>
</ul>
<div class="MsoNormal">
<b><span lang="EN-US" style="font-family: "Times New Roman","serif";">Designing a Web Page</span></b></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">A
web page is basically made up of text and HTML tags that can be interpreted by
a web browser of an applet-viewer. A web page is also known as HTML page or
HTML document. These pages are saved using the extension .html. HTML files
should be saved in the same directory where the java applet file is saved. <o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b style="mso-bidi-font-weight: normal;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">A webpage is divided into 3
sections:<o:p></o:p></span></b></div>
<div class="MsoNormal">
<br /></div>
<ul style="margin-top: 0cm;" type="disc">
<li class="MsoNormal" style="mso-list: l7 level1 lfo7; tab-stops: list 36.0pt;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">Comment section
(optional)<o:p></o:p></span></li>
<li class="MsoNormal" style="mso-list: l7 level1 lfo7; tab-stops: list 36.0pt;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">Head section
(Optional)<o:p></o:p></span></li>
<li class="MsoNormal" style="mso-list: l7 level1 lfo7; tab-stops: list 36.0pt;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">Body section<o:p></o:p></span></li>
</ul>
<div class="MsoNormal" style="margin-left: 18.0pt;">
<br /></div>
<div class="MsoNormal">
<b style="mso-bidi-font-weight: normal;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">Comment section<o:p></o:p></span></b></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">This
section contains comments about the web page. A comment line begins with <!
and ends with >. It can be included anywhere in the web page.<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span><! The text in this will be
ignored by the browser ><o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span><o:p></o:p></span></div>
<div class="MsoNormal">
<b style="mso-bidi-font-weight: normal;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">Head section<o:p></o:p></span></b></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">This
section usually contains a title for the web page. <o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span><head><o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span><title> Welcome
</title><o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span></head><o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">The
text enclosed between <title> tags will appear in the title bar of the
web page. The head section is also optional.<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b style="mso-bidi-font-weight: normal;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">Body section<o:p></o:p></span></b></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">This
section contains the entire information about the web page and its behavior. <o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span><body><o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span><center><o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 3;"> </span><h1>
welcome to java applets </h1><o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span></center><o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span><br><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-left: 36.0pt; text-indent: 36.0pt;">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><applet
code=filename.class <o:p></o:p></span></div>
<div class="MsoNormal" style="margin-left: 72.0pt; text-indent: 36.0pt;">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">width=size in pixels<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-left: 72.0pt; text-indent: 36.0pt;">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">height=size in
pixels><o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span></applet><o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span></body><o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b style="mso-bidi-font-weight: normal;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">Applet Tag <o:p></o:p></span></b></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">The
<APPLET…> tag supplies the name of the applet to be loaded and tells the
browser how much space the applet requires.<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">/*
<applet code=”hello.class” height=400 width=300> </applet> */<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">The
width and height statements specify the dimensions of the display area used by
the applet. This HTML code tells the browser to load the compiled Java applet
hello.class.<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b style="mso-bidi-font-weight: normal;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">Adding Applet to HTML file <o:p></o:p></span></b></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b style="mso-bidi-font-weight: normal;"><span lang="EN-US" style="font-family: "Times New Roman","serif";"><</span></b><span lang="EN-US" style="font-family: "Times New Roman","serif";">html><o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span><head><o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span><title> Welcome
</title><o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span></head><o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span><body><o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span><center><o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 3;"> </span><h1>
welcome to java applets </h1><o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span></center><o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span><applet
code=filename.class <o:p></o:p></span></div>
<div class="MsoNormal" style="margin-left: 36.0pt; text-indent: 36.0pt;">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-spacerun: yes;"> </span>width=size in pixels<span style="mso-tab-count: 1;"> </span><span style="mso-spacerun: yes;"> </span>//adding appletcode to
html file<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-left: 36.0pt; text-indent: 36.0pt;">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-spacerun: yes;"> </span>height=size in pixels><o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span></applet><o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span></body><o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"></html><o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b style="mso-bidi-font-weight: normal;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">Running the Applet <o:p></o:p></span></b></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">To
run an applet, we require one of the following tools:<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<ul style="margin-top: 0cm;" type="disc">
<li class="MsoNormal" style="mso-list: l0 level1 lfo8; tab-stops: list 36.0pt; text-align: left;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">Java-enabled
Web Browser (such as HotJava or Netscape)<o:p></o:p></span></li>
<li class="MsoNormal" style="mso-list: l0 level1 lfo8; tab-stops: list 36.0pt; text-align: left;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">Java
appletviewer<o:p></o:p></span></li>
</ul>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">If
we use java enabled web browser we will be able to see the entire web page
containing the applet. If we use the appletviewer, we will only see the applet
output. <o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b style="mso-bidi-font-weight: normal;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">To run our applet:<o:p></o:p></span></b></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">appletviewer
classname.html (for executing HTML file)<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">appletviewer
classname.java (for executing java file)<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b style="mso-bidi-font-weight: normal;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">More about Applet Tag <o:p></o:p></span></b></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">The
applet tag is used to start an applet from both an HTML document and from an
appletviewer. <o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><APPLET<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>[CODEBASE=codebase URL]<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>CODE=appletfile<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>[ALT=alternate text]<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>[NAME=appletinstancename]<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>WIDTH= pixels<span style="mso-spacerun: yes;"> </span>HEIGHT= pixels<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>[ALIGN=alignment]<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>[VSPACE=pixels][HSPACE=pixels]<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">><o:p> </o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">[<PARAM
NAME=AttributeName1 VALUE=AttributeValue>]<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">[<PARAM
NAME= AttributeName2 VALUE= AttributeValue>]<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">…………<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">[HTML]<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"></APPLET><o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">Bracketed
items are optional<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b style="mso-bidi-font-weight: normal;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">CODEBASE<span style="mso-tab-count: 2;"> </span></span></b><span lang="EN-US" style="font-family: "Times New Roman","serif";">Codebase
is an optional attribute that specifies the base URL of the applet code, which
is the directory that will be searched for the applet’s executable class file.<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b style="mso-bidi-font-weight: normal;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">CODE <span style="mso-tab-count: 1;"> </span></span></b><span lang="EN-US" style="font-family: "Times New Roman","serif";">Code
is a required attribute that gives the name of the file containing your
applet’s compiled<span style="mso-spacerun: yes;"> </span>.class file.<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b style="mso-bidi-font-weight: normal;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">ALT<span style="mso-tab-count: 1;"> </span></span></b><span lang="EN-US" style="font-family: "Times New Roman","serif";">Non_Java
browsers will display this text where the applet would normally go. This
attribute is optional.<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b style="mso-bidi-font-weight: normal;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">NAME<span style="mso-tab-count: 1;"> </span></span></b><span lang="EN-US" style="font-family: "Times New Roman","serif";">Name
is an optional attribute used to specify a name for the applet instance.<span style="mso-spacerun: yes;"> </span>This provides inter-applet communication
i.e., applets must be named in order for other applets on the same page to find
them by name and communicate with them. To obtain an applet by name, use
getApplet( ) which is defined by AppletContext interface.<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b style="mso-bidi-font-weight: normal;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">WIDTH AND HEIGHT<span style="mso-tab-count: 1;"> </span></span></b><span lang="EN-US" style="font-family: "Times New Roman","serif";">Width and Height are required
attributes that give the size in pixels of the applet display area.<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b style="mso-bidi-font-weight: normal;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">ALIGN</span></b><span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>Align
is an optional attribute that specifies the alignment of the applet with
possible values such as LEFT, RIGHT, TOP, BOTTOM, MIDDLE, TEXTTOP, ABSBOTTOM,
ABSMIDDLE.<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b style="mso-bidi-font-weight: normal;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">VSPACE AND HSPACE <span style="mso-tab-count: 1;"> </span></span></b><span lang="EN-US" style="font-family: "Times New Roman","serif";">Vspace
specifies the space in pixels, above and below the applet. Hspace specifies the
space in pixels, on each side of the applet.<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b style="mso-bidi-font-weight: normal;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">PARAM NAME AND VALUE<span style="mso-tab-count: 1;"> </span></span></b><span lang="EN-US" style="font-family: "Times New Roman","serif";">The PARAM tag allows you to
specify applet specific arguments in an HTML page. Applets access their
attributes with the getParameter( ) method.<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b style="mso-bidi-font-weight: normal;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">Passing Parameters to Applets <o:p></o:p></span></b></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">Applet
tag in HTML allows you to pass parameters to your applet. To retrieve a
parameter, use the getParameter( ) method. It returns the specified parameter
in the form of a String object. We can supply user-defined parameters to an
applet using <PARAM..> tags. Each tag has a name and a value attribute.<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">To
set up and handle parameters, we need to do 2 things:<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-left: 18.0pt; mso-list: l5 level1 lfo6; tab-stops: list 18.0pt; text-indent: -18.0pt;">
<!--[if !supportLists]--><span lang="EN-US" style="font-family: Symbol; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;"><span style="mso-list: Ignore;">·<span style="font: 7.0pt "Times New Roman";">
</span></span></span><!--[endif]--><span lang="EN-US" style="font-family: "Times New Roman","serif";">Include
appropriate <PARAM..> tags in the HTML document.<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-left: 18.0pt; mso-list: l5 level1 lfo6; tab-stops: list 18.0pt; text-indent: -18.0pt;">
<!--[if !supportLists]--><span lang="EN-US" style="font-family: Symbol; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;"><span style="mso-list: Ignore;">·<span style="font: 7.0pt "Times New Roman";">
</span></span></span><!--[endif]--><span lang="EN-US" style="font-family: "Times New Roman","serif";">Provide
code in the applet to parse these parameters.<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b style="mso-bidi-font-weight: normal;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">Java Program: hellojava.java<o:p></o:p></span></b></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-bidi-font-weight: bold;">import java.awt.*;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-bidi-font-weight: bold;">import java.applet.*;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-bidi-font-weight: bold;">public class hellojava extends Applet<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-bidi-font-weight: bold;">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-bidi-font-weight: bold;">String str,str1;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-bidi-font-weight: bold;">public void init()<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-bidi-font-weight: bold;">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-bidi-font-weight: bold;">str=getParameter("string");<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-bidi-font-weight: bold;">str1=getParameter("color");<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-bidi-font-weight: bold;">if(str==null)<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-bidi-font-weight: bold;">str="java";<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-bidi-font-weight: bold;">else<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-bidi-font-weight: bold;">str="Hello<span style="mso-spacerun: yes;">
</span>"+str+str1;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-bidi-font-weight: bold;">}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-bidi-font-weight: bold;">public void paint(Graphics g)<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-bidi-font-weight: bold;">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-bidi-font-weight: bold;">g.drawString(str,10,100);<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-bidi-font-weight: bold;">}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-bidi-font-weight: bold;">}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">D:\
>javac hellojava.java<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b><span lang="EN-US" style="font-family: "Times New Roman","serif";">HTML
File: hellojava.html<o:p></o:p></span></b></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><html><o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><!
parameter html file><o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><head><o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><title><h3>Parameter
html file</h3></title><o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"></head><o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><body><o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><applet
code=hellojava.class<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>width=400<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>height=200<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>><o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><param
name="string" VALUE="Applet!.."><o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><param
name = color value="red"><o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"></applet><o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"></body><o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"></html><o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">D:\
>appletviewer hellojava.html<o:p></o:p></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiUjcpyDg0fMAjZqZxRK0FqgclSvjsSQqMDYYv97BSTb7IE78Id6_Grdd4KEgMraEopk9_lgeIy2p5akhthUpK-PfNexBhnXSApOdyZbvPAYHMWJ2eeYi8KsW6DaFJuS7PXLTWBv1DkfFQ/s1600/Untitled.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="208" data-original-width="316" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiUjcpyDg0fMAjZqZxRK0FqgclSvjsSQqMDYYv97BSTb7IE78Id6_Grdd4KEgMraEopk9_lgeIy2p5akhthUpK-PfNexBhnXSApOdyZbvPAYHMWJ2eeYi8KsW6DaFJuS7PXLTWBv1DkfFQ/s1600/Untitled.png" /></a></div>
<div align="center" class="MsoNormal" style="text-align: center;">
<span style="font-family: "Times New Roman","serif"; mso-ansi-language: EN-IN; mso-fareast-language: EN-IN; mso-no-proof: yes;"><!--[if gte vml 1]><v:shape id="Picture_x0020_12"
o:spid="_x0000_i1026" type="#_x0000_t75" style='width:234pt;height:153pt;
visibility:visible;mso-wrap-style:square'>
<v:imagedata src="file:///C:\Users\Student\AppData\Local\Temp\msohtmlclip1\01\clip_image002.png"
o:title=""/>
</v:shape><![endif]--><!--[if !vml]--><!--[endif]--></span><span lang="EN-US" style="font-family: "Times New Roman","serif";"><o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoBodyText">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">Here
first the java source file should be compiled then it produces a class file
then that class file should be placed in the HTML document then through applet
viewer you have to execute this HTML file. <o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b style="mso-bidi-font-weight: normal;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">More about HTML tags <o:p></o:p></span></b></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoBodyText">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">HTML
stands for Hypertext Markup Language. The following are the some of the HTML
tags.<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<table border="1" cellpadding="0" cellspacing="0" class="MsoNormalTable" style="border-collapse: collapse; border: none; mso-border-alt: solid windowtext .5pt; mso-border-insideh: .5pt solid windowtext; mso-border-insidev: .5pt solid windowtext; mso-padding-alt: 0cm 5.4pt 0cm 5.4pt;">
<tbody>
<tr style="mso-yfti-firstrow: yes; mso-yfti-irow: 0;">
<td style="border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt;" valign="top">
<div class="MsoNormal">
<b style="mso-bidi-font-weight: normal;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">Tag Names<o:p></o:p></span></b></div>
</td>
<td style="border-left: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt;" valign="top">
<div class="MsoNormal">
<b style="mso-bidi-font-weight: normal;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">Description<o:p></o:p></span></b></div>
</td>
</tr>
<tr style="mso-yfti-irow: 1;">
<td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt;" valign="top">
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-bidi-font-weight: bold;"><html> </html><o:p></o:p></span></div>
</td>
<td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt;" valign="top">
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 10.0pt; mso-bidi-font-size: 11.0pt;">The <b>text</b> between <b><html></b>
and <b></html></b> describes the <b>web page.</b><o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
</td>
</tr>
<tr style="mso-yfti-irow: 2;">
<td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt;" valign="top">
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-bidi-font-weight: bold;"><title> </title><o:p></o:p></span></div>
</td>
<td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt;" valign="top">
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 10.0pt; mso-bidi-font-size: 11.0pt; mso-bidi-font-weight: bold;">The
text contained in it will appear in the title bar.<o:p></o:p></span></div>
</td>
</tr>
<tr style="mso-yfti-irow: 3;">
<td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt;" valign="top">
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-bidi-font-weight: bold;"><head> </head><o:p></o:p></span></div>
</td>
<td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt;" valign="top">
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 10.0pt; mso-bidi-font-size: 11.0pt; mso-bidi-font-weight: bold;">This include
the details of the web page<o:p></o:p></span></div>
</td>
</tr>
<tr style="mso-yfti-irow: 4;">
<td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt;" valign="top">
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-bidi-font-weight: bold;"><body> </body><o:p></o:p></span></div>
</td>
<td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt;" valign="top">
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 10.0pt; mso-bidi-font-size: 11.0pt; mso-bidi-font-weight: bold;">This
tag contains the main text of the web page<o:p></o:p></span></div>
</td>
</tr>
<tr style="mso-yfti-irow: 5;">
<td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt;" valign="top">
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-bidi-font-weight: bold;"><br><o:p></o:p></span></div>
</td>
<td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt;" valign="top">
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 10.0pt; mso-bidi-font-size: 11.0pt; mso-bidi-font-weight: bold;">Line
break tag.<o:p></o:p></span></div>
</td>
</tr>
<tr style="mso-yfti-irow: 6;">
<td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt;" valign="top">
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-bidi-font-weight: bold;"><p> </p><o:p></o:p></span></div>
</td>
<td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt;" valign="top">
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 10.0pt; mso-bidi-font-size: 11.0pt; mso-bidi-font-weight: bold;">This
tag moves to the next line and start a paragraph<o:p></o:p></span></div>
</td>
</tr>
<tr style="mso-yfti-irow: 7;">
<td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt;" valign="top">
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-bidi-font-weight: bold;"><a href=” “> </a><o:p></o:p></span></div>
</td>
<td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt;" valign="top">
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 10.0pt; mso-bidi-font-size: 11.0pt; mso-bidi-font-weight: bold;">Anchor
tag used to add hyperlinks<o:p></o:p></span></div>
</td>
</tr>
<tr style="mso-yfti-irow: 8;">
<td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt;" valign="top">
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-bidi-font-weight: bold;"><img src=” “> <o:p></o:p></span></div>
</td>
<td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt;" valign="top">
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 10.0pt; mso-bidi-font-size: 11.0pt; mso-bidi-font-weight: bold;">This
tag displays the image on the webpage<o:p></o:p></span></div>
</td>
</tr>
<tr style="mso-yfti-irow: 9;">
<td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt;" valign="top">
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-bidi-font-weight: bold;"><h1><span style="mso-spacerun: yes;">
</span></h1> to<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-bidi-font-weight: bold;"><h6><span style="mso-spacerun: yes;">
</span></h6><o:p></o:p></span></div>
</td>
<td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt;" valign="top">
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 10.0pt; mso-bidi-font-size: 11.0pt; mso-bidi-font-weight: bold;">Header
tags. Used to display headings<o:p></o:p></span></div>
</td>
</tr>
<tr style="mso-yfti-irow: 10; mso-yfti-lastrow: yes;">
<td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt;" valign="top">
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-bidi-font-weight: bold;"><font> </font><o:p></o:p></span></div>
</td>
<td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt;" valign="top">
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 10.0pt; mso-bidi-font-size: 11.0pt; mso-bidi-font-weight: bold;">We
can change the style,color and size of the font.<o:p></o:p></span></div>
</td>
</tr>
</tbody></table>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b style="mso-bidi-font-weight: normal;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">Displaying Numerical Values <o:p></o:p></span></b></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">In
applets, we can display numerical values by first converting them into strings
and then using the drawString( ) method of graphics class. We can do this
easily by calling the valueOf( ) method of String class.<o:p></o:p></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi_ukiSkEMPDZLO5rDvidNm2zbtnfOm0RU-3XW8xo6T7EDRv_yjgE-Jzwxz6Xz0oQ_fl5FXI-J_sLCEq6gLQdUWx4WZR4tD8gi0kfH68BKUDMJ6W-6MXAqnbMGp0mCgm5iOjuhvzbNblKw/s1600/Untitled.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="208" data-original-width="257" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi_ukiSkEMPDZLO5rDvidNm2zbtnfOm0RU-3XW8xo6T7EDRv_yjgE-Jzwxz6Xz0oQ_fl5FXI-J_sLCEq6gLQdUWx4WZR4tD8gi0kfH68BKUDMJ6W-6MXAqnbMGp0mCgm5iOjuhvzbNblKw/s1600/Untitled.png" /></a></div>
<h1>
<!--[if gte vml 1]><v:shape id="Picture_x0020_141" o:spid="_x0000_s1052"
type="#_x0000_t75" style='position:absolute;left:0;text-align:left;
margin-left:243pt;margin-top:6.65pt;width:190.1pt;height:153pt;z-index:2;
visibility:visible;mso-wrap-style:square;mso-wrap-distance-left:9pt;
mso-wrap-distance-top:0;mso-wrap-distance-right:9pt;
mso-wrap-distance-bottom:0;mso-position-horizontal:absolute;
mso-position-horizontal-relative:text;mso-position-vertical:absolute;
mso-position-vertical-relative:text'>
<v:imagedata src="file:///C:\Users\Student\AppData\Local\Temp\msohtmlclip1\01\clip_image004.png"
o:title=""/>
<w:wrap type="square"/>
</v:shape><![endif]--><!--[if !vml]--><!--[endif]--><span lang="EN-US" style="font-family: "Times New Roman","serif";"><o:p></o:p></span></h1>
<h1>
Filename:<span style="font-family: "Times New Roman", serif;"> </span><span style="font-family: "Times New Roman", serif;">parademo.java</span></h1>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">import
java.awt.*;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">import
java.applet.*;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">public
class parademo extends Applet<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>int a;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>int b;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>int c;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>String x,y,z;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>public void init()<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span>a=Integer.parseInt(getParameter("a1"));<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span>y=String.valueOf(a);<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span>y="A="+y;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span>b=Integer.parseInt(getParameter("b1"));<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span>z="B="+String.valueOf(b);<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span>c=a+b;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span>x="C="+String.valueOf(c);<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>public void paint(Graphics g)<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span>g.drawString(y,10,100);<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span>g.drawString(z,15,150);<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span>g.drawString(x,20,200);<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">}<o:p></o:p></span></div>
<div class="MsoNormal">
<b><span lang="EN-US" style="font-family: "Times New Roman","serif";">Filename:</span></b><span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-spacerun: yes;"> </span><b>parademo.html<o:p></o:p></b></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><html><o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span><body> <o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span><applet
code=parademo.class<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 3;"> </span>height=500<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 3;"> </span>width=800<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 3;"> </span>ALIGN=TEXTTOP><o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span><param
name="a1" value=10><o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span><param
name="b1" value=20><o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span></applet><o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span></body><o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"></html><o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b><span lang="EN-US" style="font-family: "Times New Roman","serif";">Output:<o:p></o:p></span></b></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-bidi-font-weight: bold;">D:\>javac parademo.java<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-bidi-font-weight: bold;">D:\>appletviewer parademo.html<o:p></o:p></span></div>
<div class="MsoNormal">
<b style="mso-bidi-font-weight: normal;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">Getting Input from the user.<o:p></o:p></span></b></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-bidi-font-weight: bold;">import java.awt.*;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-bidi-font-weight: bold;">import java.awt.event.*;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-bidi-font-weight: bold;">import java.applet.*;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-bidi-font-weight: bold;">//<applet code="textinput" width=500
height=300></applet><o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-bidi-font-weight: bold;">public class textinput extends Applet implements
ActionListener<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-bidi-font-weight: bold;">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-bidi-font-weight: bold;"><span style="mso-tab-count: 1;"> </span>Font
f=new Font("TimesRoman",Font.BOLD,30);<o:p></o:p></span></div>
<div class="MsoNormal">
<!--[if gte vml 1]><v:shape id="Picture_x0020_142" o:spid="_x0000_s1051"
type="#_x0000_t75" style='position:absolute;left:0;text-align:left;
margin-left:270pt;margin-top:8.25pt;width:189pt;height:140.05pt;z-index:3;
visibility:visible;mso-wrap-style:square;mso-wrap-distance-left:9pt;
mso-wrap-distance-top:0;mso-wrap-distance-right:9pt;
mso-wrap-distance-bottom:0;mso-position-horizontal:absolute;
mso-position-horizontal-relative:text;mso-position-vertical:absolute;
mso-position-vertical-relative:text'>
<v:imagedata src="file:///C:\Users\Student\AppData\Local\Temp\msohtmlclip1\01\clip_image006.png"
o:title=""/>
<w:wrap type="square"/>
</v:shape><![endif]--><!--[if !vml]--><!--[endif]--><span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-bidi-font-weight: bold;"><span style="mso-tab-count: 1;"> </span>TextField t1,t2;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-bidi-font-weight: bold;"><span style="mso-tab-count: 1;"> </span>Button
b1;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-bidi-font-weight: bold;"><span style="mso-tab-count: 1;"> </span>Label
l1;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-bidi-font-weight: bold;"><span style="mso-tab-count: 1;"> </span>public
void init()<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-bidi-font-weight: bold;"><span style="mso-tab-count: 1;"> </span>{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-bidi-font-weight: bold;"><span style="mso-tab-count: 2;"> </span>setBackground(Color.pink);<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-bidi-font-weight: bold;"><span style="mso-tab-count: 2;"> </span>setForeground(Color.black);<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-bidi-font-weight: bold;"><span style="mso-tab-count: 2;"> </span>t1=new
TextField(8);<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-bidi-font-weight: bold;"><span style="mso-tab-count: 2;"> </span>t2=new
TextField(8);<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-bidi-font-weight: bold;"><span style="mso-tab-count: 2;"> </span>b1=new
Button("Ok");<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-bidi-font-weight: bold;"><span style="mso-tab-count: 2;"> </span>setFont(f);<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-bidi-font-weight: bold;"><span style="mso-tab-count: 2;"> </span>l1=new
Label("Enter a Number");<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-bidi-font-weight: bold;"><span style="mso-tab-count: 2;"> </span>add(l1);<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-bidi-font-weight: bold;"><span style="mso-tab-count: 2;"> </span>add(t1);<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-bidi-font-weight: bold;"><span style="mso-tab-count: 2;"> </span>add(t2);<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-bidi-font-weight: bold;"><span style="mso-tab-count: 2;"> </span>add(b1);<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-bidi-font-weight: bold;"><span style="mso-tab-count: 2;"> </span>b1.addActionListener(this);<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-bidi-font-weight: bold;"><span style="mso-tab-count: 1;"> </span>}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-bidi-font-weight: bold;"><span style="mso-tab-count: 1;"> </span>public
void actionPerformed(ActionEvent e)<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-bidi-font-weight: bold;"><span style="mso-tab-count: 1;"> </span>{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-bidi-font-weight: bold;"><span style="mso-tab-count: 2;"> </span>if(e.getSource()==b1)<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-bidi-font-weight: bold;"><span style="mso-tab-count: 2;"> </span>{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-bidi-font-weight: bold;"><span style="mso-tab-count: 3;"> </span>int
n, r,rev=0;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-bidi-font-weight: bold;"><span style="mso-tab-count: 3;"> </span>String
s1;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-bidi-font-weight: bold;"><span style="mso-tab-count: 3;"> </span>s1=t1.getText();<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-bidi-font-weight: bold;"><span style="mso-tab-count: 3;"> </span>n=Integer.parseInt(s1);<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-bidi-font-weight: bold;"><span style="mso-tab-count: 3;"> </span>while(n!=0)<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-bidi-font-weight: bold;"><span style="mso-tab-count: 3;"> </span>{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-bidi-font-weight: bold;"><span style="mso-tab-count: 4;"> </span>r=n%10;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-bidi-font-weight: bold;"><span style="mso-tab-count: 4;"> </span>rev=rev*10+r;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-bidi-font-weight: bold;"><span style="mso-tab-count: 4;"> </span>n=n/10;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-bidi-font-weight: bold;"><span style="mso-tab-count: 3;"> </span>}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-bidi-font-weight: bold;"><span style="mso-tab-count: 3;"> </span>String
x=String.valueOf(rev);<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-bidi-font-weight: bold;"><span style="mso-tab-count: 3;"> </span>t2.setText(x);<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-bidi-font-weight: bold;"><span style="mso-tab-count: 2;"> </span>}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-bidi-font-weight: bold;"><span style="mso-tab-count: 1;"> </span>}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-bidi-font-weight: bold;">}<o:p></o:p></span></div>
<div class="MsoNormal">
<b style="mso-bidi-font-weight: normal;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">Output:<o:p></o:p></span></b></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-bidi-font-weight: bold;">D:\>javac textinput.java<o:p></o:p></span></div>
<div class="MsoHeader" style="tab-stops: 36.0pt;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEid_-xKJkRlBDd34H-hChjty9l6F4lUBmW-b9d6y6q41T_6zCPAHnDphwayCFXBXKdID0-8apKxI8_uJjQvtnHsUFhPamWNuKR5C2VMIv1FYnsKZlZKqMDcapmSIB6Zpzd6QP_G4gIq9GU/s1600/Untitled.png" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" data-original-height="190" data-original-width="256" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEid_-xKJkRlBDd34H-hChjty9l6F4lUBmW-b9d6y6q41T_6zCPAHnDphwayCFXBXKdID0-8apKxI8_uJjQvtnHsUFhPamWNuKR5C2VMIv1FYnsKZlZKqMDcapmSIB6Zpzd6QP_G4gIq9GU/s1600/Untitled.png" /></a><span lang="EN-US" style="mso-bidi-font-weight: bold;">D:\>appletviewer textinput.java</span></div>
<br /></div>
Bagadhi Sateeshhttp://www.blogger.com/profile/16786636572407672825noreply@blogger.com0tag:blogger.com,1999:blog-8352540103162095489.post-80582566126552752542018-09-15T15:24:00.001+05:302018-09-15T15:24:25.008+05:30Exception Handling<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<div class="Section1">
<h3>
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 17.0pt; mso-bidi-font-size: 12.0pt;">Exception Handling</span><span lang="EN-US" style="font-family: "Times New Roman","serif";"><o:p></o:p></span></h3>
<div class="MsoNormal">
<span style="font-family: "Times New Roman", serif;"><span style="font-size: large;"><b>Managing
Errors and Exceptions</b></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">Exception
occurs only at the execution state of the program and can be generated in a
java program if:<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-left: 36.0pt; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-indent: -18.0pt;">
<!--[if !supportLists]--><span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-fareast-font-family: "Times New Roman";"><span style="mso-list: Ignore;">(a)<span style="font: 7.0pt "Times New Roman";">
</span></span></span><!--[endif]--><span lang="EN-US" style="font-family: "Times New Roman","serif";">the
array index crosses the range<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-left: 36.0pt; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-indent: -18.0pt;">
<!--[if !supportLists]--><span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-fareast-font-family: "Times New Roman";"><span style="mso-list: Ignore;">(b)<span style="font: 7.0pt "Times New Roman";">
</span></span></span><!--[endif]--><span lang="EN-US" style="font-family: "Times New Roman","serif";">a
number is divided by Zero<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-left: 36.0pt; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-indent: -18.0pt;">
<!--[if !supportLists]--><span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-fareast-font-family: "Times New Roman";"><span style="mso-list: Ignore;">(c)<span style="font: 7.0pt "Times New Roman";">
</span></span></span><!--[endif]--><span lang="EN-US" style="font-family: "Times New Roman","serif";">the
file one is trying to open , does not exist<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-left: 36.0pt; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-indent: -18.0pt;">
<!--[if !supportLists]--><span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-fareast-font-family: "Times New Roman";"><span style="mso-list: Ignore;">(d)<span style="font: 7.0pt "Times New Roman";">
</span></span></span><!--[endif]--><span lang="EN-US" style="font-family: "Times New Roman","serif";">the
class file which a programmer wants to load is missing, etc.<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-left: 36.0pt;">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">some of the exceptions are
detected at complied time and some others during the run time. In java
exceptions that are detected at compile time are known as checked exceptions
and exception that are detected during execution are known as unchecked
exceptions.<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman", serif;">In java
Exception handling is done by five key words</span></div>
<div class="MsoNormal" style="margin-left: 36.0pt;">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span>try<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-left: 36.0pt;">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span>catch<span style="mso-tab-count: 1;"> </span><o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 3;"> </span>throw<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif"; mso-bidi-font-size: 14.0pt;"><span style="mso-tab-count: 3;"> </span>throws<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif"; mso-bidi-font-size: 14.0pt;"><span style="mso-tab-count: 3;"> </span>finally<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi8L0MeX2WfQqbgOx3Q8jBZ_86iImstSuHnmVVYzjwIgZDDcca-MtLVSlDa8y23fHSXgfz1Eq2jHCutOQta_9mnC7fuQzBEW6jqgzRCIfdKrbAfVPVe-xGTVwg84dUXTHOLPr49fHahmHo/s1600/Untitled.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="277" data-original-width="472" height="232" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi8L0MeX2WfQqbgOx3Q8jBZ_86iImstSuHnmVVYzjwIgZDDcca-MtLVSlDa8y23fHSXgfz1Eq2jHCutOQta_9mnC7fuQzBEW6jqgzRCIfdKrbAfVPVe-xGTVwg84dUXTHOLPr49fHahmHo/s400/Untitled.png" width="400" /></a></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif"; mso-bidi-font-size: 14.0pt;"><o:p> </o:p></span><span style="font-family: "Times New Roman", serif;"> </span><b><span lang="EN-US" style="font-family: "Times New Roman", serif;">the general Syntax of
Exception Handling Code</span></b></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif"; mso-bidi-font-size: 14.0pt;">try<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif"; mso-bidi-font-size: 14.0pt;">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif"; mso-bidi-font-size: 14.0pt;">//block of code to monitor
for errors<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif"; mso-bidi-font-size: 14.0pt;">}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif"; mso-bidi-font-size: 14.0pt;">catch(Exception_Type_1
excp1)<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif"; mso-bidi-font-size: 14.0pt;">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif"; mso-bidi-font-size: 14.0pt;">//codes to handle the
exception<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif"; mso-bidi-font-size: 14.0pt;">}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif"; mso-bidi-font-size: 14.0pt;">catch(Exception_type_2
excp2)<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif"; mso-bidi-font-size: 14.0pt;">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif"; mso-bidi-font-size: 14.0pt;">//codes to handle the
exception<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif"; mso-bidi-font-size: 14.0pt;">}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif"; mso-bidi-font-size: 14.0pt;">catch(Exception_type_3
excp3)<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif"; mso-bidi-font-size: 14.0pt;">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif"; mso-bidi-font-size: 14.0pt;">//codes to handle the
exception<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif"; mso-bidi-font-size: 14.0pt;">}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif"; mso-bidi-font-size: 14.0pt;">……<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif"; mso-bidi-font-size: 14.0pt;">……<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif"; mso-bidi-font-size: 14.0pt;">finally<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif"; mso-bidi-font-size: 14.0pt;">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif"; mso-bidi-font-size: 14.0pt;">//codes that have to be
executed must<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif"; mso-bidi-font-size: 14.0pt;">}<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b><span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-bidi-font-size: 14.0pt;">Types of Errors & Exceptions</span></b></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><o:p> </o:p></span><span style="font-family: "Times New Roman", serif;">ArithmeticException</span></div>
</div>
<div class="Section2">
<ul style="margin-top: 0cm;" type="square">
<li class="MsoNormal" style="mso-list: l1 level1 lfo2; tab-stops: list 36.0pt; text-align: left;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">ArrayIndexOutOfBoundsException<o:p></o:p></span></li>
<li class="MsoNormal" style="mso-list: l1 level1 lfo2; tab-stops: list 36.0pt; text-align: left;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">ArrayStoreException<o:p></o:p></span></li>
<li class="MsoNormal" style="mso-list: l1 level1 lfo2; tab-stops: list 36.0pt; text-align: left;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">ClassCastException<o:p></o:p></span></li>
<li class="MsoNormal" style="mso-list: l1 level1 lfo2; tab-stops: list 36.0pt; text-align: left;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">IllegalArgumentException<o:p></o:p></span></li>
<li class="MsoNormal" style="mso-list: l1 level1 lfo2; tab-stops: list 36.0pt; text-align: left;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">IllegalMonitorStateException<o:p></o:p></span></li>
<li class="MsoNormal" style="mso-list: l1 level1 lfo2; tab-stops: list 36.0pt; text-align: left;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">IllegalStateException<o:p></o:p></span></li>
<li class="MsoNormal" style="mso-list: l1 level1 lfo2; tab-stops: list 36.0pt; text-align: left;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">IllegalThreadStateException<o:p></o:p></span></li>
<li class="MsoNormal" style="mso-list: l1 level1 lfo2; tab-stops: list 36.0pt; text-align: left;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">IndexOutOfBoundsException<o:p></o:p></span></li>
<li class="MsoNormal" style="mso-list: l1 level1 lfo2; tab-stops: list 36.0pt; text-align: left;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">NegativeArraySizeException<o:p></o:p></span></li>
<li class="MsoNormal" style="mso-list: l1 level1 lfo2; tab-stops: list 36.0pt; text-align: left;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">NullPointerException<o:p></o:p></span></li>
</ul>
<div align="left" class="MsoNormal" style="margin-left: 36.0pt; mso-list: l1 level1 lfo2; tab-stops: list 45.0pt; text-align: left; text-indent: -9.0pt;">
<!--[if !supportLists]--><span lang="EN-US" style="font-family: Wingdings; mso-bidi-font-family: Wingdings; mso-fareast-font-family: Wingdings;"><span style="mso-list: Ignore;">§<span style="font: 7.0pt "Times New Roman";"> </span></span></span><!--[endif]--><span lang="EN-US" style="font-family: "Times New Roman","serif";">NumberFormatException<o:p></o:p></span></div>
<div align="left" class="MsoNormal" style="margin-left: 36.0pt; mso-list: l1 level1 lfo2; tab-stops: list 45.0pt; text-align: left; text-indent: -9.0pt;">
<!--[if !supportLists]--><span lang="EN-US" style="font-family: Wingdings; mso-bidi-font-family: Wingdings; mso-fareast-font-family: Wingdings;"><span style="mso-list: Ignore;">§<span style="font: 7.0pt "Times New Roman";"> </span></span></span><!--[endif]--><span lang="EN-US" style="font-family: "Times New Roman","serif";">SecurityException<o:p></o:p></span></div>
<div align="left" class="MsoNormal" style="margin-left: 36.0pt; mso-list: l1 level1 lfo2; tab-stops: list 45.0pt; text-align: left; text-indent: -9.0pt;">
<!--[if !supportLists]--><span lang="EN-US" style="font-family: Wingdings; mso-bidi-font-family: Wingdings; mso-fareast-font-family: Wingdings;"><span style="mso-list: Ignore;">§<span style="font: 7.0pt "Times New Roman";"> </span></span></span><!--[endif]--><span lang="EN-US" style="font-family: "Times New Roman","serif";">StringIndexOutOfBounds<o:p></o:p></span></div>
<div align="left" class="MsoNormal" style="margin-left: 36.0pt; mso-list: l1 level1 lfo2; tab-stops: list 45.0pt; text-align: left; text-indent: -9.0pt;">
<!--[if !supportLists]--><span lang="EN-US" style="font-family: Wingdings; mso-bidi-font-family: Wingdings; mso-fareast-font-family: Wingdings;"><span style="mso-list: Ignore;">§<span style="font: 7.0pt "Times New Roman";"> </span></span></span><!--[endif]--><span lang="EN-US" style="font-family: "Times New Roman","serif";">UnsupportedOperationException<o:p></o:p></span></div>
<div align="left" class="MsoNormal" style="margin-left: 36.0pt; mso-list: l1 level1 lfo2; tab-stops: list 45.0pt; text-align: left; text-indent: -9.0pt;">
<!--[if !supportLists]--><span lang="EN-US" style="font-family: Wingdings; mso-bidi-font-family: Wingdings; mso-fareast-font-family: Wingdings;"><span style="mso-list: Ignore;">§<span style="font: 7.0pt "Times New Roman";"> </span></span></span><!--[endif]--><span lang="EN-US" style="font-family: "Times New Roman","serif";">ClassNotFoundException<o:p></o:p></span></div>
<div align="left" class="MsoNormal" style="margin-left: 36.0pt; mso-list: l1 level1 lfo2; tab-stops: list 45.0pt; text-align: left; text-indent: -9.0pt;">
<!--[if !supportLists]--><span lang="EN-US" style="font-family: Wingdings; mso-bidi-font-family: Wingdings; mso-fareast-font-family: Wingdings;"><span style="mso-list: Ignore;">§<span style="font: 7.0pt "Times New Roman";"> </span></span></span><!--[endif]--><span lang="EN-US" style="font-family: "Times New Roman","serif";">CloneNotSupportedException<o:p></o:p></span></div>
<div align="left" class="MsoNormal" style="margin-left: 36.0pt; mso-list: l1 level1 lfo2; tab-stops: list 45.0pt; text-align: left; text-indent: -9.0pt;">
<!--[if !supportLists]--><span lang="EN-US" style="font-family: Wingdings; mso-bidi-font-family: Wingdings; mso-fareast-font-family: Wingdings;"><span style="mso-list: Ignore;">§<span style="font: 7.0pt "Times New Roman";"> </span></span></span><!--[endif]--><span lang="EN-US" style="font-family: "Times New Roman","serif";">IllegalAccessException<o:p></o:p></span></div>
<div align="left" class="MsoNormal" style="margin-left: 36.0pt; mso-list: l1 level1 lfo2; tab-stops: list 45.0pt; text-align: left; text-indent: -9.0pt;">
<!--[if !supportLists]--><span lang="EN-US" style="font-family: Wingdings; mso-bidi-font-family: Wingdings; mso-fareast-font-family: Wingdings;"><span style="mso-list: Ignore;">§<span style="font: 7.0pt "Times New Roman";"> </span></span></span><!--[endif]--><span lang="EN-US" style="font-family: "Times New Roman","serif";">InstantiationException<o:p></o:p></span></div>
<div align="left" class="MsoNormal" style="margin-left: 36.0pt; mso-list: l1 level1 lfo2; tab-stops: list 45.0pt; text-align: left; text-indent: -9.0pt;">
<!--[if !supportLists]--><span lang="EN-US" style="font-family: Wingdings; mso-bidi-font-family: Wingdings; mso-fareast-font-family: Wingdings;"><span style="mso-list: Ignore;">§<span style="font: 7.0pt "Times New Roman";"> </span></span></span><!--[endif]--><span lang="EN-US" style="font-family: "Times New Roman","serif";">NoSuchFieldException<o:p></o:p></span></div>
<div align="left" class="MsoNormal" style="margin-left: 36.0pt; mso-list: l1 level1 lfo2; tab-stops: list 45.0pt; text-align: left; text-indent: -9.0pt;">
<!--[if !supportLists]--><span lang="EN-US" style="font-family: Wingdings; mso-bidi-font-family: Wingdings; mso-fareast-font-family: Wingdings;"><span style="mso-list: Ignore;">§<span style="font: 7.0pt "Times New Roman";"> </span></span></span><!--[endif]--><span lang="EN-US" style="font-family: "Times New Roman","serif";">NoSuchMethodException<o:p></o:p></span></div>
</div>
<div class="MsoNormal" style="margin-left: 18.0pt;">
<br /></div>
<div class="MsoNormal">
<b><span lang="EN-US" style="font-family: "Times New Roman","serif";">Example
for Arithmetic Exception:<o:p></o:p></span></b></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">class
arith<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">public
static void main(String args[])<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">int
a=5,b=5,c=10;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">try<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">int
z=c/(a-b);<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">System.out.println("Z
value="+z);<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">throw
new ArithmeticException();<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">catch(ArithmeticException
e)<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">System.out.println(e);<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">}<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<h5>
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="font-size: large;">Example
Array Out Of Bounds Exception</span><o:p></o:p></span></h5>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">class
array<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">public
static void main(String args[])<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">{<o:p></o:p></span></div>
<div class="MsoNormal" style="text-indent: 36.0pt;">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">int a[]=new int[5];<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-left: 36.0pt;">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">ArrayIndexOutOfBoundsException
ae=new ArrayIndexOutOfBoundsException("Not In Range\t");<o:p></o:p></span></div>
<div class="MsoNormal" style="text-indent: 36.0pt;">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">for(int i=0;i<5;i++)<o:p></o:p></span></div>
<div class="MsoNormal" style="text-indent: 36.0pt;">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">{<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-left: 36.0pt; text-indent: 36.0pt;">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">a[i]=i+1;<o:p></o:p></span></div>
<div class="MsoNormal" style="text-indent: 36.0pt;">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">}<o:p></o:p></span></div>
<div class="MsoNormal" style="text-indent: 36.0pt;">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">try<o:p></o:p></span></div>
<div class="MsoNormal" style="text-indent: 36.0pt;">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">{<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-left: 36.0pt; text-indent: 36.0pt;">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">for(int
i=0;i<10;i++)<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-left: 36.0pt; text-indent: 36.0pt;">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">{<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-left: 72.0pt; text-indent: 36.0pt;">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">System.out.println(a[i]);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-left: 36.0pt; text-indent: 36.0pt;">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">}<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-left: 36.0pt; text-indent: 36.0pt;">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">throw ae; <o:p></o:p></span></div>
<div class="MsoNormal" style="text-indent: 36.0pt;">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">}<o:p></o:p></span></div>
<div class="MsoNormal" style="text-indent: 36.0pt;">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">catch(ArrayIndexOutOfBoundsException
e)<o:p></o:p></span></div>
<div class="MsoNormal" style="text-indent: 36.0pt;">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">{<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-left: 36.0pt; text-indent: 36.0pt;">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">System.out.println(e);<o:p></o:p></span></div>
<div class="MsoNormal" style="text-indent: 36.0pt;">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">}<span style="mso-tab-count: 1;"> </span><o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<h5>
<span lang="EN-US" style="font-family: "Times New Roman","serif";">Example for
Illegal argument Exception<o:p></o:p></span></h5>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">class
MyClock<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">int
hours ,minutes, seconds;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-spacerun: yes;"> </span>MyClock(int hours, int minutes, int seconds)<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">if
(hours < 1 || hours > 12)<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">throw
new IllegalArgumentException("Hours must be between 1 and 12");<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">if
(minutes < 0 || minutes > 59)<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">throw
new IllegalArgumentException("Minutes must be between 0 and 59");<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">if
(seconds < 0 || seconds > 59)<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">throw
new IllegalArgumentException("Seconds must be between 0 and 59");<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">this.hours
= hours;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">this.minutes
= minutes;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">this.seconds
= seconds;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">System.out.println(hours+"hrs:"+minutes+"mins:"+seconds+"sec;");<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">public
MyClock(int hours, int minutes)<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">this(hours,
minutes, 0);<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">public
MyClock(int hours)<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">this(hours,
0, 0);<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">public
class ThrowTest<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">public
static void main( String args [])<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">try<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">MyClock
clock = new MyClock(1, 10,20);<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">MyClock
c=new MyClock(1);<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">MyClock
a=new MyClock(20,70,40);<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">catch(
IllegalArgumentException e)<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">System.out.println("IllegalArgumentException
is caught...."+e.getMessage());<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">}<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<h2>
<span lang="EN-US" style="font-family: "Times New Roman","serif";">Multiple
Catch Statements <o:p></o:p></span></h2>
<div class="MsoBodyText">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">Sometimes
there may be a chance to have multiple exceptions in a program. You can use
multiple catch clauses to catch the different kinds of exceptions that code can
throw. If more than one exception is raised by a block of code, then to handle
these exceptions more than one catch clauses are used. When an exception is
thrown, different catch blocks associated with try block inspect in order and
the first one whose type (the exception type passed as argument in catch
clause) matches with the exception type is executed.</span><span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-bidi-font-size: 14.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<h2>
<span lang="EN-US" style="font-family: "Times New Roman","serif";">Using
Finally Statement <o:p></o:p></span></h2>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif"; mso-bidi-font-size: 14.0pt;">A finally block is always
executed, regardless of the cause of exit from the try block, or whether any
catch block was executed. Generally finally block is used for freeing
resources, cleaning up, closing connections etc. Any statements in the body of
the finally clause are guaranteed to be executed.<o:p></o:p></span></div>
<h2>
<span lang="EN-US" style="font-family: "Times New Roman","serif";">Throwing our
own Exceptions:<o:p></o:p></span></h2>
<div class="MsoNormal">
<span style="font-family: "Times New Roman", serif;">There
may be times when we would like to throw our own exceptions. We can do this by
using the </span><b style="font-family: "Times New Roman", serif;">throw </b><span style="font-family: "Times New Roman", serif;">keyword.</span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<!--[if gte vml 1]><v:group id="_x0000_s1043" style='position:absolute;
left:0;text-align:left;margin-left:225pt;margin-top:1.85pt;width:162pt;
height:153pt;z-index:251674624' coordorigin="6120,2880" coordsize="3240,3060">
<v:shapetype id="_x0000_t88" coordsize="21600,21600" o:spt="88" adj="1800,10800"
path="m,qx10800@0l10800@2qy21600@11,10800@3l10800@1qy,21600e" filled="f">
<v:formulas>
<v:f eqn="val #0"/>
<v:f eqn="sum 21600 0 #0"/>
<v:f eqn="sum #1 0 #0"/>
<v:f eqn="sum #1 #0 0"/>
<v:f eqn="prod #0 9598 32768"/>
<v:f eqn="sum 21600 0 @4"/>
<v:f eqn="sum 21600 0 #1"/>
<v:f eqn="min #1 @6"/>
<v:f eqn="prod @7 1 2"/>
<v:f eqn="prod #0 2 1"/>
<v:f eqn="sum 21600 0 @9"/>
<v:f eqn="val #1"/>
</v:formulas>
<v:path arrowok="t" o:connecttype="custom" o:connectlocs="0,0;21600,@11;0,21600"
textboxrect="0,@4,7637,@5"/>
<v:handles>
<v:h position="center,#0" yrange="0,@8"/>
<v:h position="bottomRight,#1" yrange="@9,@10"/>
</v:handles>
</v:shapetype><v:shape id="_x0000_s1044" type="#_x0000_t88" style='position:absolute;
left:6120;top:2880;width:720;height:3060'/>
<v:shape id="_x0000_s1045" type="#_x0000_t202" style='position:absolute;
left:7200;top:3960;width:2160;height:720' stroked="f">
<v:textbox>
<![if !mso]>
<table cellpadding=0 cellspacing=0 width="100%">
<tr>
<td><![endif]>
<div>
<p class=MsoNormal>
<span lang=EN-US>Defining user defined exception</span></p>
</div>
<![if !mso]></td>
</tr>
</table>
<![endif]></v:textbox>
</v:shape></v:group><![endif]--><!--[if !vml]--><span style="height: 206px; left: 0px; margin-left: 299px; margin-top: 1px; mso-ignore: vglayout; position: absolute; width: 219px; z-index: 251674624;"></span><!--[endif]--><span lang="EN-US" style="font-family: "Times New Roman","serif";">class MyException
extends Exception<span style="mso-spacerun: yes;"> </span><o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">String
s1;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">MyException(String
s1) <o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">this.s1=s1;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">public
String toString()<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">return(s1);<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">class
Myclass<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">public
static void main(String args[])<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">int
marks[]={59,33,99,100,97};<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">int
stno[]={1,2,3,4,5};<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">try<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">for(int
i=0;i<6;i++)<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">{<o:p></o:p></span></div>
<div class="MsoBodyText">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">if
(marks[i]>100)<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">throw
new MyException("invaid data");<span style="mso-spacerun: yes;">
</span><b>// throwing user-defined exception</b><o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">if
(i<4)<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">System.out.println("rollno="+stno[i]+"\tmarks="+marks[i]);<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">else<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">throw
new ArrayIndexOutOfBoundsException("Array out of bnds");<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">}<o:p></o:p></span></div>
<div class="MsoNormal">
<!--[if gte vml 1]><v:group id="_x0000_s1037" style='position:absolute;
left:0;text-align:left;margin-left:270pt;margin-top:2.7pt;width:126pt;
height:99pt;z-index:251672576' coordorigin="7020,11340" coordsize="2520,1980">
<v:shape id="_x0000_s1038" type="#_x0000_t88" style='position:absolute;left:7020;
top:11340;width:720;height:1980'/>
<v:shape id="_x0000_s1039" type="#_x0000_t202" style='position:absolute;
left:8100;top:11700;width:1440;height:1080' stroked="f">
<v:textbox>
<![if !mso]>
<table cellpadding=0 cellspacing=0 width="100%">
<tr>
<td><![endif]>
<div>
<p class=MsoNormal>
<span lang=EN-US>Multiple Catch Statements</span></p>
</div>
<![if !mso]></td>
</tr>
</table>
<![endif]></v:textbox>
</v:shape></v:group><![endif]--><!--[if !vml]--><span style="height: 134px; left: 0px; margin-left: 359px; margin-top: 3px; mso-ignore: vglayout; position: absolute; width: 171px; z-index: 251672576;"></span><!--[endif]--><span lang="EN-US" style="font-family: "Times New Roman","serif";">}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">catch(MyException
e)<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">System.out.println("Exception="+e);<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">catch(ArrayIndexOutOfBoundsException
a)<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">System.out.println("Index
out of range"+a);<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">}<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman", serif;">finally</span><span style="font-family: "Times New Roman", serif;"> </span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">System.out.println("finished");<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">}<o:p></o:p></span></div>
<br /></div>
Bagadhi Sateeshhttp://www.blogger.com/profile/16786636572407672825noreply@blogger.com0tag:blogger.com,1999:blog-8352540103162095489.post-24368758577756103512018-09-07T14:57:00.003+05:302018-09-07T14:57:42.761+05:30Multithreading<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<div class="MsoTitle">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="font-size: large;">Multithreading</span><o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b style="mso-bidi-font-weight: normal;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">Introduction:<o:p></o:p></span></b></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">It
is one of the important features of Java that allows us to run two different
parts of the program concurrently by sharing the common resources of the
system. <o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">A
Thread is a lightweight component that is similar to a program.<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">Multithreading
is a conceptual programming where a program is divided into two or more
processes which can be implemented at the same time in parallel. <o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b style="mso-bidi-font-weight: normal;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">Ex:-</span></b><span lang="EN-US" style="font-family: "Times New Roman","serif";"> In a MS-Word we can modify the
document on the foreground, at then we can send the job of<span style="mso-spacerun: yes;"> </span>printing at the background.<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b style="mso-bidi-font-weight: normal;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">Keypoints:<o:p></o:p></span></b></div>
<ol start="1" style="margin-top: 0cm;" type="1">
<li class="MsoNormal" style="mso-list: l2 level1 lfo1; tab-stops: list 36.0pt;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">By default every
java program is under the implementation of main <o:p></o:p></span></li>
<li class="MsoNormal" style="mso-list: l2 level1 lfo1; tab-stops: list 36.0pt;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">thread.<o:p></o:p></span></li>
<li class="MsoNormal" style="mso-list: l2 level1 lfo1; tab-stops: list 36.0pt;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">Each thread has a
main and a priority<o:p></o:p></span></li>
<li class="MsoNormal" style="mso-list: l2 level1 lfo1; tab-stops: list 36.0pt;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">Threads has to be
started explicitly.<o:p></o:p></span></li>
<li class="MsoNormal" style="mso-list: l2 level1 lfo1; tab-stops: list 36.0pt;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">Threads can be
synchronized.<o:p></o:p></span></li>
<li class="MsoNormal" style="mso-list: l2 level1 lfo1; tab-stops: list 36.0pt;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">Threads can be
intercommunicated.<o:p></o:p></span></li>
</ol>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b style="mso-bidi-font-weight: normal;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">Creating Threads:<o:p></o:p></span></b></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><o:p> </o:p></span><span style="font-family: "Times New Roman", serif;">A
new thread can be created in 2 ways:</span></div>
<div class="MsoNormal" style="margin-left: 36.0pt; text-indent: 36.0pt;">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">1. By extending from
Thread Class<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-left: 36.0pt; text-indent: 36.0pt;">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">2. By implementing a
Runnable Interface.<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">If
it requires extending from more than one class, then we have to implement the
Runnable interface, since Java classes cannot have two superclass. It depends
on the classes we create. Otherwise we can use Thread Class. The Runnable
interface has only one method, run().<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b style="mso-bidi-font-weight: normal;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">By extending from Thread Class:<o:p></o:p></span></b></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">class
classname extends Thread<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>Thread () {<span style="mso-spacerun: yes;"> </span>}<span style="mso-tab-count: 1;"> </span>//
Thread constructor if required<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>public void run()<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span>-------<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span>-------<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">}<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b style="mso-bidi-font-weight: normal;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">To start the Thread:<o:p></o:p></span></b></div>
<div class="MsoNormal">
<b style="mso-bidi-font-weight: normal;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">For example</span></b><span lang="EN-US" style="font-family: "Times New Roman","serif";"> we take classname is
ABC<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">ABC
a=new ABC();<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">a.start();<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b style="mso-bidi-font-weight: normal;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">Ex:<o:p></o:p></span></b></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">class
ABC extends Thread<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span><o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>public void run()<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span>System.out.println("Welcome
to the concept of Threads");<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">class
xx<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>public static void main(String
[]args)<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span><span style="mso-spacerun: yes;"> </span>ABC a=new ABC();<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-spacerun: yes;"> </span>Thread t=new
Thread(a);<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span><span style="mso-tab-count: 2;"> </span>t.start();<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span><o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">}<span style="mso-tab-count: 1;"> </span><o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b style="mso-bidi-font-weight: normal;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">By implementing a Runnable
Interface:<o:p></o:p></span></b></div>
<div class="MsoNormal">
<br /></div>
<ol start="1" style="margin-top: 0cm;" type="1">
<li class="MsoNormal" style="mso-list: l0 level1 lfo2; tab-stops: list 36.0pt;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">Declare the class
as implementing the Runnable interface<o:p></o:p></span></li>
<li class="MsoNormal" style="mso-list: l0 level1 lfo2; tab-stops: list 36.0pt;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">Implement the
run() method<o:p></o:p></span></li>
<li class="MsoNormal" style="mso-list: l0 level1 lfo2; tab-stops: list 36.0pt;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">Create a thread
by defining an object that is instantiated from this 'runnable' interface<o:p></o:p></span></li>
<li class="MsoNormal" style="mso-list: l0 level1 lfo2; tab-stops: list 36.0pt;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">Call the threads
start() method to run the thread.<o:p></o:p></span></li>
</ol>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b style="mso-bidi-font-weight: normal;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">Ex:<o:p></o:p></span></b></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">class
y<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">int
bal=100;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">class
x implements Runnable<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">y
p;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">int
r;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">int
sleepValue;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">x(int
a,int b, y g)<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">r=a;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">sleepValue=b;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">p=g;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">public
void run()<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">if(p.bal>r)<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">System.out.println("fund
is available");<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">p.bal=p.bal-r;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">System.out.println("Got
it!!!"+Thread.currentThread());<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">synchronized(p)<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">try<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">Thread.sleep(sleepValue);<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">catch
(Exception e){}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">else<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">System.out.println("Insufficient
bal "+Thread.currentThread());<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">class
Thread2<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">public
static void main(String args[])<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">y=new
y();<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">x
job1=new x(50,1000,n);<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">x
job2=new x(80,0,n);<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">Thread
t1=new Thread(job1,"job1");<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">Thread
t2=new Thread(job2,"job2");<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">t1.start();<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">t2.start();<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><o:p> </o:p></span><b><span lang="EN-US" style="font-family: "Times New Roman","serif";"><o:p> </o:p></span></b></div>
<div class="MsoNormal">
<b style="mso-bidi-font-weight: normal;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">Stopping and Blocking a Thread:<o:p></o:p></span></b></div>
<div class="MsoNormal">
<b style="mso-bidi-font-weight: normal;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">Stopping Thread:<o:p></o:p></span></b></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">whenever
we want to stop a thread from running further, we may do so by calling its
stop() method, like <o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>Thread.stop();<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">The
stop() may be used when the premature death of a thread is needed.<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b style="mso-bidi-font-weight: normal;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">Blocking a Thread</span></b><span lang="EN-US" style="font-family: "Times New Roman","serif";">:<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">A
thread can also be temporarly suspended or blocked from the runnable or running
state by<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>sleep()<span style="mso-tab-count: 1;"> </span>// blocked for a specified time<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>suspend()<span style="mso-tab-count: 1;"> </span>//blocked until further orders<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>wait()<span style="mso-tab-count: 2;"> </span>//blocked until certain condition occurs<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">Again
the thread enters into the running state from blocked state by resume() method
in case of suspend() and the notify() method is called in the case of wait().<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b style="mso-bidi-font-weight: normal;"><span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="font-size: large;">Life Cycle of a Thread:</span><o:p></o:p></span></b></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">Stages
occured during the Life Cycle of a Thread<o:p></o:p></span></div>
<ol start="1" style="margin-top: 0cm;" type="1">
<li class="MsoNormal" style="mso-list: l3 level1 lfo3; tab-stops: list 36.0pt;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">Newborn State<o:p></o:p></span></li>
<li class="MsoNormal" style="mso-list: l3 level1 lfo3; tab-stops: list 36.0pt;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">Runnable State<o:p></o:p></span></li>
<li class="MsoNormal" style="mso-list: l3 level1 lfo3; tab-stops: list 36.0pt;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">Running State<o:p></o:p></span></li>
<li class="MsoNormal" style="mso-list: l3 level1 lfo3; tab-stops: list 36.0pt;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">Blocked State<o:p></o:p></span></li>
<li class="MsoNormal" style="mso-list: l3 level1 lfo3; tab-stops: list 36.0pt;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">Dead State<o:p></o:p></span></li>
</ol>
<div class="MsoNormal">
<b style="mso-bidi-font-weight: normal;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">Newborn State:<o:p></o:p></span></b></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">When
we create a thread object, the thread is born and is said to be in newborn
state. At this state, we can do only one of the following things with it:<o:p></o:p></span></div>
<ul style="margin-top: 0cm;" type="disc">
<li class="MsoNormal" style="mso-list: l1 level1 lfo4; tab-stops: list 36.0pt;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">schedule it for
running using start() method<o:p></o:p></span></li>
<li class="MsoNormal" style="mso-list: l1 level1 lfo4; tab-stops: list 36.0pt;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">kill it using
stop() method<o:p></o:p></span></li>
</ul>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">If
scheduled it moves to the runnable state.<o:p></o:p></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEixtvMOqq4Sr4OzcqhuCy4zN6AszjeEIwo97jnxEme-0sMqXbULN2OBaISTyWQG8IPtM4iLy0fTC8B-ffdmbVe2_YV2gVqLM_Gec3_Y-LHz8b-Mec4waI4ikOZnZUXAN5oHfzvlZuYIxvM/s1600/Untitled.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="188" data-original-width="526" height="142" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEixtvMOqq4Sr4OzcqhuCy4zN6AszjeEIwo97jnxEme-0sMqXbULN2OBaISTyWQG8IPtM4iLy0fTC8B-ffdmbVe2_YV2gVqLM_Gec3_Y-LHz8b-Mec4waI4ikOZnZUXAN5oHfzvlZuYIxvM/s400/Untitled.png" width="400" /></a></div>
<div class="MsoNormal">
<!--[if mso & !supportInlineShapes & supportFields]><b
style='mso-bidi-font-weight:normal'><span lang=EN-US style='font-family:"Times New Roman","serif"'><span
style='mso-element:field-begin;mso-field-lock:yes'></span><span
style='mso-spacerun:yes'> </span>SHAPE <span
style='mso-spacerun:yes'> </span>\* MERGEFORMAT <span style='mso-element:field-separator'></span></span></b><![endif]--><b style="mso-bidi-font-weight: normal;"><span lang="EN-US" style="font-family: "Times New Roman","serif";"><!--[if gte vml 1]><v:group
id="_x0000_s1065" editas="canvas" style='width:261pt;height:162pt;
mso-position-horizontal-relative:char;mso-position-vertical-relative:line'
coordorigin="3780,1620" coordsize="5220,3240">
<o:lock v:ext="edit" aspectratio="t"/>
<v:shapetype id="_x0000_t75" coordsize="21600,21600" o:spt="75"
o:preferrelative="t" path="m@4@5l@4@11@9@11@9@5xe" filled="f" stroked="f">
<v:stroke joinstyle="miter"/>
<v:formulas>
<v:f eqn="if lineDrawn pixelLineWidth 0"/>
<v:f eqn="sum @0 1 0"/>
<v:f eqn="sum 0 0 @1"/>
<v:f eqn="prod @2 1 2"/>
<v:f eqn="prod @3 21600 pixelWidth"/>
<v:f eqn="prod @3 21600 pixelHeight"/>
<v:f eqn="sum @0 0 1"/>
<v:f eqn="prod @6 1 2"/>
<v:f eqn="prod @7 21600 pixelWidth"/>
<v:f eqn="sum @8 21600 0"/>
<v:f eqn="prod @7 21600 pixelHeight"/>
<v:f eqn="sum @10 21600 0"/>
</v:formulas>
<v:path o:extrusionok="f" gradientshapeok="t" o:connecttype="rect"/>
<o:lock v:ext="edit" aspectratio="t"/>
</v:shapetype><v:shape id="_x0000_s1066" type="#_x0000_t75" style='position:absolute;
left:3780;top:1620;width:5220;height:3240' o:preferrelative="f">
<v:fill o:detectmouseclick="t"/>
<v:path o:extrusionok="t" o:connecttype="none"/>
<o:lock v:ext="edit" text="t"/>
</v:shape><v:group id="_x0000_s1067" style='position:absolute;left:4140;top:1801;
width:4500;height:3059' coordorigin="4140,1801" coordsize="4320,3059">
<v:oval id="_x0000_s1068" style='position:absolute;left:5760;top:1801;
width:1080;height:899'>
<v:textbox>
<![if !mso]>
<table cellpadding=0 cellspacing=0 width="100%">
<tr>
<td><![endif]>
<div>
<p class=MsoNormal>
<span lang=EN-US>New Born</span></p>
</div>
<![if !mso]></td>
</tr>
</table>
<![endif]></v:textbox>
</v:oval><v:oval id="_x0000_s1069" style='position:absolute;left:4140;top:3780;
width:1620;height:1080'>
<v:textbox>
<![if !mso]>
<table cellpadding=0 cellspacing=0 width="100%">
<tr>
<td><![endif]>
<div>
<p class=MsoNormal align=center style='text-align:center'>
<span
lang=EN-US>Runnable State</span></p>
</div>
<![if !mso]></td>
</tr>
</table>
<![endif]></v:textbox>
</v:oval><v:oval id="_x0000_s1070" style='position:absolute;left:7020;top:3780;
width:1440;height:1080'>
<v:textbox>
<![if !mso]>
<table cellpadding=0 cellspacing=0 width="100%">
<tr>
<td><![endif]>
<div>
<p class=MsoNormal align=center style='text-align:center'>
<span
lang=EN-US>Dead</span></p>
<p class=MsoNormal align=center style='text-align:center'>
<span
lang=EN-US>State</span></p>
</div>
<![if !mso]></td>
</tr>
</table>
<![endif]></v:textbox>
</v:oval><v:line id="_x0000_s1071" style='position:absolute;flip:x' from="5040,2520"
to="5760,3780">
<v:stroke endarrow="block"/>
</v:line><v:line id="_x0000_s1072" style='position:absolute' from="6660,2520"
to="7560,3780">
<v:stroke endarrow="block"/>
</v:line><v:shapetype id="_x0000_t202" coordsize="21600,21600" o:spt="202"
path="m,l,21600r21600,l21600,xe">
<v:stroke joinstyle="miter"/>
<v:path gradientshapeok="t" o:connecttype="rect"/>
</v:shapetype><v:shape id="_x0000_s1073" type="#_x0000_t202" style='position:absolute;
left:4320;top:2700;width:900;height:360' stroked="f">
<v:textbox>
<![if !mso]>
<table cellpadding=0 cellspacing=0 width="100%">
<tr>
<td><![endif]>
<div>
<p class=MsoNormal>
<span lang=EN-US>Start</span></p>
</div>
<![if !mso]></td>
</tr>
</table>
<![endif]></v:textbox>
</v:shape><v:shape id="_x0000_s1074" type="#_x0000_t202" style='position:absolute;
left:7200;top:2700;width:900;height:540' stroked="f">
<v:textbox>
<![if !mso]>
<table cellpadding=0 cellspacing=0 width="100%">
<tr>
<td><![endif]>
<div>
<p class=MsoNormal>
<span lang=EN-US>Stop</span></p>
</div>
<![if !mso]></td>
</tr>
</table>
<![endif]></v:textbox>
</v:shape></v:group><w:wrap type="none"/>
<w:anchorlock/>
</v:group><![endif]--><!--[if !vml]--><!--[endif]--></span></b><!--[if mso & !supportInlineShapes & supportFields]><b
style='mso-bidi-font-weight:normal'><span lang=EN-US style='font-family:"Times New Roman","serif"'><v:shape
id="_x0000_i1025" type="#_x0000_t75" style='width:261pt;height:162pt'>
<v:imagedata croptop="-65520f" cropbottom="65520f"/>
</v:shape><span style='mso-element:field-end'></span></span></b><![endif]--><b style="mso-bidi-font-weight: normal;"><span lang="EN-US" style="font-family: "Times New Roman","serif";"><o:p></o:p></span></b></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b style="mso-bidi-font-weight: normal;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">Runnable State:<o:p></o:p></span></b></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman", serif;">The
runnable state means that the thread is ready for execution and is waiting for
the availability of the processor. That is, the thread has joined the queue of
the threads that are waiting for execution. If we want a thread to
relinquish(give up) control to another thread of equal priority before it turn
comes, we can do so by using the yield() method.</span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b style="mso-bidi-font-weight: normal;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">Running State:<o:p></o:p></span></b></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><o:p> </o:p></span><span style="font-family: "Times New Roman", serif;">Running
means that the processor has given its time to the thread for its execution.
The thread runs until it gives up control on its own or it is preempted by a
higher priority thread. A running thread may gives up</span><span style="font-family: "Times New Roman", serif;"> </span><span style="font-family: "Times New Roman", serif;">its control in one of the following
situations.</span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">1.
It has been suspended using suspend () method. A suspended thread can be
revived by using the resume() method.<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiBIGveXxkaUvHyeUlX0v-YEgYJUSCY_P6Um1X2NxpR8n_zSkBwQHUiNX3aj36WmHGPkrseLyhldiL3ZUQamwnLFHmPl4HRjF2b2MJRTByfL83nj3-P2fsd9-P8GbDE57q-hLa0Lq32RfY/s1600/Untitled.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="180" data-original-width="526" height="136" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiBIGveXxkaUvHyeUlX0v-YEgYJUSCY_P6Um1X2NxpR8n_zSkBwQHUiNX3aj36WmHGPkrseLyhldiL3ZUQamwnLFHmPl4HRjF2b2MJRTByfL83nj3-P2fsd9-P8GbDE57q-hLa0Lq32RfY/s400/Untitled.png" width="400" /></a></div>
<br />
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<!--[if mso & !supportInlineShapes & supportFields]><span
lang=EN-US style='font-family:"Times New Roman","serif"'><span
style='mso-element:field-begin;mso-field-lock:yes'></span><span
style='mso-spacerun:yes'> </span>SHAPE <span
style='mso-spacerun:yes'> </span>\* MERGEFORMAT <span style='mso-element:field-separator'></span></span><![endif]--><span lang="EN-US" style="font-family: "Times New Roman","serif";"><!--[if gte vml 1]><v:group
id="_x0000_s1052" editas="canvas" style='width:6in;height:126pt;
mso-position-horizontal-relative:char;mso-position-vertical-relative:line'
coordorigin="2527,3202" coordsize="7200,2160">
<o:lock v:ext="edit" aspectratio="t"/>
<v:shape id="_x0000_s1053" type="#_x0000_t75" style='position:absolute;left:2527;
top:3202;width:7200;height:2160' o:preferrelative="f">
<v:fill o:detectmouseclick="t"/>
<v:path o:extrusionok="t" o:connecttype="none"/>
<o:lock v:ext="edit" text="t"/>
</v:shape><v:group id="_x0000_s1054" style='position:absolute;left:2677;top:3202;
width:6900;height:1543' coordorigin="2677,3356" coordsize="6900,1543">
<v:oval id="_x0000_s1055" style='position:absolute;left:2677;top:4128;
width:1500;height:771'>
<v:textbox style='mso-next-textbox:#_x0000_s1055'>
<![if !mso]>
<table cellpadding=0 cellspacing=0 width="100%">
<tr>
<td><![endif]>
<div>
<p class=MsoNormal align=center style='text-align:center'>
<span
lang=EN-US>Running</span></p>
</div>
<![if !mso]></td>
</tr>
</table>
<![endif]></v:textbox>
</v:oval><v:oval id="_x0000_s1056" style='position:absolute;left:5377;top:4128;
width:1500;height:771'>
<v:textbox style='mso-next-textbox:#_x0000_s1056'>
<![if !mso]>
<table cellpadding=0 cellspacing=0 width="100%">
<tr>
<td><![endif]>
<div>
<p class=MsoNormal align=center style='text-align:center'>
<span
lang=EN-US>Runnable</span></p>
</div>
<![if !mso]></td>
</tr>
</table>
<![endif]></v:textbox>
</v:oval><v:oval id="_x0000_s1057" style='position:absolute;left:8077;top:4128;
width:1500;height:771'>
<v:textbox style='mso-next-textbox:#_x0000_s1057'>
<![if !mso]>
<table cellpadding=0 cellspacing=0 width="100%">
<tr>
<td><![endif]>
<div>
<p class=MsoNormal align=center style='text-align:center'>
<span
lang=EN-US>Suspended</span></p>
</div>
<![if !mso]></td>
</tr>
</table>
<![endif]></v:textbox>
</v:oval><v:line id="_x0000_s1058" style='position:absolute;flip:x' from="4177,4436"
to="5377,4437">
<v:stroke endarrow="block"/>
</v:line><v:line id="_x0000_s1059" style='position:absolute;flip:x' from="6877,4436"
to="8077,4437">
<v:stroke endarrow="block"/>
</v:line><v:shape id="_x0000_s1060" type="#_x0000_t202" style='position:absolute;
left:7027;top:3973;width:1050;height:309' stroked="f">
<v:textbox style='mso-next-textbox:#_x0000_s1060'>
<![if !mso]>
<table cellpadding=0 cellspacing=0 width="100%">
<tr>
<td><![endif]>
<div>
<p class=MsoNormal>
<span lang=EN-US>Resume</span></p>
</div>
<![if !mso]></td>
</tr>
</table>
<![endif]></v:textbox>
</v:shape><v:line id="_x0000_s1061" style='position:absolute;flip:y' from="3277,3819"
to="3277,4128"/>
<v:line id="_x0000_s1062" style='position:absolute' from="3277,3819" to="8677,3819"/>
<v:line id="_x0000_s1063" style='position:absolute' from="8677,3819" to="8677,4128">
<v:stroke endarrow="block"/>
</v:line><v:shape id="_x0000_s1064" type="#_x0000_t202" style='position:absolute;
left:5827;top:3356;width:1050;height:463' stroked="f">
<v:textbox style='mso-next-textbox:#_x0000_s1064'>
<![if !mso]>
<table cellpadding=0 cellspacing=0 width="100%">
<tr>
<td><![endif]>
<div>
<p class=MsoNormal align=center style='text-align:center'>
<span
lang=EN-US>Suspend</span></p>
</div>
<![if !mso]></td>
</tr>
</table>
<![endif]></v:textbox>
</v:shape></v:group><w:wrap type="none"/>
<w:anchorlock/>
</v:group><![endif]--><!--[if !vml]--><!--[endif]--></span><!--[if mso & !supportInlineShapes & supportFields]><span
lang=EN-US style='font-family:"Times New Roman","serif"'><v:shape id="_x0000_i1026"
type="#_x0000_t75" style='width:6in;height:126pt'>
<v:imagedata croptop="-65520f" cropbottom="65520f"/>
</v:shape><span style='mso-element:field-end'></span></span><![endif]--><span lang="EN-US" style="font-family: "Times New Roman","serif";"><o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">2.
It has been made to sleep. We can put a thread to sleep for a specified time
period, where time is in milliseconds. This means that the thread is out of the
queue during this time period. The thread re-enters the runnable state as soon
as this time period is elapsed.<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjmrUBda2cduScU8dFukXgDHyBBPuJVfQ2Pgbt0DLGWDZ-1h8tfb71lPuCFK7R26CjbFUkWG8sVa0VGWj-YBUA9oimWv1O-FCRSMf7FrkH_ZZqOo1iPJieVftjjjRcZWVI1zKzwrT7teHg/s1600/Untitled.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="180" data-original-width="526" height="136" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjmrUBda2cduScU8dFukXgDHyBBPuJVfQ2Pgbt0DLGWDZ-1h8tfb71lPuCFK7R26CjbFUkWG8sVa0VGWj-YBUA9oimWv1O-FCRSMf7FrkH_ZZqOo1iPJieVftjjjRcZWVI1zKzwrT7teHg/s400/Untitled.png" width="400" /></a></div>
<br />
<div class="MsoNormal">
<!--[if mso & !supportInlineShapes & supportFields]><span
lang=EN-US style='font-family:"Times New Roman","serif"'><span
style='mso-element:field-begin;mso-field-lock:yes'></span><span
style='mso-spacerun:yes'> </span>SHAPE <span
style='mso-spacerun:yes'> </span>\* MERGEFORMAT <span style='mso-element:field-separator'></span></span><![endif]--><span lang="EN-US" style="font-family: "Times New Roman","serif";"><!--[if gte vml 1]><v:group
id="_x0000_s1039" editas="canvas" style='width:6in;height:126pt;
mso-position-horizontal-relative:char;mso-position-vertical-relative:line'
coordorigin="2527,3202" coordsize="7200,2160">
<o:lock v:ext="edit" aspectratio="t"/>
<v:shape id="_x0000_s1040" type="#_x0000_t75" style='position:absolute;left:2527;
top:3202;width:7200;height:2160' o:preferrelative="f">
<v:fill o:detectmouseclick="t"/>
<v:path o:extrusionok="t" o:connecttype="none"/>
<o:lock v:ext="edit" text="t"/>
</v:shape><v:group id="_x0000_s1041" style='position:absolute;left:2677;top:3356;
width:6900;height:1543' coordorigin="2677,3356" coordsize="6900,1543">
<v:oval id="_x0000_s1042" style='position:absolute;left:2677;top:4128;
width:1500;height:771'>
<v:textbox style='mso-next-textbox:#_x0000_s1042'>
<![if !mso]>
<table cellpadding=0 cellspacing=0 width="100%">
<tr>
<td><![endif]>
<div>
<p class=MsoNormal align=center style='text-align:center'>
<span
lang=EN-US>Running</span></p>
</div>
<![if !mso]></td>
</tr>
</table>
<![endif]></v:textbox>
</v:oval><v:oval id="_x0000_s1043" style='position:absolute;left:5377;top:4128;
width:1500;height:771'>
<v:textbox style='mso-next-textbox:#_x0000_s1043'>
<![if !mso]>
<table cellpadding=0 cellspacing=0 width="100%">
<tr>
<td><![endif]>
<div>
<p class=MsoNormal align=center style='text-align:center'>
<span
lang=EN-US>Runnable</span></p>
</div>
<![if !mso]></td>
</tr>
</table>
<![endif]></v:textbox>
</v:oval><v:oval id="_x0000_s1044" style='position:absolute;left:8077;top:4128;
width:1500;height:771'>
<v:textbox style='mso-next-textbox:#_x0000_s1044'>
<![if !mso]>
<table cellpadding=0 cellspacing=0 width="100%">
<tr>
<td><![endif]>
<div>
<p class=MsoNormal align=center style='text-align:center'>
<span
lang=EN-US>Sleeping</span></p>
</div>
<![if !mso]></td>
</tr>
</table>
<![endif]></v:textbox>
</v:oval><v:line id="_x0000_s1045" style='position:absolute;flip:x' from="4177,4436"
to="5377,4437">
<v:stroke endarrow="block"/>
</v:line><v:line id="_x0000_s1046" style='position:absolute;flip:x' from="6877,4436"
to="8077,4437">
<v:stroke endarrow="block"/>
</v:line><v:shape id="_x0000_s1047" type="#_x0000_t202" style='position:absolute;
left:7027;top:3973;width:1050;height:309' stroked="f">
<v:textbox style='mso-next-textbox:#_x0000_s1047'>
<![if !mso]>
<table cellpadding=0 cellspacing=0 width="100%">
<tr>
<td><![endif]>
<div>
<p class=MsoNormal align=center style='text-align:center'>
<span
lang=EN-US>after t</span></p>
</div>
<![if !mso]></td>
</tr>
</table>
<![endif]></v:textbox>
</v:shape><v:line id="_x0000_s1048" style='position:absolute;flip:y' from="3277,3819"
to="3277,4128"/>
<v:line id="_x0000_s1049" style='position:absolute' from="3277,3819" to="8677,3819"/>
<v:line id="_x0000_s1050" style='position:absolute' from="8677,3819" to="8677,4128">
<v:stroke endarrow="block"/>
</v:line><v:shape id="_x0000_s1051" type="#_x0000_t202" style='position:absolute;
left:5827;top:3356;width:1050;height:463' stroked="f">
<v:textbox style='mso-next-textbox:#_x0000_s1051'>
<![if !mso]>
<table cellpadding=0 cellspacing=0 width="100%">
<tr>
<td><![endif]>
<div>
<p class=MsoNormal align=center style='text-align:center'>
<span
lang=EN-US>Sleep</span></p>
</div>
<![if !mso]></td>
</tr>
</table>
<![endif]></v:textbox>
</v:shape></v:group><w:wrap type="none"/>
<w:anchorlock/>
</v:group><![endif]--><!--[if !vml]--><!--[endif]--></span><!--[if mso & !supportInlineShapes & supportFields]><span
lang=EN-US style='font-family:"Times New Roman","serif"'><v:shape id="_x0000_i1027"
type="#_x0000_t75" style='width:6in;height:126pt'>
<v:imagedata croptop="-65520f" cropbottom="65520f"/>
</v:shape><span style='mso-element:field-end'></span></span><![endif]--><span lang="EN-US" style="font-family: "Times New Roman","serif";"><o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">3.
It has been told to wait until some event occurs. The thread can be scheduled
to run again using the notify() method.<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg1Ld58oAeuTLHvDaam5vwE2KjEsXOg_VX5QwjRo6TtnlcursfhG0sVQ6PRWJP1PSiRoQYcJo1v0L9ZM7SncWho107VZC6QsbQ1VqT28fwM_Jyp9VkWwjypXzzyRicZu9Ah8-mruNa6KNg/s1600/Untitled.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="180" data-original-width="526" height="136" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg1Ld58oAeuTLHvDaam5vwE2KjEsXOg_VX5QwjRo6TtnlcursfhG0sVQ6PRWJP1PSiRoQYcJo1v0L9ZM7SncWho107VZC6QsbQ1VqT28fwM_Jyp9VkWwjypXzzyRicZu9Ah8-mruNa6KNg/s400/Untitled.png" width="400" /></a></div>
<br />
<div class="MsoNormal">
<!--[if mso & !supportInlineShapes & supportFields]><span
lang=EN-US style='font-family:"Times New Roman","serif"'><span
style='mso-element:field-begin;mso-field-lock:yes'></span><span
style='mso-spacerun:yes'> </span>SHAPE <span
style='mso-spacerun:yes'> </span>\* MERGEFORMAT <span style='mso-element:field-separator'></span></span><![endif]--><span lang="EN-US" style="font-family: "Times New Roman","serif";"><!--[if gte vml 1]><v:group
id="_x0000_s1026" editas="canvas" style='width:6in;height:126pt;
mso-position-horizontal-relative:char;mso-position-vertical-relative:line'
coordorigin="2527,3202" coordsize="7200,2160">
<o:lock v:ext="edit" aspectratio="t"/>
<v:shape id="_x0000_s1027" type="#_x0000_t75" style='position:absolute;left:2527;
top:3202;width:7200;height:2160' o:preferrelative="f">
<v:fill o:detectmouseclick="t"/>
<v:path o:extrusionok="t" o:connecttype="none"/>
<o:lock v:ext="edit" text="t"/>
</v:shape><v:group id="_x0000_s1028" style='position:absolute;left:2677;top:3356;
width:6900;height:1543' coordorigin="2677,3356" coordsize="6900,1543">
<v:oval id="_x0000_s1029" style='position:absolute;left:2677;top:4128;
width:1500;height:771'>
<v:textbox style='mso-next-textbox:#_x0000_s1029'>
<![if !mso]>
<table cellpadding=0 cellspacing=0 width="100%">
<tr>
<td><![endif]>
<div>
<p class=MsoNormal align=center style='text-align:center'>
<span
lang=EN-US>Running</span></p>
</div>
<![if !mso]></td>
</tr>
</table>
<![endif]></v:textbox>
</v:oval><v:oval id="_x0000_s1030" style='position:absolute;left:5377;top:4128;
width:1500;height:771'>
<v:textbox style='mso-next-textbox:#_x0000_s1030'>
<![if !mso]>
<table cellpadding=0 cellspacing=0 width="100%">
<tr>
<td><![endif]>
<div>
<p class=MsoNormal align=center style='text-align:center'>
<span
lang=EN-US>Runnable</span></p>
</div>
<![if !mso]></td>
</tr>
</table>
<![endif]></v:textbox>
</v:oval><v:oval id="_x0000_s1031" style='position:absolute;left:8077;top:4128;
width:1500;height:771'>
<v:textbox style='mso-next-textbox:#_x0000_s1031'>
<![if !mso]>
<table cellpadding=0 cellspacing=0 width="100%">
<tr>
<td><![endif]>
<div>
<p class=MsoNormal align=center style='text-align:center'>
<span
lang=EN-US>Waiting</span></p>
</div>
<![if !mso]></td>
</tr>
</table>
<![endif]></v:textbox>
</v:oval><v:line id="_x0000_s1032" style='position:absolute;flip:x' from="4177,4436"
to="5377,4437">
<v:stroke endarrow="block"/>
</v:line><v:line id="_x0000_s1033" style='position:absolute;flip:x' from="6877,4436"
to="8077,4437">
<v:stroke endarrow="block"/>
</v:line><v:shape id="_x0000_s1034" type="#_x0000_t202" style='position:absolute;
left:7027;top:3973;width:1050;height:309' stroked="f">
<v:textbox style='mso-next-textbox:#_x0000_s1034'>
<![if !mso]>
<table cellpadding=0 cellspacing=0 width="100%">
<tr>
<td><![endif]>
<div>
<p class=MsoNormal>
<span lang=EN-US>notify</span></p>
</div>
<![if !mso]></td>
</tr>
</table>
<![endif]></v:textbox>
</v:shape><v:line id="_x0000_s1035" style='position:absolute;flip:y' from="3277,3819"
to="3277,4128"/>
<v:line id="_x0000_s1036" style='position:absolute' from="3277,3819" to="8677,3819"/>
<v:line id="_x0000_s1037" style='position:absolute' from="8677,3819" to="8677,4128">
<v:stroke endarrow="block"/>
</v:line><v:shape id="_x0000_s1038" type="#_x0000_t202" style='position:absolute;
left:5827;top:3356;width:1050;height:463' stroked="f">
<v:textbox style='mso-next-textbox:#_x0000_s1038'>
<![if !mso]>
<table cellpadding=0 cellspacing=0 width="100%">
<tr>
<td><![endif]>
<div>
<p class=MsoNormal align=center style='text-align:center'>
<span
lang=EN-US>wait</span></p>
</div>
<![if !mso]></td>
</tr>
</table>
<![endif]></v:textbox>
</v:shape></v:group><w:wrap type="none"/>
<w:anchorlock/>
</v:group><![endif]--><!--[if !vml]--><!--[endif]--></span><!--[if mso & !supportInlineShapes & supportFields]><span
lang=EN-US style='font-family:"Times New Roman","serif"'><v:shape id="_x0000_i1028"
type="#_x0000_t75" style='width:6in;height:126pt'>
<v:imagedata croptop="-65520f" cropbottom="65520f"/>
</v:shape><span style='mso-element:field-end'></span></span><![endif]--><span lang="EN-US" style="font-family: "Times New Roman","serif";"><o:p></o:p></span></div>
<div class="MsoNormal">
<b style="mso-bidi-font-weight: normal;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">Blocked State:<o:p></o:p></span></b></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><o:p> </o:p></span><span style="font-family: "Times New Roman", serif;">A
thread is said to be blocked when it is prevented( not permitted) from entering
into the runnable state and subsequently the running state. This happens when
the thread is suspended, sleeping, or waiting in order to satisfy certain
requirements. A blocked thread is considered “not runnable” but not dead and
therefore fully qualified to run again.</span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b style="mso-bidi-font-weight: normal;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">Dead State:<o:p></o:p></span></b></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><o:p> </o:p></span><span style="font-family: "Times New Roman", serif;">A
running thread ends its life when it has completed executing its run() method.
It is a natural death.</span><span style="font-family: "Times New Roman", serif;"> </span><span style="font-family: "Times New Roman", serif;">We can kill it by
sending the stop() to it at any state thus causing a premature death to it.</span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b style="mso-bidi-font-weight: normal;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">Thread Class Methods:<o:p></o:p></span></b></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman", serif;">Some
commonly used methods of Thread Class are:</span></div>
<div class="MsoNormal">
<br /></div>
<table border="1" cellpadding="0" cellspacing="0" class="MsoNormalTable" style="border-collapse: collapse; border: none; mso-border-alt: solid windowtext .5pt; mso-border-insideh: .5pt solid windowtext; mso-border-insidev: .5pt solid windowtext; mso-padding-alt: 0cm 5.4pt 0cm 5.4pt; mso-yfti-tbllook: 480;">
<tbody>
<tr style="mso-yfti-firstrow: yes; mso-yfti-irow: 0;">
<td style="border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt;" valign="top">
<div align="center" class="MsoNormal" style="text-align: center;">
<b style="mso-bidi-font-weight: normal;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">Method
Name<o:p></o:p></span></b></div>
</td>
<td style="border-left: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt;" valign="top">
<div align="center" class="MsoNormal" style="text-align: center;">
<b style="mso-bidi-font-weight: normal;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">Description<o:p></o:p></span></b></div>
</td>
</tr>
<tr style="mso-yfti-irow: 1;">
<td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt;" valign="top">
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">Static
Thread currentThread()<o:p></o:p></span></div>
</td>
<td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt;" valign="top">
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">Returns
a reference to the currently executing thread object.<o:p></o:p></span></div>
</td>
</tr>
<tr style="mso-yfti-irow: 2;">
<td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt;" valign="top">
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">String
getName()<o:p></o:p></span></div>
</td>
<td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt;" valign="top">
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">Returns
the name of the thread in which it is called.<o:p></o:p></span></div>
</td>
</tr>
<tr style="mso-yfti-irow: 3;">
<td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt;" valign="top">
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">int
getPriority)<o:p></o:p></span></div>
</td>
<td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt;" valign="top">
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">Returns
the thread priority<o:p></o:p></span></div>
</td>
</tr>
<tr style="mso-yfti-irow: 4;">
<td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt;" valign="top">
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">Void
interrupt()<o:p></o:p></span></div>
</td>
<td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt;" valign="top">
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">Used
for interrupting the thread<o:p></o:p></span></div>
</td>
</tr>
<tr style="mso-yfti-irow: 5;">
<td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt;" valign="top">
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">Void
setName(String Newname)<o:p></o:p></span></div>
</td>
<td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt;" valign="top">
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">Changes
the name of the thread to new name<o:p></o:p></span></div>
</td>
</tr>
<tr style="mso-yfti-irow: 6;">
<td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt;" valign="top">
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">Void
setPriority()<o:p></o:p></span></div>
</td>
<td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt;" valign="top">
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">Changes
the thread priority<o:p></o:p></span></div>
</td>
</tr>
<tr style="mso-yfti-irow: 7;">
<td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt;" valign="top">
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">Static
void sleep(long millisec)<o:p></o:p></span></div>
</td>
<td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt;" valign="top">
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">Causes
the currently running thread to sleep<o:p></o:p></span></div>
</td>
</tr>
<tr style="mso-yfti-irow: 8;">
<td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt;" valign="top">
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">Void
start()<o:p></o:p></span></div>
</td>
<td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt;" valign="top">
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">Used
to begin the execution of a thread. It calls the run()<o:p></o:p></span></div>
</td>
</tr>
<tr style="mso-yfti-irow: 9;">
<td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt;" valign="top">
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">Static
void yield()<o:p></o:p></span></div>
</td>
<td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt;" valign="top">
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">Used
to pause temporarily to current thread object and allows other thread to
execute<o:p></o:p></span></div>
</td>
</tr>
<tr style="mso-yfti-irow: 10;">
<td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt;" valign="top">
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">String
toString()<o:p></o:p></span></div>
</td>
<td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt;" valign="top">
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">Returns
a string representation of thread. String includes threadgroup, threadsname
and priority<o:p></o:p></span></div>
</td>
</tr>
<tr style="mso-yfti-irow: 11; mso-yfti-lastrow: yes;">
<td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt;" valign="top">
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">Void
destroy()<o:p></o:p></span></div>
</td>
<td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt;" valign="top">
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">Destroys
the thread without any cleanup.<o:p></o:p></span></div>
</td>
</tr>
</tbody></table>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b style="mso-bidi-font-weight: normal;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">Thread Exceptions:<o:p></o:p></span></b></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoBodyText">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-bidi-font-weight: bold;">Whenever we call a thread method that is likely to
throw an exception, we have to supply an appropriate exception handler to catch
it. The catch statement may take one of the following forms:<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-bidi-font-weight: bold;">catch(ThreadDeath e)<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-bidi-font-weight: bold;">{<o:p></o:p></span></div>
<div class="MsoNormal">
<!--[if gte vml 1]><v:shape id="_x0000_s1075" type="#_x0000_t202"
style='position:absolute;left:0;text-align:left;margin-left:108pt;
margin-top:3.9pt;width:99pt;height:18pt;z-index:251675648' stroked="f"/><![endif]--><!--[if !vml]--><span style="height: 28px; left: 0px; margin-left: 144px; margin-top: 5px; mso-ignore: vglayout; position: absolute; width: 136px; z-index: 251675648;">
<table cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td bgcolor="white" height="28" style="background: white; vertical-align: top;" width="136"><!--[endif]--><!--[if !mso]--><span style="left: 0pt; mso-ignore: vglayout; position: absolute; z-index: 251675648;">
<table cellpadding="0" cellspacing="0" style="width: 100%px;">
<tbody>
<tr>
<td><!--[endif]-->
<div class="shape" style="padding: 3.6pt 7.2pt 3.6pt 7.2pt;" v:shape="_x0000_s1075">
<div class="MsoNormal">
<span lang="EN-US">//Killed Thread</span></div>
</div>
<!--[if !mso]--></td>
</tr>
</tbody></table>
</span><!--[endif]--><!--[if !mso & !vml]--> <!--[endif]--><!--[if !vml]--></td>
</tr>
</tbody></table>
</span><!--[endif]--><span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-bidi-font-weight: bold;"><span style="mso-tab-count: 1;"> </span>-----<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-bidi-font-weight: bold;"><span style="mso-tab-count: 1;"> </span>-----<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-bidi-font-weight: bold;">}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-bidi-font-weight: bold;">catch(InterruptedException e)<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-bidi-font-weight: bold;">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-bidi-font-weight: bold;"><span style="mso-tab-count: 1;"> </span>-----<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-bidi-font-weight: bold;"><span style="mso-tab-count: 1;"> </span>-----<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-bidi-font-weight: bold;">}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-bidi-font-weight: bold;">catch(<span style="mso-spacerun: yes;"> </span>)<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-bidi-font-weight: bold;">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-bidi-font-weight: bold;"><span style="mso-tab-count: 1;"> </span>-----<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-bidi-font-weight: bold;"><span style="mso-tab-count: 1;"> </span>-----<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-bidi-font-weight: bold;">}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-bidi-font-weight: bold;">catch(<span style="mso-spacerun: yes;"> </span>)<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-bidi-font-weight: bold;">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-bidi-font-weight: bold;"><span style="mso-tab-count: 1;"> </span>-----<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-bidi-font-weight: bold;"><span style="mso-tab-count: 1;"> </span>-----<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-bidi-font-weight: bold;">}<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b style="mso-bidi-font-weight: normal;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">Thread Priorities:<o:p></o:p></span></b></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">Java assigns to each thread a priority<b>. </b>Thread priority is
an integer that specifies the relative priority of one thread to another. A
thread can voluntarily relinquish its control. Threads relinquish control by
explicitly yielding, sleeping, or blocking on pending Input/ Output operations.
In this scenario, all other threads are examined, and the highest- priority
thread that is ready to run gets the chance to use the CPU. <o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">A higher-priority thread can pre-empt a low priority thread. In
this case, a lower- priority thread that does not yield the processor is
forcibly pre-empted. In cases where two threads with the same priority are
competing for CPU cycles, the situation is handled differently by different
operating systems. <o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">Java thread class has defined two constants MIN_PRIORITY and
MAX_PRIORITY. Any thread priority lies between MIN_PRIORITY and MAX_PRIORITY.
Currently, the value of MIN_PRIORITY is 1 and MAX_PRIORITY is 10. <o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">The priority of a thread is set at the time of creation. It is set
to the same priority as the Thread that created it. The default priority of a
thread can be changed by using the setPriority( ) method of Thread class. <o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">Final void setPriority (int Priority_Level) where Priority_Level
specifies the new priority for the calling thread. <o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">To return a thread to default priority, specify Norm_Priority,
which is currently 5. <o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">You can obtain the current priority setting by calling the
getPriority( ) method of thread class. <o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">final int getPriority( ). <o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b><span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">//program <o:p></o:p></span></b></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">class Thread_Priority <o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">{ <o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">public static void main (String args [ ]) <o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">{ <o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">try <o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">{ <o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">Thread Td1 = new Thread ("Thread1"); <o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">Thread Td2 = new Thread ("Thread2"); <o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">System.out.println ("Before any change in default
priority:"); <o:p></o:p></span></div>
<div class="MsoBodyText2">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">System.out.println("ThePriority
of "+Td1.getName() +" is "+ Td1.getPriority()); <o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">System.out.println("The Priority of "+Td1.getName()
+" is "+ Td2.getPriority()); <o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">//change in priority <o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">Td1.setPriority(7); <o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">Td2.setPriority(8); <o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">System.out.println ("After changing in Priority:"); <o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">System.out.println("The Priority of "+Td1.getName()
+" is "+ Td1.getPriority()); <o:p></o:p></span></div>
<div class="MsoBodyText2">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">System.out.println("The
Priority of "+Td1.getName() +" is "+ Td2.getPriority()); <o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">} <o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">catch ( Exception e) <o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">{ <o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">System.out.println("Main thread interrupted"); <o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">} <o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">} <o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">} <o:p></o:p></span></div>
<div class="MsoNormal">
<b><span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">Output: <o:p></o:p></span></b></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">Before any change in default priority: <o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">The Priority of Thread1 is 5 <o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">The Priority of Thread1 is 5 <o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">After changing in Priority: <o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">The Priority of Thread1 is 7 <o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">The Priority of Thread1 is 8</span><b style="mso-bidi-font-weight: normal;"><span lang="EN-US" style="font-family: "Times New Roman","serif";"><o:p></o:p></span></b></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b style="mso-bidi-font-weight: normal;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">Synchronization:<o:p></o:p></span></b></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">It
is the process of running only one thread (or) one resource by making other
threads to be wait in the queue. Synchronization is achieved with the help of
an object called monitor which allows only one thread to enter by making other
threads to wait. Once the thread in the monitor has completed the job either
the next thread or thread based on higher priority will be executed.
Synchronization is achieved in java with the help of a method called
Synchronized() which can be applied either for methods (or) statements.<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b style="mso-bidi-font-weight: normal;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">Ex:<o:p></o:p></span></b></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">While
printing job has been assigned from different systems simultaneously, the
task<span style="mso-spacerun: yes;"> </span>should be done serially otherwise
it may results to wrong prints. We make the<span style="mso-spacerun: yes;">
</span>printing method synchronized such that the task will be done serially.<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">class
SynchronizeDemo2<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>public static void main(String
args[])<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span>Shared shared = new
Shared();<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span>CustomThread thread1 =
new CustomThread(shared, "one");<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span>CustomThread thread2 =
new CustomThread(shared, "two");<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span>CustomThread thread3=new
CustomThread(shared, "three");<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span>CustomThread thread4 =
new CustomThread(shared, "four");<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span>try <o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span>{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 3;"> </span>thread1.join();<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 3;"> </span>thread2.join();<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 3;"> </span>thread3.join();<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 3;"> </span>thread4.join();<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span>} <o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span>catch(InterruptedException
e) {}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">}<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">class
CustomThread extends Thread<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>Shared shared;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>public CustomThread(Shared shared,
String string) <o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span>super(string);<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span>this.shared = shared;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span>start();<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>public void run() <o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span>shared.doWork(Thread.currentThread().getName());<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">}<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">class
Shared<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span><span style="mso-spacerun: yes;"> </span>synchronized void doWork(String string) <o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span>System.out.println("Starting
" + string);<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span>try <o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span>{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 3;"> </span>Thread.sleep(1000);<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span>} <o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span>catch
(InterruptedException e) { }<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span>System.out.println("Ending
" + string);<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">}</span><span style="font-family: "Times New Roman", serif;"> </span></div>
<br /><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEij_Pu7e2IGT9_WQj1ujxak5Ul7SjE9zPlCofGebm0V5P1vPy49hPl1Cbb5C3ed3gVV_YfJ_cNZyaAUhzbakB9WB28p_7VcF-7hjVlJXaR7mTx7A-AroH0JhPivSEW8HlJebsurIBmndBo/s1600/Untitled.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="207" data-original-width="663" height="122" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEij_Pu7e2IGT9_WQj1ujxak5Ul7SjE9zPlCofGebm0V5P1vPy49hPl1Cbb5C3ed3gVV_YfJ_cNZyaAUhzbakB9WB28p_7VcF-7hjVlJXaR7mTx7A-AroH0JhPivSEW8HlJebsurIBmndBo/s400/Untitled.png" width="400" /></a></div>
<br /></div>
Bagadhi Sateeshhttp://www.blogger.com/profile/16786636572407672825noreply@blogger.com0tag:blogger.com,1999:blog-8352540103162095489.post-501945495769315462018-08-30T13:13:00.000+05:302018-08-30T13:13:01.838+05:30PACKAGES<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<div align="center" class="MsoNormal" style="text-align: center;">
<b><span lang="EN-US" style="color: black; font-family: "Times New Roman","serif"; font-size: 14.0pt;">PACKAGES<o:p></o:p></span></b></div>
<div class="MsoNormal">
<span style="font-size: large;"><b><span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><o:p> </o:p></span></b><b><span lang="EN-US" style="font-family: "Times New Roman", serif;">Java API Packages</span></b></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">Java API provides a large number of classes grouped into different
packages according to functionality. Most frequently used packages are:-<o:p></o:p></span></div>
<ul style="margin-top: 0cm;" type="disc">
<li class="MsoNormal" style="mso-list: l1 level1 lfo1; tab-stops: list 36.0pt; text-align: left;"><b><i><span lang="EN-US" style="font-family: "Times New Roman","serif";">Java.lang:<span style="mso-spacerun: yes;"> </span><o:p></o:p></span></i></b></li>
</ul>
<div class="MsoNormal" style="margin-left: 36.0pt;">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">These are classes that java
compiler itself uses and therefore they are automatically imported. They
include classes for primitive types.<o:p></o:p></span></div>
<ul style="margin-top: 0cm;" type="disc">
<li class="MsoNormal" style="mso-list: l1 level1 lfo1; tab-stops: list 36.0pt; text-align: left;"><b><i><span lang="EN-US" style="font-family: "Times New Roman","serif";">Java.util:<span style="mso-tab-count: 1;"> </span> <o:p></o:p></span></i></b></li>
</ul>
<div class="MsoNormal" style="margin-left: 36.0pt;">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">A collection of classes to
provide utility functions such as vectors, hash tables, random numbers, date
and time functions etc.<o:p></o:p></span></div>
<ul style="margin-top: 0cm;" type="disc">
<li class="MsoNormal" style="mso-list: l1 level1 lfo1; tab-stops: list 36.0pt; text-align: left;"><b><i><span lang="EN-US" style="font-family: "Times New Roman","serif";">Java.io:</span></i></b><i><span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-spacerun: yes;"> </span><o:p></o:p></span></i></li>
</ul>
<div class="MsoNormal" style="text-indent: 36.0pt;">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">A Collection of classes required
for Input/Output manipulations.<o:p></o:p></span></div>
<ul style="margin-top: 0cm;" type="disc">
<li class="MsoNormal" style="mso-list: l1 level1 lfo1; tab-stops: list 36.0pt; text-align: left;"><b><i><span lang="EN-US" style="font-family: "Times New Roman","serif";">Java.net:<span style="mso-spacerun: yes;"> </span><o:p></o:p></span></i></b></li>
</ul>
<div class="MsoNormal" style="margin-left: 36.0pt;">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">A collection of classes for
communicating with other computers via network.<o:p></o:p></span></div>
<ul style="margin-top: 0cm;" type="disc">
<li class="MsoNormal" style="mso-list: l1 level1 lfo1; tab-stops: list 36.0pt; text-align: left;"><b><i><span lang="EN-US" style="font-family: "Times New Roman","serif";">Java.awt:
<o:p></o:p></span></i></b></li>
</ul>
<div class="MsoNormal" style="margin-left: 36.0pt;">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">The Abstract Window Tool Kit
package contains classes that implements platform independent graphical user
interface.<o:p></o:p></span></div>
<ul style="margin-top: 0cm;" type="disc">
<li class="MsoNormal" style="mso-list: l1 level1 lfo1; tab-stops: list 36.0pt; text-align: left;"><b><span lang="EN-US" style="font-family: "Times New Roman","serif";">Java.applet:
<o:p></o:p></span></b></li>
</ul>
<div class="MsoNormal" style="text-indent: 36.0pt;">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">This includes a set of classes
that allows us to create Java applets.<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b><span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;">Using system Packages </span><o:p></o:p></span></b></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; mso-pagination: none; text-autospace: none; text-indent: 36.0pt;">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">There
are two ways of accessing the classes stored in a package. The first approach
is to use the <i>fully qualified class name </i>of the class that we want to
use. This is done by using the package name containing the class and then
appending the class name to it using the dot operator. For example, if we want
to refer to the class Color in the awt package, then we may do so as follows:<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 36.95pt; margin-right: 273.35pt; margin-top: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">java.awt.Colour<o:p></o:p></span></div>
<div class="MsoBodyText2">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">Notice
that awt is a package within the package java and the hierarchy is represented
by separating the levels with dots. This approach is perhaps the best and
easiest one if we need to access the class only once or when we need not have
to access any other classes of the package.<o:p></o:p></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">But,
in many situations, we might want to use a class in a number of places in the
program or we may like to use many of the classes contained in a package. We
may achieve this easily as follows;<o:p></o:p></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; mso-pagination: none; text-autospace: none; text-indent: 36.0pt;">
<b><span lang="EN-US" style="font-family: "Times New Roman","serif";">import
</span></b><span lang="EN-US" style="font-family: "Times New Roman","serif";">packagename.classname;
or<o:p></o:p></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; mso-pagination: none; text-autospace: none; text-indent: 36.0pt;">
<b><span lang="EN-US" style="font-family: "Times New Roman","serif";">import
</span></b><span lang="EN-US" style="font-family: "Times New Roman","serif";">packagename.*;<o:p></o:p></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; mso-pagination: none; tab-stops: 7.2pt; text-autospace: none;">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">These
are known as <i>import statements </i>and must appear at the top of the file,
before any class declarations.<o:p></o:p></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; mso-pagination: none; tab-stops: 7.2pt; text-autospace: none;">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">The
first statement allows the specified class in the specified package to be
imported. For example, the statement<o:p></o:p></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; mso-pagination: none; tab-stops: 26.6pt; text-autospace: none;">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>import java.awt.Color;<o:p></o:p></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">imports
the class Colour and therefore the class name can now be directly used in the
program. <o:p></o:p></span></div>
<div class="MsoNormal" style="margin-left: .7pt; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">The
second statement imports-every class contained in the specified package. For
example, the statement import java.awt.*; bring all classes of java.awt package<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b><span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;">Naming Conventions </span><o:p></o:p></span></b></div>
<ul style="margin-top: 0cm;" type="disc">
<li class="MsoNormal" style="color: black; mso-list: l1 level1 lfo1; tab-stops: list 36.0pt;"><span lang="EN-US" style="color: windowtext; font-family: "Times New Roman","serif";">Packages
begin with lowercase letters</span><b><span lang="EN-US" style="font-family: "Times New Roman","serif";"><o:p></o:p></span></b></li>
<li class="MsoNormal" style="color: black; mso-list: l1 level1 lfo1; tab-stops: list 36.0pt;"><span lang="EN-US" style="color: windowtext; font-family: "Times New Roman","serif";">Every
package name must be unique</span><b><span lang="EN-US" style="font-family: "Times New Roman","serif";"><o:p></o:p></span></b></li>
</ul>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><o:p> </o:p></span><b><span lang="EN-US" style="font-family: "Times New Roman", serif;"><o:p> </o:p></span></b></div>
<div class="MsoNormal">
<b><span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;">Creating Packages </span><o:p></o:p></span></b></div>
<h2>
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-weight: normal;"><span style="font-size: small;">Packages declare the name of the package using the package keyword
followed by a package name. This must be the first statement in Java source
file.</span><o:p></o:p></span></h2>
<div class="MsoFooter" style="tab-stops: 36.0pt;">
<span lang="EN-US">package first;</span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">public
class firstclass<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>body<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">}<o:p></o:p></span></div>
<h2>
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-weight: normal;"><span style="font-size: small;">here the package name is first. This should be saved as firstclass.java
and located in a directory named first. When the source file is compiled, java
will create a .class file and store it in the same directory.</span><o:p></o:p></span></h2>
<h3>
<span style="font-size: large;"><span lang="EN-US" style="font-family: "Times New Roman","serif";"><o:p> </o:p></span>Steps to
create package</span></h3>
<ol start="1" style="margin-top: 0cm;" type="1">
<li class="MsoNormal" style="mso-list: l0 level1 lfo2; tab-stops: list 36.0pt; text-align: left;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">Declare
the package at the beginning of a file using the form,<o:p></o:p></span></li>
</ol>
<div class="MsoNormal" style="margin-left: 72.0pt;">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">Package packagename; <o:p></o:p></span></div>
<ol start="2" style="margin-top: 0cm;" type="1">
<li class="MsoNormal" style="mso-list: l0 level1 lfo2; tab-stops: list 36.0pt; text-align: left;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">Define
the class that is to be put in the package and declare it public.<o:p></o:p></span></li>
<li class="MsoNormal" style="mso-list: l0 level1 lfo2; tab-stops: list 36.0pt; text-align: left;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">Create
a subdirectory under the directory where the main source files are stored.<o:p></o:p></span></li>
<li class="MsoNormal" style="mso-list: l0 level1 lfo2; tab-stops: list 36.0pt; text-align: left;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">Store
the file as the classname.java in the subdirectory created.<o:p></o:p></span></li>
<li class="MsoNormal" style="mso-list: l0 level1 lfo2; tab-stops: list 36.0pt; text-align: left;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">Compile
the file. This creates .class file in the subdirectory.<o:p></o:p></span></li>
</ol>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">Subdirectory
name must match the package name exactly. Java also supports the concept of
package hierarchy.<o:p></o:p></span></div>
<div class="MsoBodyText2">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">A
java package file can have more than one class definition. In such cases, only
one of the classes may be declared as public and that class name with .java
extension is the source file name. When a source file with more than one class
definition is compiled, Java creates independent .class files for those
classes.<o:p></o:p></span></div>
<h2>
<span style="font-size: large;"><span lang="EN-US" style="font-family: "Times New Roman","serif";"><o:p> </o:p></span>Accessing a
Package</span></h2>
<div class="MsoBodyText2">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">Packages
are accessed through a fully qualified class name or using a shortcut approach
through the import statement. We use the import statement when there are many
references to a particular package or the package name is too long and
unwieldy.<o:p></o:p></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">The
same approaches can be used to access the user-defined packages as well. The
import statement can be used to search a list of packages for a particular
class. The general form of import statement for searching a class is as
follows:<o:p></o:p></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; mso-pagination: none; text-autospace: none; text-indent: 36.0pt;">
<b><span lang="EN-US" style="font-family: "Times New Roman","serif";">import
<i>packagel [.package2][.package3] </i>.classname;<o:p></o:p></span></b></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">Here
<i>packagel </i>is the name of the top level package, <i>package2 </i>is the
name of the package that is inside the <i>packagel, </i>and so on. We can have
any number of packages in a package hierarchy. Finally, the explicit <i>class
name </i>is specified.<o:p></o:p></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">The
following is an example of importing a particular class:<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 21.35pt; margin-right: 121.9pt; margin-top: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none; text-indent: 14.65pt;">
<b><span lang="EN-US" style="font-family: "Times New Roman","serif";">import
firstPackage.secondPackage.MyClass;<o:p></o:p></span></b></div>
<div class="MsoNormal" style="margin-top: 6.45pt; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">After
defining this statement, all the members of the class MyClass can be directly
accessed using the class name or its objects directly without using the package
name.<o:p></o:p></span></div>
<div class="MsoBodyText2" style="mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">We
can also use another approach as follows:<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 21.35pt; margin-right: 255.8pt; margin-top: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none; text-indent: 14.65pt;">
<b><span lang="EN-US" style="font-family: "Times New Roman","serif";">import <i>packagename. </i>*; <o:p></o:p></span></b></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">Here,
<i>packagename </i>may denote a single package or a hierarchy of packages as
mentioned earlier. The star (") indicates that the compiler should search
this entire package hierarchy when it encounters a class name. This implies
that we can access all classes contained in the above package directly.<o:p></o:p></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal">
<b><span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;">Using a Package </span><o:p></o:p></span></b></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">This
source file should be named calculations.java and stored in the subdirectory
arithmetic. Now compile this java file. The resultant calculations.class will
be stored in the arithmetic subdirectory.<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b><span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;">//Program to calculate arithmetic operations</span><o:p></o:p></span></b></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">package arithmetic;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">public class calculations<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>public int
add(int a,int b)<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span>return
a+b;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>public int sub(int
a,int b)<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span>return
a-b;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>public int
mul(int a,int b)<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span>return
a*b;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>public int
div(int a,int b)<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span>return
a/b;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><br /></span></div>
<div class="MsoNormal">
<b><span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="font-size: large;">Now
consider the listing shown below</span><span style="color: black;"><o:p></o:p></span></span></b></div>
<div class="MsoNormal">
<b><span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;">//importing package</span><o:p></o:p></span></b></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">import arithmetic.calculations;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">class performoperations<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>public static
void main(String []args)<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span>calculations
c=new calculations();<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span>int
a=Integer.parseInt(args[0]);<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span>int
b=Integer.parseInt(args[1]);<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span>int
z=c.mul(a,b);<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span>int
v=c.sub(a,b);<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span>System.out.println("Addition
is:"+c.add(a,b));<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span>System.out.println("Division
is:"+c.div(a,b));<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span>System.out.println("Multiplication
is:"+z);<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span>System.out.println("Subtraction
is:"+v);<span style="mso-tab-count: 1;"> </span><o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">}<o:p></o:p></span></div>
<div class="MsoNormal">
<b><span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">Output:<o:p></o:p></span></b></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">D:\ \programs>javac performoperations.java<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">D:\ \programs>java performoperations 6 2<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">Addition is:8<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">Division is:3<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">Multiplication is:12<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">Subtraction is:4<o:p></o:p></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">This
listing shows a simple program that imports the class calculations from the
package arithmetic. The source file should be saved as performoperations.java
and then compiled.<o:p></o:p></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">During
the compilation of performoperations.java the compiler checks for the file
calculations.class in the arithmetic directory for information it needs, but it
does not actually include the code from calculations.class in the file
performoperations.java. When the performoperations.java program is run, Java
looks for the file calculations.class and loads it using something called <i>class
loader. </i>Now the interpreter knows that it also needs the code in the file
calculations.class and loads it as well.<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b><span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;">Adding a Class to a Package </span><o:p></o:p></span></b></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">It
is simple to add a class to an existing package. Consider the following
package:<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-right: 15.35pt; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">package
pl;<o:p></o:p></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">public
ClassA<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 1.65pt; margin-right: 89.0pt; margin-top: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">{<o:p></o:p></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; mso-pagination: none; text-autospace: none; text-indent: 36.0pt;">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">//
body of A<o:p></o:p></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">}<o:p></o:p></span></div>
<div class="MsoBodyText">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">The
package p1 contains one public class by name A. Suppose we want to add another
class to this package. This can be done as follows:<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-left: 14.15pt; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">1.
<span style="mso-tab-count: 1;"> </span>Define the class and make it public.<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 14.15pt; margin-right: 215.5pt; margin-top: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">2.
<span style="mso-tab-count: 1;"> </span>Place the package statement<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 73.2pt; margin-right: 215.5pt; margin-top: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">package
p1;<o:p></o:p></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; mso-pagination: none; text-autospace: none; text-indent: 36.0pt;">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">before
the class definition as follows:<o:p></o:p></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; mso-pagination: none; text-autospace: none; text-indent: 36.0pt;">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">package
pl; <o:p></o:p></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; mso-pagination: none; text-autospace: none; text-indent: 36.0pt;">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">public
class B<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-left: 2.15pt; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none; text-indent: 33.85pt;">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">{<span style="mso-tab-count: 1;"> </span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-left: 36.0pt; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none; text-indent: 36.0pt;">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">// body of B<o:p></o:p></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>}<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-left: 13.9pt; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">3.
<span style="mso-tab-count: 1;"> </span>Store this as B.java file under the
directory p1.<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-left: 35.65pt; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none; text-indent: -21.75pt;">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">4. <span style="mso-tab-count: 1;"> </span>Compile B.java file. This will create a B.class file and place it
in the directory p1.<o:p></o:p></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">Remember
that, since a Java source file can have only one class declared as public, we
cannot put two or more public classes together in a .java file. This is because
of the restriction that file name should be same as the name of the public
class with .java extension.<o:p></o:p></span></div>
<div class="MsoBodyText3">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">If
we want to create a package with multiple public classes in it, we may follow
the following steps: <o:p></o:p></span></div>
<ul style="margin-top: 0cm;" type="disc">
<li class="MsoNormal" style="mso-layout-grid-align: none; mso-list: l2 level1 lfo3; mso-pagination: none; tab-stops: list 36.0pt; text-autospace: none;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">Decide the name
of the package.<o:p></o:p></span></li>
<li class="MsoNormal" style="mso-layout-grid-align: none; mso-list: l2 level1 lfo3; mso-pagination: none; tab-stops: list 36.0pt; text-align: left; text-autospace: none;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">Create a
subdirectory with this name under the directory where main source files
are stored.<o:p></o:p></span></li>
<li class="MsoNormal" style="mso-layout-grid-align: none; mso-list: l2 level1 lfo3; mso-pagination: none; tab-stops: list 36.0pt; text-align: left; text-autospace: none;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">Create classes
that are to be placed in the package in separate source files and declare
the package statement<o:p></o:p></span></li>
</ul>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 54.0pt; margin-right: 181.4pt; margin-top: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none; text-indent: 18.0pt;">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">package packagename; <o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 18.0pt; margin-right: 181.4pt; margin-top: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none; text-indent: 18.0pt;">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">at the top of each source file.<o:p></o:p></span></div>
<ul style="margin-top: 0cm;" type="disc">
<li class="MsoNormal" style="mso-layout-grid-align: none; mso-list: l2 level1 lfo3; mso-pagination: none; tab-stops: list 36.0pt; text-align: left; text-autospace: none;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">Switch to the
subdirectory created earlier and compile each source file. When completed,
the package would contain. class files of the entire source files.<o:p></o:p></span></li>
</ul>
<div class="MsoNormal">
<b><span lang="EN-US" style="font-family: "Times New Roman", serif;"><span style="font-size: large;">Hiding Classes</span></span></b></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">When we import a package using asterisk(*), all public classes are
imported. However, we may prefer to not import certain classes. Such classes
should not be declared as public.<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">Ex:<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">package p1;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">class y<span style="mso-tab-count: 1;"> </span>//not public so it
is hidden class<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>body<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">}<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoBodyText">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">Here
the class y which is not declared public is hidden from outside of package p1.</span></div>
<br /></div>
Bagadhi Sateeshhttp://www.blogger.com/profile/16786636572407672825noreply@blogger.com0tag:blogger.com,1999:blog-8352540103162095489.post-10157019966441976382018-08-29T13:17:00.005+05:302018-08-29T13:17:56.710+05:30Interface :: Multiple Inheritance<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<div align="center" class="MsoNormal" style="text-align: center;">
<b><span lang="EN-US" style="color: black; font-family: "Times New Roman", serif;"><span style="font-size: large;">Interface :: </span></span></b><b><span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;">Multiple
Inheritance</span><o:p></o:p></span></b></div>
<div align="center" class="MsoNormal" style="text-align: center;">
<br /></div>
<div class="MsoBodyText">
<!--[if gte vml 1]><v:group id="_x0000_s1026" style='position:absolute;
left:0;text-align:left;margin-left:138pt;margin-top:26.6pt;width:140.35pt;
height:135.35pt;z-index:251669504' coordorigin="4279,1842" coordsize="2807,2707">
<v:rect id="_x0000_s1027" style='position:absolute;left:4279;top:1842;width:853;
height:769'>
<v:textbox style='mso-next-textbox:#_x0000_s1027'>
<![if !mso]>
<table cellpadding=0 cellspacing=0 width="100%">
<tr>
<td><![endif]>
<div>
<p class=MsoNormal>
<span lang=EN-US style='font-family:"Times New Roman","serif"'><span
style='mso-spacerun:yes'> </span>A</span></p>
</div>
<![if !mso]></td>
</tr>
</table>
<![endif]></v:textbox>
</v:rect><v:rect id="_x0000_s1028" style='position:absolute;left:6233;top:1842;
width:853;height:769'>
<v:textbox style='mso-next-textbox:#_x0000_s1028'>
<![if !mso]>
<table cellpadding=0 cellspacing=0 width="100%">
<tr>
<td><![endif]>
<div>
<p class=MsoNormal>
<span lang=EN-US style='font-family:"Times New Roman","serif"'><span
style='mso-spacerun:yes'> </span>B</span></p>
</div>
<![if !mso]></td>
</tr>
</table>
<![endif]></v:textbox>
</v:rect><v:rect id="_x0000_s1029" style='position:absolute;left:5040;top:3780;
width:852;height:769'>
<v:textbox style='mso-next-textbox:#_x0000_s1029'>
<![if !mso]>
<table cellpadding=0 cellspacing=0 width="100%">
<tr>
<td><![endif]>
<div>
<p class=MsoNormal>
<span lang=EN-US style='font-family:"Times New Roman","serif"'><span
style='mso-spacerun:yes'> </span>C</span></p>
</div>
<![if !mso]></td>
</tr>
</table>
<![endif]></v:textbox>
</v:rect><v:line id="_x0000_s1030" style='position:absolute' from="4644,2689"
to="4644,3266"/>
<v:line id="_x0000_s1031" style='position:absolute' from="6633,2689" to="6633,3266"/>
<v:line id="_x0000_s1032" style='position:absolute' from="4644,3266" to="5354,3266"/>
<v:line id="_x0000_s1033" style='position:absolute' from="5496,3266" to="6633,3266"/>
<v:line id="_x0000_s1034" style='position:absolute' from="5354,3266" to="5354,3843">
<v:stroke endarrow="block"/>
</v:line><v:line id="_x0000_s1035" style='position:absolute' from="5496,3266"
to="5496,3843">
<v:stroke endarrow="block"/>
</v:line></v:group><![endif]--><!--[if !vml]--><span style="height: 187px; left: 0px; margin-left: 183px; margin-top: 34px; mso-ignore: vglayout; position: absolute; width: 193px; z-index: 251669504;"></span><!--[endif]--><b><span lang="EN-US" style="font-family: "Times New Roman","serif";">Multiple inheritance</span></b><span lang="EN-US" style="font-family: "Times New Roman","serif";">: Derivation of a
class from two or more classes is called multiple inheritances.<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<b><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjue5vuGE5ByM_c78bh-Anh5CUt2ekgPBut0lCkmtelgKJubEjPWuYbbjgwJUG3QXUTIWz-wEMrr-M3R5Y2KP5sTV9w9VsDRYf7n9TOsdazEzY3l4NsnmtSP0lSCvH2HDg4ks2SASs56JY/s1600/Untitled.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="220" data-original-width="317" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjue5vuGE5ByM_c78bh-Anh5CUt2ekgPBut0lCkmtelgKJubEjPWuYbbjgwJUG3QXUTIWz-wEMrr-M3R5Y2KP5sTV9w9VsDRYf7n9TOsdazEzY3l4NsnmtSP0lSCvH2HDg4ks2SASs56JY/s1600/Untitled.png" /></a></b></div>
<span style="font-family: "Times New Roman", serif;"> </span><br />
<div class="MsoNormal">
<span style="font-family: "Times New Roman", serif;">Since Java does not support multiple inheritances, which leads to
duplication in the methods for the derived classes which lead to complication
at run-time. To overcome this drawback java provides a concept of Interfaces.</span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b><span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">Defining Interfaces <o:p></o:p></span></b></div>
<h2>
<i><span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">Interface
is a collection of ‘n’ number of final members and abstract methods that can be
implemented by any number of subclasses.</span></i><span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt; font-weight: normal;">
Interface provides dynamic request dispatching of methods when implemented by
‘n’ number of sub-classes. No objects will be created for Interface because it
implements the particular class so the object will be created for that class.<o:p></o:p></span></h2>
<div class="MsoNormal">
<b><span lang="EN-US" style="font-family: "Times New Roman","serif";">Syntax
for declaration:<o:p></o:p></span></b></div>
<div class="MsoNormal">
<b><span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span></span></b><span lang="EN-US" style="font-family: "Times New Roman","serif";">Interface<span style="mso-tab-count: 1;"> </span><interfacename><o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span>members=value;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span>returntype
<methodname>(argslist);<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>}<o:p></o:p></span></div>
<div class="MsoNormal">
<b><span lang="EN-US" style="font-family: "Times New Roman","serif";">Syntax
for implementation:<o:p></o:p></span></b></div>
<div class="MsoFooter" style="tab-stops: 36.0pt; text-indent: 36.0pt;">
<span lang="EN-US">Class <name> implements <interfacename></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span>overridden methods from
interface ( )<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span>{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 3;"> </span>body;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span>}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>}<o:p></o:p></span></div>
<h2>
<span lang="EN-US" style="font-family: "Times New Roman","serif";">keypoints :<o:p></o:p></span></h2>
<ul style="margin-top: 0cm;" type="disc">
<li class="MsoNormal" style="mso-list: l0 level1 lfo1; tab-stops: list 36.0pt;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">All the methods
declared inside the interface does not require any body and they are by
default abstract types<o:p></o:p></span></li>
<li class="MsoNormal" style="mso-list: l0 level1 lfo1; tab-stops: list 36.0pt;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">All the members
declared inside the interface are by default final which must be
initialized and cannot be modified in the subclasses<o:p></o:p></span></li>
<li class="MsoNormal" style="mso-list: l0 level1 lfo1; tab-stops: list 36.0pt;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">Once a class
implements an interface it has to over-ride all the methods of the
interface atleast with null body.<o:p></o:p></span></li>
<li class="MsoNormal" style="mso-list: l0 level1 lfo1; tab-stops: list 36.0pt;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">Interfaces cannot
have instances<o:p></o:p></span></li>
<li class="MsoNormal" style="mso-list: l0 level1 lfo1; tab-stops: list 36.0pt;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">One class can
implement any number of interfaces.<o:p></o:p></span></li>
<li class="MsoNormal" style="mso-list: l0 level1 lfo1; tab-stops: list 36.0pt;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">Interface can be
pointed to the objects of those classes which implements the interface
leads to dynamic method dispatching.<o:p></o:p></span></li>
</ul>
<div class="MsoNormal" style="margin-left: 18.0pt;">
<br /></div>
<h2>
<span lang="EN-US" style="font-family: "Times New Roman","serif";">Extending
Interfaces <o:p></o:p></span></h2>
<div class="MsoBodyText">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">Like
classes, interfaces can also be extended i.e., an interface can be sub
interfaced from other interfaces. The new subinterface will inherit all the
members of the superinterface in the manner similar to subclasses. This is
achieved using the keyword extends as shown below:<o:p></o:p></span></div>
<div class="MsoBodyText">
<b><span lang="EN-US" style="font-family: "Times New Roman","serif";">Syntax:</span></b><span lang="EN-US" style="font-family: "Times New Roman","serif";"><o:p></o:p></span></div>
<div class="MsoBodyText">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">Interface
name2 extends name1<o:p></o:p></span></div>
<div class="MsoBodyText">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">{<o:p></o:p></span></div>
<div class="MsoBodyText">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>body<o:p></o:p></span></div>
<div class="MsoBodyText">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">}<o:p></o:p></span></div>
<div class="MsoBodyText">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">One
interface can inherit from another interface and if a class implements the
later interface the class must override all the methods of both the interfaces.<o:p></o:p></span></div>
<div class="MsoBodyText">
<br /></div>
<div class="MsoNormal">
<b><span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">Implementing Interfaces <o:p></o:p></span></b></div>
<div class="MsoBodyText">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">Interfaces
are used as “superclass” whose properties are inherited by classes.<o:p></o:p></span></div>
<div class="MsoNormal">
<b><span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">Syntax:<o:p></o:p></span></b></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">Class classname implements interfacename<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>body<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">}<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b><span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">Accessing Interface Variables<o:p></o:p></span></b></div>
<div class="MsoBodyText">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">Interfaces
can be used to declare a set of constants that can be used in different
classes. The constant values will be available to any class that implements the
interface. The values can be used in any method, where we can use a final
value.<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b><span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">Example Program:</span></b><b><span lang="EN-US" style="color: black; font-family: "Times New Roman","serif"; font-size: 14.0pt;"><o:p></o:p></span></b></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">interface demo<span style="mso-tab-count: 2;"> </span>//definition
of interface<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>int sno=101;<span style="mso-tab-count: 2;"> </span>//by default final which cannot
be modified<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>String
sname="GVP";<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">}<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">interface demo2 extends demo<span style="mso-tab-count: 1;"> </span>//extending
interfaces<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>void display();<span style="mso-tab-count: 2;"> </span>//by default abstract<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span><o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">class example implements demo2<span style="mso-tab-count: 1;"> </span>//implementation
of interface<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>public void
display()<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span>System.out.println("Sno="+sno+"\n"+"Sname="+sname);<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span>//accessing
interface variables<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">}<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">class inter<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>public static
void main(String []args)<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span>example
e=new example();<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span>e.display();<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">}<o:p></o:p></span></div>
<div class="MsoNormal">
<b><span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">Output:</span></b><b><span lang="EN-US" style="color: black; font-family: "Times New Roman","serif"; font-size: 14.0pt;"><o:p></o:p></span></b></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">D:\ \programs>javac inter.java<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">D:\ \programs>java inter<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">Sno=101<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">Sname=GVP<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b><span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><br /></span></b></div>
<div class="MsoNormal">
<b><span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">//Bank Transactions using Interfaces<o:p></o:p></span></b></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">interface bank<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>int accno=101;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>String
accname="GVP";<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>int amt=10000;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">interface acctype extends bank<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>void
calc_interest(int rof);<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>void
put_details();<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">abstract class members implements acctype<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>float
interest=0.0f;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>float bal=0.0f;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>public void
put_details()<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span>System.out.println("Account
Number="+accno);<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span>System.out.println("Account
Name="+accname);<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span>System.out.println("Amount
="+amt);<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span>System.out.println("Interest="+interest);<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span>System.out.println("Balance="+bal);<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">class current_accnt<span style="mso-spacerun: yes;"> </span>extends
members implements acctype<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">{<span style="mso-tab-count: 1;"> </span><o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>public void
calc_interest(int rof)<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span>interest=(rof*amt)/100;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span>bal=amt-interest;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">class savings_accnt extends members implements acctype <o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>public void
calc_interest(int rof)<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span>interest=(rof*amt)/100;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span>bal=amt-interest;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">class interest<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>public static
void main(String []args)<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span>current_accnt
ca=new current_accnt(); <o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span>savings_accnt
sa=new savings_accnt();<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span>if(args[0].equals("current"))<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span>{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 3;"> </span>ca.calc_interest(10);<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 3;"> </span>ca.put_details();<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span>}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span>else
if(args[0].equals("savings"))<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span>{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 3;"> </span>sa.calc_interest(5);<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 3;"> </span>sa.put_details();<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span>}<span style="mso-tab-count: 1;"> </span><o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span>else<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 3;"> </span>System.exit(0);<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">}<o:p></o:p></span></div>
<div class="MsoNormal">
<b><span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">Output:<o:p></o:p></span></b></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">D:\ \programs>javac interest.java<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">D:\ \programs>java interest current<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">Account Number=101<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">Account Name=GVP<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">Amount =10000<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">Interest=1000.0<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">Balance=9000</span><b><span lang="EN-US" style="color: black; font-family: "Times New Roman","serif"; font-size: 14.0pt;"><o:p></o:p></span></b></div>
<br /></div>
Bagadhi Sateeshhttp://www.blogger.com/profile/16786636572407672825noreply@blogger.com0tag:blogger.com,1999:blog-8352540103162095489.post-84261003469006504012018-08-28T14:24:00.001+05:302018-08-28T14:24:11.001+05:30Vectors & Wrapper Classes<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<div class="MsoNormal">
<b><span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;">Vectors</span><o:p></o:p></span></b></div>
<div class="MsoBodyText">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">Vectors
class can be used to create a generic dynamic array known as vector that can
hold objects of any type and any number. Vector class contained in the java.util.package.
The objects do not have to be homogenous. Vectors are created like arrays as
follows:<o:p></o:p></span></div>
<div class="MsoBodyText">
<br /></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>Vector vect=new
vector();<span style="mso-tab-count: 1;"> </span>//declaring without size<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>Vector vect=new
vect(3);<span style="mso-tab-count: 2;"> </span>//declaring
with size.<o:p></o:p></span></div>
<h2>
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><o:p> </o:p></span>Vectors
possess a number of advantages over arrays:-</h2>
<ol start="1" style="margin-top: 0cm;" type="1">
<li class="MsoNormal" style="color: black; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">It is convenient
to use vectors to store objects<o:p></o:p></span></li>
<li class="MsoNormal" style="color: black; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">A vector can be
used to store a list of objects that may vary in size.<o:p></o:p></span></li>
<li class="MsoNormal" style="color: black; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt;"><span lang="EN-US" style="font-family: "Times New Roman","serif";">We can add and
delete objects from the list as and when required.<o:p></o:p></span></li>
</ol>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">Vectors
can hold only Objects and not primitive types (eg, </span><code><span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: minor-fareast;">5</span></code><span lang="EN-US" style="font-family: "Times New Roman","serif";">).<o:p></o:p></span></div>
<h2 style="mso-line-height-alt: 12.0pt;">
Common Vector Methods</h2>
<div style="line-height: 12.0pt; text-align: justify;">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">There are many useful methods in
the Vector class and its parent classes. Here are some of the most useful. </span><code><b><span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 10.0pt;">v</span></b></code><span lang="EN-US" style="font-family: "Times New Roman","serif";"> is a Vector, </span><code><b><span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 10.0pt;">i</span></b></code><span lang="EN-US" style="font-family: "Times New Roman","serif";"> is an int index, </span><code><b><span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 10.0pt;">o</span></b></code><span lang="EN-US" style="font-family: "Times New Roman","serif";"> is an Object. <o:p></o:p></span></div>
<table border="1" cellpadding="0" cellspacing="0" class="MsoNormalTable" style="mso-cellspacing: 0cm;">
<tbody>
<tr style="mso-yfti-firstrow: yes; mso-yfti-irow: 0;">
<td style="border-left: none; border: inset 1.0pt; mso-border-bottom-alt: inset windowtext .75pt; mso-border-right-alt: inset windowtext .75pt; mso-border-top-alt: inset windowtext .75pt; padding: .75pt .75pt .75pt .75pt;">
<div align="center" class="MsoNormal" style="line-height: 12.0pt; text-align: center;">
<b><i><span lang="EN-US" style="font-family: "Times New Roman","serif";">Method</span></i></b><b><span lang="EN-US" style="font-family: "Times New Roman","serif";"><o:p></o:p></span></b></div>
</td>
<td style="border-right: none; border: inset 1.0pt; mso-border-bottom-alt: inset windowtext .75pt; mso-border-left-alt: inset windowtext .75pt; mso-border-top-alt: inset windowtext .75pt; padding: .75pt .75pt .75pt .75pt;">
<div align="center" class="MsoNormal" style="line-height: 12.0pt; text-align: center;">
<b><i><span lang="EN-US" style="font-family: "Times New Roman","serif";">Description</span></i></b><b><span lang="EN-US" style="font-family: "Times New Roman","serif";"><o:p></o:p></span></b></div>
</td>
</tr>
<tr style="mso-yfti-irow: 1;">
<td style="border-left: none; border: inset 1.0pt; mso-border-bottom-alt: inset windowtext .75pt; mso-border-right-alt: inset windowtext .75pt; mso-border-top-alt: inset windowtext .75pt; padding: .75pt .75pt .75pt .75pt;">
<div class="MsoNormal" style="line-height: 12.0pt;">
<code><span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: minor-fareast;">v.add(o)</span></code><span lang="EN-US" style="font-family: "Times New Roman","serif";"><o:p></o:p></span></div>
</td>
<td style="border-right: none; border: inset 1.0pt; mso-border-bottom-alt: inset windowtext .75pt; mso-border-left-alt: inset windowtext .75pt; mso-border-top-alt: inset windowtext .75pt; padding: .75pt .75pt .75pt .75pt;">
<div class="MsoNormal" style="line-height: 12.0pt;">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">adds Object o to Vector v<o:p></o:p></span></div>
</td>
</tr>
<tr style="mso-yfti-irow: 2;">
<td style="border-left: none; border: inset 1.0pt; mso-border-bottom-alt: inset windowtext .75pt; mso-border-right-alt: inset windowtext .75pt; mso-border-top-alt: inset windowtext .75pt; padding: .75pt .75pt .75pt .75pt;">
<div class="MsoNormal" style="line-height: 12.0pt;">
<code><span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: minor-fareast;">v.add(i, o)</span></code><span lang="EN-US" style="font-family: "Times New Roman","serif";"><o:p></o:p></span></div>
</td>
<td style="border-right: none; border: inset 1.0pt; mso-border-bottom-alt: inset windowtext .75pt; mso-border-left-alt: inset windowtext .75pt; mso-border-top-alt: inset windowtext .75pt; padding: .75pt .75pt .75pt .75pt;">
<div class="MsoNormal" style="line-height: 12.0pt;">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">Inserts Object o at index i,
shifting elements up as necessary.<o:p></o:p></span></div>
</td>
</tr>
<tr style="mso-yfti-irow: 3;">
<td style="border-left: none; border: inset 1.0pt; mso-border-bottom-alt: inset windowtext .75pt; mso-border-right-alt: inset windowtext .75pt; mso-border-top-alt: inset windowtext .75pt; padding: .75pt .75pt .75pt .75pt;">
<div class="MsoNormal" style="line-height: 12.0pt;">
<code><span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: minor-fareast;">v.clear()</span></code><span lang="EN-US" style="font-family: "Times New Roman","serif";"><o:p></o:p></span></div>
</td>
<td style="border-right: none; border: inset 1.0pt; mso-border-bottom-alt: inset windowtext .75pt; mso-border-left-alt: inset windowtext .75pt; mso-border-top-alt: inset windowtext .75pt; padding: .75pt .75pt .75pt .75pt;">
<div class="MsoNormal" style="line-height: 12.0pt;">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">removes all elements from
Vector v<o:p></o:p></span></div>
</td>
</tr>
<tr style="mso-yfti-irow: 4;">
<td style="border-left: none; border: inset 1.0pt; mso-border-bottom-alt: inset windowtext .75pt; mso-border-right-alt: inset windowtext .75pt; mso-border-top-alt: inset windowtext .75pt; padding: .75pt .75pt .75pt .75pt;">
<div class="MsoNormal" style="line-height: 12.0pt;">
<code><span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: minor-fareast;">v.contains(o)</span></code><span lang="EN-US" style="font-family: "Times New Roman","serif";"><o:p></o:p></span></div>
</td>
<td style="border-right: none; border: inset 1.0pt; mso-border-bottom-alt: inset windowtext .75pt; mso-border-left-alt: inset windowtext .75pt; mso-border-top-alt: inset windowtext .75pt; padding: .75pt .75pt .75pt .75pt;">
<div class="MsoNormal" style="line-height: 12.0pt;">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">Returns true if Vector v
contains Object o<o:p></o:p></span></div>
</td>
</tr>
<tr style="mso-yfti-irow: 5;">
<td style="border-left: none; border: inset 1.0pt; mso-border-bottom-alt: inset windowtext .75pt; mso-border-right-alt: inset windowtext .75pt; mso-border-top-alt: inset windowtext .75pt; padding: .75pt .75pt .75pt .75pt;">
<div class="MsoNormal" style="line-height: 12.0pt;">
<code><span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: minor-fareast;">v.firstElement(i)</span></code><span lang="EN-US" style="font-family: "Times New Roman","serif";"><o:p></o:p></span></div>
</td>
<td style="border-right: none; border: inset 1.0pt; mso-border-bottom-alt: inset windowtext .75pt; mso-border-left-alt: inset windowtext .75pt; mso-border-top-alt: inset windowtext .75pt; padding: .75pt .75pt .75pt .75pt;">
<div class="MsoNormal" style="line-height: 12.0pt;">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">Returns the first element.<o:p></o:p></span></div>
</td>
</tr>
<tr style="mso-yfti-irow: 6;">
<td style="border-left: none; border: inset 1.0pt; mso-border-bottom-alt: inset windowtext .75pt; mso-border-right-alt: inset windowtext .75pt; mso-border-top-alt: inset windowtext .75pt; padding: .75pt .75pt .75pt .75pt;">
<div class="MsoNormal" style="line-height: 12.0pt;">
<code><span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: minor-fareast;">v.get(i)</span></code><span lang="EN-US" style="font-family: "Times New Roman","serif";"><o:p></o:p></span></div>
</td>
<td style="border-right: none; border: inset 1.0pt; mso-border-bottom-alt: inset windowtext .75pt; mso-border-left-alt: inset windowtext .75pt; mso-border-top-alt: inset windowtext .75pt; padding: .75pt .75pt .75pt .75pt;">
<div class="MsoNormal" style="line-height: 12.0pt;">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">Returns the object at int index
i.<o:p></o:p></span></div>
</td>
</tr>
<tr style="mso-yfti-irow: 7;">
<td style="border-left: none; border: inset 1.0pt; mso-border-bottom-alt: inset windowtext .75pt; mso-border-right-alt: inset windowtext .75pt; mso-border-top-alt: inset windowtext .75pt; padding: .75pt .75pt .75pt .75pt;">
<div class="MsoNormal" style="line-height: 12.0pt;">
<code><span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: minor-fareast;">v.lastElement(i)</span></code><span lang="EN-US" style="font-family: "Times New Roman","serif";"><o:p></o:p></span></div>
</td>
<td style="border-right: none; border: inset 1.0pt; mso-border-bottom-alt: inset windowtext .75pt; mso-border-left-alt: inset windowtext .75pt; mso-border-top-alt: inset windowtext .75pt; padding: .75pt .75pt .75pt .75pt;">
<div class="MsoNormal" style="line-height: 12.0pt;">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">Returns the last element.<o:p></o:p></span></div>
</td>
</tr>
<tr style="mso-yfti-irow: 8;">
<td style="border-left: none; border: inset 1.0pt; mso-border-bottom-alt: inset windowtext .75pt; mso-border-right-alt: inset windowtext .75pt; mso-border-top-alt: inset windowtext .75pt; padding: .75pt .75pt .75pt .75pt;">
<div class="MsoNormal" style="line-height: 12.0pt;">
<code><span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: minor-fareast;">v.listIterator()</span></code><span lang="EN-US" style="font-family: "Times New Roman","serif";"><o:p></o:p></span></div>
</td>
<td style="border-right: none; border: inset 1.0pt; mso-border-bottom-alt: inset windowtext .75pt; mso-border-left-alt: inset windowtext .75pt; mso-border-top-alt: inset windowtext .75pt; padding: .75pt .75pt .75pt .75pt;">
<div class="MsoNormal" style="line-height: 12.0pt;">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">Returns a ListIterator that can
be used to go over the Vector. This is a useful alternative to the for loop.<o:p></o:p></span></div>
</td>
</tr>
<tr style="mso-yfti-irow: 9;">
<td style="border-left: none; border: inset 1.0pt; mso-border-bottom-alt: inset windowtext .75pt; mso-border-right-alt: inset windowtext .75pt; mso-border-top-alt: inset windowtext .75pt; padding: .75pt .75pt .75pt .75pt;">
<div class="MsoNormal" style="line-height: 12.0pt;">
<code><span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: minor-fareast;">v.remove(i)</span></code><span lang="EN-US" style="font-family: "Times New Roman","serif";"><o:p></o:p></span></div>
</td>
<td style="border-right: none; border: inset 1.0pt; mso-border-bottom-alt: inset windowtext .75pt; mso-border-left-alt: inset windowtext .75pt; mso-border-top-alt: inset windowtext .75pt; padding: .75pt .75pt .75pt .75pt;">
<div class="MsoNormal" style="line-height: 12.0pt;">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">Removes the element at position
i, and shifts all following elements down.<o:p></o:p></span></div>
</td>
</tr>
<tr style="mso-yfti-irow: 10;">
<td style="border-left: none; border: inset 1.0pt; mso-border-bottom-alt: inset windowtext .75pt; mso-border-right-alt: inset windowtext .75pt; mso-border-top-alt: inset windowtext .75pt; padding: .75pt .75pt .75pt .75pt;">
<div class="MsoNormal" style="line-height: 12.0pt;">
<code><span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: minor-fareast;">v.set(i,o)</span></code><span lang="EN-US" style="font-family: "Times New Roman","serif";"><o:p></o:p></span></div>
</td>
<td style="border-right: none; border: inset 1.0pt; mso-border-bottom-alt: inset windowtext .75pt; mso-border-left-alt: inset windowtext .75pt; mso-border-top-alt: inset windowtext .75pt; padding: .75pt .75pt .75pt .75pt;">
<div class="MsoNormal" style="line-height: 12.0pt;">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">Sets the element at index i to
o.<o:p></o:p></span></div>
</td>
</tr>
<tr style="mso-yfti-irow: 11;">
<td style="border-left: none; border: inset 1.0pt; mso-border-bottom-alt: inset windowtext .75pt; mso-border-right-alt: inset windowtext .75pt; mso-border-top-alt: inset windowtext .75pt; padding: .75pt .75pt .75pt .75pt;">
<div class="MsoNormal" style="line-height: 12.0pt;">
<code><span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: minor-fareast;">v.size()</span></code><span lang="EN-US" style="font-family: "Times New Roman","serif";"><o:p></o:p></span></div>
</td>
<td style="border-right: none; border: inset 1.0pt; mso-border-bottom-alt: inset windowtext .75pt; mso-border-left-alt: inset windowtext .75pt; mso-border-top-alt: inset windowtext .75pt; padding: .75pt .75pt .75pt .75pt;">
<div class="MsoNormal" style="line-height: 12.0pt;">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">Returns the number of elements
in Vector v.<o:p></o:p></span></div>
</td>
</tr>
<tr style="mso-yfti-irow: 12;">
<td style="border-left: none; border: inset 1.0pt; mso-border-bottom-alt: inset windowtext .75pt; mso-border-right-alt: inset windowtext .75pt; mso-border-top-alt: inset windowtext .75pt; padding: .75pt .75pt .75pt .75pt;">
<div class="MsoNormal" style="line-height: 12.0pt;">
<code><span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: minor-fareast;">v.toArray(Object[])</span></code><span lang="EN-US" style="font-family: "Times New Roman","serif";"><o:p></o:p></span></div>
</td>
<td style="border-right: none; border: inset 1.0pt; mso-border-bottom-alt: inset windowtext .75pt; mso-border-left-alt: inset windowtext .75pt; mso-border-top-alt: inset windowtext .75pt; padding: .75pt .75pt .75pt .75pt;">
<div class="MsoNormal" style="line-height: 12.0pt;">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">The array parameter can be any
Object subclass (eg, String). This returns the vector values in that array
(or a larger array if necessary). This is useful when you need the generality
of a Vector for input, but need the speed of arrays when processing the data.<o:p></o:p></span></div>
</td>
</tr>
<tr style="mso-yfti-irow: 13;">
<td style="border-left: none; border: inset 1.0pt; mso-border-bottom-alt: inset windowtext .75pt; mso-border-right-alt: inset windowtext .75pt; mso-border-top-alt: inset windowtext .75pt; padding: .75pt .75pt .75pt .75pt;">
<div class="MsoNormal" style="line-height: 12.0pt;">
<code><span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: minor-fareast;">v.addElement(item)<o:p></o:p></span></code></div>
</td>
<td style="border-right: none; border: inset 1.0pt; mso-border-bottom-alt: inset windowtext .75pt; mso-border-left-alt: inset windowtext .75pt; mso-border-top-alt: inset windowtext .75pt; padding: .75pt .75pt .75pt .75pt;">
<div class="MsoNormal" style="line-height: 12.0pt;">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">Adds the item specified to the
list at the end<o:p></o:p></span></div>
</td>
</tr>
<tr style="mso-yfti-irow: 14;">
<td style="border-left: none; border: inset 1.0pt; mso-border-bottom-alt: inset windowtext .75pt; mso-border-right-alt: inset windowtext .75pt; mso-border-top-alt: inset windowtext .75pt; padding: .75pt .75pt .75pt .75pt;">
<div class="MsoNormal" style="line-height: 12.0pt;">
<code><span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: minor-fareast;">v.elementAt(10)<o:p></o:p></span></code></div>
</td>
<td style="border-right: none; border: inset 1.0pt; mso-border-bottom-alt: inset windowtext .75pt; mso-border-left-alt: inset windowtext .75pt; mso-border-top-alt: inset windowtext .75pt; padding: .75pt .75pt .75pt .75pt;">
<div class="MsoNormal" style="line-height: 12.0pt;">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">Gives the name of the 10<sup>th</sup>
object<o:p></o:p></span></div>
</td>
</tr>
<tr style="mso-yfti-irow: 15;">
<td style="border-left: none; border: inset 1.0pt; mso-border-bottom-alt: inset windowtext .75pt; mso-border-right-alt: inset windowtext .75pt; mso-border-top-alt: inset windowtext .75pt; padding: .75pt .75pt .75pt .75pt;">
<div class="MsoNormal" style="line-height: 12.0pt;">
<code><span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: minor-fareast;">v.size()<o:p></o:p></span></code></div>
</td>
<td style="border-right: none; border: inset 1.0pt; mso-border-bottom-alt: inset windowtext .75pt; mso-border-left-alt: inset windowtext .75pt; mso-border-top-alt: inset windowtext .75pt; padding: .75pt .75pt .75pt .75pt;">
<div class="MsoNormal" style="line-height: 12.0pt;">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">Gives the number of objects
present<o:p></o:p></span></div>
</td>
</tr>
<tr style="mso-yfti-irow: 16;">
<td style="border-left: none; border: inset 1.0pt; mso-border-bottom-alt: inset windowtext .75pt; mso-border-right-alt: inset windowtext .75pt; mso-border-top-alt: inset windowtext .75pt; padding: .75pt .75pt .75pt .75pt;">
<div class="MsoNormal" style="line-height: 12.0pt;">
<code><span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: minor-fareast;">v.removeElement(item)<o:p></o:p></span></code></div>
</td>
<td style="border-right: none; border: inset 1.0pt; mso-border-bottom-alt: inset windowtext .75pt; mso-border-left-alt: inset windowtext .75pt; mso-border-top-alt: inset windowtext .75pt; padding: .75pt .75pt .75pt .75pt;">
<div class="MsoNormal" style="line-height: 12.0pt;">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">Removes the specified item from
the list<o:p></o:p></span></div>
</td>
</tr>
<tr style="mso-yfti-irow: 17;">
<td style="border-left: none; border: inset 1.0pt; mso-border-bottom-alt: inset windowtext .75pt; mso-border-right-alt: inset windowtext .75pt; mso-border-top-alt: inset windowtext .75pt; padding: .75pt .75pt .75pt .75pt;">
<div class="MsoNormal" style="line-height: 12.0pt;">
<code><span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: minor-fareast;">v.removeElementAt(n)<o:p></o:p></span></code></div>
</td>
<td style="border-right: none; border: inset 1.0pt; mso-border-bottom-alt: inset windowtext .75pt; mso-border-left-alt: inset windowtext .75pt; mso-border-top-alt: inset windowtext .75pt; padding: .75pt .75pt .75pt .75pt;">
<div class="MsoNormal" style="line-height: 12.0pt;">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">Removes the item stored in the
nth position of the list<o:p></o:p></span></div>
</td>
</tr>
<tr style="mso-yfti-irow: 18;">
<td style="border-left: none; border: inset 1.0pt; mso-border-bottom-alt: inset windowtext .75pt; mso-border-right-alt: inset windowtext .75pt; mso-border-top-alt: inset windowtext .75pt; padding: .75pt .75pt .75pt .75pt;">
<div class="MsoNormal" style="line-height: 12.0pt;">
<code><span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: minor-fareast;">v.removeAllElements(
)<o:p></o:p></span></code></div>
</td>
<td style="border-right: none; border: inset 1.0pt; mso-border-bottom-alt: inset windowtext .75pt; mso-border-left-alt: inset windowtext .75pt; mso-border-top-alt: inset windowtext .75pt; padding: .75pt .75pt .75pt .75pt;">
<div class="MsoNormal" style="line-height: 12.0pt;">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">Removes all the elements in the
list<o:p></o:p></span></div>
</td>
</tr>
<tr style="mso-yfti-irow: 19;">
<td style="border-left: none; border: inset 1.0pt; mso-border-bottom-alt: inset windowtext .75pt; mso-border-right-alt: inset windowtext .75pt; mso-border-top-alt: inset windowtext .75pt; padding: .75pt .75pt .75pt .75pt;">
<div class="MsoNormal" style="line-height: 12.0pt;">
<code><span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: minor-fareast;">v.copyInto(array)<o:p></o:p></span></code></div>
</td>
<td style="border-right: none; border: inset 1.0pt; mso-border-bottom-alt: inset windowtext .75pt; mso-border-left-alt: inset windowtext .75pt; mso-border-top-alt: inset windowtext .75pt; padding: .75pt .75pt .75pt .75pt;">
<div class="MsoNormal" style="line-height: 12.0pt;">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">Copies all items from list to
array<o:p></o:p></span></div>
</td>
</tr>
<tr style="mso-yfti-irow: 20; mso-yfti-lastrow: yes;">
<td style="border-left: none; border: inset 1.0pt; mso-border-bottom-alt: inset windowtext .75pt; mso-border-right-alt: inset windowtext .75pt; mso-border-top-alt: inset windowtext .75pt; padding: .75pt .75pt .75pt .75pt;">
<div class="MsoNormal" style="line-height: 12.0pt;">
<code><span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: minor-fareast;">v.insertElementAt(item,n)<o:p></o:p></span></code></div>
</td>
<td style="border-right: none; border: inset 1.0pt; mso-border-bottom-alt: inset windowtext .75pt; mso-border-left-alt: inset windowtext .75pt; mso-border-top-alt: inset windowtext .75pt; padding: .75pt .75pt .75pt .75pt;">
<div class="MsoNormal" style="line-height: 12.0pt;">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">Inserts the item at nth
position<o:p></o:p></span></div>
</td>
</tr>
</tbody></table>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b><span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">Example Program:<o:p></o:p></span></b></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">import java.io.*;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">import java.util.*; <o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">class VectorDemo1<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">{ <o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">public static void main(String args[]) throws IOException<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">{ <o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">Vector v = new Vector( ); <o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">BufferedReader br=new BufferedReader(new
InputStreamReader(System.in));<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">while(true)<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">System.out.println("1.Creation");<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">System.out.println("2.Insertion");<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">System.out.println("3.Deletion");<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">System.out.println("4.Display");<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">System.out.println("5.exit");<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">System.out.println("Enter Ur Choice:");<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">int n=Integer.parseInt(br.readLine());<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">switch(n)<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>case 1: <span style="mso-tab-count: 1;"> </span><o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span>System.out.println("Enter
the Element:");<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span>v.addElement(new
Integer(br.readLine())); <o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span>break;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>case 2:
System.out.println("Enter the position to be inserted:");<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span>int
x=Integer.parseInt(br.readLine());<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span>v.insertElementAt(new
Integer(br.readLine()),x); <o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span>break;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>case
3:System.out.println("Enter the position to be deleted:");<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span>int
y=Integer.parseInt(br.readLine());<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span>v.removeElementAt(y);
<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span>break;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>case 4:
System.out.println("Elements are:");<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span>for(int
i=0;i<v.size();i++)<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span>System.out.println(v.get(i)+"
");<span style="mso-tab-count: 2;"> </span><o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span>break;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>case
5:System.exit(0);<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">} <o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">}<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b><span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;">Wrapper Classes </span><o:p></o:p></span></b></div>
<div class="MsoBodyText">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">Vectors
cannot handle primitive data types like int,float,long,char and double.
Primitive data types may be converted into object types by using the wrapper
classes contained in Java.lang package.<o:p></o:p></span></div>
<br />
<br />
<b><span lang="EN-US" style="font-family: "Times New Roman","serif";">Following
table lists the primitive types and the corresponding wrapper classes:<o:p></o:p></span></b><br />
<table border="0" cellpadding="0" cellspacing="0" class="MsoNormalTable" style="border-collapse: collapse; margin-left: 114.0pt; mso-padding-alt: 2.25pt 2.25pt 2.25pt 2.25pt; width: 33%px;">
<tbody>
<tr style="mso-yfti-firstrow: yes; mso-yfti-irow: 0;">
<td style="padding: 2.25pt 2.25pt 2.25pt 2.25pt; width: 33.58%;" width="33%">
<div align="center" class="MsoNormal" style="text-align: center;">
<b><span lang="EN-US" style="font-family: "Times New Roman","serif";">Primitive</span></b><b><span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-fareast-font-family: "Arial Unicode MS";"><o:p></o:p></span></b></div>
</td>
<td style="padding: 2.25pt 2.25pt 2.25pt 2.25pt; width: 66.42%;" width="66%">
<div align="center" class="MsoNormal" style="text-align: center;">
<b><span lang="EN-US" style="font-family: "Times New Roman","serif";">Wrapper</span></b><b><span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-fareast-font-family: "Arial Unicode MS";"><o:p></o:p></span></b></div>
</td>
</tr>
<tr style="mso-yfti-irow: 1;">
<td style="padding: 2.25pt 2.25pt 2.25pt 2.25pt; width: 33.58%;" width="33%">
<div align="center" class="MsoNormal" style="text-align: center;">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">boolean</span><span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-fareast-font-family: "Arial Unicode MS";"><o:p></o:p></span></div>
</td>
<td style="padding: 2.25pt 2.25pt 2.25pt 2.25pt; width: 66.42%;" width="66%">
<div class="MsoFooter" style="tab-stops: 36.0pt;">
<span lang="EN-US"> java.lang.Boolean</span><span lang="EN-US" style="mso-fareast-font-family: "Arial Unicode MS";"><o:p></o:p></span></div>
</td>
</tr>
<tr style="mso-yfti-irow: 2;">
<td style="padding: 2.25pt 2.25pt 2.25pt 2.25pt; width: 33.58%;" width="33%">
<div align="center" class="MsoNormal" style="text-align: center;">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">byte</span><span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-fareast-font-family: "Arial Unicode MS";"><o:p></o:p></span></div>
</td>
<td style="padding: 2.25pt 2.25pt 2.25pt 2.25pt; width: 66.42%;" width="66%">
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"> java.lang.Byte</span><span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-fareast-font-family: "Arial Unicode MS";"><o:p></o:p></span></div>
</td>
</tr>
<tr style="mso-yfti-irow: 3;">
<td style="padding: 2.25pt 2.25pt 2.25pt 2.25pt; width: 33.58%;" width="33%">
<div align="center" class="MsoNormal" style="text-align: center;">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">char</span><span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-fareast-font-family: "Arial Unicode MS";"><o:p></o:p></span></div>
</td>
<td style="padding: 2.25pt 2.25pt 2.25pt 2.25pt; width: 66.42%;" width="66%">
<div class="MsoFooter" style="tab-stops: 36.0pt;">
<span lang="EN-US"> java.lang.Character</span><span lang="EN-US" style="mso-fareast-font-family: "Arial Unicode MS";"><o:p></o:p></span></div>
</td>
</tr>
<tr style="mso-yfti-irow: 4;">
<td style="padding: 2.25pt 2.25pt 2.25pt 2.25pt; width: 33.58%;" width="33%">
<div align="center" class="MsoNormal" style="text-align: center;">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">double</span><span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-fareast-font-family: "Arial Unicode MS";"><o:p></o:p></span></div>
</td>
<td style="padding: 2.25pt 2.25pt 2.25pt 2.25pt; width: 66.42%;" width="66%">
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"> java.lang.Double</span><span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-fareast-font-family: "Arial Unicode MS";"><o:p></o:p></span></div>
</td>
</tr>
<tr style="mso-yfti-irow: 5;">
<td style="padding: 2.25pt 2.25pt 2.25pt 2.25pt; width: 33.58%;" width="33%">
<div align="center" class="MsoNormal" style="text-align: center;">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">float</span><span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-fareast-font-family: "Arial Unicode MS";"><o:p></o:p></span></div>
</td>
<td style="padding: 2.25pt 2.25pt 2.25pt 2.25pt; width: 66.42%;" width="66%">
<div class="MsoFooter" style="tab-stops: 36.0pt;">
<span lang="EN-US"> java.lang.Float</span><span lang="EN-US" style="mso-fareast-font-family: "Arial Unicode MS";"><o:p></o:p></span></div>
</td>
</tr>
<tr style="mso-yfti-irow: 6;">
<td style="padding: 2.25pt 2.25pt 2.25pt 2.25pt; width: 33.58%;" width="33%">
<div align="center" class="MsoNormal" style="text-align: center;">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">int</span><span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-fareast-font-family: "Arial Unicode MS";"><o:p></o:p></span></div>
</td>
<td style="padding: 2.25pt 2.25pt 2.25pt 2.25pt; width: 66.42%;" width="66%">
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"> java.lang.Integer</span><span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-fareast-font-family: "Arial Unicode MS";"><o:p></o:p></span></div>
</td>
</tr>
<tr style="mso-yfti-irow: 7;">
<td style="padding: 2.25pt 2.25pt 2.25pt 2.25pt; width: 33.58%;" width="33%">
<div align="center" class="MsoNormal" style="text-align: center;">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">long</span><span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-fareast-font-family: "Arial Unicode MS";"><o:p></o:p></span></div>
</td>
<td style="padding: 2.25pt 2.25pt 2.25pt 2.25pt; width: 66.42%;" width="66%">
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"> java.lang.Long</span><span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-fareast-font-family: "Arial Unicode MS";"><o:p></o:p></span></div>
</td>
</tr>
<tr style="mso-yfti-irow: 8; mso-yfti-lastrow: yes;">
<td style="padding: 2.25pt 2.25pt 2.25pt 2.25pt; width: 33.58%;" width="33%">
<div align="center" class="MsoNormal" style="text-align: center;">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">short</span><span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-fareast-font-family: "Arial Unicode MS";"><o:p></o:p></span></div>
</td>
<td style="padding: 2.25pt 2.25pt 2.25pt 2.25pt; width: 66.42%;" width="66%">
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"> java.lang.Short</span><span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-fareast-font-family: "Arial Unicode MS";"><o:p></o:p></span></div>
</td>
</tr>
</tbody></table>
<div class="MsoNormal">
<br /></div>
<br /></div>
Bagadhi Sateeshhttp://www.blogger.com/profile/16786636572407672825noreply@blogger.com0tag:blogger.com,1999:blog-8352540103162095489.post-81569909330597179262018-08-28T14:22:00.003+05:302018-08-28T14:22:35.435+05:30Strings<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<h1>
<span lang="EN-US" style="font-family: "Times New Roman", serif;"><span style="font-size: large;">Strings
</span><span style="font-size: 12pt;"><o:p></o:p></span></span></h1>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">A
String represents the sequence of characters the easiest way to represent to a
sequence of characters in java is by using a character array.<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b><span lang="EN-US" style="font-family: "Times New Roman","serif";">Example:<o:p></o:p></span></b></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">Char
charArray[ ]=new char[4];<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">CharArray[0]=’J’;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">CharArray[1]=’a’;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">CharArray[2]=’v’;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">CharArray[3]=’a’;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>In java strings are class objects
and implemented using two classes, namely, String and StringBuffer. A java
string is an instantiated object of the class String class. A java string is
not a character array and is not NULL terminated. Strings may be declared as
follows:<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span>String Stringname;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span>Stringname = new
string(“String”);<o:p></o:p></span></div>
<h3>
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><o:p> </o:p></span>Example:</h3>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">String
firstname;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">firstname
= new String(“Anil”);<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">these
two statements may be combined as follows:<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">String
firstname = new String(“Anil”);<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">Like
arrays, it is possible to get the length of string using the <b>length</b>
method of the <b>String</b> class.<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">int
m=firstname.length();<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">Java
strings can be concatenated using the + operator.<o:p></o:p></span></div>
<h3>
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><o:p> </o:p></span>Example;</h3>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">String
fullName =<span style="mso-spacerun: yes;"> </span>name1+name2;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">String
city = ”New”+”Delhi”;<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b><span lang="EN-US" style="font-family: "Times New Roman","serif";">//Program
to find substring in java<o:p></o:p></span></b></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">import
java.io.*;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">import
java.lang.String;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">class
strings<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>public static void main(String
[]args) throws IOException<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">BufferedReader
br=new BufferedReader(new InputStreamReader(System.in));<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span>String fname,sname;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span>int flag=0;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span>System.out.println("Enter
the First Name:");<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span>fname=String.valueOf(br.readLine());<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span>System.out.println("Enter
the Second Name:");<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span>sname=String.valueOf(br.readLine());<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span>for(int
i=0;i<fname.length();i++)<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span>{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 3;"> </span>for(int
j=0;j<sname.length();j++)<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 3;"> </span>{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 4;"> </span>if(fname.charAt(i)!=(sname.charAt(j)))<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 5;"> </span>continue;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 4;"> </span>else<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 5;"> </span>flag++;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 3;"> </span>}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span>}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span>if(flag!=0)<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 3;"> </span>System.out.println(sname
+ " is a substring of "+fname);<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span>else<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 3;"> </span>System.out.println(sname
+ " is not a substring of "+fname);<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">}<o:p></o:p></span></div>
<div class="MsoNormal">
<b><span lang="EN-US" style="font-family: "Times New Roman","serif";">Output:<o:p></o:p></span></b></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">D:\
\programs>javac strings.java<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">D:\
\programs>java strings<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">Enter
the First Name:<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">mega
star<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">Enter
the Second Name:<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">mega<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">mega
is a substring of mega star<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<h3>
<span lang="EN-US" style="font-family: "Times New Roman","serif";">Commonly
used string methods<o:p></o:p></span></h3>
<table border="1" cellpadding="0" cellspacing="0" class="MsoNormalTable" style="border-collapse: collapse; border: none; mso-border-alt: solid windowtext .5pt; mso-border-insideh: .5pt solid windowtext; mso-border-insidev: .5pt solid windowtext; mso-padding-alt: 0cm 5.4pt 0cm 5.4pt;">
<tbody>
<tr style="mso-yfti-firstrow: yes; mso-yfti-irow: 0;">
<td style="border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt;" valign="top">
<div class="MsoNormal">
<b><span lang="EN-US" style="font-family: "Times New Roman","serif";">Method
Name<o:p></o:p></span></b></div>
</td>
<td style="border-left: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt;" valign="top">
<div class="MsoNormal">
<b><span lang="EN-US" style="font-family: "Times New Roman","serif";">Task
Performed <o:p></o:p></span></b></div>
</td>
</tr>
<tr style="mso-yfti-irow: 1;">
<td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt;" valign="top">
<div class="MsoFooter" style="tab-stops: 36.0pt;">
<span lang="EN-US">S2=s1.toLowerCase;</span></div>
</td>
<td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt;" valign="top">
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">Converts
string s1 to lowercase<o:p></o:p></span></div>
</td>
</tr>
<tr style="mso-yfti-irow: 2;">
<td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt;" valign="top">
<div class="MsoFooter" style="tab-stops: 36.0pt;">
<span lang="EN-US">S2=s1.toUpperCase;</span></div>
</td>
<td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt;" valign="top">
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">Converts
string s1 to uppercase<o:p></o:p></span></div>
</td>
</tr>
<tr style="mso-yfti-irow: 3;">
<td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt;" valign="top">
<div class="MsoFooter" style="tab-stops: 36.0pt;">
<span lang="EN-US">S2=s1.replace(‘x’,’y’);</span></div>
</td>
<td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt;" valign="top">
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">Replace
all x with y<o:p></o:p></span></div>
</td>
</tr>
<tr style="mso-yfti-irow: 4;">
<td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt;" valign="top">
<div class="MsoFooter" style="tab-stops: 36.0pt;">
<span lang="EN-US">S2=s1.trim();</span></div>
</td>
<td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt;" valign="top">
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">Remove
white spaces<o:p></o:p></span></div>
</td>
</tr>
<tr style="mso-yfti-irow: 5;">
<td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt;" valign="top">
<div class="MsoFooter" style="tab-stops: 36.0pt;">
<span lang="EN-US">s1.equals(s2)</span></div>
</td>
<td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt;" valign="top">
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">Returns
true is s1=s2<o:p></o:p></span></div>
</td>
</tr>
<tr style="mso-yfti-irow: 6;">
<td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt;" valign="top">
<div class="MsoFooter" style="tab-stops: 36.0pt;">
<span lang="EN-US">s1.equalsIgnoreCase(s2)</span></div>
</td>
<td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt;" valign="top">
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">Returns
true is s1=s2, ignoring the case<o:p></o:p></span></div>
</td>
</tr>
<tr style="mso-yfti-irow: 7;">
<td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt;" valign="top">
<div class="MsoFooter" style="tab-stops: 36.0pt;">
<span lang="EN-US">s1.length()</span></div>
</td>
<td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt;" valign="top">
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">Finds
the length of s1<o:p></o:p></span></div>
</td>
</tr>
<tr style="mso-yfti-irow: 8;">
<td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt;" valign="top">
<div class="MsoFooter" style="tab-stops: 36.0pt;">
<span lang="EN-US">s1.charAt(n)</span></div>
</td>
<td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt;" valign="top">
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">Gives
nth character of s1<o:p></o:p></span></div>
</td>
</tr>
<tr style="mso-yfti-irow: 9;">
<td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt;" valign="top">
<div class="MsoFooter" style="tab-stops: 36.0pt;">
<span lang="EN-US">s1.compareTo(s2)</span></div>
</td>
<td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt;" valign="top">
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">Returns
negative if s1<s2, positive if s1>s2, and zero if s1=s2<o:p></o:p></span></div>
</td>
</tr>
<tr style="mso-yfti-irow: 10;">
<td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt;" valign="top">
<div class="MsoFooter" style="tab-stops: 36.0pt;">
<span lang="EN-US">s1.concat(s2)</span></div>
</td>
<td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt;" valign="top">
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">Concatenates
s1 and s2<o:p></o:p></span></div>
</td>
</tr>
<tr style="mso-yfti-irow: 11;">
<td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt;" valign="top">
<div class="MsoFooter" style="tab-stops: 36.0pt;">
<span lang="EN-US">s1.substring(n)</span></div>
</td>
<td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt;" valign="top">
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">Gives
substring starting from nth character<o:p></o:p></span></div>
</td>
</tr>
<tr style="mso-yfti-irow: 12; mso-yfti-lastrow: yes;">
<td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt;" valign="top">
<div class="MsoFooter" style="tab-stops: 36.0pt;">
<span lang="EN-US">s1.indexOf(‘x’)</span></div>
</td>
<td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt;" valign="top">
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">Gives
the position of first occurrence of x in string s1.<o:p></o:p></span></div>
</td>
</tr>
</tbody></table>
<div class="MsoNormal">
<br /></div>
<br /></div>
Bagadhi Sateeshhttp://www.blogger.com/profile/16786636572407672825noreply@blogger.com0tag:blogger.com,1999:blog-8352540103162095489.post-89650990262603809462018-08-28T14:18:00.001+05:302018-08-28T14:18:07.369+05:30Arrays<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<div class="MsoNormal">
<b><span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;">One-dimensional Arrays:</span><o:p></o:p></span></b></div>
<div class="MsoBodyText">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">A
list of items can be given one variable name using only one subscript and such
a variable is called a single-subscripted variable or<span style="mso-spacerun: yes;"> </span>a one dimensional array.<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>Ex:
x[0],x[1],x[2],…………, x[n]<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">The subscript can begin with 0 or 1<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">Like any other variable arrays must be declared and created in the
computer memory before they are used. Creation of an array involves 3 steps:<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-left: 54.0pt; mso-list: l0 level1 lfo1; tab-stops: list 54.0pt; text-indent: -36.0pt;">
<!--[if !supportLists]--><span lang="EN-US" style="color: black; font-family: "Times New Roman","serif"; mso-fareast-font-family: "Times New Roman";"><span style="mso-list: Ignore;">1.<span style="font: 7.0pt "Times New Roman";">
</span></span></span><!--[endif]--><span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">Declare the array<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-left: 54.0pt; mso-list: l0 level1 lfo1; tab-stops: list 54.0pt; text-indent: -36.0pt;">
<!--[if !supportLists]--><span lang="EN-US" style="color: black; font-family: "Times New Roman","serif"; mso-fareast-font-family: "Times New Roman";"><span style="mso-list: Ignore;">2.<span style="font: 7.0pt "Times New Roman";">
</span></span></span><!--[endif]--><span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">Create memory locations<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-left: 54.0pt; mso-list: l0 level1 lfo1; tab-stops: list 54.0pt; text-indent: -36.0pt;">
<!--[if !supportLists]--><span lang="EN-US" style="color: black; font-family: "Times New Roman","serif"; mso-fareast-font-family: "Times New Roman";"><span style="mso-list: Ignore;">3.<span style="font: 7.0pt "Times New Roman";">
</span></span></span><!--[endif]--><span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">Put values into the memory location<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-left: 18.0pt;">
<br /></div>
<div class="MsoNormal" style="margin-left: 18.0pt;">
<b><span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">Declaration of
arrays:<o:p></o:p></span></b></div>
<div class="MsoNormal" style="margin-left: 18.0pt;">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">Arrays in java may be
declared in two forms:</span></div>
<div class="MsoNormal" style="margin-left: 18.0pt;">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><br /></span></div>
<div class="MsoNormal" style="margin-left: 18.0pt;">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"></span></div>
<div class="MsoNormal">
<b><span lang="EN-US" style="font-size: 14.0pt;">Form1: type arrayname[
];<o:p></o:p></span></b></div>
<div class="MsoNormal">
<b><span lang="EN-US" style="font-size: 14.0pt;"><br /></span></b></div>
<div class="MsoNormal">
<b><span lang="EN-US" style="font-size: 14.0pt;">Form2: type [ ]
arrayname;<o:p></o:p></span></b></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b><span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">Examples:<o:p></o:p></span></b></div>
<div class="MsoNormal" style="margin-left: 36.0pt; text-indent: 36.0pt;">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">int <span style="mso-tab-count: 2;"> </span>number[ ];<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-left: 36.0pt; text-indent: 36.0pt;">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">float <span style="mso-tab-count: 2;"> </span>average[ ];<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-left: 36.0pt; text-indent: 36.0pt;">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">int[ ]<span style="mso-tab-count: 2;"> </span>counter;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-left: 36.0pt; text-indent: 36.0pt;">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">float[ ]<span style="mso-tab-count: 1;"> </span>marks;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">Remember that we do not enter the size of the arrays in
declaration.<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b><span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">Creation of arrays:<o:p></o:p></span></b></div>
<div class="MsoBodyText">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">After
declaration of an array we need to create it ion memory. Java allows us to
create arrays using new operator only. As shown below:<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 3;"> </span>arrayname=
new type[size];<o:p></o:p></span></div>
<div class="MsoNormal">
<b><span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">Example:<o:p></o:p></span></b></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>number<span style="mso-tab-count: 1;"> </span>=<span style="mso-tab-count: 1;"> </span>new
int[5];<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>average<span style="mso-tab-count: 1;"> </span>=<span style="mso-tab-count: 1;"> </span>new
float[10];<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b><span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">Initialization of Arrays:<o:p></o:p></span></b></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">The final step is to put values into the array created. This
process is known as initialization this done using the array subscripts as
shown below:<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span>Arrayname[subscript]=value;<o:p></o:p></span></div>
<div class="MsoNormal">
<b><span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">Example:<o:p></o:p></span></b></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">number[0]=35;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">number[1]=40;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">…………………<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">…………………<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">number[4]=19;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">note: java creates arrays starting with a subscript of 0 and ends
with a value one less than the size specified.<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">We can also initialize arrays automatically<span style="mso-spacerun: yes;"> </span>in the same way as the ordinary variables
when they are declared, as shown below:<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-left: 36.0pt; text-indent: 36.0pt;">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">type
arrayname[ <span style="mso-spacerun: yes;"> </span>] = { list of values };<o:p></o:p></span></div>
<div class="MsoNormal">
<b><span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">Example:<o:p></o:p></span></b></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span>int
number[ ] = { 35,40,20,57,19 };<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<h2>
<span lang="EN-US" style="font-family: "Times New Roman","serif";">Array length<o:p></o:p></span></h2>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">In java all arrays store the allocated size in a variable named
length. <o:p></o:p></span></div>
<div class="MsoNormal">
<b><span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">Example:</span></b><span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"> we can access the length of the array A is<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>int
Asize=A.length;<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">import java.io.*;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">class array1<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">public static void main(String args[]) throws Exception<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">BufferedReader br=new BufferedReader(new
InputStreamReader(System.in));<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">Float [ ]a =new Float [5];<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">Float x[ ]=new Float[5];<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">int i,j=0;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">System.out.println("enter how many");<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">int n=Integer.parseInt(br.readLine());<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">System.out.println("enter the array elements");<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">for(i=0;i<n;i++)<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">a[i]=Float.valueOf(br.readLine());<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">System.out.println("<span style="mso-spacerun: yes;">
</span>given array is....");<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">for(i=0;i<n;i++)<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">System.out.println("element at index "+ i +"<span style="mso-spacerun: yes;"> </span>is<span style="mso-spacerun: yes;">
</span>" +a[i]);<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">}<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b><span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">OUTPUT::<o:p></o:p></span></b></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">D:\ \programs>javac array1.java<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">D:\ \programs>java array1<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">enter how many<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">5<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">enter the array elements<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">1.1<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">1.2<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">1.3<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">1.4<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">1.5<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">given array is....<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">element at index 0<span style="mso-spacerun: yes;"> </span>is<span style="mso-spacerun: yes;"> </span>1.1<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">element at index 1<span style="mso-spacerun: yes;"> </span>is<span style="mso-spacerun: yes;"> </span>1.2<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">element at index 2<span style="mso-spacerun: yes;"> </span>is<span style="mso-spacerun: yes;"> </span>1.3<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">element at index 3<span style="mso-spacerun: yes;"> </span>is<span style="mso-spacerun: yes;"> </span>1.4<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">element at index 4<span style="mso-spacerun: yes;"> </span>is<span style="mso-spacerun: yes;"> </span>1.5<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b><span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;">Two dimensional Arrays:</span><o:p></o:p></span></b></div>
<div class="MsoNormal">
<b><span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span></span></b><span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">For
creating two-dimensional arrays we must follow the same steps as that of simple
arrays. We may create a two dimensional array like this:<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span>int
myArray[ ][ ];<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span>myArray
= new int[3][4];<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 3;"> </span>(or)<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span>int
myArray[ ][ ]=new int [3][4];<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b><span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">The following example is for addition two matrices:<o:p></o:p></span></b></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">import java.io.*;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">class matrix1<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">public static void main(String args[])throws IOException<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">int a[ ][ ]=new int [3][3];<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">int b[ ][ ]=new int [3][3];<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">int c[ ][ ]=new int [3][3];<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">int i,j;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">BufferedReader br=new BufferedReader(new
InputStreamReader(System.in));<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">System.out.println("enter how many rows and columns for
matrix A:");<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">int m=Integer.parseInt(br.readLine());<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">int n= Integer.parseInt(br.readLine());<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">System.out.println("enter the lements into matrix:A");<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">for( i=0;i<m;i++)<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">for( j=0;j<n;j++)<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">a[i][j]=Integer.parseInt(br.readLine());<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">System.out.println("enter how many rows and columns for
matrix B:");<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">int p=Integer.parseInt(br.readLine());<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">int q= Integer.parseInt(br.readLine());<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">System.out.println("enter the lements into matrix:B");<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">for( i=0;i<p;i++)<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">for( j=0;j<q;j++)<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">b[i][]=Integer.parseInt(br.readLine());<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">if(m!=p&&n!=q)<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">System.out.println("Addition is not Possible");<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">System.exit(0);<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">else<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">for(i=0;i<m;i++)<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">for(j=0;j<n;j++)<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">c[i][j]=a[i][j]+b[i][j];<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">System.out.println("result matrix is...");<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">for(i=0;i<m;i++)<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">System.out.println();<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">for(j=0;j<n;j++)<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">System.out.print("\t"+c[i][j]);<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">}<o:p></o:p></span></div>
<div class="MsoNormal">
<b><span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">Output:<o:p></o:p></span></b></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">D:\ \programs>javac matrix1.java<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">D:\ \programs>java matrix1<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">enter how many rows and columns for matrix A:<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">2<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">2<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">enter the lements into matrix:A<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">1<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">2<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">3<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">4<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">enter how many rows and columns for matrix B:<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">2<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">2<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">enter the lements into matrix:B<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">1<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">2<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">3<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">4<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">result matrix is...<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-spacerun: yes;"> </span>2<span style="mso-spacerun: yes;"> </span>4<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-spacerun: yes;"> </span>6<span style="mso-spacerun: yes;"> </span>8<o:p></o:p></span></div>
<br /></div>
Bagadhi Sateeshhttp://www.blogger.com/profile/16786636572407672825noreply@blogger.com0tag:blogger.com,1999:blog-8352540103162095489.post-28119526461076359962018-08-27T14:13:00.002+05:302018-08-27T14:13:32.008+05:30Abstract Methods and Classes<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<div class="MsoNormal">
<b><span lang="EN-US" style="color: black; font-family: "Times New Roman","serif"; font-size: 14.0pt;">Abstract Methods and Classes <o:p></o:p></span></b></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">Whenever a class contains a method only for the purpose of
overriding but does not have any body such methods has to be declare as
Abstract Methods. Once a class contains at least one abstract method the class
must be declared as abstract and for an abstract class we cannot create any
instances but it can be inherited. Every method in the abstract class has to be
override.</span><span lang="EN-US" style="color: black; font-family: "Times New Roman","serif"; font-size: 14.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<b><span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">Ex: <span style="mso-tab-count: 1;"> </span></span></b><span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">abstract
class common<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span>abstract
void assign();<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span>abstract
void show();<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>}<span style="mso-tab-count: 1;"> </span><o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<br /></div>
Bagadhi Sateeshhttp://www.blogger.com/profile/16786636572407672825noreply@blogger.com0tag:blogger.com,1999:blog-8352540103162095489.post-56471917555471502642018-08-27T14:12:00.003+05:302018-08-27T14:12:47.763+05:30Final Variables, Methods and Classes<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<h2>
<span lang="EN-US" style="font-family: "Times New Roman","serif";">Final
Variables, Methods and Classes<o:p></o:p></span></h2>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><o:p> </o:p></span><span style="font-family: "Times New Roman", serif;">The
keyword "final" in Java is used in different ways depending on the
context. We can have final methods, final classes, final data members, final
local variables and final parameters. A final class implicitly has all the
methods as final, but not necessarily the data members. A final class may not
be extended, neither may a final method be overridden.</span></div>
<div class="MsoBodyText2">
<br /></div>
<div class="MsoBodyText2">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">It
is applicable for a class for the following 3 purposes:-<o:p></o:p></span></div>
<div class="MsoBodyText2" style="margin-left: 36.0pt; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt left 47.25pt; text-indent: -18.0pt;">
<!--[if !supportLists]--><span lang="EN-US" style="color: black; font-family: Wingdings; mso-bidi-font-family: Wingdings; mso-fareast-font-family: Wingdings;"><span style="mso-list: Ignore;">Ø<span style="font: 7.0pt "Times New Roman";"> </span></span></span><!--[endif]--><span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">For the
members<o:p></o:p></span></div>
<div class="MsoBodyText2" style="margin-left: 36.0pt; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt left 47.25pt; text-indent: -18.0pt;">
<!--[if !supportLists]--><span lang="EN-US" style="color: black; font-family: Wingdings; mso-bidi-font-family: Wingdings; mso-fareast-font-family: Wingdings;"><span style="mso-list: Ignore;">Ø<span style="font: 7.0pt "Times New Roman";"> </span></span></span><!--[endif]--><span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">For the
methods<o:p></o:p></span></div>
<div class="MsoBodyText2" style="margin-left: 36.0pt; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt left 47.25pt; text-indent: -18.0pt;">
<!--[if !supportLists]--><span lang="EN-US" style="color: black; font-family: Wingdings; mso-bidi-font-family: Wingdings; mso-fareast-font-family: Wingdings;"><span style="mso-list: Ignore;">Ø<span style="font: 7.0pt "Times New Roman";"> </span></span></span><!--[endif]--><span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">For the
class itself.<o:p></o:p></span></div>
<h2 style="margin-left: 108.0pt; mso-list: l0 level3 lfo1; tab-stops: list 108.0pt; text-indent: -18.0pt;">
<!--[if !supportLists]--><span lang="EN-US" style="font-family: Wingdings; font-size: 12.0pt; font-weight: normal; mso-bidi-font-family: Wingdings; mso-fareast-font-family: Wingdings;"><span style="mso-list: Ignore;">§<span style="font: 7.0pt "Times New Roman";"> </span></span></span><!--[endif]--><span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt; font-weight: normal;">If it is applied for members they become sharable constants
and can be used in other classes but it cannot be modified<o:p></o:p></span></h2>
<div align="left" class="MsoNormal" style="margin-left: 108.0pt; mso-list: l0 level3 lfo1; tab-stops: list 108.0pt; text-align: left; text-indent: -18.0pt;">
<!--[if !supportLists]--><span lang="EN-US" style="font-family: Wingdings; mso-bidi-font-family: Wingdings; mso-fareast-font-family: Wingdings;"><span style="mso-list: Ignore;">§<span style="font: 7.0pt "Times New Roman";"> </span></span></span><!--[endif]--><span lang="EN-US" style="font-family: "Times New Roman","serif";">If it is applied for
methods the methods cannot be overridden in child classes.<o:p></o:p></span></div>
<div align="left" class="MsoNormal" style="margin-left: 108.0pt; mso-list: l0 level3 lfo1; tab-stops: list 108.0pt; text-align: left; text-indent: -18.0pt;">
<!--[if !supportLists]--><span lang="EN-US" style="font-family: Wingdings; mso-bidi-font-family: Wingdings; mso-fareast-font-family: Wingdings;"><span style="mso-list: Ignore;">§<span style="font: 7.0pt "Times New Roman";"> </span></span></span><!--[endif]--><span lang="EN-US" style="font-family: "Times New Roman","serif";">If it is applied for
the class itself it cannot be inherited but instances can be created.<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">class
tree<span style="mso-tab-count: 1;"> </span>//if you keep final before
the class its not inheritable further<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>final String head;<span style="mso-tab-count: 1;"> </span>//it becomes readonly<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>public tree()<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span>head="Final Keyword
Concept";<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>final void assign() //cannot be
overridden in subclass<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span>//head="Final";<span style="mso-tab-count: 1;"> </span>not valid<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">class
node extends tree<span style="mso-tab-count: 1;"> </span><o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>/* void assign()<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span>head="Child node";<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>} <span style="mso-tab-count: 1;"> </span>*/<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">class
impfinal<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>public static void main(String
[]args)<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span>node n=new node();<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span>n.assign();<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 2;"> </span>System.out.println(n.head);<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="mso-tab-count: 1;"> </span>}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">}<o:p></o:p></span></div>
<div class="MsoNormal">
<b><span lang="EN-US" style="font-family: "Times New Roman","serif";">Output:<o:p></o:p></span></b></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">C:\>javac
impfinal.java<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">C:\>java
impfinal<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">Final
Keyword Concept<o:p></o:p></span></div>
<br /></div>
Bagadhi Sateeshhttp://www.blogger.com/profile/16786636572407672825noreply@blogger.com0tag:blogger.com,1999:blog-8352540103162095489.post-53532563852977118992018-08-27T14:08:00.000+05:302018-08-27T14:10:05.607+05:30 Inheritance<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<div class="MsoNormal">
<b><span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: 14.0pt;">Inheritance <o:p></o:p></span></b></div>
<div class="MsoBodyText">
<span lang="EN-US" style="font-family: "times new roman" , "serif";">The
mechanism of deriving a new class from an old one is called as <b>INHERITANCE.</b>
The existing classes are called as <b>base/parent classes</b> where as the new
classes are called as <b>child/derived classes. </b>The derived class inherits
all the capabilities of the base class and can add refinements and extensions
of its own.</span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgZDN1aKzahXKflJpw-L7ZyncjyRBUq-ZDOvw_NZAnAV643J4rnqJagDWFboClVJO97B4sr0lkK5zOiR_lFr8nYQHcOyAJ4OUT_OrR-Cuo9Usv5gG6MgYoAMFiXsxeP2xBU0xo25PfR0tI/s1600/Untitled.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="223" data-original-width="495" height="180" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgZDN1aKzahXKflJpw-L7ZyncjyRBUq-ZDOvw_NZAnAV643J4rnqJagDWFboClVJO97B4sr0lkK5zOiR_lFr8nYQHcOyAJ4OUT_OrR-Cuo9Usv5gG6MgYoAMFiXsxeP2xBU0xo25PfR0tI/s400/Untitled.png" width="400" /></a></div>
<div class="MsoBodyText">
<span lang="EN-US" style="font-family: "times new roman" , "serif";"><br /></span></div>
<div class="MsoBodyText">
<b><span lang="EN-US" style="font-family: "times new roman" , "serif";"><br /></span></b></div>
<div class="MsoBodyText">
<b><span lang="EN-US" style="font-family: "times new roman" , "serif";">Defining
derived classes</span></b></div>
<div class="MsoBodyText">
<span lang="EN-US" style="font-family: "times new roman" , "serif";">A
derived class can be defined by specifying its relationship with the base class
in addition to its own details. The general form of defining a derived class
is:<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif";">class subclassname extends superclassname<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif";">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif";"><span style="mso-tab-count: 1;"> </span>variable
declaration;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif";"><span style="mso-tab-count: 1;"> </span>method
declaration;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif";">}<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , "serif";">Java
supports the following types of Inheritance<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-left: 39.75pt; mso-list: l0 level1 lfo1; tab-stops: list 39.75pt; text-indent: -21.75pt;">
<!--[if !supportLists]--><span lang="EN-US" style="font-family: "times new roman" , "serif"; mso-fareast-font-family: "Times New Roman";"><span style="mso-list: Ignore;">a)<span style="font: 7.0pt "Times New Roman";">
</span></span></span><!--[endif]--><span lang="EN-US" style="font-family: "times new roman" , "serif";">Single<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-left: 39.75pt; mso-list: l0 level1 lfo1; tab-stops: list 39.75pt; text-indent: -21.75pt;">
<!--[if !supportLists]--><span lang="EN-US" style="font-family: "times new roman" , "serif"; mso-fareast-font-family: "Times New Roman";"><span style="mso-list: Ignore;">b)<span style="font: 7.0pt "Times New Roman";">
</span></span></span><!--[endif]--><span lang="EN-US" style="font-family: "times new roman" , "serif";">Multilevel<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-left: 39.75pt; mso-list: l0 level1 lfo1; tab-stops: list 39.75pt; text-indent: -21.75pt;">
<!--[if !supportLists]--><span lang="EN-US" style="font-family: "times new roman" , "serif"; mso-fareast-font-family: "Times New Roman";"><span style="mso-list: Ignore;">c)<span style="font: 7.0pt "Times New Roman";">
</span></span></span><!--[endif]--><span lang="EN-US" style="font-family: "times new roman" , "serif";">Hierarchical</span></div>
<div class="MsoNormal" style="margin-left: 39.75pt; mso-list: l0 level1 lfo1; tab-stops: list 39.75pt; text-indent: -21.75pt;">
<span lang="EN-US" style="font-family: "times new roman" , "serif";"><br /></span></div>
<div class="MsoBodyText">
<b><span lang="EN-US" style="font-family: "times new roman" , "serif";">Single
inheritance:</span></b><span lang="EN-US" style="font-family: "times new roman" , "serif";">
Derivation of a class from only one base class is called single inheritance. <o:p></o:p></span></div>
<div class="MsoBodyText">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhhMphnblm0fZbXrwqUht10aa5XxnYW4XTcFbe53CkU65hKwVtlZKDIe9XfOeQa-hLn2_cxzeCDTTf8DYphufj4FF0rVBzZBh2h8H8-QR6NGNLsCr4eKeoRnppNaYK0xwffiBOrl4H8_yI/s1600/Untitled.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="178" data-original-width="225" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhhMphnblm0fZbXrwqUht10aa5XxnYW4XTcFbe53CkU65hKwVtlZKDIe9XfOeQa-hLn2_cxzeCDTTf8DYphufj4FF0rVBzZBh2h8H8-QR6NGNLsCr4eKeoRnppNaYK0xwffiBOrl4H8_yI/s1600/Untitled.png" /></a></div>
<div class="MsoBodyText">
<span style="font-family: "times new roman" , serif;">class Dept</span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;"> int dno;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;"> String dname;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;"> String loc;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;"> void
setDetails(int x,String y,String z)<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;"> {<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;"> dno=x;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;"> dname=y;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;"> loc=z;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;"> }<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;">}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;">class emp extends Dept<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;"> int eno;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;"> String ename;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;"> String job;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;"> void setemp(int
x,String y,String z)<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;"> {<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;"> eno=x;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;"> ename=y;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;"> job=z;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;"> }<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;"> void
showdetails()<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;"> {<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;"> System.out.println("Dept
Details="+dno+"\t\t"+dname+"\t\t"+loc);<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;"> System.out.println("Emp
Details="+eno+"\t\t"+ename+"\t\t"+job);<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;"> }<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;">}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;">class single<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;"> public static
void main(String []args)<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;"> {<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;"> emp
e=new emp();<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;"> e.setDetails(10,"sales","vizag");<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;"> e.setemp(101,"Smith","manager");<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;"> e.showdetails();<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;"> }<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;">}<o:p></o:p></span></div>
<div class="MsoNormal">
<b><span lang="EN-US" style="font-family: "times new roman" , serif;">Output:<o:p></o:p></span></b></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;">C:\>javac single.java<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;">C:\>java single<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;">Dept Details=10
sales vizag<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;">Emp Details=101
Smith manager<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-left: 39.75pt; mso-list: l0 level1 lfo1; tab-stops: list 39.75pt; text-indent: -21.75pt;">
<span lang="EN-US" style="font-family: "times new roman" , "serif";">
</span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoBodyText">
<b><span lang="EN-US" style="font-family: "times new roman" , "serif";">Hierarchical
inheritance:</span></b><span lang="EN-US" style="font-family: "times new roman" , "serif";">
Derivation of several classes from a single base class i.e. the traits of one
class may be inherited by more than one class is called hierarchical
inheritance. We can achieve runtime polymorphism with the help of method
overriding.<o:p></o:p></span></div>
<div class="MsoNormal">
</div>
<div class="MsoNormal">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgbP-6q2sr8XxW5boAtcX3RyTJhu0RfOL_urmtpuc3fcVbTONkEyOhTOyBHUx34Qs_8ZJngW5o4scaZefTbAFf_gMQccYC-4aMhqkGIOScknKhG_O84iZXSrf9_RZs8KLiJ3-tkcEu9WJA/s1600/Untitled.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="244" data-original-width="348" height="224" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgbP-6q2sr8XxW5boAtcX3RyTJhu0RfOL_urmtpuc3fcVbTONkEyOhTOyBHUx34Qs_8ZJngW5o4scaZefTbAFf_gMQccYC-4aMhqkGIOScknKhG_O84iZXSrf9_RZs8KLiJ3-tkcEu9WJA/s320/Untitled.png" width="320" /></a></div>
<div class="MsoNormal">
<b><span lang="EN-US" style="font-family: "times new roman" , serif;">Example:<o:p></o:p></span></b></div>
<br />
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;">class common<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;"> void assign() { }<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;"> void show( ) { }<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;">}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;">class prodinfo extends common<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;"> int pno;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;"> String pname;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;"> public void
assign()<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;"> {<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;"> pno=100;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;"> pname="Lux";<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;"> }<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;"> public void
show()<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;"> {<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;"> System.out.println("Product
Details");<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;"> System.out.println(pno+"\t\t"+pname);<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;"> }<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;">}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;">class custinfo extends common<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;"> int cno;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;"> String cname;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;"> public void
assign()<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;"> {<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;"> cno=10;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;"> cname="Gayatri";<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;"> }<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;"> public void
show()<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;"> {<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;"> System.out.println("Customer
Details");<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;"> System.out.println(cno+"\t\t"+cname);<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;"> }<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;">}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;">class hierar<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;"> public static
void main(String []args)<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;"> {<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;"> common
c; //reference variable<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;"> if(args[0].equals("product"))<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;"> c=new
prodinfo();<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;"> else<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;"> c=new
custinfo();<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;"> c.assign();<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;"> c.show();<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;"> }<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;">}<o:p></o:p></span></div>
<div class="MsoNormal">
<b><span lang="EN-US" style="font-family: "times new roman" , serif;">Output:<o:p></o:p></span></b></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;">C:\>javac hierar.java<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;">C:\>java hierar opo<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;">Customer Details<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;">10 Gayatri<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;">C:\>java hierar product<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;">Product Details<o:p></o:p></span></div>
<div class="separator" style="clear: both;">
</div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;">100 Lux<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;"><br /></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;"></span></div>
<div class="MsoBodyText">
<b><span lang="EN-US" style="font-family: "times new roman" , "serif";">Multilevel
inheritance:</span></b><span lang="EN-US" style="font-family: "times new roman" , "serif";">
Derivation of a class from another derived class is called multilevel
inheritance.<o:p></o:p></span></div>
<div class="MsoBodyText">
<span lang="EN-US" style="font-family: "times new roman" , "serif";"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjeY6aWmjAvr8Ys5lB9b5-zXSQmc3qqRjTuSx0hT2W2vXM8_dMcb-fMUjGvATwuKOVAh6CcLsIK61u7qAHhxlGfBqm0orsot6Mi9IFDySkL7AlO__rhF9YbnlrEjf7hC25JzrmXAWNwWU4/s1600/Untitled.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="266" data-original-width="225" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjeY6aWmjAvr8Ys5lB9b5-zXSQmc3qqRjTuSx0hT2W2vXM8_dMcb-fMUjGvATwuKOVAh6CcLsIK61u7qAHhxlGfBqm0orsot6Mi9IFDySkL7AlO__rhF9YbnlrEjf7hC25JzrmXAWNwWU4/s1600/Untitled.png" /></a></div>
<div class="MsoBodyText">
<span lang="EN-US" style="font-family: "times new roman" , "serif";"><br /></span></div>
<div class="MsoNormal">
<b><span lang="EN-US" style="font-family: "times new roman" , "serif";">Example:
<o:p></o:p></span></b></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;">class student<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;">int rno;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;">void get_no(int a)<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;">rno=a;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;">}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;">void put_no()<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;">System.out.println("Rno="+rno);<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;">}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;">}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;">class test extends student<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;">float sub1,sub2;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;">void get_marks(float sub1, float sub2)<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;">this.sub1=sub1;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;">this.sub2=sub2;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;">}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;">void put_marks()<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;">System.out.println("Sub1="+sub1);<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;">System.out.println("Sub2="+sub2);<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;">}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;">}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;">class result extends test<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;">float total;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;">void display()<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;">total=sub1+sub2;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;">System.out.println("Total="+total);<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;">}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;">}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;">class multi<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;"> public static
void main(String []args)<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;"> {<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;"> result
r=new result();<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;"> r.get_no(9);<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;"> r.get_marks(56.7f,78.9f);<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;"> r.put_no();<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;"> r.put_marks();<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;"> r.display();<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;"> }<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;">}<o:p></o:p></span></div>
<div class="MsoNormal">
<b><span lang="EN-US" style="font-family: "times new roman" , serif;">Output:<o:p></o:p></span></b></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;">C:\>javac multi.java<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;">C:\>java multi<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;">Rno=9<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;">Sub1=56.7<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;">Sub2=78.9<o:p></o:p></span></div>
<div class="MsoBodyText">
<span lang="EN-US" style="font-family: "times new roman" , "serif";">
</span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , serif;">Total=135.6<o:p></o:p></span></div>
</div>
Bagadhi Sateeshhttp://www.blogger.com/profile/16786636572407672825noreply@blogger.com0tag:blogger.com,1999:blog-8352540103162095489.post-29802800624264007362018-08-21T16:01:00.004+05:302018-08-21T16:01:50.724+05:30Nesting of Methods<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="font-size: large;">Only
an object of that class using a dot operator can call a member function of a
class. A member function can be called by using its name inside another member
function of the same class. This is known as <b>nesting of member functions.<o:p></o:p></b></span></span></div>
<div class="MsoNormal">
<b><span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;">Example Program:<o:p></o:p></span></span></b></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;">class nest<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;">{<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;"><span style="mso-tab-count: 1;"> </span>int m,n;<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;"><span style="mso-tab-count: 1;"> </span>void accept(int
x,int y)<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;"><span style="mso-tab-count: 1;"> </span>{<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;"><span style="mso-tab-count: 2;"> </span>m=x;<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;"><span style="mso-tab-count: 2;"> </span>n=y;<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;"><span style="mso-tab-count: 1;"> </span>}<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;"><span style="mso-tab-count: 1;"> </span>int largest()<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;"><span style="mso-tab-count: 1;"> </span>{<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;"><span style="mso-tab-count: 2;"> </span>if(m>=n)<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;"><span style="mso-tab-count: 3;"> </span>return
m;<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;"><span style="mso-tab-count: 2;"> </span>else<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;"><span style="mso-tab-count: 3;"> </span>return
n;<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;"><span style="mso-tab-count: 1;"> </span>}<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;"><span style="mso-tab-count: 1;"> </span>void display()<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;"><span style="mso-tab-count: 1;"> </span>{<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;"><span style="mso-tab-count: 2;"> </span>int
large=largest();<span style="mso-tab-count: 1;"> </span>//calling a method<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;"><span style="mso-tab-count: 2;"> </span>System.out.println("Largest
Value="+large);<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;"><span style="mso-tab-count: 1;"> </span>}<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;">}<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;">class nesting<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;">{<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;"><span style="mso-tab-count: 1;"> </span>public static
void main(String []args)<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;"><span style="mso-tab-count: 1;"> </span>{<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;"><span style="mso-tab-count: 2;"> </span>nest
n=new nest();<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;"><span style="mso-tab-count: 2;"> </span>n.accept(6,7);<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;"><span style="mso-tab-count: 2;"> </span>n.display();<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;"><span style="mso-tab-count: 1;"> </span>}<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;">}<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span style="font-size: large;"><b><span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">Output:</span></b><b><span lang="EN-US" style="color: black; font-family: "Times New Roman", serif;"><o:p></o:p></span></b></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;">D:\ \programs>javac nesting.java<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;">D:\ \programs>java nesting<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;">Largest Value=7</span><span style="mso-tab-count: 1;"> </span><o:p></o:p></span></div>
<br /></div>
Bagadhi Sateeshhttp://www.blogger.com/profile/16786636572407672825noreply@blogger.com0tag:blogger.com,1999:blog-8352540103162095489.post-9314636896328497582018-08-21T16:00:00.002+05:302018-08-21T16:00:34.659+05:30Static Members<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<div class="MsoNormal">
<b><span lang="EN-US" style="color: black; font-family: "Times New Roman", serif;"><span style="font-size: large;">Static Members <o:p></o:p></span></span></b></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;">Static members are like global variables which are sharable across
all the objects of the class and will maintain their values between objects.<o:p></o:p></span></span></div>
<div class="MsoNormal">
<b><span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;">Features:<o:p></o:p></span></span></b></div>
<ul style="margin-top: 0cm;" type="disc">
<li class="MsoNormal" style="color: black; mso-list: l0 level1 lfo1;"><span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="font-size: large;">They should be
declared with the help of keyword “static”.<o:p></o:p></span></span></li>
<li class="MsoNormal" style="color: black; mso-list: l0 level1 lfo1;"><span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="font-size: large;">They are
accessible across the entire class objects.<o:p></o:p></span></span></li>
<li class="MsoNormal" style="color: black; mso-list: l0 level1 lfo1;"><span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="font-size: large;">They are
generally used to persist the value between objects calling.<o:p></o:p></span></span></li>
<li class="MsoNormal" style="color: black; mso-list: l0 level1 lfo1;"><span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="font-size: large;">If they are
declared as public they can be accessible with the help of classname
instead of object name.<o:p></o:p></span></span></li>
</ul>
<div class="MsoNormal">
<b><span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;">//Program on Static Members<o:p></o:p></span></span></b></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;">class staticdemo<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;">{<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;"><span style="mso-tab-count: 1;"> </span>int objno; <span style="mso-tab-count: 1;"> </span><o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;"><span style="mso-tab-count: 1;"> </span>static int
objcnt;<span style="mso-tab-count: 1;"> </span><o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;"><span style="mso-tab-count: 1;"> </span>void hitcount( )<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;"><span style="mso-tab-count: 1;"> </span>{<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;"><span style="mso-tab-count: 2;"> </span>objno=++objcnt;<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;"><span style="mso-tab-count: 1;"> </span>}<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;"><span style="mso-tab-count: 1;"> </span>void showhits()<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;"><span style="mso-tab-count: 1;"> </span>{<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;"><span style="mso-tab-count: 2;"> </span>System.out.println("This
page has been hit for "+objcnt);<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;"><span style="mso-tab-count: 1;"> </span>}<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;"><span style="mso-tab-count: 1;"> </span>void
showposition()<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;"><span style="mso-tab-count: 1;"> </span>{<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;"><span style="mso-tab-count: 2;"> </span>System.out.println("Client
" + objno+<span style="mso-spacerun: yes;"> </span>"/" +objcnt);<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;"><span style="mso-tab-count: 1;"> </span>}<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;">}<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;">class Implstatic<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;">{<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;"><span style="mso-tab-count: 1;"> </span>public static
void main(String []args)<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;"><span style="mso-tab-count: 1;"> </span>{<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;"><span style="mso-tab-count: 2;"> </span>staticdemo
s=new staticdemo();<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;"><span style="mso-tab-count: 2;"> </span>staticdemo
t=new staticdemo();<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;"><span style="mso-tab-count: 2;"> </span>staticdemo
v=new staticdemo();<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;"><span style="mso-tab-count: 2;"> </span>s.hitcount();<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;"><span style="mso-tab-count: 2;"> </span>t.hitcount();<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;"><span style="mso-tab-count: 2;"> </span>v.hitcount();<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;"><span style="mso-tab-count: 2;"> </span>v.showhits();<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;"><span style="mso-tab-count: 2;"> </span>s.showposition();<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;"><span style="mso-tab-count: 2;"> </span>t.showposition();<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;"><span style="mso-tab-count: 2;"> </span>v.showposition();<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;"><span style="mso-tab-count: 1;"> </span>}<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;">}<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span style="font-size: large;"><b><span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">Output:</span></b><b><span lang="EN-US" style="color: black; font-family: "Times New Roman", serif;"><o:p></o:p></span></b></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;">D:\sysvol>javac Implstatic.java<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;">D:\sysvol>java Implstatic<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;">This page has been hit for 3<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;">Client1/3<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;">Client2/3<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;">Client3/3<o:p></o:p></span></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b><span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;">Static Methods:<o:p></o:p></span></span></b></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;">Similar to static members, within the class concept we can have
static methods, which are capable of accessing only static members, and can be
called with the help of class name.<o:p></o:p></span></span></div>
<br /></div>
Bagadhi Sateeshhttp://www.blogger.com/profile/16786636572407672825noreply@blogger.com0tag:blogger.com,1999:blog-8352540103162095489.post-12996137010007519172018-08-21T15:59:00.000+05:302018-08-21T15:59:01.372+05:30<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<div class="MsoNormal">
<b><span lang="EN-US" style="color: black; font-family: "Times New Roman", serif;"><span style="font-size: large;">Methods Overloading <o:p></o:p></span></span></b></div>
<div class="MsoBodyText">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="font-size: large;">Overloading
is the concept of using the same name for multiple purposes by sharing the same
external definition. The appropriate definition gets called depending upon the
arguments and written type of the method. Using the concept of method
overloading, we can design a family of functions with one method name but with
different argument lists. The method would perform different operations depends
on the argument list in the method call.<o:p></o:p></span></span></div>
<div class="MsoNormal">
<b><span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;">Program:<o:p></o:p></span></span></b></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;">class test<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;">{<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;"><span style="mso-tab-count: 1;"> </span>int area(int i)<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;"><span style="mso-tab-count: 1;"> </span>{<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;"><span style="mso-tab-count: 2;"> </span>return
i*i;<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;"><span style="mso-tab-count: 1;"> </span>}<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;"><span style="mso-tab-count: 1;"> </span>int area(int
a,int b)<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;"><span style="mso-tab-count: 1;"> </span>{<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;"><span style="mso-tab-count: 2;"> </span>return
a*b;<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;"><span style="mso-tab-count: 1;"> </span>}<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;">}<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;">class area<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;">{<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;"><span style="mso-tab-count: 1;"> </span>public static
void main(String []args)<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;"><span style="mso-tab-count: 1;"> </span>{<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;"><span style="mso-tab-count: 2;"> </span>test
t=new test();<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;"><span style="mso-tab-count: 2;"> </span>int
area;<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;"><span style="mso-tab-count: 2;"> </span>area=t.area(5);<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;"><span style="mso-tab-count: 2;"> </span>System.out.println("Area
of Sqaure is:"+area);<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;"><span style="mso-tab-count: 2;"> </span>area=t.area(5,6);<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;"><span style="mso-tab-count: 2;"> </span>System.out.println("Area
of Sqaure is:"+area);<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;"><span style="mso-tab-count: 1;"> </span>}<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;">}<o:p></o:p></span></span></div>
<div class="MsoNormal">
<b><span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;">Output:<o:p></o:p></span></span></b></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;">D:\sysvol>javac area.java<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;">D:\sysvol>java area<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;">Area of Sqaure is:25<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;">Area of Sqaure is:30</span><o:p></o:p></span></div>
<br /></div>
Bagadhi Sateeshhttp://www.blogger.com/profile/16786636572407672825noreply@blogger.com0tag:blogger.com,1999:blog-8352540103162095489.post-84484542839557852022018-08-21T15:58:00.000+05:302018-08-21T15:58:00.490+05:30<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<h2>
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="font-size: large;">Constructors
<o:p></o:p></span></span></h2>
<h3>
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-weight: normal;"><span style="font-size: large;">A Constructor is a special member function, which is used to initialize
the objects of its class. The Constructor is invoked whenever an object of its
associated class is created. The constructor constructs the value of data
members of the class.<o:p></o:p></span></span></h3>
<div class="MsoNormal">
<b><span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="font-size: large;">Features
:<o:p></o:p></span></span></b></div>
<ul style="margin-top: 0cm;" type="circle">
<li class="MsoNormal" style="mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-align: left;"><span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="font-size: large;">They
are invoked automatically when the objects are created.<o:p></o:p></span></span></li>
<li class="MsoNormal" style="mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-align: left;"><span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="font-size: large;">They
do not have return type not even void.<o:p></o:p></span></span></li>
<li class="MsoNormal" style="mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-align: left;"><span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="font-size: large;">The
compiler calls constructor implicitly as soon as an object of its type is
created.<o:p></o:p></span></span></li>
<li class="MsoNormal" style="mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-align: left;"><span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="font-size: large;">Constructors
can be overloaded.<o:p></o:p></span></span></li>
<li class="MsoNormal" style="mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-align: left;"><span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="font-size: large;">The
constructor name is same as class name.<o:p></o:p></span></span></li>
</ul>
<h6 style="line-height: 150%;">
<b><span lang="EN-US" style="line-height: 150%; text-decoration: none;"><span style="font-size: large;">Syntax: <o:p></o:p></span></span></b></h6>
<h3>
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-weight: normal;"><span style="font-size: large;"><span style="mso-tab-count: 2;"> </span>Class
class_name<o:p></o:p></span></span></h3>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="font-size: large;"><span style="mso-tab-count: 2;"> </span>{<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="font-size: large;"><span style="mso-tab-count: 3;"> </span>data
members;<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="font-size: large;"><span style="mso-tab-count: 3;"> </span>class_name();<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="font-size: large;"><span style="mso-tab-count: 2;"> </span>};<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="font-size: large;"><span style="mso-tab-count: 2;"> </span>classname::classname()<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="font-size: large;"><span style="mso-tab-count: 2;"> </span>{<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="font-size: large;"><span style="mso-tab-count: 3;"> </span>----------------<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="font-size: large;"><span style="mso-tab-count: 3;"> </span>----------------<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="font-size: large;"><span style="mso-tab-count: 2;"> </span>}<o:p></o:p></span></span></div>
<div class="MsoNormal">
<b><span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="font-size: large;">Example:<o:p></o:p></span></span></b></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="font-size: large;"><span style="mso-tab-count: 2;"> </span>Class sample<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="font-size: large;"><span style="mso-tab-count: 2;"> </span>{<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="font-size: large;"><span style="mso-tab-count: 3;"> </span>sample();<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="font-size: large;"><span style="mso-tab-count: 2;"> </span>};<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="font-size: large;"><span style="mso-tab-count: 2;"> </span>sample::sampe()<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="font-size: large;"><span style="mso-tab-count: 2;"> </span>{<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="font-size: large;"><span style="mso-tab-count: 3;"> </span>cout<<”constructor
Demo”;<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><span style="font-size: large;"><span style="mso-tab-count: 2;"> </span>}<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span style="font-size: large;"><b><span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">Program:</span></b><b><span lang="EN-US" style="color: black; font-family: "Times New Roman", serif;"><o:p></o:p></span></b></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;">class complex<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;">{<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;">int real,img;<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;">complex(){ }<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;">complex(int a)<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;">{<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;">real=img=a;<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;">}<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;">complex(int x,int y)<span style="mso-spacerun: yes;">
</span>//parameterized constructor<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;">{<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;">real=x;<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;">img=y;<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;">}<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;">complex sum(complex c1,complex c2)<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;">{<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;">complex c3=new complex();<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;">c3.real=c1.real+c2.real;<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;">c3.img=c1.img+c2.img;<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;">return c3;<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;">}<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;">void display()<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;">{<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;">System.out.println(real+"+i"+img);<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;">}<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;">}<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;">class complexnum<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;">{<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;">public static void main(String args[])<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;">{<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;">complex c1=new complex(1,2);<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;">complex c2=new complex(2);<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;">complex c3=new complex();<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;">c3=c3.sum(c1,c2);<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;">c3.display();<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;">}<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;">}<o:p></o:p></span></span></div>
<div class="MsoNormal">
<b><span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;">Output:<o:p></o:p></span></span></b></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;">C:\>javac complexnum.java<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;">C:\>java complexnum<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><span style="font-size: large;">3+i4<o:p></o:p></span></span></div>
<br /></div>
Bagadhi Sateeshhttp://www.blogger.com/profile/16786636572407672825noreply@blogger.com0tag:blogger.com,1999:blog-8352540103162095489.post-45582653213544674672018-08-21T15:54:00.003+05:302018-08-21T15:57:01.282+05:30Class/Objects and Methods<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<div class="MsoNormal">
<span style="font-size: large;"><span lang="EN-US" style="font-family: "times new roman" , serif;"><o:p> </o:p></span>Defining a
Class and Object:</span></div>
<div class="MsoNormal">
<span style="font-size: large;"><b><span lang="EN-US" style="font-family: "times new roman" , "serif";">Class:</span></b><span lang="EN-US" style="font-family: "times new roman" , "serif";"> class is a user
defined data type that represents an entity, which is a collection of members
and methods.<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , "serif"; font-size: large;">The
entire set of data and code of an object can be made the user define data type
with help of a class. Infact objects are variables of type class. Once a class
has been defined, we can create any number of objects belonging to that class.<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-size: large;"><b><span lang="EN-US" style="font-family: "times new roman" , "serif";">Syntax:</span></b><span lang="EN-US" style="font-family: "times new roman" , "serif";"> <span style="mso-tab-count: 1;"> </span>class class_name<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-tab-count: 1;"> </span><span style="mso-spacerun: yes;">
</span><span style="mso-tab-count: 1;"> </span>{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-tab-count: 1;"> </span><span style="mso-spacerun: yes;"> </span><span style="mso-tab-count: 1;"> </span><span style="mso-spacerun: yes;"> </span><span style="mso-tab-count: 1;"> </span>variable
declarations/data members;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-tab-count: 3;"> </span>function
declarations/member functions;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-left: 36.0pt; text-indent: 36.0pt;">
<span lang="EN-US" style="font-family: "times new roman" , "serif"; font-size: large;">}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , "serif"; font-size: large;">The
class body contains the declarations of variables and functions, which are
called as class members. The variables declare inside the class are known as <b>data
members</b> and functions are known as <b>member functions.</b><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-size: large;"><br /></span></div>
<h3>
<span lang="EN-US" style="font-family: "times new roman" , "serif"; font-size: large;">Creating
Objects <o:p></o:p></span></h3>
<div class="MsoNormal">
<span style="font-size: large;"><b><span lang="EN-US" style="font-family: "times new roman" , "serif";">Object:
</span></b><span lang="EN-US" style="font-family: "times new roman" , "serif";">is a
functionable element that is used to access the members and methods of a class.
Simply, object is an instance of class.<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , "serif"; font-size: large;">The
declaration of an object is similar to that of a variable of any basic type.<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-size: large;"><b><span lang="EN-US" style="font-family: "times new roman" , "serif";">Syntax:</span></b><span lang="EN-US" style="font-family: "times new roman" , "serif";"> classname
obj_name=new classname();<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span style="font-size: large;"><b><span lang="EN-US" style="font-family: "times new roman" , "serif";">Example:</span></b><span lang="EN-US" style="font-family: "times new roman" , "serif";"> student s=new
student();<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , "serif"; font-size: large;">where
s is an object of class student.<o:p></o:p></span></div>
<h1>
<b><span lang="EN-US" style="font-family: "times new roman" , "serif";"><span style="font-size: large;">Accessing
class members</span></span></b></h1>
<div class="MsoBodyText">
<span lang="EN-US" style="font-family: "times new roman" , "serif"; font-size: large;">Once
an object of a class has been created there must be a provision to access its
members. This is done by using the member access operator (.) called as dot.<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-size: large;"><b><span lang="EN-US" style="font-family: "times new roman" , "serif";">Syntax:</span></b><span lang="EN-US" style="font-family: "times new roman" , "serif";"><o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-tab-count: 1;"> </span>Object_name.datamember=value;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-tab-count: 1;"> </span>Object_name.memberfunction(actual_args);<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-size: large;"><br /></span></div>
<div class="MsoNormal">
<span style="font-size: large;"><b><span lang="EN-US" style="font-family: "times new roman" , "serif";">Example:</span></b><span lang="EN-US" style="font-family: "times new roman" , "serif";"><o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-tab-count: 1;"> </span>s.a=10;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-tab-count: 1;"> </span>s.display();<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-size: large;"><br /></span></div>
<div class="MsoNormal">
<b><span lang="EN-US" style="font-family: "times new roman" , "serif"; font-size: large;">Example
program:<o:p></o:p></span></b></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , "serif"; font-size: large;">class
student<span style="mso-spacerun: yes;"> </span>//userdefined class<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , "serif"; font-size: large;">{<span style="mso-tab-count: 1;"> </span><o:p></o:p></span></div>
<div class="MsoNormal" style="text-indent: 36.0pt;">
<span lang="EN-US" style="font-family: "times new roman" , "serif"; font-size: large;">int sno=10;<span style="mso-tab-count: 1;"> </span>//members/fields declaration<span style="mso-tab-count: 1;"> </span><o:p></o:p></span></div>
<div class="MsoNormal" style="text-indent: 36.0pt;">
<span lang="EN-US" style="font-family: "times new roman" , "serif"; font-size: large;">void show()<span style="mso-tab-count: 1;"> </span>//method declaration<span style="mso-tab-count: 1;"> </span><o:p></o:p></span></div>
<div class="MsoNormal" style="text-indent: 36.0pt;">
<span lang="EN-US" style="font-family: "times new roman" , "serif"; font-size: large;">{<span style="mso-tab-count: 2;"> </span><o:p></o:p></span></div>
<div class="MsoNormal" style="text-indent: 36.0pt;">
<span lang="EN-US" style="font-family: "times new roman" , "serif"; font-size: large;">System.out.println("Hai");<span style="mso-tab-count: 1;"> </span><o:p></o:p></span></div>
<div class="MsoNormal" style="text-indent: 36.0pt;">
<span lang="EN-US" style="font-family: "times new roman" , "serif"; font-size: large;">}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , "serif"; font-size: large;">}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , "serif"; font-size: large;">class
simple<span style="mso-tab-count: 1;"> </span><o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , "serif"; font-size: large;">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-tab-count: 1;"> </span>public static void main(String
[]args)<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-tab-count: 1;"> </span>{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-tab-count: 2;"> </span>student s=new student();
//object created<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-tab-count: 2;"> </span>System.out.println("Sno="+s.sno);<span style="mso-spacerun: yes;"> </span>//accessing members of class<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-tab-count: 2;"> </span>s.show();<span style="mso-tab-count: 1;"> </span>//calling method<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-tab-count: 1;"> </span>}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , "serif"; font-size: large;">}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , "serif"; font-size: large;">Output:<b>C:\>javac
simple.java</b><o:p></o:p></span></div>
<h2>
<span lang="EN-US" style="font-family: "times new roman" , "serif"; font-size: large; font-weight: normal;">C:\>java simple<o:p></o:p></span></h2>
<h2>
<span lang="EN-US" style="font-family: "times new roman" , "serif"; font-size: large; font-weight: normal;">Sno=10<o:p></o:p></span></h2>
<h2>
<span lang="EN-US" style="font-family: "times new roman" , "serif"; font-size: large; font-weight: normal;">Hai<o:p></o:p></span></h2>
<br /></div>
Bagadhi Sateeshhttp://www.blogger.com/profile/16786636572407672825noreply@blogger.com0tag:blogger.com,1999:blog-8352540103162095489.post-2793975105326890092018-08-21T15:49:00.002+05:302018-08-21T15:56:11.841+05:30Decision Making and Branching, Decision Making and Looping and Jumps in Loops<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="font-size: large;"><br /></span>
<h4>
<span lang="EN-US" style="font-family: "times new roman" , "serif"; font-size: large;">Decision
Making and Branching<o:p></o:p></span></h4>
<div class="MsoNormal">
<b><span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;">Decision Making with If statement</span></b></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;">The general form of simple statement is <o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-tab-count: 2;"> </span>if(test
expression)<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-left: 72.0pt; text-indent: 36.0pt;">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;">{<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-left: 72.0pt; text-indent: 36.0pt;">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;">Statement-block;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-left: 72.0pt; text-indent: 36.0pt;">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;">}<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-left: 72.0pt; text-indent: 36.0pt;">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;">Statement
–x;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-left: 72.0pt; text-indent: 36.0pt;">
<span style="font-size: large;"><br /></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-tab-count: 1;"> </span>The statement
block may be a single statement or a group of statements. If the test
expression is true, the statement-block will executed; otherwise the
statement-block will be skipped and the execution will jump to the statement-x<o:p></o:p></span></div>
<div class="MsoNormal">
<b><span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;">Example:<o:p></o:p></span></b></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;">class gross<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-tab-count: 1;"> </span>public static
void main(String []args)<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-tab-count: 1;"> </span>{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-tab-count: 1;"> </span><span style="mso-tab-count: 1;"> </span>float gross_sal,net_sal=0.0f;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-tab-count: 2;"> </span>gross_sal=Float.valueOf(args[0]).floatValue();<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-tab-count: 2;"> </span>if(gross_sal<10000.0f)<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-tab-count: 3;"> </span>net_sal=gross_sal;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-tab-count: 2;"> </span>if(gross_sal>=10000.0f)<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-tab-count: 3;"> </span>net_sal=gross_sal-0.15f*gross_sal;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-tab-count: 2;"> </span>System.out.println("Net
Salary is Rs " + net_sal);<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-tab-count: 1;"> </span>}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;">}<o:p></o:p></span></div>
<div class="MsoNormal">
<b><span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;">Output: <o:p></o:p></span></b></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;">D:\ >javac gross.java<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;">D:\ >java gross 4.5<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;">Net Salary is Rs 4.5<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;">D:\ >java gross 12876.7<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;">Net Salary is Rs 10945.195<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-size: large;"><br /></span></div>
<div class="MsoNormal">
<b><span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;">If else Statement<o:p></o:p></span></b></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;">the if-else statement is an extension of the simple if statement.
The general form is..<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-tab-count: 1;"> </span>if(test
expression)<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-tab-count: 2;"> </span>{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-tab-count: 3;"> </span>True-block
statement(s)<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-tab-count: 2;"> </span>}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-tab-count: 1;"> </span>Else<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-tab-count: 2;"> </span>{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-tab-count: 3;"> </span>False-block
statement(s)<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-left: 36.0pt; text-indent: 36.0pt;">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;">}<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-left: 36.0pt; text-indent: 36.0pt;">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;">Statement-x;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;">If the test expression is true then the true-block statement(s)
immediately following the if statement are executed; otherwise the false-block
statement(s) are executed. In either case, either true-block or false-block
will be executed, not both.<o:p></o:p></span></div>
<h3>
<span lang="EN-US" style="font-family: "times new roman" , "serif"; font-size: large;">The
following is the example of <o:p></o:p></span></h3>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;">class evenodd<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-tab-count: 1;"> </span>public static
void main(String []args)<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-tab-count: 1;"> </span>{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-tab-count: 2;"> </span>int
num=Integer.parseInt(args[0]);<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-tab-count: 2;"> </span>if(num%2==0)<span style="mso-tab-count: 1;"> </span><o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-tab-count: 3;"> </span>System.out.println(num
+ " is even");<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-tab-count: 2;"> </span>else<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-tab-count: 3;"> </span>System.out.println(num
+ " is odd");<span style="mso-tab-count: 1;"> </span><o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-tab-count: 1;"> </span>}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;">}<o:p></o:p></span></div>
<div class="MsoNormal">
<b><span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;">Output:<o:p></o:p></span></b></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;">D:\ \programs>javac evenodd.java<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;">D:\ \programs>java evenodd 6<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;">6 is even<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;">D:\ \programs>java evenodd 5<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;">5 is odd<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-size: large;"><br /></span></div>
<div class="MsoNormal">
<b><span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;">Nesting If Else Statement<o:p></o:p></span></b></div>
<div class="MsoBodyText">
<span lang="EN-US" style="font-family: "times new roman" , "serif"; font-size: large;">When
a series of decisions are involved, we may have to use more than one if..else
statement in nested form as follows:<o:p></o:p></span></div>
<pre style="margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 36.0pt; margin-right: 36.0pt; margin-top: 0cm;"><span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;">IF (logical-expression) <o:p></o:p></span></pre>
<pre style="margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 36.0pt; margin-right: 36.0pt; margin-top: 0cm;"><span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;">{<o:p></o:p></span></pre>
<pre style="margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 36.0pt; margin-right: 36.0pt; margin-top: 0cm;"><span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-spacerun: yes;"> </span>IF (logical-expression) {<o:p></o:p></span></pre>
<pre style="margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 36.0pt; margin-right: 36.0pt; margin-top: 0cm;"><span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-spacerun: yes;"> </span>Statements<span style="mso-spacerun: yes;"> </span>}<o:p></o:p></span></pre>
<pre style="margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 36.0pt; margin-right: 36.0pt; margin-top: 0cm;"><span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-spacerun: yes;"> </span>ELSE<o:p></o:p></span></pre>
<pre style="margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 36.0pt; margin-right: 36.0pt; margin-top: 0cm;"><span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-spacerun: yes;"> </span>{<span style="mso-spacerun: yes;"> </span>statements<span style="mso-spacerun: yes;"> </span>}<o:p></o:p></span></pre>
<pre style="margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 36.0pt; margin-right: 36.0pt; margin-top: 0cm;"><span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-spacerun: yes;"> </span>statements<o:p></o:p></span></pre>
<pre style="margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 36.0pt; margin-right: 36.0pt; margin-top: 0cm;"><span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;">ELSE<o:p></o:p></span></pre>
<pre style="margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 36.0pt; margin-right: 36.0pt; margin-top: 0cm;"><span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-spacerun: yes;"> </span>statements<o:p></o:p></span></pre>
<pre style="margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 36.0pt; margin-right: 36.0pt; margin-top: 0cm;"><span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-spacerun: yes;"> </span>IF (logical-expression) {<o:p></o:p></span></pre>
<pre style="margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 36.0pt; margin-right: 36.0pt; margin-top: 0cm; tab-stops: 36.0pt;"><span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-spacerun: yes;"> </span>statements<o:p></o:p></span></pre>
<pre style="margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 36.0pt; margin-right: 36.0pt; margin-top: 0cm;"><span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-spacerun: yes;"> </span>}<o:p></o:p></span></pre>
<pre style="margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 36.0pt; margin-right: 36.0pt; margin-top: 0cm;"><span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-spacerun: yes;"> </span>statements<o:p></o:p></span></pre>
<pre style="margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 36.0pt; margin-right: 36.0pt; margin-top: 0cm; tab-stops: 36.0pt;"><span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;">}<o:p></o:p></span></pre>
<pre style="margin-right: 36.0pt; tab-stops: 36.0pt;"><b><span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;">Program:<o:p></o:p></span></b></pre>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;">class nestedif<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-tab-count: 1;"> </span>public static
void main(String []args)<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-tab-count: 1;"> </span>{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-tab-count: 2;"> </span>int
a=325,b=712,c=478;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-tab-count: 2;"> </span>System.out.print("Largest
value is:");<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-tab-count: 2;"> </span>if(a>b)<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-tab-count: 2;"> </span>{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-tab-count: 3;"> </span>if(a>c)<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-tab-count: 3;"> </span>{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-tab-count: 4;"> </span>System.out.print(a);<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-tab-count: 3;"> </span>}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-tab-count: 3;"> </span>else<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-tab-count: 3;"> </span>{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-tab-count: 4;"> </span>System.out.print(c);<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-tab-count: 3;"> </span>}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-tab-count: 2;"> </span>}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-tab-count: 2;"> </span>else<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-tab-count: 2;"> </span>{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-tab-count: 3;"> </span>if(c>b)<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-tab-count: 3;"> </span>{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-tab-count: 4;"> </span>System.out.print(c);<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-tab-count: 3;"> </span>}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-tab-count: 3;"> </span>else<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-tab-count: 3;"> </span>{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-tab-count: 4;"> </span>System.out.print(b);<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-tab-count: 3;"> </span>}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-tab-count: 2;"> </span>}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-tab-count: 1;"> </span>}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;">}<o:p></o:p></span></div>
<div class="MsoNormal">
<b><span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;">Output:<o:p></o:p></span></b></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;">D:\ \programs>javac nestedif.java<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;">D:\ \programs>java nestedif<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;">Largest value is: 712<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-size: large;"><br /></span></div>
<div class="MsoNormal">
<b><span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;">ElseIf Ladder<o:p></o:p></span></b></div>
<div class="MsoBodyText">
<span lang="EN-US" style="font-family: "times new roman" , "serif"; font-size: large;">The
conditions are evaluated from the top. As soon as the true condition is found,
the statement associated with it is executed and the control is transferred to
the statement-x. When all the n conditions become false, then the final else
containing the default-statement will be executed.<o:p></o:p></span></div>
<div class="MsoBodyText">
<span lang="EN-US" style="font-family: "times new roman" , "serif"; font-size: large;">The
general form is:<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;">if(condition1)<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-tab-count: 1;"> </span>Statement-1;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;">else if(condition 2)<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-tab-count: 1;"> </span>Statement –2;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;">else if(condition 3)<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-tab-count: 1;"> </span>Statement –3;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;">----------------------<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;">else if(condition n)<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-tab-count: 1;"> </span>statement –n;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;">else<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-tab-count: 1;"> </span>default
statement;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;">statement-x;<o:p></o:p></span></div>
<div class="MsoNormal">
<b><span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;">Program:<o:p></o:p></span></b></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;">class elsif<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-tab-count: 1;"> </span>public static void
main(String []args)<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-tab-count: 1;"> </span>{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-tab-count: 2;"> </span>int
per=Integer.parseInt(args[0]);<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-tab-count: 2;"> </span>char
grade;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-tab-count: 2;"> </span>if(per>=90)<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-tab-count: 3;"> </span>grade='A';<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-tab-count: 2;"> </span>else
if(per>=75)<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-tab-count: 3;"> </span>grade='B';<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-tab-count: 2;"> </span>else
if(per>=60)<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-tab-count: 3;"> </span>grade='C';<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-tab-count: 2;"> </span>else
if(per>=50)<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-tab-count: 3;"> </span>grade='D';<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-tab-count: 2;"> </span>else<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-tab-count: 3;"> </span>grade='F';<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-tab-count: 2;"> </span>System.out.println("Grade="
+grade);<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-tab-count: 1;"> </span>}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;">}<o:p></o:p></span></div>
<div class="MsoNormal">
<b><span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;">Output:<o:p></o:p></span></b></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;">D:\ \programs>javac elsif.java<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;">D:\ \programs>java elsif 67<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;">Grade=C<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-size: large;"><br /></span></div>
<div class="MsoNormal">
<b><span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;">The switch Statement <o:p></o:p></span></b></div>
<div class="MsoBodyText">
<span lang="EN-US" style="font-family: "times new roman" , "serif"; font-size: large;">The
switch statement tests the value of a given variable (or expression) against a
list of case values and when a match is found a block of statements associated
with that case is executed. The general form of the switch statement is as
shown below:<o:p></o:p></span></div>
<div class="MsoBodyText">
<span style="font-size: large;"><br /></span></div>
<div class="MsoBodyText">
<span lang="EN-US" style="font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-tab-count: 3;"> </span>switch(expression)<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-tab-count: 3;"> </span>{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-tab-count: 4;"> </span>case
value 1:<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-tab-count: 7;"> </span>block1;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-tab-count: 7;"> </span>break;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-tab-count: 4;"> </span>case
value2:<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-tab-count: 7;"> </span>block2;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-tab-count: 7;"> </span>break;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-tab-count: 4;"> </span>………………<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-tab-count: 4;"> </span>………………<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-tab-count: 4;"> </span>default:<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-tab-count: 7;"> </span>default-block;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-tab-count: 7;"> </span>break;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-tab-count: 3;"> </span>}<o:p></o:p></span></div>
<div class="MsoNormal">
<b><span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;">Example:<o:p></o:p></span></b></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;">class color<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;">public static void main(String args[])<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;">String ch=args[0];<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;">char choice=ch.charAt(0);<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;">System.out.println("Press B for Blue<span style="mso-spacerun: yes;"> </span>");<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;">System.out.println("Press G for Green ");<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;">System.out.println("Press R for Red<span style="mso-spacerun: yes;"> </span>");<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-size: large;"><br /></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;">switch(choice)<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;">case 'B':<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;">case 'b':<span style="mso-tab-count: 1;"> </span>System.out.println("You
choose Blue color");<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-tab-count: 2;"> </span>break;<o:p></o:p></span></div>
<div class="MsoBodyText">
<span lang="EN-US" style="font-family: "times new roman" , "serif"; font-size: large;">case
'G':<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;">case 'g':<span style="mso-tab-count: 1;"> </span>System.out.println("You
choose Green color");<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-tab-count: 2;"> </span>break;<span style="mso-tab-count: 1;"> </span><o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;">case 'r':<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;">case 'R':<span style="mso-tab-count: 1;"> </span>System.out.println("You
choose Red color");<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-tab-count: 2;"> </span>break;<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-size: large;"><br /></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;">default:<span style="mso-tab-count: 1;"> </span>System.out.println("invalid
choice");<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;">}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;">}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;">}<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-size: large;"><br /></span></div>
<div class="MsoNormal">
<b><span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;">The ?: operator.<o:p></o:p></span></b></div>
<div style="text-align: justify;">
<span style="font-size: large;"><span lang="EN-US" style="font-family: "times new roman" , "serif";">The
value of a variable often depends on whether a particular Boolean expression is
or is not true and on nothing else. For instance one common operation is
setting the value of a variable to the maximum of two quantities<span style="mso-spacerun: yes;"> </span>Is </span><code><span lang="EN-US" style="font-family: "times new roman" , "serif";"><o:p></o:p></span></code></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm; text-align: justify;">
<span style="font-size: large;"><code><span lang="EN-US" style="font-family: "times new roman" , "serif";"><span style="mso-spacerun: yes;"> </span>(a > b) ? a : b;</span></code><span lang="EN-US" style="font-family: "times new roman" , "serif";"> is an expression
which returns one of two values, </span><code><span lang="EN-US" style="font-family: "times new roman" , "serif";">a</span></code><span lang="EN-US" style="font-family: "times new roman" , "serif";"> or </span><code><span lang="EN-US" style="font-family: "times new roman" , "serif";">b</span></code><span lang="EN-US" style="font-family: "times new roman" , "serif";">. The condition, </span><code><span lang="EN-US" style="font-family: "times new roman" , "serif";">(a
> b)</span></code><span lang="EN-US" style="font-family: "times new roman" , "serif";">,
is tested. If it is true the first value, </span><code><span lang="EN-US" style="font-family: "times new roman" , "serif";">a</span></code><span lang="EN-US" style="font-family: "times new roman" , "serif";">, is returned. If it
is false, the second value, </span><code><span lang="EN-US" style="font-family: "times new roman" , "serif";">b</span></code><span lang="EN-US" style="font-family: "times new roman" , "serif";">, is returned. Whichever value is
returned is dependent on the conditional test, </span><code><span lang="EN-US" style="font-family: "times new roman" , "serif";">a > b</span></code><span lang="EN-US" style="font-family: "times new roman" , "serif";">. The condition can be
any expression, which returns a boolean value.<o:p></o:p></span></span></div>
<div class="MsoNormal">
<b><span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;">Example:<o:p></o:p></span></b></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;">class conditional<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;">public static void main(String args[])<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;">int a,b;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;">a=Integer.parseInt(args[0]);<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;">b=Integer.parseInt(args[1]);<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;">int max;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;">max=(a>b)? a : b;<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;">System.out.println("max="+max);<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;">}<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;">}<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-size: large;"><br /></span></div>
<div class="MsoNormal" style="margin-left: 72.0pt; text-indent: 36.0pt;">
<b><span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;">Decision Making and Looping<o:p></o:p></span></b></div>
<div class="MsoNormal">
<b><span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;">The while statement <o:p></o:p></span></b></div>
<div class="MsoNormal">
<span style="font-size: large;"><span lang="EN-US" style="font-family: "times new roman" , "serif";">The
</span><code><span lang="EN-US" style="font-family: "times new roman" , "serif";">while</span></code><span lang="EN-US" style="font-family: "times new roman" , "serif";"> statement evaluates <i>expression</i>,
which must return a </span><code><span lang="EN-US" style="font-family: "times new roman" , "serif";">boolean</span></code><span lang="EN-US" style="font-family: "times new roman" , "serif";"> value. If the expression
evaluates to </span><code><span lang="EN-US" style="font-family: "times new roman" , "serif";">true</span></code><span lang="EN-US" style="font-family: "times new roman" , "serif";">, the </span><code><span lang="EN-US" style="font-family: "times new roman" , "serif";">while</span></code><span lang="EN-US" style="font-family: "times new roman" , "serif";"> statement executes
the <em>statement</em>(s) in the </span><code><span lang="EN-US" style="font-family: "times new roman" , "serif";">while</span></code><span lang="EN-US" style="font-family: "times new roman" , "serif";"> block. The </span><code><span lang="EN-US" style="font-family: "times new roman" , "serif";">while</span></code><span lang="EN-US" style="font-family: "times new roman" , "serif";"> statement continues
testing the expression and executing its block until the expression evaluates
to </span><code><span lang="EN-US" style="font-family: "times new roman" , "serif";">false</span></code><span lang="EN-US" style="font-family: "times new roman" , "serif";">. <o:p></o:p></span></span></div>
<div class="MsoNormal">
<span style="font-size: large;"><b><span lang="EN-US" style="font-family: "times new roman" , "serif";">Syntax:</span></b><span lang="EN-US" style="font-family: "times new roman" , "serif";"><span style="mso-spacerun: yes;"> </span>While(expression){<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-spacerun: yes;"> </span>Statements; }<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-size: large;"><b><span lang="EN-US" style="font-family: "times new roman" , "serif";">Using
the </span></b><code><b><span lang="EN-US" style="font-family: "times new roman" , "serif";">while</span></b></code><b><span lang="EN-US" style="font-family: "times new roman" , "serif";"> statement to print the values
from 1 through 10 can be accomplished as in the following </span></b><span lang="EN-US"><a href="http://java.sun.com/docs/books/tutorial/java/nutsandbolts/examples/WhileDemo.java" target="_blank"><code><b><span style="color: black; font-family: "times new roman" , "serif"; text-decoration: none;">WhileDemo</span></b></code></a></span><b><span lang="EN-US" style="color: black; font-family: "times new roman" , "serif";"> </span></b><b><span lang="EN-US" style="font-family: "times new roman" , "serif";">program: </span></b><b><span lang="EN-US" style="font-family: "times new roman" , "serif"; mso-fareast-font-family: "Arial Unicode MS";"><o:p></o:p></span></b></span></div>
<pre style="tab-stops: 36.0pt;"><span lang="EN-US" style="font-family: "times new roman" , "serif"; font-size: large;">class WhileDemo {<o:p></o:p></span></pre>
<pre style="tab-stops: 36.0pt;"><span lang="EN-US" style="font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-spacerun: yes;"> </span>public static void main(String[ ] args){<o:p></o:p></span></pre>
<pre style="tab-stops: 36.0pt;"><span lang="EN-US" style="font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-spacerun: yes;"> </span>int count = 1;<o:p></o:p></span></pre>
<pre style="tab-stops: 36.0pt;"><span lang="EN-US" style="font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-spacerun: yes;"> </span>while (count < 11) {<o:p></o:p></span></pre>
<pre style="tab-stops: 36.0pt;"><span lang="EN-US" style="font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-spacerun: yes;"> </span>System.out.println("Count is: " + count);<o:p></o:p></span></pre>
<pre style="tab-stops: 36.0pt;"><span lang="EN-US" style="font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-spacerun: yes;"> </span>count++;<o:p></o:p></span></pre>
<pre style="tab-stops: 36.0pt;"><span lang="EN-US" style="font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-spacerun: yes;"> </span>}<o:p></o:p></span></pre>
<pre style="tab-stops: 36.0pt;"><span lang="EN-US" style="font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-spacerun: yes;"> </span>}<o:p></o:p></span></pre>
<pre style="tab-stops: 36.0pt;"><span lang="EN-US" style="font-family: "times new roman" , "serif"; font-size: large;">}<o:p></o:p></span></pre>
<div class="MsoNormal">
<span style="font-size: large;"><br /></span></div>
<div class="MsoNormal">
<b><span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;">The do-while statement <o:p></o:p></span></b></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="font-size: large;"><span lang="EN-US" style="font-family: "times new roman" , "serif";">The Java programming language also provides a </span><code><span lang="EN-US" style="font-family: "times new roman" , "serif";">do-while</span></code><span lang="EN-US" style="font-family: "times new roman" , "serif";"> statement, which can
be expressed as follows: <o:p></o:p></span></span></div>
<pre style="tab-stops: 36.0pt;"><span style="font-size: large;"><b><span lang="EN-US" style="font-family: "times new roman" , "serif";">Syntax</span></b><span lang="EN-US" style="font-family: "times new roman" , "serif";">:<span style="mso-tab-count: 1;"> </span>do {<o:p></o:p></span></span></pre>
<pre style="margin-left: 36.0pt; tab-stops: 36.0pt; text-indent: 36.0pt;"><span lang="EN-US" style="font-family: "times new roman" , "serif"; font-size: large;">statement(s)<o:p></o:p></span></pre>
<pre style="margin-left: 36.0pt; tab-stops: 36.0pt; text-indent: 36.0pt;"><span lang="EN-US" style="font-family: "times new roman" , "serif"; font-size: large;">} while (expression);<o:p></o:p></span></pre>
<div class="MsoNormal">
<span style="font-size: large;"><span lang="EN-US" style="font-family: "times new roman" , "serif";">The
difference between </span><code><span lang="EN-US" style="font-family: "times new roman" , "serif";">do-while</span></code><span lang="EN-US" style="font-family: "times new roman" , "serif";"> and </span><code><span lang="EN-US" style="font-family: "times new roman" , "serif";">while</span></code><span lang="EN-US" style="font-family: "times new roman" , "serif";"> is that </span><code><span lang="EN-US" style="font-family: "times new roman" , "serif";">do-while</span></code><span lang="EN-US" style="font-family: "times new roman" , "serif";"> evaluates its
expression at the bottom of the loop instead of the top. Therefore, the
statements within the </span><code><span lang="EN-US" style="font-family: "times new roman" , "serif";">do</span></code><span lang="EN-US" style="font-family: "times new roman" , "serif";"> block are always executed at
least once, as shown in the following </span><span lang="EN-US"><a href="http://java.sun.com/docs/books/tutorial/java/nutsandbolts/examples/DoWhileDemo.java" target="_blank"><code><span style="color: black; font-family: "times new roman" , "serif"; text-decoration: none;">DoWhileDemo</span></code></a></span><span lang="EN-US" style="font-family: "times new roman" , "serif";"> program: <o:p></o:p></span></span></div>
<pre style="tab-stops: 36.0pt;"><span lang="EN-US" style="font-family: "times new roman" , "serif"; font-size: large;">class DoWhileDemo {<o:p></o:p></span></pre>
<pre><span lang="EN-US" style="font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-spacerun: yes;"> </span>public static void main(String[] args){<o:p></o:p></span></pre>
<pre><span lang="EN-US" style="font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-spacerun: yes;"> </span>int count = 1;<o:p></o:p></span></pre>
<pre><span lang="EN-US" style="font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-spacerun: yes;"> </span>do {<o:p></o:p></span></pre>
<pre><span lang="EN-US" style="font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-spacerun: yes;"> </span>System.out.println("Count is: " + count);<o:p></o:p></span></pre>
<pre><span lang="EN-US" style="font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-spacerun: yes;"> </span>count++;<o:p></o:p></span></pre>
<pre><span lang="EN-US" style="font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-spacerun: yes;"> </span>} while (count <= 11);<o:p></o:p></span></pre>
<pre><span lang="EN-US" style="font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-spacerun: yes;"> </span>}<o:p></o:p></span></pre>
<pre><span lang="EN-US" style="font-family: "times new roman" , "serif"; font-size: large;">}<o:p></o:p></span></pre>
<div class="MsoNormal">
<span style="font-size: large;"><br /></span></div>
<h3>
<span lang="EN-US" style="font-family: "times new roman" , "serif"; font-size: large;">The for
statement <o:p></o:p></span></h3>
<div class="MsoNormal">
<span style="font-size: large;"><span lang="EN-US" style="font-family: "times new roman" , "serif";">The
</span><code><span lang="EN-US" style="font-family: "times new roman" , "serif";">for</span></code><span lang="EN-US" style="font-family: "times new roman" , "serif";"> statement provides a
compact way to iterate over a range of values.<b><span style="color: black;"><o:p></o:p></span></b></span></span></div>
<div class="MsoNormal">
<span style="font-size: large;"><span lang="EN-US" style="font-family: "times new roman" , "serif";">The
general form of the </span><code><span lang="EN-US" style="font-family: "times new roman" , "serif";">for</span></code><span lang="EN-US" style="font-family: "times new roman" , "serif";"> statement can be expressed as
follows: </span><span lang="EN-US" style="font-family: "times new roman" , "serif"; mso-fareast-font-family: "Arial Unicode MS";"><o:p></o:p></span></span></div>
<pre style="text-align: justify;"><span lang="EN-US" style="font-family: "times new roman" , "serif"; font-size: large;">for (<em>initialization</em>; <em>termination</em>; <em>increment</em>) {<o:p></o:p></span></pre>
<pre style="text-align: justify;"><span lang="EN-US" style="font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-spacerun: yes;"> </span><em>statement(s)</em><o:p></o:p></span></pre>
<pre style="tab-stops: 36.0pt; text-align: justify;"><span lang="EN-US" style="font-family: "times new roman" , "serif"; font-size: large;">}<o:p></o:p></span></pre>
<div class="MsoNormal">
<span style="font-size: large;"><span lang="EN-US" style="font-family: "times new roman" , "serif";">When
using this version of the </span><code><span lang="EN-US" style="font-family: "times new roman" , "serif";">for</span></code><span lang="EN-US" style="font-family: "times new roman" , "serif";"> statement, keep in mind that: <o:p></o:p></span></span></div>
<ul style="margin-top: 0cm;" type="disc">
<li class="MsoNormal" style="mso-list: l1 level1 lfo1; tab-stops: list 36.0pt;"><span lang="EN-US" style="font-family: "times new roman" , "serif"; font-size: large;">The <em>initialization</em>
expression initializes the loop; it's executed once, as the loop begins. <o:p></o:p></span></li>
<li class="MsoNormal" style="mso-list: l1 level1 lfo1; tab-stops: list 36.0pt;"><span style="font-size: large;"><span lang="EN-US" style="font-family: "times new roman" , "serif";">When the <em>termination</em>
expression evaluates to </span><code><span lang="EN-US" style="font-family: "times new roman" , "serif";">false</span></code><span lang="EN-US" style="font-family: "times new roman" , "serif";">, the loop
terminates. <o:p></o:p></span></span></li>
<li class="MsoNormal" style="mso-list: l1 level1 lfo1; tab-stops: list 36.0pt;"><span lang="EN-US" style="font-family: "times new roman" , "serif"; font-size: large;">The <em>increment</em>
expression is invoked after each iteration through the loop; it is
perfectly acceptable for this expression to increment <i>or</i> decrement
a value. <o:p></o:p></span></li>
</ul>
<div style="margin-bottom: .0001pt; margin: 0cm; text-align: justify;">
<span style="font-size: large;"><b><span lang="EN-US" style="font-family: "times new roman" , "serif";">The following program,
</span></b><code><b><span lang="EN-US" style="font-family: "times new roman" , "serif";">For
Demo</span></b></code><b><span lang="EN-US" style="font-family: "times new roman" , "serif";">,
uses the general form of the </span></b><code><b><span lang="EN-US" style="font-family: "times new roman" , "serif";">for</span></b></code><b><span lang="EN-US" style="font-family: "times new roman" , "serif";"> statement to print
the numbers 1 through 10 to standard output: <o:p></o:p></span></b></span></div>
<pre style="text-align: justify;"><span lang="EN-US" style="font-family: "times new roman" , "serif"; font-size: large;">class ForDemo <o:p></o:p></span></pre>
<pre style="text-align: justify;"><span lang="EN-US" style="font-family: "times new roman" , "serif"; font-size: large;">{<o:p></o:p></span></pre>
<pre style="text-align: justify;"><span lang="EN-US" style="font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-spacerun: yes;"> </span>public static void main(String[] args){<o:p></o:p></span></pre>
<pre style="text-align: justify;"><span lang="EN-US" style="font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-spacerun: yes;"> </span>for(int i=1; i<11; i++){<o:p></o:p></span></pre>
<pre style="tab-stops: 36.0pt; text-align: justify;"><span lang="EN-US" style="font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-spacerun: yes;"> </span>System.out.println("Count is: " + i);<o:p></o:p></span></pre>
<pre style="text-align: justify;"><span lang="EN-US" style="font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-spacerun: yes;"> </span>}<o:p></o:p></span></pre>
<pre style="text-align: justify;"><span lang="EN-US" style="font-family: "times new roman" , "serif"; font-size: large;"><span style="mso-spacerun: yes;"> </span>}<o:p></o:p></span></pre>
<pre style="text-align: justify;"><span lang="EN-US" style="font-family: "times new roman" , "serif"; font-size: large;">}<o:p></o:p></span></pre>
<div class="MsoNormal">
<span style="font-size: large;"><br /></span></div>
<div class="MsoNormal">
<b><span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;">Jumps in Loops<o:p></o:p></span></b></div>
<div class="MsoBodyText">
<span lang="EN-US" style="font-family: "times new roman" , "serif"; font-size: large;">Java
supports three types of jumping statements:<o:p></o:p></span></div>
<ul style="margin-top: 0cm;" type="disc">
<li class="MsoNormal" style="color: black; mso-list: l0 level1 lfo2; tab-stops: list 36.0pt;"><span lang="EN-US" style="font-family: "times new roman" , "serif"; font-size: large;">Break<o:p></o:p></span></li>
<li class="MsoNormal" style="color: black; mso-list: l0 level1 lfo2; tab-stops: list 36.0pt;"><span lang="EN-US" style="font-family: "times new roman" , "serif"; font-size: large;">Continue<o:p></o:p></span></li>
<li class="MsoNormal" style="color: black; mso-list: l0 level1 lfo2; tab-stops: list 36.0pt;"><span style="font-size: large;"><span lang="EN-US" style="font-family: "times new roman" , "serif";">Return</span><span lang="EN-US" style="font-family: "times new roman" , "serif";"><o:p></o:p></span></span></li>
</ul>
<div class="MsoBodyText2" style="tab-stops: 36.0pt;">
<span style="font-size: large;"><br /></span></div>
<div class="MsoBodyText2" style="tab-stops: 36.0pt;">
<b><span lang="EN-US" style="font-family: "times new roman" , "serif"; font-size: large;">Break:<o:p></o:p></span></b></div>
<div class="MsoBodyText2" style="tab-stops: 36.0pt;">
<span style="font-size: large;"><span lang="EN-US" style="font-family: "times new roman" , "serif";">Some times we need to exit from a
loop before the completion of the loop then we use break statement and exit
from the loop and loop is terminated.</span><b><span lang="EN-US" style="font-family: "times new roman" , "serif";"><o:p></o:p></span></b></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm; text-align: justify;">
<b><span lang="EN-US" style="font-family: "times new roman" , "serif"; font-size: large;">Continue:<o:p></o:p></span></b></div>
<div style="margin-bottom: .0001pt; margin: 0cm; text-align: justify;">
<span lang="EN-US" style="font-family: "times new roman" , "serif"; font-size: large;">Sometimes we do not
need to execute some statements under the loop then we use the continue
statement that stops the normal flow of the control and control returns to the
loop without executing the statements written after the continue statement. <o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm; text-align: justify;">
<b><span lang="EN-US" style="font-family: "times new roman" , "serif"; font-size: large;">Diff between break and
continue:<o:p></o:p></span></b></div>
<div style="margin-bottom: .0001pt; margin: 0cm; text-align: justify;">
<span lang="EN-US" style="font-family: "times new roman" , "serif"; font-size: large;">There is the
difference between break and continue statement that the break statement exit
control from the loop but continue statement keeps continuity in loop without
executing the statement written after the continue statement according to the
conditions.<o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm; text-align: justify;">
<b><span lang="EN-US" style="font-family: "times new roman" , "serif"; font-size: large;">Examples for break and
continue<o:p></o:p></span></b></div>
<div style="margin-bottom: .0001pt; margin: 0cm; text-align: justify;">
<span lang="EN-US" style="font-family: "times new roman" , "serif"; font-size: large;">class star<o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm; text-align: justify;">
<span lang="EN-US" style="font-family: "times new roman" , "serif"; font-size: large;">{<o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm; text-align: justify;">
<span lang="EN-US" style="font-family: "times new roman" , "serif"; font-size: large;">public static void
main(String args[])<o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm; text-align: justify;">
<span lang="EN-US" style="font-family: "times new roman" , "serif"; font-size: large;">{<o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm; text-align: justify;">
<span lang="EN-US" style="font-family: "times new roman" , "serif"; font-size: large;">loop1: for(int
i=1;i<=100;i++)<o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm; text-align: justify;">
<span lang="EN-US" style="font-family: "times new roman" , "serif"; font-size: large;">{<o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm; text-align: justify;">
<span lang="EN-US" style="font-family: "times new roman" , "serif"; font-size: large;">System.out.println();<o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm; text-align: justify;">
<span lang="EN-US" style="font-family: "times new roman" , "serif"; font-size: large;">if(i>10) break;<o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm; text-align: justify;">
<span lang="EN-US" style="font-family: "times new roman" , "serif"; font-size: large;">for(int
j=1;j<=100;j++)<o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm; text-align: justify;">
<span lang="EN-US" style="font-family: "times new roman" , "serif"; font-size: large;">{<o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm; text-align: justify;">
<span lang="EN-US" style="font-family: "times new roman" , "serif"; font-size: large;">System.out.print("*");<o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm; text-align: justify;">
<span lang="EN-US" style="font-family: "times new roman" , "serif"; font-size: large;">if(i==j)continue
loop1;<o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm; text-align: justify;">
<span lang="EN-US" style="font-family: "times new roman" , "serif"; font-size: large;">}<o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm; text-align: justify;">
<span lang="EN-US" style="font-family: "times new roman" , "serif"; font-size: large;">}<o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm; text-align: justify;">
<span lang="EN-US" style="font-family: "times new roman" , "serif"; font-size: large;">}<o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm; text-align: justify;">
<span lang="EN-US" style="font-family: "times new roman" , "serif"; font-size: large;">}<o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm; text-align: justify;">
<span style="font-size: large;"><br /></span></div>
<div class="MsoNormal">
<b><span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;">Return Statement:<o:p></o:p></span></b></div>
<div class="MsoNormal">
<span lang="EN-US" style="color: black; font-family: "times new roman" , "serif"; font-size: large;">It is used to explicitly return from the current method. The flow
of control transfers back to the caller of the method. To return a value,
simply put the value after the return keyword.<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-size: large;"><br /></span></div>
<br /></div>
Bagadhi Sateeshhttp://www.blogger.com/profile/16786636572407672825noreply@blogger.com0tag:blogger.com,1999:blog-8352540103162095489.post-54038182238649224892018-08-14T17:23:00.001+05:302018-08-14T17:23:23.012+05:30Operators and Expressions<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<div class="MsoNormal">
<b><span lang="EN-US" style="color: black; font-family: "Times New Roman","serif"; font-size: 14.0pt;">Operators and Expressions<o:p></o:p></span></b></div>
<div class="MsoBodyText">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">An
operator is a symbol that tells the computer to perform certain mathematical or
logical manipulations. Operators are used in program to manipulate data and
variables. The data item that operators act upon is called operands. <o:p></o:p></span></div>
<div class="MsoBodyText">
<b><span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 14.0pt;">Types of Operators:<o:p></o:p></span></b></div>
<div class="MsoBodyText" style="margin-left: 36.0pt; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-indent: -18.0pt;">
<!--[if !supportLists]--><span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-fareast-font-family: "Times New Roman";"><span style="mso-list: Ignore;">1.<span style="font: 7.0pt "Times New Roman";">
</span></span></span><!--[endif]--><span lang="EN-US" style="font-family: "Times New Roman","serif";">Arithmetic
Operators <o:p></o:p></span></div>
<div class="MsoBodyText" style="margin-left: 36.0pt; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-indent: -18.0pt;">
<!--[if !supportLists]--><span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 14.0pt; mso-fareast-font-family: "Times New Roman";"><span style="mso-list: Ignore;">2.<span style="font: 7.0pt "Times New Roman";">
</span></span></span><!--[endif]--><span lang="EN-US" style="font-family: "Times New Roman","serif";">Relational
Operators</span><span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 14.0pt;"><o:p></o:p></span></div>
<div class="MsoBodyText" style="margin-left: 36.0pt; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-indent: -18.0pt;">
<!--[if !supportLists]--><span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 14.0pt; mso-fareast-font-family: "Times New Roman";"><span style="mso-list: Ignore;">3.<span style="font: 7.0pt "Times New Roman";">
</span></span></span><!--[endif]--><span lang="EN-US" style="font-family: "Times New Roman","serif";">Logical
Operators</span><span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 14.0pt;"><o:p></o:p></span></div>
<div class="MsoBodyText" style="margin-left: 36.0pt; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-indent: -18.0pt;">
<!--[if !supportLists]--><span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 14.0pt; mso-fareast-font-family: "Times New Roman";"><span style="mso-list: Ignore;">4.<span style="font: 7.0pt "Times New Roman";">
</span></span></span><!--[endif]--><span lang="EN-US" style="font-family: "Times New Roman","serif";">Assignment
Operators</span><span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 14.0pt;"><o:p></o:p></span></div>
<div class="MsoBodyText" style="margin-left: 36.0pt; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-indent: -18.0pt;">
<!--[if !supportLists]--><span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 14.0pt; mso-fareast-font-family: "Times New Roman";"><span style="mso-list: Ignore;">5.<span style="font: 7.0pt "Times New Roman";">
</span></span></span><!--[endif]--><span lang="EN-US" style="font-family: "Times New Roman","serif";">Increment
and Decrement Operators</span><span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 14.0pt;"><o:p></o:p></span></div>
<div class="MsoBodyText" style="margin-left: 36.0pt; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-indent: -18.0pt;">
<!--[if !supportLists]--><span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 14.0pt; mso-fareast-font-family: "Times New Roman";"><span style="mso-list: Ignore;">6.<span style="font: 7.0pt "Times New Roman";">
</span></span></span><!--[endif]--><span lang="EN-US" style="font-family: "Times New Roman","serif";">Conditional
Operators</span><span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 14.0pt;"><o:p></o:p></span></div>
<div class="MsoBodyText" style="margin-left: 36.0pt; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-indent: -18.0pt;">
<!--[if !supportLists]--><span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 14.0pt; mso-fareast-font-family: "Times New Roman";"><span style="mso-list: Ignore;">7.<span style="font: 7.0pt "Times New Roman";">
</span></span></span><!--[endif]--><span lang="EN-US" style="font-family: "Times New Roman","serif";">Bitwise
Operators</span><span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 14.0pt;"><o:p></o:p></span></div>
<div class="MsoBodyText" style="margin-left: 36.0pt; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-indent: -18.0pt;">
<!--[if !supportLists]--><span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 14.0pt; mso-fareast-font-family: "Times New Roman";"><span style="mso-list: Ignore;">8.<span style="font: 7.0pt "Times New Roman";">
</span></span></span><!--[endif]--><span lang="EN-US" style="font-family: "Times New Roman","serif";">Special
Operators</span><span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 14.0pt;"><o:p></o:p></span></div>
<div class="MsoBodyText">
<br /></div>
<div class="MsoBodyText">
<b><span lang="EN-US" style="font-family: "Times New Roman","serif";">Arithmetic
Operators:<o:p></o:p></span></b></div>
<h3 style="background: white; margin-right: 3.75pt;">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-weight: normal;">Arithmetic
operators are ( +, -, *, /, % )<o:p></o:p></span></h3>
<div class="MsoNormal">
<br /></div>
<div align="center">
<table border="1" cellpadding="0" cellspacing="0" class="MsoNormalTable" style="border-collapse: collapse; border: none; margin-left: 46.75pt; mso-border-alt: solid windowtext .5pt; mso-border-insideh: .5pt solid windowtext; mso-border-insidev: .5pt solid windowtext;">
<tbody>
<tr style="mso-yfti-firstrow: yes; mso-yfti-irow: 0;">
<td style="border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; padding: .75pt .75pt .75pt .75pt; width: 71.0pt;" width="95">
<div class="MsoNormal">
<b style="mso-bidi-font-weight: normal;"><span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">Java Symbol<o:p></o:p></span></b></div>
</td>
<td style="border-left: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; padding: .75pt .75pt .75pt .75pt; width: 76.5pt;" width="102">
<div class="MsoNormal">
<b style="mso-bidi-font-weight: normal;"><span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">Meaning<o:p></o:p></span></b></div>
</td>
<td style="border-left: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; padding: .75pt .75pt .75pt .75pt; width: 67.5pt;" valign="top" width="90">
<div class="MsoNormal">
<b style="mso-bidi-font-weight: normal;"><span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">Usage <o:p></o:p></span></b></div>
</td>
</tr>
<tr style="mso-yfti-irow: 1;">
<td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: .75pt .75pt .75pt .75pt; width: 71.0pt;" width="95">
<div align="center" class="MsoNormal" style="text-align: center;">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">+</span><span lang="EN-US" style="color: black; font-family: "Times New Roman","serif"; mso-fareast-font-family: "Arial Unicode MS";"><o:p></o:p></span></div>
</td>
<td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: .75pt .75pt .75pt .75pt; width: 76.5pt;" width="102">
<div align="left" class="MsoNormal" style="text-align: left;">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">addition</span><span lang="EN-US" style="color: black; font-family: "Times New Roman","serif"; mso-fareast-font-family: "Arial Unicode MS";"><o:p></o:p></span></div>
</td>
<td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: .75pt .75pt .75pt .75pt; width: 67.5pt;" valign="top" width="90">
<div align="center" class="MsoNormal" style="text-align: center;">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">a + b<o:p></o:p></span></div>
</td>
</tr>
<tr style="mso-yfti-irow: 2;">
<td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: .75pt .75pt .75pt .75pt; width: 71.0pt;" width="95">
<div align="center" class="MsoNormal" style="text-align: center;">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">-</span><span lang="EN-US" style="color: black; font-family: "Times New Roman","serif"; mso-fareast-font-family: "Arial Unicode MS";"><o:p></o:p></span></div>
</td>
<td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: .75pt .75pt .75pt .75pt; width: 76.5pt;" width="102">
<div align="left" class="MsoNormal" style="text-align: left;">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">subtraction</span><span lang="EN-US" style="color: black; font-family: "Times New Roman","serif"; mso-fareast-font-family: "Arial Unicode MS";"><o:p></o:p></span></div>
</td>
<td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: .75pt .75pt .75pt .75pt; width: 67.5pt;" valign="top" width="90">
<div align="center" class="MsoNormal" style="text-align: center;">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">a - b<o:p></o:p></span></div>
</td>
</tr>
<tr style="mso-yfti-irow: 3;">
<td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: .75pt .75pt .75pt .75pt; width: 71.0pt;" width="95">
<div align="center" class="MsoNormal" style="text-align: center;">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">*</span><span lang="EN-US" style="color: black; font-family: "Times New Roman","serif"; mso-fareast-font-family: "Arial Unicode MS";"><o:p></o:p></span></div>
</td>
<td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: .75pt .75pt .75pt .75pt; width: 76.5pt;" width="102">
<div align="left" class="MsoNormal" style="text-align: left;">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">multiplication</span><span lang="EN-US" style="color: black; font-family: "Times New Roman","serif"; mso-fareast-font-family: "Arial Unicode MS";"><o:p></o:p></span></div>
</td>
<td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: .75pt .75pt .75pt .75pt; width: 67.5pt;" valign="top" width="90">
<div align="center" class="MsoNormal" style="text-align: center;">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">a * b<o:p></o:p></span></div>
</td>
</tr>
<tr style="mso-yfti-irow: 4;">
<td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: .75pt .75pt .75pt .75pt; width: 71.0pt;" width="95">
<div align="center" class="MsoNormal" style="text-align: center;">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">/</span><span lang="EN-US" style="color: black; font-family: "Times New Roman","serif"; mso-fareast-font-family: "Arial Unicode MS";"><o:p></o:p></span></div>
</td>
<td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: .75pt .75pt .75pt .75pt; width: 76.5pt;" width="102">
<div align="left" class="MsoNormal" style="text-align: left;">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">Division</span><span lang="EN-US" style="color: black; font-family: "Times New Roman","serif"; mso-fareast-font-family: "Arial Unicode MS";"><o:p></o:p></span></div>
</td>
<td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: .75pt .75pt .75pt .75pt; width: 67.5pt;" valign="top" width="90">
<div align="center" class="MsoNormal" style="text-align: center;">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">a / b<o:p></o:p></span></div>
</td>
</tr>
<tr style="mso-yfti-irow: 5; mso-yfti-lastrow: yes;">
<td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: .75pt .75pt .75pt .75pt; width: 71.0pt;" width="95">
<div align="center" class="MsoNormal" style="text-align: center;">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">%</span><span lang="EN-US" style="color: black; font-family: "Times New Roman","serif"; mso-fareast-font-family: "Arial Unicode MS";"><o:p></o:p></span></div>
</td>
<td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: .75pt .75pt .75pt .75pt; width: 76.5pt;" width="102">
<div align="left" class="MsoNormal" style="text-align: left;">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">Modulo</span><span lang="EN-US" style="color: black; font-family: "Times New Roman","serif"; mso-fareast-font-family: "Arial Unicode MS";"><o:p></o:p></span></div>
</td>
<td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: .75pt .75pt .75pt .75pt; width: 67.5pt;" valign="top" width="90">
<div align="center" class="MsoNormal" style="text-align: center;">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">a % b<o:p></o:p></span></div>
</td>
</tr>
</tbody></table>
</div>
<div class="MsoNormal" style="background: white; margin-right: 3.6pt;">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">Operations of
addition, subtraction, multiplication and division literally correspond with
their respective mathematical operators. The only one that you might not be so
used to see is <i>modulo</i>; whose operator is the percentage sign (</span><tt><span lang="EN-US" style="color: black; font-family: "Times New Roman","serif"; font-size: 12.0pt;">%</span></tt><span lang="EN-US" style="font-family: "Times New Roman","serif";">).
Modulo is the operation that gives the remainder of a division of two values.
For example, if we write: <o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; margin-right: 3.6pt;">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">a=11%3;<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; margin-right: 3.6pt;">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">the variable </span><tt><span lang="EN-US" style="color: black; font-family: "Times New Roman","serif"; font-size: 12.0pt;">a</span></tt><span lang="EN-US" style="font-family: "Times New Roman","serif";">
will contain the value </span><tt><span lang="EN-US" style="color: black; font-family: "Times New Roman","serif"; font-size: 12.0pt;">2</span></tt><span lang="EN-US" style="font-family: "Times New Roman","serif";">, since </span><tt><span lang="EN-US" style="color: black; font-family: "Times New Roman","serif"; font-size: 12.0pt;">2</span></tt><span lang="EN-US" style="font-family: "Times New Roman","serif";">
is the remainder from dividing </span><tt><span lang="EN-US" style="color: black; font-family: "Times New Roman","serif"; font-size: 12.0pt;">11</span></tt><span lang="EN-US" style="font-family: "Times New Roman","serif";"> between </span><tt><span lang="EN-US" style="color: black; font-family: "Times New Roman","serif"; font-size: 12.0pt;">3</span></tt><span lang="EN-US" style="font-family: "Times New Roman","serif";">.<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; margin-right: 3.6pt;">
<br /></div>
<div class="MsoBodyText">
<b><span lang="EN-US" style="font-family: "Times New Roman","serif";">Relational
Operators</span></b><b><span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 14.0pt;"><o:p></o:p></span></b></div>
<h3 style="background: white; margin-right: 3.75pt;">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-weight: normal;">Relational and
equality operators ( ==, !=, >, <, >=, <= )</span><span lang="EN-US" style="font-family: "Times New Roman","serif"; font-weight: normal; mso-fareast-font-family: "Arial Unicode MS";"><o:p></o:p></span></h3>
<div class="MsoBodyText2" style="background: white; margin-bottom: 12.0pt; margin-left: 0cm; margin-right: 3.75pt; margin-top: 0cm; tab-stops: 36.0pt;">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">In order to evaluate
a comparison between two expressions we can use the relational and equality
operators. The result of a relational operation is a Boolean value that can
only be true or false, according to its Boolean result.<br />
<br />
We may want to compare two expressions, for example, to know if they are equal
or if one is greater than the other is. <o:p></o:p></span></div>
<table border="1" cellpadding="0" cellspacing="0" class="MsoNormalTable" style="border-collapse: collapse; border: none; margin-left: 113.25pt; mso-border-alt: solid windowtext .5pt; mso-border-insideh: .5pt solid windowtext; mso-border-insidev: .5pt solid windowtext;">
<tbody>
<tr style="mso-yfti-firstrow: yes; mso-yfti-irow: 0;">
<td style="border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; padding: .75pt .75pt .75pt .75pt; width: 76.0pt;" width="101">
<div class="MsoNormal">
<b style="mso-bidi-font-weight: normal;"><span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">Java Symbol<o:p></o:p></span></b></div>
</td>
<td style="border-left: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; padding: .75pt .75pt .75pt .75pt; width: 117.5pt;" width="157">
<div class="MsoNormal">
<b style="mso-bidi-font-weight: normal;"><span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">Meaning<o:p></o:p></span></b></div>
</td>
<td style="border-left: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; padding: .75pt .75pt .75pt .75pt; width: 81.0pt;" valign="top" width="108">
<div class="MsoNormal">
<b style="mso-bidi-font-weight: normal;"><span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">Usage <o:p></o:p></span></b></div>
</td>
</tr>
<tr style="mso-yfti-irow: 1;">
<td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: .75pt .75pt .75pt .75pt; width: 76.0pt;" width="101">
<div align="center" class="MsoNormal" style="text-align: center;">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">==</span><span lang="EN-US" style="color: black; font-family: "Times New Roman","serif"; mso-fareast-font-family: "Arial Unicode MS";"><o:p></o:p></span></div>
</td>
<td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: .75pt .75pt .75pt .75pt; width: 117.5pt;" width="157">
<div align="left" class="MsoNormal" style="text-align: left;">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">Equal to</span><span lang="EN-US" style="color: black; font-family: "Times New Roman","serif"; mso-fareast-font-family: "Arial Unicode MS";"><o:p></o:p></span></div>
</td>
<td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: .75pt .75pt .75pt .75pt; width: 81.0pt;" valign="top" width="108">
<div align="center" class="MsoNormal" style="text-align: center;">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">if(a==b)<o:p></o:p></span></div>
</td>
</tr>
<tr style="mso-yfti-irow: 2;">
<td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: .75pt .75pt .75pt .75pt; width: 76.0pt;" width="101">
<div align="center" class="MsoNormal" style="text-align: center;">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">!=</span><span lang="EN-US" style="color: black; font-family: "Times New Roman","serif"; mso-fareast-font-family: "Arial Unicode MS";"><o:p></o:p></span></div>
</td>
<td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: .75pt .75pt .75pt .75pt; width: 117.5pt;" width="157">
<div align="left" class="MsoNormal" style="text-align: left;">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">Not equal to</span><span lang="EN-US" style="color: black; font-family: "Times New Roman","serif"; mso-fareast-font-family: "Arial Unicode MS";"><o:p></o:p></span></div>
</td>
<td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: .75pt .75pt .75pt .75pt; width: 81.0pt;" valign="top" width="108">
<div align="center" class="MsoNormal" style="text-align: center;">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">if(a!=b)<o:p></o:p></span></div>
</td>
</tr>
<tr style="mso-yfti-irow: 3;">
<td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: .75pt .75pt .75pt .75pt; width: 76.0pt;" width="101">
<div align="center" class="MsoNormal" style="text-align: center;">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">></span><span lang="EN-US" style="color: black; font-family: "Times New Roman","serif"; mso-fareast-font-family: "Arial Unicode MS";"><o:p> </o:p></span></div>
</td>
<td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: .75pt .75pt .75pt .75pt; width: 117.5pt;" width="157">
<div align="left" class="MsoNormal" style="text-align: left;">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">Greater than</span><span lang="EN-US" style="color: black; font-family: "Times New Roman","serif"; mso-fareast-font-family: "Arial Unicode MS";"><o:p></o:p></span></div>
</td>
<td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: .75pt .75pt .75pt .75pt; width: 81.0pt;" valign="top" width="108">
<div align="center" class="MsoNormal" style="text-align: center;">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">if(a>b)<o:p></o:p></span></div>
</td>
</tr>
<tr style="mso-yfti-irow: 4;">
<td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: .75pt .75pt .75pt .75pt; width: 76.0pt;" width="101">
<div align="center" class="MsoNormal" style="text-align: center;">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><</span><span lang="EN-US" style="color: black; font-family: "Times New Roman","serif"; mso-fareast-font-family: "Arial Unicode MS";"><o:p> </o:p></span></div>
</td>
<td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: .75pt .75pt .75pt .75pt; width: 117.5pt;" width="157">
<div align="left" class="MsoNormal" style="text-align: left;">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">Less than</span><span lang="EN-US" style="color: black; font-family: "Times New Roman","serif"; mso-fareast-font-family: "Arial Unicode MS";"><o:p></o:p></span></div>
</td>
<td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: .75pt .75pt .75pt .75pt; width: 81.0pt;" valign="top" width="108">
<div align="center" class="MsoNormal" style="text-align: center;">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">if(a<b)<o:p></o:p></span></div>
</td>
</tr>
<tr style="mso-yfti-irow: 5;">
<td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: .75pt .75pt .75pt .75pt; width: 76.0pt;" width="101">
<div align="center" class="MsoNormal" style="text-align: center;">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">>=</span><span lang="EN-US" style="color: black; font-family: "Times New Roman","serif"; mso-fareast-font-family: "Arial Unicode MS";"><o:p></o:p></span></div>
</td>
<td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: .75pt .75pt .75pt .75pt; width: 117.5pt;" width="157">
<div align="left" class="MsoNormal" style="text-align: left;">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">Greater than or
equal to</span><span lang="EN-US" style="color: black; font-family: "Times New Roman","serif"; mso-fareast-font-family: "Arial Unicode MS";"><o:p></o:p></span></div>
</td>
<td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: .75pt .75pt .75pt .75pt; width: 81.0pt;" valign="top" width="108">
<div align="center" class="MsoNormal" style="text-align: center;">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">if(a>=b)<o:p></o:p></span></div>
</td>
</tr>
<tr style="mso-yfti-irow: 6; mso-yfti-lastrow: yes;">
<td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: .75pt .75pt .75pt .75pt; width: 76.0pt;" width="101">
<div align="center" class="MsoNormal" style="text-align: center;">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"><=</span><span lang="EN-US" style="color: black; font-family: "Times New Roman","serif"; mso-fareast-font-family: "Arial Unicode MS";"><o:p></o:p></span></div>
</td>
<td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: .75pt .75pt .75pt .75pt; width: 117.5pt;" width="157">
<div align="left" class="MsoNormal" style="text-align: left;">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">Less than or equal
to</span><span lang="EN-US" style="color: black; font-family: "Times New Roman","serif"; mso-fareast-font-family: "Arial Unicode MS";"><o:p></o:p></span></div>
</td>
<td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: .75pt .75pt .75pt .75pt; width: 81.0pt;" valign="top" width="108">
<div align="center" class="MsoNormal" style="text-align: center;">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">if(a<=b)<o:p></o:p></span></div>
</td>
</tr>
</tbody></table>
<br />
<div class="MsoBodyText">
<b><span lang="EN-US" style="font-family: "Times New Roman","serif";">Logical
Operators</span></b><b><span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 14.0pt;"><o:p></o:p></span></b></div>
<h3 style="background: white; margin-right: 3.75pt;">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-weight: normal;">Logical
operators ( !, &&, || )</span><span lang="EN-US" style="font-family: "Times New Roman","serif"; font-weight: normal; mso-fareast-font-family: "Arial Unicode MS";"><o:p></o:p></span></h3>
<div class="MsoNormal" style="background: white; margin-bottom: 12.0pt; margin-left: 0cm; margin-right: 3.75pt; margin-top: 0cm;">
<span lang="EN-US" style="font-family: "Times New Roman", serif;">The Operator </span><tt><span lang="EN-US" style="font-family: "Times New Roman", serif; font-size: 12pt;">!</span></tt><span lang="EN-US" style="font-family: "Times New Roman", serif;"> is the Java operator to perform the Boolean operation NOT, it has
only one operand, located at its right, and the only thing that it does is to
inverse the value of it, producing false if its operand is true and true if its
operand is false. Basically, it returns the opposite Boolean value of
evaluating its operand. <o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; margin-right: 3.75pt;">
<span lang="EN-US" style="font-family: "Times New Roman", serif;">The
logical operators </span><tt><span lang="EN-US" style="font-family: "Times New Roman", serif; font-size: 12pt;">&&</span></tt><span lang="EN-US" style="font-family: "Times New Roman", serif;"> and </span><tt><span lang="EN-US" style="font-family: "Times New Roman", serif; font-size: 12pt;">||</span></tt><span lang="EN-US" style="font-family: "Times New Roman", serif;"> are used when evaluating two expressions to obtain a single
relational result. The operator </span><tt><span lang="EN-US" style="font-family: "Times New Roman", serif; font-size: 12pt;">&&</span></tt><span lang="EN-US" style="font-family: "Times New Roman", serif;">
corresponds with Boolean logical operation AND. This operation results true if
both its two operands are true, and false otherwise. The following panel shows
the result of operator </span><tt><span lang="EN-US" style="font-family: "Times New Roman", serif; font-size: 12pt;">&&</span></tt><span lang="EN-US" style="font-family: "Times New Roman", serif;">
evaluating the expression </span><tt><span lang="EN-US" style="font-family: "Times New Roman", serif; font-size: 12pt;">a && b</span></tt><span lang="EN-US" style="font-family: "Times New Roman", serif;">:<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; margin-right: 3.75pt;">
<span lang="EN-US" style="font-family: "Times New Roman", serif;"><br />
<!--[if !supportLineBreakNewLine]--><br />
<!--[endif]--><o:p></o:p></span></div>
<table border="1" cellpadding="0" cellspacing="0" class="MsoNormalTable" style="border-collapse: collapse; border: none; margin-left: 127.5pt; mso-border-alt: solid windowtext .5pt; mso-border-insideh: .5pt solid windowtext; mso-border-insidev: .5pt solid windowtext;">
<tbody>
<tr>
<td style="border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; padding: .75pt .75pt .75pt .75pt;">
<div class="MsoNormal">
<b><span lang="EN-US" style="font-family: "Times New Roman", serif;">A</span></b><b><span lang="EN-US" style="font-family: "Times New Roman", serif;"><o:p></o:p></span></b></div>
</td>
<td style="border-left: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; padding: .75pt .75pt .75pt .75pt;">
<div class="MsoNormal">
<b><span lang="EN-US" style="font-family: "Times New Roman", serif;">b</span></b><b><span lang="EN-US" style="font-family: "Times New Roman", serif;"><o:p></o:p></span></b></div>
</td>
<td style="border-left: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; padding: .75pt .75pt .75pt .75pt;">
<div class="MsoNormal">
<b><span lang="EN-US" style="font-family: "Times New Roman", serif;">a && b</span></b><b><span lang="EN-US" style="font-family: "Times New Roman", serif;"><o:p></o:p></span></b></div>
</td>
</tr>
<tr>
<td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: .75pt .75pt .75pt .75pt;">
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman", serif;">true</span><span lang="EN-US" style="font-family: "Times New Roman", serif;"><o:p></o:p></span></div>
</td>
<td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: .75pt .75pt .75pt .75pt;">
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman", serif;">true</span><span lang="EN-US" style="font-family: "Times New Roman", serif;"><o:p></o:p></span></div>
</td>
<td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: .75pt .75pt .75pt .75pt;">
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman", serif;">true</span><span lang="EN-US" style="font-family: "Times New Roman", serif;"><o:p></o:p></span></div>
</td>
</tr>
<tr>
<td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: .75pt .75pt .75pt .75pt;">
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman", serif;">true</span><span lang="EN-US" style="font-family: "Times New Roman", serif;"><o:p></o:p></span></div>
</td>
<td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: .75pt .75pt .75pt .75pt;">
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman", serif;">false</span><span lang="EN-US" style="font-family: "Times New Roman", serif;"><o:p></o:p></span></div>
</td>
<td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: .75pt .75pt .75pt .75pt;">
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman", serif;">false</span><span lang="EN-US" style="font-family: "Times New Roman", serif;"><o:p></o:p></span></div>
</td>
</tr>
<tr>
<td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: .75pt .75pt .75pt .75pt;">
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman", serif;">false</span><span lang="EN-US" style="font-family: "Times New Roman", serif;"><o:p></o:p></span></div>
</td>
<td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: .75pt .75pt .75pt .75pt;">
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman", serif;">true</span><span lang="EN-US" style="font-family: "Times New Roman", serif;"><o:p></o:p></span></div>
</td>
<td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: .75pt .75pt .75pt .75pt;">
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman", serif;">false</span><span lang="EN-US" style="font-family: "Times New Roman", serif;"><o:p></o:p></span></div>
</td>
</tr>
<tr>
<td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: .75pt .75pt .75pt .75pt;">
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman", serif;">false</span><span lang="EN-US" style="font-family: "Times New Roman", serif;"><o:p></o:p></span></div>
</td>
<td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: .75pt .75pt .75pt .75pt;">
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman", serif;">false</span><span lang="EN-US" style="font-family: "Times New Roman", serif;"><o:p></o:p></span></div>
</td>
<td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: .75pt .75pt .75pt .75pt;">
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman", serif;">false</span><span lang="EN-US" style="font-family: "Times New Roman", serif;"><o:p></o:p></span></div>
</td>
</tr>
</tbody></table>
<div class="MsoNormal" style="background: white; margin-right: 3.75pt;">
<br /></div>
<div class="MsoNormal" style="background: white; margin-right: 3.75pt;">
<span lang="EN-US" style="font-family: "Times New Roman", serif;">The
operator </span><tt><span lang="EN-US" style="font-family: "Times New Roman", serif; font-size: 12pt;">||</span></tt><span lang="EN-US" style="font-family: "Times New Roman", serif;"> corresponds with Boolean logical operation OR. This operation
results true if either one of its two operands is true, thus being false only
when both operands are false themselves. Here are the possible results of </span><tt><span lang="EN-US" style="font-family: "Times New Roman", serif; font-size: 12pt;">a || b</span></tt><span lang="EN-US" style="font-family: "Times New Roman", serif;">:<o:p></o:p></span></div>
<table border="1" cellpadding="0" cellspacing="0" class="MsoNormalTable" style="border-collapse: collapse; border: none; margin-left: 127.5pt; mso-border-alt: solid windowtext .5pt; mso-border-insideh: .5pt solid windowtext; mso-border-insidev: .5pt solid windowtext;">
<tbody>
<tr>
<td style="border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; padding: .75pt .75pt .75pt .75pt;">
<div class="MsoNormal">
<b><span lang="EN-US" style="font-family: "Times New Roman", serif;">A</span></b><b><span lang="EN-US" style="font-family: "Times New Roman", serif;"><o:p></o:p></span></b></div>
</td>
<td style="border-left: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; padding: .75pt .75pt .75pt .75pt;">
<div class="MsoNormal">
<b><span lang="EN-US" style="font-family: "Times New Roman", serif;">b</span></b><b><span lang="EN-US" style="font-family: "Times New Roman", serif;"><o:p></o:p></span></b></div>
</td>
<td style="border-left: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; padding: .75pt .75pt .75pt .75pt;">
<div class="MsoNormal">
<b><span lang="EN-US" style="font-family: "Times New Roman", serif;">a || b</span></b><b><span lang="EN-US" style="font-family: "Times New Roman", serif;"><o:p></o:p></span></b></div>
</td>
</tr>
<tr>
<td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: .75pt .75pt .75pt .75pt;">
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman", serif;">true</span><span lang="EN-US" style="font-family: "Times New Roman", serif;"><o:p></o:p></span></div>
</td>
<td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: .75pt .75pt .75pt .75pt;">
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman", serif;">true</span><span lang="EN-US" style="font-family: "Times New Roman", serif;"><o:p></o:p></span></div>
</td>
<td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: .75pt .75pt .75pt .75pt;">
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman", serif;">true</span><span lang="EN-US" style="font-family: "Times New Roman", serif;"><o:p></o:p></span></div>
</td>
</tr>
<tr>
<td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: .75pt .75pt .75pt .75pt;">
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman", serif;">true</span><span lang="EN-US" style="font-family: "Times New Roman", serif;"><o:p></o:p></span></div>
</td>
<td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: .75pt .75pt .75pt .75pt;">
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman", serif;">false</span><span lang="EN-US" style="font-family: "Times New Roman", serif;"><o:p></o:p></span></div>
</td>
<td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: .75pt .75pt .75pt .75pt;">
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman", serif;">true</span><span lang="EN-US" style="font-family: "Times New Roman", serif;"><o:p></o:p></span></div>
</td>
</tr>
<tr>
<td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: .75pt .75pt .75pt .75pt;">
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman", serif;">false</span><span lang="EN-US" style="font-family: "Times New Roman", serif;"><o:p></o:p></span></div>
</td>
<td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: .75pt .75pt .75pt .75pt;">
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman", serif;">true</span><span lang="EN-US" style="font-family: "Times New Roman", serif;"><o:p></o:p></span></div>
</td>
<td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: .75pt .75pt .75pt .75pt;">
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman", serif;">true</span><span lang="EN-US" style="font-family: "Times New Roman", serif;"><o:p></o:p></span></div>
</td>
</tr>
<tr>
<td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: .75pt .75pt .75pt .75pt;">
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman", serif;">false</span><span lang="EN-US" style="font-family: "Times New Roman", serif;"><o:p></o:p></span></div>
</td>
<td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: .75pt .75pt .75pt .75pt;">
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman", serif;">false</span><span lang="EN-US" style="font-family: "Times New Roman", serif;"><o:p></o:p></span></div>
</td>
<td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: .75pt .75pt .75pt .75pt;">
<div class="MsoNormal">
<span lang="EN-US" style="font-family: "Times New Roman", serif;">false</span><span lang="EN-US" style="font-family: "Times New Roman", serif;"><o:p></o:p></span></div>
</td>
</tr>
</tbody></table>
<div class="MsoBodyText">
</div>
<div class="MsoBodyText">
<b><span lang="EN-US" style="font-family: "Times New Roman","serif";">Assignment
Operators</span></b><b><span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 14.0pt;"><o:p></o:p></span></b></div>
<h3 style="background: white; margin-right: 3.75pt;">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-weight: normal;">Assignment (=)</span><span lang="EN-US" style="font-family: "Times New Roman","serif"; font-weight: normal; mso-fareast-font-family: "Arial Unicode MS";"><o:p></o:p></span></h3>
<div class="MsoNormal" style="background: white; margin-right: 3.6pt;">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">The
assignment operator assigns a value to a variable.<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; margin-right: 3.6pt;">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">a=5;<br />
This statement assigns the integer value 5 to the variable </span><tt><span lang="EN-US" style="color: black; font-family: "Times New Roman","serif"; font-size: 12.0pt;">a</span></tt><span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">. The lvalue has to be a variable whereas the rvalue can be either
a constant, a variable, the result of an operation or any combination of these.<o:p></o:p></span></div>
<div class="MsoBodyText">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">a=b;<br />
This statement assigns to variable </span><tt><span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 10.0pt;">a</span></tt><span lang="EN-US" style="font-family: "Times New Roman","serif";"> (the lvalue) the
value contained in variable </span><tt><span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 10.0pt;">b</span></tt><span lang="EN-US" style="font-family: "Times New Roman","serif";"> (the rvalue).<o:p></o:p></span></div>
<div class="MsoBodyText">
<br /></div>
<div class="MsoBodyText">
<b><span lang="EN-US" style="font-family: "Times New Roman","serif";">Increment
and Decrement Operators<o:p></o:p></span></b></div>
<div class="MsoBodyText">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">The
operator ++ adds 1 to the operand while –- subtracts 1. Both are unary
operators and are used in the following form:<o:p></o:p></span></div>
<div class="MsoBodyText">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">++m
or m++;<o:p></o:p></span></div>
<div class="MsoBodyText">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">--m
or m--;<o:p></o:p></span></div>
<div class="MsoBodyText">
<br /></div>
<div class="MsoBodyText">
<b><span lang="EN-US" style="font-family: "Times New Roman","serif";">Conditional
Operators</span></b><b><span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 14.0pt;"><o:p></o:p></span></b></div>
<div class="MsoBodyText2" style="background: white; margin-right: 3.6pt; tab-stops: 36.0pt;">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">The conditional operator evaluates an expression returning a value
if that expression is true and a different one if the expression is evaluated
as false. Its format is: <o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; margin-right: 3.6pt;">
<tt><b><span lang="EN-US" style="color: black; font-family: "Times New Roman","serif"; font-size: 12.0pt;">condition ? result1 : result2<o:p></o:p></span></b></tt></div>
<div class="MsoNormal" style="background: white; margin-right: 3.6pt;">
<span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">If </span><tt><span lang="EN-US" style="color: black; font-family: "Times New Roman","serif"; font-size: 12.0pt;">condition</span></tt><span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";"> is true the expression will return </span><tt><span lang="EN-US" style="color: black; font-family: "Times New Roman","serif"; font-size: 12.0pt;">result1</span></tt><span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">, if it is
not it will return </span><tt><span lang="EN-US" style="color: black; font-family: "Times New Roman","serif"; font-size: 12.0pt;">result2</span></tt><span lang="EN-US" style="color: black; font-family: "Times New Roman","serif";">.<o:p></o:p></span></div>
<pre style="tab-stops: 36.0pt;"><span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">7==5 ? 4 : 3<span style="mso-spacerun: yes;"> </span><span class="comm1">// returns 3, since 7 is not equal to 5.</span><o:p></o:p></span></pre>
<pre style="tab-stops: 36.0pt;"><span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">7==5+2 ? 4 : 3<span style="mso-spacerun: yes;"> </span><span class="comm1">// returns 4, since 7 is equal to 5+2.</span><o:p></o:p></span></pre>
<pre style="tab-stops: 36.0pt;"><span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">5>3 ? a : b<span style="mso-spacerun: yes;"> </span><span class="comm1">// returns the value of a, since 5 is greater than 3.</span><o:p></o:p></span></pre>
<div class="MsoNormal" style="background: white; margin-right: 3.6pt;">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">a>b ? a : b<span style="mso-spacerun: yes;"> </span><span class="comm1">// returns whichever is
greater, a or b.</span></span><span lang="EN-US" style="font-family: "Times New Roman","serif"; mso-fareast-font-family: "Arial Unicode MS";"><o:p></o:p></span></div>
<div class="MsoBodyText">
<br /></div>
<div class="MsoBodyText">
<b><span lang="EN-US" style="font-family: "Times New Roman","serif";">Bitwise
Operators</span></b><b><span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 14.0pt;"><o:p></o:p></span></b></div>
<div class="MsoBodyText">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">These
operators are used for manipulation of data at values of bit level. These
operators are used for testing the bits, or shifting them to the right or left.
Bitwise operators may not be applied to float or double.<o:p></o:p></span></div>
<div class="MsoBodyText">
<b><span lang="EN-US" style="font-family: "Times New Roman","serif";">Operator<span style="mso-tab-count: 3;"> </span>Meaning<o:p></o:p></span></b></div>
<div class="MsoBodyText">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">&<span style="mso-tab-count: 4;"> </span>Bitwise
AND<o:p></o:p></span></div>
<div class="MsoBodyText">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">!<span style="mso-tab-count: 4;"> </span>Bitwise
OR<o:p></o:p></span></div>
<div class="MsoBodyText">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">^<span style="mso-tab-count: 4;"> </span>bitwise
exclusive OR<o:p></o:p></span></div>
<div class="MsoBodyText">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">~<span style="mso-tab-count: 4;"> </span>one’s
complement<o:p></o:p></span></div>
<div class="MsoBodyText">
<span lang="EN-US" style="font-family: "Times New Roman","serif";"><<<span style="mso-tab-count: 4;"> </span>shift
left<o:p></o:p></span></div>
<div class="MsoBodyText">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">>><span style="mso-tab-count: 4;"> </span>shift
right<o:p></o:p></span></div>
<div class="MsoBodyText">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">>>><span style="mso-tab-count: 4;"> </span>shift
right with zero fill<o:p></o:p></span></div>
<div class="MsoBodyText">
<br /></div>
<div class="MsoBodyText">
<b><span lang="EN-US" style="font-family: "Times New Roman","serif";">Special
Operators</span></b><b><span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 14.0pt;"><o:p></o:p></span></b></div>
<div class="MsoNormal" style="background: white; margin-right: 3.6pt;">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">Java supports some
special operators of interest such as <b>instanceof </b>operator and <b>member
selection operator</b> (.)<o:p></o:p></span></div>
<ol start="1" style="margin-top: 0cm;" type="1">
<li class="MsoNormal" style="background: white; margin-right: 3.6pt; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt;"><b><span lang="EN-US" style="font-family: "Times New Roman","serif";">instanceof operator<o:p></o:p></span></b></li>
</ol>
<div class="MsoBodyText3" style="margin-left: 18.0pt;">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">The instanceof is an object reference
operator and returns true, if the object on the left-hand side is an instance
of the class given on the right-hand side. This operator allows us to determine
whether the object belongs to a particular class or not.<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; margin-right: 3.6pt; text-indent: 18.0pt;">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">Ex:<span style="mso-spacerun: yes;"> </span>person instanceof student<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; margin-right: 3.6pt; text-indent: 18.0pt;">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">is true
if the object person belongs to the class student; otherwise it is false.<o:p></o:p></span></div>
<ol start="2" style="margin-top: 0cm;" type="1">
<li class="MsoNormal" style="background: white; margin-right: 3.6pt; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt;"><b><span lang="EN-US" style="font-family: "Times New Roman","serif";">member selection operator<o:p></o:p></span></b></li>
</ol>
<div class="MsoNormal" style="background: white; margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 18.0pt; margin-right: 3.6pt; margin-top: 0cm;">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">The dot operator(.) is used to
access the instance variables and methods of class objects:<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; margin-right: 3.6pt; text-indent: 18.0pt;">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">Person1.age<span style="mso-tab-count: 2;"> </span>//reference to variable
age<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; margin-right: 3.6pt; text-indent: 18.0pt;">
<span lang="EN-US" style="font-family: "Times New Roman","serif";">Person1.salary()<span style="mso-tab-count: 1;"> </span>//reference to method salary<o:p></o:p></span></div>
<br /></div>
Bagadhi Sateeshhttp://www.blogger.com/profile/16786636572407672825noreply@blogger.com0tag:blogger.com,1999:blog-8352540103162095489.post-45743625831772176932018-08-08T15:08:00.002+05:302018-08-08T15:10:09.682+05:30TYPE CASTING<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "times new roman" , "serif"; font-size: 11.5pt;">The process of converting one
data type to another is called type casting<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<b><span style="font-family: "times new roman" , "serif"; font-size: 11.5pt;">Examples:<o:p></o:p></span></b></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "times new roman" , "serif"; font-size: 11.5pt;">int m=50;<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "times new roman" , "serif"; font-size: 11.5pt;">byte n=(byte)m;<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "times new roman" , "serif"; font-size: 11.5pt;">long count=(long) m;<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "times new roman" , "serif"; font-size: 11.5pt;">class Typecasting<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "times new roman" , "serif"; font-size: 11.5pt;">{<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "times new roman" , "serif"; font-size: 11.5pt;">public static void main(String
args[])<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "times new roman" , "serif"; font-size: 11.5pt;">{<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "times new roman" , "serif"; font-size: 11.5pt;">System.out.println("variales
created");<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "times new roman" , "serif"; font-size: 11.5pt;">char c='x';<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "times new roman" , "serif"; font-size: 11.5pt;">byte b=50;<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "times new roman" , "serif"; font-size: 11.5pt; line-height: 115%;">short s=1996;</span><br />
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "times new roman" , serif; font-size: 11.5pt;">int i=123456789;</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "times new roman" , "serif"; font-size: 11.5pt;">long l=1234567654321L;<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "times new roman" , "serif"; font-size: 11.5pt;">float f1=3.142F;<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "times new roman" , "serif"; font-size: 11.5pt;">float f2=1.2e-5F;<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "times new roman" , "serif"; font-size: 11.5pt;">double d2=0.000000987;<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "times new roman" , "serif"; font-size: 11.5pt;">System.out.println("
c="+c);<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "times new roman" , "serif"; font-size: 11.5pt;">System.out.println(" b
="+b);<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "times new roman" , "serif"; font-size: 11.5pt;">System.out.println(" s=
"+s);<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "times new roman" , "serif"; font-size: 11.5pt;">System.out.println("
i="+i);<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "times new roman" , "serif"; font-size: 11.5pt;">System.out.println("
l="+l);<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "times new roman" , "serif"; font-size: 11.5pt;">System.out.println(" f1=
"+f1);<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "times new roman" , "serif"; font-size: 11.5pt;">System.out.println("
f2="+f2);<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "times new roman" , "serif"; font-size: 11.5pt;">System.out.println("d2
="+d2);<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "times new roman" , "serif"; font-size: 11.5pt;">System.out.println("
");<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "times new roman" , "serif"; font-size: 11.5pt;">System.out.println(" Types
converted");<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "times new roman" , "serif"; font-size: 11.5pt;">short s1=(short)b;<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "times new roman" , "serif"; font-size: 11.5pt;">short s2=(short)i;<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "times new roman" , "serif"; font-size: 11.5pt;">float n1=(float)l;<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "times new roman" , "serif"; font-size: 11.5pt;">int m1=(int)f1;<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "times new roman" , "serif"; font-size: 11.5pt;">System.out.println("
(short)b ="+s1);<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "times new roman" , "serif"; font-size: 11.5pt;">System.out.println("
(short)i ="+s2);<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "times new roman" , "serif"; font-size: 11.5pt;">System.out.println("
(float)l= "+n1);<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "times new roman" , "serif"; font-size: 11.5pt;">System.out.println("
(int)f1= - "+m1);<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "times new roman" , "serif"; font-size: 11.5pt;">}<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "times new roman" , "serif"; font-size: 11.5pt;">}<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<b><span style="font-family: "times new roman" , "serif"; font-size: 11.5pt;">Note : </span></b><span style="font-family: "times new roman" , "serif"; font-size: 11.5pt;">floating point
constants have a default type of double<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "times new roman" , "serif"; font-size: 11.5pt;">For example when we want to
declare a float variable and initializing it to constant<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "times new roman" , "serif"; font-size: 11.5pt;">float x=7.56;<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "times new roman" , "serif"; font-size: 11.5pt;">This will give “incompatible type
for declaration. Explicit cast needed to convert double to<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "times new roman" , "serif"; font-size: 11.5pt;">float.”<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "times new roman" , "serif"; font-size: 11.5pt;">This should be written as<o:p></o:p></span></div>
<span style="font-family: "times new roman" , "serif"; font-size: 11.5pt; line-height: 115%;">
</span><br />
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "times new roman" , "serif"; font-size: 11.5pt;">float x=7.56F<b><o:p></o:p></b></span></div>
</div>
<br /></div>
Bagadhi Sateeshhttp://www.blogger.com/profile/16786636572407672825noreply@blogger.com0tag:blogger.com,1999:blog-8352540103162095489.post-56571818493650329652018-08-08T15:07:00.003+05:302018-08-08T15:07:27.337+05:30VARIABLES<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "Times New Roman","serif"; font-size: 11.5pt;">A variable is a basic unit of
storage, which represents memory location in which value can be<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "Times New Roman","serif"; font-size: 11.5pt;">stored.<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<b><i><span style="font-family: "Times New Roman","serif"; font-size: 11.5pt;">Rules for
variables:<o:p></o:p></span></i></b></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "Times New Roman","serif"; font-size: 11.5pt;">1. They must not begin with a
digit<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "Times New Roman","serif"; font-size: 11.5pt;">2. It should not be a keyword<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "Times New Roman","serif"; font-size: 11.5pt;">3. White space is not allowed<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "Times New Roman","serif"; font-size: 11.5pt;">4. Variable names can be of any
length<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<b><span style="font-family: "Times New Roman","serif"; font-size: 11.5pt;">DECLARATION OF
VARIABLES<o:p></o:p></span></b></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "Times New Roman","serif"; font-size: 11.5pt;">Before using any variable, it
must first be declared. A variable declaration specifies the<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "Times New Roman","serif"; font-size: 11.5pt;">datatype, the variable name, and
optionally the default value for the variable.<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "Times New Roman","serif"; font-size: 11.5pt;">Syntax: datatype identifier
{=default value}<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "Times New Roman","serif"; font-size: 11.5pt;">Ex: byte b;<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "Times New Roman","serif"; font-size: 11.5pt;">int age, enrolno<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "Times New Roman","serif"; font-size: 11.5pt;">boolean male<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<b><span style="font-family: "Times New Roman","serif"; font-size: 11.5pt;">GIVING VALUES TO
VARIABLES<o:p></o:p></span></b></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "Times New Roman","serif"; font-size: 11.5pt;">Once you have declared the type
of a variable, you can initialize it with some value.<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "Times New Roman","serif"; font-size: 11.5pt;">Syntax: variable name=some value<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "Times New Roman","serif"; font-size: 11.5pt;">Ex: int year=20;<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<b><span style="font-family: "Times New Roman","serif"; font-size: 11.5pt;">SCOPE OF
VARIABLES<o:p></o:p></span></b></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "Times New Roman","serif"; font-size: 11.5pt;">Java actually has three kinds of
variables<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "Times New Roman","serif"; font-size: 11.5pt;">Instance variables<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "Times New Roman","serif"; font-size: 11.5pt;">Class variables<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "Times New Roman","serif"; font-size: 11.5pt;">Local variables<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "Times New Roman","serif"; font-size: 11.5pt;">Instance variables are created
when the objects are instantiated and therefore they are<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "Times New Roman","serif"; font-size: 11.5pt;">associated with the objects. They
take different values for each object. Class variables are<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "Times New Roman","serif"; font-size: 11.5pt;">similar to instance variables,
except their values apply to all the instances of a class rather<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "Times New Roman","serif"; font-size: 11.5pt;">than having different values for
each object. Local variables are declared and used inside<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "Times New Roman","serif"; font-size: 11.5pt;">methods.<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<b><span style="font-family: "Times New Roman","serif"; font-size: 11.5pt;">Variables :<o:p></o:p></span></b></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "Times New Roman","serif"; font-size: 11.5pt;">Variables are also the key to
creating programs that can perform calculations.<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "Times New Roman","serif"; font-size: 11.5pt;">Type of Variables :<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "Times New Roman","serif"; font-size: 11.5pt;">1. class variable<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "Times New Roman","serif"; font-size: 11.5pt;">2. Instance variable<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm;">
<span style="font-family: "Times New Roman","serif"; font-size: 11.5pt; line-height: 115%;">3.
Local variable<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "Times New Roman","serif"; font-size: 11.5pt;">4. Final variable<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "Times New Roman","serif"; font-size: 11.5pt;">5. shadowing variable<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<b><span style="font-family: "Times New Roman","serif"; font-size: 11.5pt;">Class Variable :<o:p></o:p></span></b></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "Times New Roman","serif"; font-size: 11.5pt;">A <i>class variable </i>is a
variable that any method in a class can access, including static<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "Times New Roman","serif"; font-size: 11.5pt;">methods such as main.<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "Times New Roman","serif"; font-size: 11.5pt;">When declaring a class variable
you have two basic rules to follow:<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "Times New Roman","serif"; font-size: 11.5pt;">1. You must place the
declarations within the body of the class, but not within any of<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "Times New Roman","serif"; font-size: 11.5pt;">the class method.<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "Times New Roman","serif"; font-size: 11.5pt;">2. You must include the word
static in the declaration. The word static comes before the<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "Times New Roman","serif"; font-size: 11.5pt;">variable type.<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "Times New Roman","serif"; font-size: 11.5pt;">E.g.: public class helloapp {<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "Times New Roman","serif"; font-size: 11.5pt;">static string hellomessage;<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "Times New Roman","serif"; font-size: 11.5pt;">public static void main(String[]
args) {<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "Times New Roman","serif"; font-size: 11.5pt;">hellomessage = “Helloworld!”;<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "Times New Roman","serif"; font-size: 11.5pt;">System.out.println(“hellomessage”);<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "Times New Roman","serif"; font-size: 11.5pt;">}<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "Times New Roman","serif"; font-size: 11.5pt;">}<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<b><span style="font-family: "Times New Roman","serif"; font-size: 11.5pt;">Instance
variable :<o:p></o:p></span></b></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "Times New Roman","serif"; font-size: 11.5pt;">An instance variable is similar
to a class variable, but doesn’t specify The word static in its<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "Times New Roman","serif"; font-size: 11.5pt;">declaration.<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "Times New Roman","serif"; font-size: 11.5pt;">• Instance variables are
associated with instances of classes.<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "Times New Roman","serif"; font-size: 11.5pt;">E.g.:<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "Times New Roman","serif"; font-size: 11.5pt;">public class helloapp {<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "Times New Roman","serif"; font-size: 11.5pt;">string hellomessage;<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "Times New Roman","serif"; font-size: 11.5pt;">public static void main(String[]
args) {<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "Times New Roman","serif"; font-size: 11.5pt;">hellomessage = “Helloworld!”;<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "Times New Roman","serif"; font-size: 11.5pt;">System.out.println(“hellomessage”);<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "Times New Roman","serif"; font-size: 11.5pt;">}<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "Times New Roman","serif"; font-size: 11.5pt;">}<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<b><span style="font-family: "Times New Roman","serif"; font-size: 11.5pt;">Error :<o:p></o:p></span></b></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "Times New Roman","serif"; font-size: 11.5pt;">Cannot make a static reference to
the non-static field hellomessage<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<b><span style="font-family: "Times New Roman","serif"; font-size: 11.5pt;">Local variable :<o:p></o:p></span></b></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "Times New Roman","serif"; font-size: 11.5pt;">A local variable is a variable
that’s declared within the body of a method.<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "Times New Roman","serif"; font-size: 11.5pt;">• You don’t specify “static” on a
declaration for a local variable.<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "Times New Roman","serif"; font-size: 11.5pt;">• local variables are not given
initial default values. The compiler checks to make sure<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "Times New Roman","serif"; font-size: 11.5pt;">that you have assigned a value
before you use a local variable.<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<b><span style="font-family: "Times New Roman","serif"; font-size: 11.5pt;">Final variable
(Constants) :<o:p></o:p></span></b></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "Times New Roman","serif"; font-size: 11.5pt;">• A final variable, also called a
constant.<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 11.5pt; line-height: 115%;">• It is a variable whose value you can’t change once
it’s been initialized.<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "Times New Roman","serif"; font-size: 11.5pt;">Final variables are class or
instance variables<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<b><span style="font-family: "Times New Roman","serif"; font-size: 11.5pt;">Shadowing
variables :<o:p></o:p></span></b></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "Times New Roman","serif"; font-size: 11.5pt;">A shadowing variable is a
variable that would otherwise be accessible, but is temporarily<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "Times New Roman","serif"; font-size: 11.5pt;">made unavailable because a
variable with the same name has been declared in a more<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "Times New Roman","serif"; font-size: 11.5pt;">immediate scope.<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<b><span style="font-family: "Times New Roman","serif"; font-size: 11.5pt;">Scope :<o:p></o:p></span></b></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "Times New Roman","serif"; font-size: 11.5pt;">The scope of a variable refers to
which parts of a class the variable exists in.<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<b><span style="font-family: "Times New Roman","serif"; font-size: 11.5pt;">*SYMBOLIC
CONSTANTS<o:p></o:p></span></b></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "Times New Roman","serif"; font-size: 11.5pt;">symbolic constants are used like
macros in C and C++<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "Times New Roman","serif"; font-size: 11.5pt;">symbolic names take the same form
as variable names. But, they are written in capitals to<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "Times New Roman","serif"; font-size: 11.5pt;">visually distinguish them from
normal variables. After declaration of symbolic constants they<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "Times New Roman","serif"; font-size: 11.5pt;">should not be assigned to any
other within the program by using an assignment statement.<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "Times New Roman","serif"; font-size: 11.5pt;">A constant can be declared as
follows:<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<b><span style="font-family: "Times New Roman","serif"; font-size: 11.5pt;">Examples:<o:p></o:p></span></b></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "Times New Roman","serif"; font-size: 11.5pt;">final int STRENGTH = 100;<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "Times New Roman","serif"; font-size: 11.5pt;">final int PASS_MARK = 50;<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "Times New Roman","serif"; font-size: 11.5pt;">final float PI = 3.14159;<o:p></o:p></span></div>
<br /></div>
Bagadhi Sateeshhttp://www.blogger.com/profile/16786636572407672825noreply@blogger.com0