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

+1

Why does the code shows error?

Abstraction and interfaces in java

4/29/2021 12:00:09 PM

alagammai uma

4 Answers

New Answer

+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

0

https://code.sololearn.com/cPsmMAnxshiO/?ref=app