- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Can an anonymous class have constructors in Java?
A constructor should have the name same as the class. Since anonymous inner class has no name, an anonymous inner class cannot have an explicit constructor in Java.
But, Java compiler internally creates a constructor for the anonymous class.
- Related Articles
- Can interfaces have constructors in Java?
- Can we have generic constructors in Java?
- Can a diamond operator be used with an anonymous inner class in Java 9?
- Constructors of StringBuffer class in Java.
- Constructors of StringBuilder class in Java.
- Constructors of StringTokenizer class in Java.
- How to implement an interface using an anonymous inner class in Java?
- How to implement lambda expression without creating an anonymous class in Java?
- Can constructors be inherited in Java?
- Differences between anonymous class and lambda expression in Java?\n
- How to create a thread by using anonymous class in Java?
- What are the types of variables a class can have in Java?
- Can constructors be marked final, abstract or static in Java?
- Can we have an empty catch block in Java?
- Constructors in Java\n

Advertisements