Answers for "abstract class in java code example"

1

implementing an abstract class jaav

interface human {
    void dothings();
    void eatthings();
    void sleep();
}
abstract class student implements human {
    public void dothings()
    {
        System.out.println("doing something");
    }
    public void eatthings()
    {
        System.out.println("eating something");
    }
}
class basisstudent extends student {
    public void sleep()
    {
        System.out.println("no");
    }
}
public class Main {
    public static void main(String[] args)
    {
        basisstudent you = new basisstudent();
        you.dothings();
        you.eatthings();
        you.sleep();
    }
}
Posted by: Guest on August-19-2021
2

abstract class example in java

//abstract parent class
abstract class Animal{
   //abstract method
   public abstract void sound();
}
//Dog class extends Animal class
public class Dog extends Animal{

   public void sound(){
	System.out.println("Woof");
   }
   public static void main(String args[]){
	Animal obj = new Dog();
	obj.sound();
   }
}
Posted by: Guest on November-11-2020

Code answers related to "abstract class in java code example"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language