Why does the code shows error? | Sololearn: Learn to code for FREE!


Why does the code shows error?

Abstraction and interfaces in java

4/29/2021 12:00:09 PM

alagammai uma

4 Answers

New Answer


Ok thank you 🅰🅹 🅐🅝🅐🅝🅣 ,Karthik Reddy Thotamgari


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


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