google.com, pub-4617457846989927, DIRECT, f08c47fec0942fa0 Learn to enjoy every minute of your life.Only I can change my life.: Java Program for Inheritance

Sunday, February 10, 2019

Java Program for Inheritance




JAVA PROGRAM FOR INHERITANCE:




import java.io.*;
 class Base
 {
     int a,b;
     void get( )
     {
         InputStreamReader ip=new InputStreamReader(System.in);
         BufferedReader br=new BufferedReader(ip);
         String ap;
         try
         {
            System.out.println("Enter Value of A:");
            ap=br.readLine( );
            a=Integer.parseInt(ap);

            System.out.println("Enter Value of B:");
            ap=br.readLine( );
            b=Integer.parseInt(ap);
           }
          catch(Exception e)
          {
            System.out.println(e);
           }
        }
    }
 class Derived extends Base
 {
    void disMin( )
    {
       if(a<b)
        System.out.println("Minimum Value is A:"+a);
       else
        System.out.println("Minimum Value is B:"+b);
       }
    void disMax( )
    {
       if(a>b)
         System.out.println("Maximum Value is A:"+a);
       else
         System.out.println("Maximum Value is B:"+b);
       }
   }
 class Inheritance
 {
   public static void main(String args[])
   {
      Derived dd=new Derived( );
      dd.get( );
      dd.disMin( );
      dd.disMax( );
    }
 }


*****************************************


OUTPUT:

*****************************************      
C:\vijay\advjava\jdk1.4\bin>java Base

Enter Value of A:
232
Enter Value of B:
236

Minimum Value is A:232
Maximum Value is B:236

C:\vijay\advjava\jdk1.4\bin>








शिव भोलेनाथ स्तुति

 जय शिवशंकर, जय गंगाधर, करुणा-कर करतार हरे,   जय कैलाशी, जय अविनाशी, सुखराशि, सुख-सार हरे जय शशि-शेखर, जय डमरू-धर जय-जय प्रेमागार हरे,   जय ...