Why does the code shows error? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Why does the code shows error?

Abstraction and interfaces in java

29th Apr 2021, 12:00 PM
alagammai uma
alagammai uma - avatar
4 Answers
29th Apr 2021, 3:44 PM
alagammai uma
alagammai uma - avatar
+ 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
29th Apr 2021, 12:51 PM
A͢J
A͢J - avatar
+ 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
29th Apr 2021, 3:28 PM
kreddyt
kreddyt - avatar
29th Apr 2021, 12:01 PM
alagammai uma
alagammai uma - avatar