<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Mehmet Başak on Medium]]></title>
        <description><![CDATA[Stories by Mehmet Başak on Medium]]></description>
        <link>https://medium.com/@mehmetbasak?source=rss-a1d5c6a41be1------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*eOlXDkpD74y1O5_wym2Ckg.jpeg</url>
            <title>Stories by Mehmet Başak on Medium</title>
            <link>https://medium.com/@mehmetbasak?source=rss-a1d5c6a41be1------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 20:39:30 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mehmetbasak/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Java Encapsulation]]></title>
            <link>https://medium.com/@mehmetbasak/java-encapsulation-c88653534d36?source=rss-a1d5c6a41be1------2</link>
            <guid isPermaLink="false">https://medium.com/p/c88653534d36</guid>
            <category><![CDATA[java]]></category>
            <category><![CDATA[access-modifier]]></category>
            <category><![CDATA[encapsulation]]></category>
            <category><![CDATA[java-access-modifier]]></category>
            <dc:creator><![CDATA[Mehmet Başak]]></dc:creator>
            <pubDate>Sun, 28 Nov 2021 13:52:25 GMT</pubDate>
            <atom:updated>2021-11-28T13:52:25.309Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*icHlE-9iVEPS2xeHLhyfhg.jpeg" /></figure><p><strong>In this topic will cover all as below:</strong></p><p><strong>1. </strong>What is Encapsulation?<br><strong>2. </strong>How to achieve of Encapsulation?<br><strong>3. </strong>What are packages and access Modifiers?<br><strong>4. </strong>Advantages of Encapsulation.</p><p>1.<strong>Encapsulation in Java</strong> is a mechanism to wrap up variables(data) and methods(code) together as a single unit. It is the process of hiding information details and protecting data and behavior of the object. It is one of the four important OOP concepts. The encapsulate class is easy to test, so it is also better for unit testing.</p><p>We have to know 2 things : <em>Packages and Access modifiers</em>.Because we do encapsulation on these things.</p><p>Packages are nothing but folder where all project classes, files etc has been saved. Below figure we can see that there are 2 folders akash and Rahul where files/code has been saved in their respective folder.</p><p>Can be defined in class by <strong>package</strong> keyword.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/341/1*ELAWROKs23AAaJ38rx04tA.png" /></figure><h3>Access modifiers:</h3><p>There are 4 types of Java access modifiers:</p><p><strong>1) Private</strong>: The access level is only <strong>within the class</strong>. It cannot be accessed from outside the class.As well you cannot access with inheritance.</p><p><strong>2) Default</strong>: The access level is <strong>only within the package</strong>. It cannot be accessed from outside the package.</p><p><strong>3) Protected</strong>: The access level is <strong>within the package</strong> and outside the package through <strong>child class</strong> (means there should be inheritance in classes).</p><p>i.e. Package com1 contains class A and package com2 contains class B. Then the variable and methods can be accessible if and only if there is relation/inheritance between class A and class B.</p><p><strong>4) Public</strong>: It can be accessible from <strong>everywhere</strong>. Can be accessible from inside/outside the class, within or outside the package. Globally accessible.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/440/1*3wTySDWk8adSooCvro0NHg.png" /></figure><h3>2. How to make an Encapsulation?</h3><p>Best example of encapsulation is <strong>POJO </strong>class (Plain Old Java Object) i.e. Declare variables as private and provide getter-setter methods for use (getter methods for use/getting any data and setter methods to set data)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/333/1*Sk2Qgt9HokSHVc_T-enbjA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/393/1*gonpSiDRojUnfY2aYQAqEw.png" /></figure><p><strong>Output</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/239/1*8TRV0F66zxjRFhKMEppeHA.png" /></figure><p><strong>Getter and Setter in Java</strong> are two conventional methods used to retrieve and update values of a variable. They are mainly used to create, modify, delete and view the variable values. The setter method is used for updating values and the getter method is used for reading or retrieving the values. They are also known as an accessor and mutator.</p><h3>3. Advantages of Encapsulation:</h3><p><strong>1.</strong> We can achieve security.</p><p><strong>2.</strong> Enhancement become very easy.</p><p><strong>3.</strong> Improve maintenance of application.</p><p><strong>4.</strong> provide flexibility.</p><p><strong>5.</strong> If we have Not define the setter method in the class then the fields can be made “Read-only” (i.e. we can only get/read data from getter methods).</p><p><strong>6.</strong> If we have Not define the getter method in the class then the fields can be made “Write-only” (i.e. we can only write/ set data from setter methods).</p><h3>4. Disadvantages:</h3><p>Code length may increase.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c88653534d36" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Java Abstraction]]></title>
            <link>https://medium.com/@mehmetbasak/java-abstraction-d6e6b7a74152?source=rss-a1d5c6a41be1------2</link>
            <guid isPermaLink="false">https://medium.com/p/d6e6b7a74152</guid>
            <category><![CDATA[java]]></category>
            <dc:creator><![CDATA[Mehmet Başak]]></dc:creator>
            <pubDate>Sat, 13 Nov 2021 20:29:06 GMT</pubDate>
            <atom:updated>2022-07-27T23:11:22.432Z</atom:updated>
            <content:encoded><![CDATA[<p>A class which is declared with the abstract keyword is known as an abstract class in <a href="https://www.javatpoint.com/java-tutorial">Java</a>. It can have abstract and non-abstract methods (method with the body).</p><p>Before learning the Java abstract class, let’s understand the abstraction in Java first.</p><h3>Abstraction in Java</h3><p><strong>Abstraction</strong> is a process of hiding the implementation details and showing only functionality to the user.</p><p>The abstract keyword is a non-access modifier, used for classes and methods:</p><ul><li><strong>Abstract class:</strong> is a restricted class that cannot be used to create objects (to access it, it must be inherited from another class).</li><li><strong>Abstract method:</strong> can only be used in an abstract class, and it does not have a body. The body is provided by the subclass (inherited from).</li></ul><p>Abstraction lets you focus on what the <a href="https://www.javatpoint.com/object-and-class-in-java">object</a> does instead of how it does it.</p><pre>abstract class Animal {<br>  public abstract void animalSound();<br>  public void sleep() {<br>    System.out.println(&quot;Zzz&quot;);<br>  }<br>}</pre><p>There are two ways to achieve abstraction in java</p><ol><li>Abstract class (0 to 100%)</li><li>Interface (100%)</li></ol><h4>Points to Remember</h4><ul><li>An abstract class must be declared with an abstract keyword.</li><li>It can have abstract and non-abstract methods.</li><li>It cannot be instantiated.</li><li>It can have <a href="https://www.javatpoint.com/java-constructor">constructors</a> and static methods also.</li><li>It can have final methods which will force the subclass not to change the body of the method.</li></ul><h3>Abstract class having constructor, data member and methods</h3><p>An abstract class can have a data member, abstract method, method body (non-abstract method), constructor, and even main() method.</p><pre>// Abstract class<br>abstract class Animal {<br>  // Abstract method (does not have a body)<br>  public abstract void animalSound();<br>  // Regular method<br>  public void sleep() {<br>    System.out.println(&quot;Zzz&quot;);<br>  }<br>}<br><br>// Subclass (inherit from Animal)<br>class Pig extends Animal {<br>  public void animalSound() {<br>    // The body of animalSound() is provided here<br>    System.out.println(&quot;The pig says: wee wee&quot;);<br>  }<br>}<br><br>class Main {<br>  public static void main(String[] args) {<br>    Pig myPig = new Pig(); // Create a Pig object<br>    myPig.animalSound();<br>    myPig.sleep();<br>  }<br>}</pre><h3>Why can’t we create an object of an Abstract Class?</h3><p>You might be wondering why can’t we instantiate an abstract class or create an object from it? Suppose, if Java allows you to create an object of the abstract class and use this object.</p><p>Now, if someone calls the abstract method through the object of the abstract class then what would happen? There would not be any actual implementation of the called method.</p><p>Also, an abstract class is like a guideline or a template that has to be extended by its child classes for the implementation.</p><p>Code to illustrate that object creation of an abstract class is invalid:</p><p>As discussed above, we cannot instantiate an abstract class. This program throws a compilation error.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/641/1*wF5av_8F0kKPkj2-Y5qtEw.png" /></figure><p>Output:</p><p>Exception in thread “main” java.lang.Error: Unresolved compilation problem:<br>Cannot instantiate the type ParentClass</p><p>References:<br>w3school.com<br>t<a href="https://www.google.com/url?sa=t&amp;rct=j&amp;q=&amp;esrc=s&amp;source=web&amp;cd=&amp;ved=2ahUKEwjI89zGk5b0AhUb8rsIHdDPD4cQFnoECCMQAQ&amp;url=https%3A%2F%2Ftechvidvan.com%2Ftutorials%2Fabstraction-in-java%2F&amp;usg=AOvVaw3FSsTar8yP2w7DEB3Cm1fA&amp;cshid=1636834505276086">e</a>chvidvan.com<br>javatpoin.com</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d6e6b7a74152" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Java’da İlkel Veri Tipleri]]></title>
            <link>https://medium.com/@mehmetbasak/javada-i%CC%87lkel-veri-tipleri-e19eace47bd8?source=rss-a1d5c6a41be1------2</link>
            <guid isPermaLink="false">https://medium.com/p/e19eace47bd8</guid>
            <category><![CDATA[java]]></category>
            <dc:creator><![CDATA[Mehmet Başak]]></dc:creator>
            <pubDate>Sun, 24 Oct 2021 17:52:50 GMT</pubDate>
            <atom:updated>2021-10-24T17:52:50.571Z</atom:updated>
            <content:encoded><![CDATA[<p>Merhaba,<br>Bu yazı Mediumda ve aynı zamanda tüm hayatım boyunca yazdığım ilk blog tarzı yazıdır.</p><p>Java diğer dillere göre , güçlü bir tipli dildir.Java da bir değişken tanımlarken bunun tip türünü yazmak zorundayız.</p><p>Java’da veri tipleri<strong> 3′e </strong>ayrılır.Bunlar ;<br>-<em>İlkel(primitive) Veri Tipleri</em><br>-<em>Referans tipler</em><br>-<em>Null Veri tipi</em></p><p>Bu veri tiplerini biraz daha açıklayacak olursak.<br><strong>İlkel(primitive)</strong> tipler , (primitives) 8 tanedir;</p><ul><li>byte * short * int * long * float * double * char ve boolean</li><li>Sayısal olmayan tek tip mantıksal(logic) tiptir ; <strong>boolean</strong></li></ul><p>Geriye kalan 7 tip de sayısaldır.</p><p><strong>char</strong>, dışında diğer 6 sayısal tip de işaretlidir (signed), pozitif <br>veya negatif değerler alabilir.<br><strong>char, </strong>karakter tipidir ve karakterlerin sıfır veya pozitif tam sayı<br>değeri vardır.</p><p>6 sayısal tipin 4&#39;ü tam sayılar , 2&#39;si ise gerçek (real) sayılar içindir:<br> * Tamsayılar : byte, short, int ve long,<br>* Gerçeksayılar : float ve double</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/488/1*zxNqsMmdrou76M6WfgswIA.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e19eace47bd8" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>