<?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 Pashikanti Rakesh on Medium]]></title>
        <description><![CDATA[Stories by Pashikanti Rakesh on Medium]]></description>
        <link>https://medium.com/@pashikantirockesh?source=rss-27f5711ce093------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*YdULiyoM8Za9vtZytNgUxQ.jpeg</url>
            <title>Stories by Pashikanti Rakesh on Medium</title>
            <link>https://medium.com/@pashikantirockesh?source=rss-27f5711ce093------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 17:34:21 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@pashikantirockesh/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 programs]]></title>
            <link>https://medium.com/@pashikantirockesh/java-programs-44ebdb9ab6a2?source=rss-27f5711ce093------2</link>
            <guid isPermaLink="false">https://medium.com/p/44ebdb9ab6a2</guid>
            <dc:creator><![CDATA[Pashikanti Rakesh]]></dc:creator>
            <pubDate>Thu, 30 May 2024 10:33:12 GMT</pubDate>
            <atom:updated>2024-05-30T10:33:12.271Z</atom:updated>
            <content:encoded><![CDATA[<p>These are the some programs asked in interviews</p><blockquote>write a program sum of the target given in array and find indices</blockquote><pre>class FindIndices{<br>int arr[]= {1,2,5,3,7,8};<br>  int target=15;<br>  findIndices(arr,target);<br>//  o/p - ele are found 2 - 4<br>     //  ele are found 4 - 5<br>}<br>public static void findIndices(int[] a,int t){<br>   int start=0,end=0,sum=0;<br>while(end&lt;a.length){<br>  sum+=a[end];<br>  while(sum &gt; t &amp;&amp; start&lt;end){<br>   sum-=a[start];<br>start++;<br>}<br>if(target==sum){<br>  System.out.println(&quot;ele are found &quot; + start + &quot; - &quot; + end);<br>}<br>end++;<br>}<br>}</pre><blockquote>Move zeros left side and 1’s right side</blockquote><pre>1.BRUTE-FORCE APPROACH :   o/p : 0 0 0 0 1 1 1 1 <br>    int[] num= {1,0,1,1,0,0,1,0};<br>  int len=num.length;<br>int[] newArray=new int[len];<br>int k=0;<br>for(int i=0;i&lt;len;i++){<br>if(num[i]==0){<br>newArray[k++]=num[i];<br>}<br>}<br> for(int i=0;i&lt;num.length;i++) {<br>     if(num[i]==1) {<br>      na[k++]= num[i]; <br>     }<br>    }<br>    for(int n : na) {<br>     System.out.println(n);<br>    }<br>2.No extra space  o/p : 0 0 0 0 1 1 1 1<br>      int[] num= {1,0,1,1,0,0,1,0};<br>    int k=0;<br>    int[] na=new int[num.length];<br>    for(int i=0;i&lt;num.length;i++) {<br>     if(num[i]==0) {<br>     na[k++]= num[i];<br>      <br>     }<br>    }<br>    while(k&lt;num.length) {<br>     na[k++]=1;<br>    }<br>    for(int w : na) {<br>     System.out.println(w + &quot; &quot;);<br>}<br><br>3.In the given array only swap.  o/p : 0 0 0 0 1 1 1 1<br><br>int[] num= {1,0,1,1,0,0,1,0};<br>    int k=0;<br>    int start=0,end=num.length-1;<br>    while(start&lt;end) {<br>     if(num[start]==1 &amp;&amp; num[end]==0) {<br>      int tendmp=num[start];<br>      num[start]=num[end];<br>      num[end]=tendmp;<br>      start++;<br>      end--;<br>     }<br>     else if(num[start]==0) {<br>      start++;<br>     }else {<br>      end--;<br>     }<br>    }<br>    for(int w : num) {<br>    System.out.println(w);<br>    }</pre><blockquote>write a program count consecutive letters and convert it into numbers</blockquote><p>eg : String s=”aabbbcccc”;<br> convertCharToNum(s); o/p : a2b3c4</p><pre>private static void  convertCharToNum(String s){<br>//First we have to split the string &quot;aabbbcccc&quot; and place into new array<br>  String[] str=s.split(&quot;&quot;);<br>  String res=&quot;&quot;;<br>//Take a set and distinct char will present a,b,c,d and convert array into List <br>  LinkedHashSet&lt;String&gt; lhs=new LinkedHashSet&lt;&gt;(Arrays.asList(str)); <br>  String[] ne=new String[lhs.size()];<br>// Again convert List into array <br>  ne=lhs.toArray(ne);<br>//traverse the loop [a,b,c,d]<br>  for(int i=0;i&lt;ne.length;i++){<br>   int count=0;<br>//it will traverse entire 1st array [aabbbcccc]<br>   for(int j=0;j&lt;str.length;j++){<br>//if it match then increment by 1<br>    if(ne[i].equals(str[j]){<br>     count++;<br>    }<br>   }<br>// then add <br>   res+=ne[i]+count;<br>  }<br>   System.out.println(res);<br>}<br></pre><blockquote>write a program convert number into consecutive letter</blockquote><p>eg: a2b3c4 — aabbbcccc</p><pre>private static void convertNumToChar(String s) {<br>  for(int i=0;i&lt;s.length();i++) {<br>   if(Character.isAlphabetic(s.charAt(i))) {<br>    System.out.println(s.charAt(i));<br>   }else {<br>    int a=Character.getNumericValue(s.charAt(i));<br>    for(int j=1;j&lt;a;j++) {<br>//  here we check the current element is number and we override that number of times with previous letter<br>     System.out.println(s.charAt(i-1));<br>    }<br>   }<br>  }<br>}</pre><p><em>write a program find consecutive 1’s count ?</em></p><pre>public class Practice{<br> public static void main(String[] args) {<br>  int[] a= {1,1,0,0,1,1,1,1,0};<br>  findConsecutiveOnes(a); // o/p : 4<br>  <br> }<br><br> private static void findConsecutiveOnes(int[] a) {<br>  int count=0;<br>  int max=0;<br>  int s=0,e=0;<br>  for(int i=0;i&lt;a.length;i++) {<br>   while(e&lt;a.length &amp;&amp; a[i]==1) {<br>    count++;<br>    i++;<br>   }<br>   if(max&lt;count) {<br>    max=count;<br>   }<br>   count=0;<br>  }<br>  System.out.println(max);<br>  <br> }<br>}</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=44ebdb9ab6a2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Oops in Java]]></title>
            <link>https://medium.com/@pashikantirockesh/oops-in-java-14596573414b?source=rss-27f5711ce093------2</link>
            <guid isPermaLink="false">https://medium.com/p/14596573414b</guid>
            <dc:creator><![CDATA[Pashikanti Rakesh]]></dc:creator>
            <pubDate>Thu, 30 May 2024 04:20:37 GMT</pubDate>
            <atom:updated>2024-05-30T07:06:15.841Z</atom:updated>
            <content:encoded><![CDATA[<p>Object means a real-world entity such as a pen, chair, table, computer etc., It simplifies software development and maintenance by providing concept.</p><p><strong><em>Abstraction</em></strong> :Abstraction is the property which is hiding the implementation details are called abstraction. It means we are providing the method declaration and we did not provide the method body. The method body will be provided in another class which are extends the abstract class or implements the interface.</p><p>Abstraction in java done by 2 ways</p><ol><li>Abstract classes : Abstract class are declared with abstract keyword while creating the class. If we are declare the class as abstract all the methods are default abstract and we did not provide abstract keyword manually. It provides the partial abstraction.</li><li>In the abstract class may contain concrete methods and did not create the object. But we can create the constructors because concrete methods declares the constructors.</li></ol><blockquote>Interface.</blockquote><p>In Interface we declare methods and the implementation logic will be provided in the another class which are implements the interface. Interface methods are default public &amp; abstract, don’t require to write manually.</p><p>If we create any instance var. the declaration must be at the time of variable declaration.</p><p>It gives the full abstraction and we did not create the objects.</p><p>below eg. how to create interface:</p><pre>public interface Calculate{<br>  public int addition(int a,int b);<br>  public int subtract(int a,int b);<br>}<br>public User implements Calculate{<br>  public int addition(int a,int b){<br>return 5+4;<br>}<br>  public int subtract(int a,int b){<br>    return 54-13;<br>}</pre><blockquote><strong>Inheritance</strong> : Inheritance is the property acquiring the Parent class properties to the child class is called inheritance. Using inheritance we can reuse the existing code. We can add more features to existing class without modifying it by extending it through its subclass. Inheritance is implemented by using “ extends “ keyword.</blockquote><p>All the data and methods which were present in Parent class is by default available to child class but the reuse is not applicable. By using child class ref. we can call both parent and child class methods. But by using Parent class ref. we can call only methods available in the Parent class &amp; we can not call Child class specific methods.</p><p>Parent class ref. can hold the child class object, but child class ref cannot be used to hold Parent class obj. Constructors are not inherited in to the sub class during inheritance, we can call the constructor of super class by invoking the super class obj.</p><p>Java supports 3 types of inheritance .</p><p>Single inheritance, multi-level inheritance, hybrid inheritance.</p><p>Java does not support multiple Inheritance because the ambiguity issue.</p><p><em>Encapsulation </em>: It is a process of wrapping code and data together into a single unit. Hiding the internal details of an object and allows access to its functionality.<br> Encapsulation in java can be achieved by including both var (data) and methods.<br> It is a way to achieve data hiding in java become other class will not be able to access the data through the private data members.<br> Make all the data members of the class private, now use public setter and getter methods for those variables.</p><p>Adv : Achieve security &amp; code reusability.</p><p>Polymorpism : It is an ability to perform mulitiple tasks with the same identity.<br> It can achieve 2 ways.<br> 1.Method Overloading : writing 2 or more methods in the same class having same name but different parameters.<br> Compiler will choose the appropriate method to execute based on the number of argument, order of argument and type of argument passed at run time. return type dosen’ t matters.<br> method resolution always takes care by compiler based on the ref type and it is also called as compile time polymorphism / static binding/ early binding.</p><p>Overloading compiler always gives presidence for child type argument then compare with Parent type argument.<br>Automatic promotion in Overloading. <br> while resolving overloading methods if exact method is not available then we won’t get any compile time Exception. First the argument will promotes to the next level<br>and check whether method matched is available or not if matched method is available then it will be configured &amp; this process will continue up to method matched to possible <br>promotion if there is no matched method then it get Compile time Exception.</p><pre>public class A {<br> <br> public int add(int a,int b) {<br>  return (a+b);<br> }<br> <br> public int add(int a,int b,int c) {<br>  return (a+b+c);<br> }<br><br>}</pre><p>Method Overriding : Writing 2 or more methods in 2 different class and having same name, same parameter and same return type. It means a method in a subclass that already exist in super class. When the method is called on object of child class the implementation in the child class will be executed instead of the implementation in the parent class.</p><p>Method resolution always takes care by JVM based on the run time object ref and it is called as run time polymorphism / dynamic polymorphism / late binding.<br>Parent class private methods are not available to child class methods hence overriding is not applicable for both private and final methods.<br>If child class is throw any checked Exception Parent class must be throw the same type exception or its Parent type. but no restriction for Unchecked Exceptions.<br>Parent &amp; child class methods are static we wont get any checked exception it seems to be overriding but it is not overriding it is method hiding. Because static methods are bonded using static binding at compile time, overriding is based on dynamic binding at run time.</p><pre>public class A {<br> public void show() {<br>  System.out.println(&quot;from parent class&quot;);<br> }<br>}<br><br>public class B extends A{<br> <br> @Override<br> public void show() {<br>  // TODO Auto-generated method stub<br>  super.show();<br>  System.out.println(&quot;from child class&quot;);<br> }<br>}<br>//Main class<br>public static void main(String[] args) {<br> A a =new A();<br> a.show(); //from parent class<br> <br> A b =new B();<br> b.show(); // //from parent class<br>           //from child class<br><br>B b1=new B();<br> b.show();// from child class<br> <br> B b2=new A();<br> b2.show();  // java.lang.Error: Unresolved compilation problem: <br>              //   Type mismatch: cannot convert from A to B<br>}<br></pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=14596573414b" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>