+ 1

Can we create object for an abstract class ?

If yes tell me how ?

20th Feb 2020, 7:03 PM
Akash
5 odpowiedzi
+ 2
No. Abstract class doesnot have full implementations for all of its methods so you can't..
20th Feb 2020, 7:24 PM
Jayakrishna 🇮🇳
+ 1
Just answered couple of hours ago. https://www.sololearn.com/Discuss/2176352/?ref=app Use the search bar for similar questions because they might have been answered already.
20th Feb 2020, 8:01 PM
Avinesh
Avinesh - avatar
0
yes, if it implements its abstract methods abstract class A { abstract void method(); } public class Program { public static void main(String[] args) { A a = new A() { void method(){} }; } }
20th Feb 2020, 8:08 PM
zemiak
0
zemiak You are creating an instance of the anonymous subclass of the abstract class. Here you have given a reference to the abstract class which holds your subclass object. This is different from an actual abstract class being instantiated directly, which is not possible.
20th Feb 2020, 8:19 PM
Avinesh
Avinesh - avatar
0
yes you are right, theoretically it is different, I thought about it from more practical point of view, the question does not specify that the creation must be directly.
20th Feb 2020, 8:57 PM
zemiak