Tuesday, July 27, 2021

simple program using Abstract Class & Abstract functions (Java) (213)

package com.company;
abstract class parent1
{
public parent1(){
System.out.println("i ma a constructor of a parent class");
}
abstract public void test();
}
class child2 extends parent1
{
public void test()
{
System.out.println("this is the function of child2");
}
}
abstract class child3 extends parent1
{
public void child3()
{
System.out.println("i am a constructor of a child3 class");
}
}
public class Program50 {
public static void main(String[] args) {
// child3 obj2=new child3(); wrong we cannot make the object of abstruct class
child2 obj=new child2();
obj.test();
}
}

No comments:

Post a Comment