Say that I'm wrong, but I'm sure you can instanciate abstract classes | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
- 1

Say that I'm wrong, but I'm sure you can instanciate abstract classes

You just need to define the abstract methods while instanciating: abstract class A { absract void print(String val); } public static void main(String[] args) { A obj = new A(){ print(String val) { System.out.println(val); } }; }

18th Oct 2018, 6:46 PM
Keheck
Keheck - avatar
1 Answer
+ 1
Well, its nothing new... They are called anonymous classes and you can use with concrete/abstract classes and interfaces
18th Oct 2018, 7:12 PM
KrOW
KrOW - avatar