4 posts / 0 new
-->
Priyanka Singh
Jyotiprava

no we can't create the object of abstract class.

Priyanka Singh

We can't create the object of abstract class because we can't instantiate abstract class.If we'll create the object of abstract class(Babychild) and  call the method we'll get compile time error.Let's take an example :

abstract class Child{
    abstract void walk();
}
abstract class Babychild extends Child

{
    abstract void sleep();
    public void walk(){
        System.out.println("Slowly");
    }
}

public class Parent {

    public static void main(String[] args) {
        Babychild b=new Babychild();             //Cannot instantiate the type Babychild
        b.sleep();

    }

}
 

sabyasachi swain

No we can't create the object of abstract class.

abstract class Student {

    
      public void name()              
      {
        System.out.println("Name is devil");
      }
      public void marks()            
      {
        System.out.println("Marks scored are 90");
      }
      public static void main(String args[])
      {
        Student s1 = new Student();   //Cannot instantiate the type Student
      }
    }