what is abstract class In java
An abstract class is class that contaions 0 or more abstract methods.
// all the object different implementation of the method abstract class myClass
abstract class Myclass
{
abstract void calculate(double x);
}
class Demo1 extends Myclass
{
void calculate(double x)
{
System.out.println("Square="+(x*x));
}
}
class Demo2 extends Myclass{
void calculate(double x){
System.out.println("Square root="+Math.sqrt(x));
}
}
class Demo3 extends Myclass{
void calculate(double x){
System.out.println("Cube="+(x*x*x));
}
}
class MainClass
{
public static void main(String[]arr)
{
Demo1 d1=new Demo1();
Demo2 d2=new Demo2();
Demo3 d3=new Demo3();
d1.calculate(4);
d2.calculate(5);
d3.calculate(6);
}
}
An abstract class is class that contaions 0 or more abstract methods.
// all the object different implementation of the method abstract class myClass
abstract class Myclass
{
abstract void calculate(double x);
}
class Demo1 extends Myclass
{
void calculate(double x)
{
System.out.println("Square="+(x*x));
}
}
class Demo2 extends Myclass{
void calculate(double x){
System.out.println("Square root="+Math.sqrt(x));
}
}
class Demo3 extends Myclass{
void calculate(double x){
System.out.println("Cube="+(x*x*x));
}
}
class MainClass
{
public static void main(String[]arr)
{
Demo1 d1=new Demo1();
Demo2 d2=new Demo2();
Demo3 d3=new Demo3();
d1.calculate(4);
d2.calculate(5);
d3.calculate(6);
}
}
1 comments:
IntersetiIng
Post a Comment