+ 1
Why does the code shows error?
Abstraction and interfaces in java
4 ответов
+ 3
Ok thank you 🅰🅹 🅐🅝🅐🅝🅣 ,Karthik Reddy Thotamgari
+ 2
alagammai uma
Because you have created abstract class inside another class
Also there is extra curly brackets on line no 14
You can't instantiate abstract class. You have to create object like this
Car obj = new Jack();
https://code.sololearn.com/cOhBQ6FkHDpp/?ref=app
+ 2
abstract class Car
{
abstract void speed();
}
class Jack extends Car
{
void speed()
{
System.out.println("hello");
}
}
public class Main{
public static void main(String[] args)
{
Jack obj=new Jack ();
obj.speed();
}
}
Try this and u cannot create instance to the abstract class