Monday, 2 April 2018

Abstraction in java (Object Oriented Programming pillar)







package javaapplication24;



abstract class shape

{



public abstract void printarea();



}

class triangle extends shape

{

   float b,h;

public  void printarea()

{

    System.out.println("area of triangle is "+0.5*b*h);

}

}



class square extends shape

{

    float s;

public  void printarea()

{

    System.out.println("area of triangle is "+s*s);

}



}







public class JavaApplication24 {



 

    public static void main(String[] args)

    {

        triangle t=new triangle();

        t.b=5;

        t.h=10;

        t.printarea();

   

        square s=new square();

        s.s=2.5f;

        s.printarea();

   

    }

   

}


No comments:

Post a Comment

Pass Dynamically Added Html Table Records List To Controller In Asp.net MVC

Controller Code: using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using ...