

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Is it possible to create a class without a name in Java?
Yes, we can create a class without a name using the Anonymous class.
Anonymous class is an inner class which does not have a name and whose instance is created at the time of the creation of class itself and these classes are somewhat different from normal classes in its creation.
Example :
public class Anonymous { public void show() {} public static void main(String args[]) { Anonymous a = new Anonymous() { public void show() { System.out.println("Anonymous Class"); } }; a.show(); } }
Output
Anonymous Class
- Related Questions & Answers
- Is it possible to create a custom exception in java without extending Exception class?
- Is it possible to override a Java method of one class in same?
- Is it possible to create static constructor in java?
- Is it possible to use pyplot without DISPLAY?
- Is it possible to create a new data type in JavaScript?
- What is the difference between simple name, canonical name and class name in a Java class?
- Is it possible to throw exception without using "throws Exception" in java?
- How to access the object of a class without using the class name from a static context in java?
- Check if it is possible to create a polygon with a given angle in Python
- Is it possible for human beings to live without any goals?
- Is it possible to use variable for collection name using PyMongo?
- Is it possible to cast in a MongoDB Query?
- Is it possible to assign a numeric value to an enum in Java?
- Is it possible to assign a reference to "this" in java?
- Is it possible to calculate a correlation in a MySQL query?
Advertisements