- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
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 a class in Java be both final and abstract?
An abstract cannot be instantiated. Therefore to use an abstract class you need to create another class and extend the abstract class and use it.
If a class is final you can’t extend it further.
So, you cannot declare a class both final and abstract.
Example
Still if you try to do so you will get a compile time error saying “illegal combination of modifiers:”
final abstract class Demo{ public final void display(){ System.out.println("Hello welcome to tutorialspoint"); } }
Output
C:\Sample>javac Demo.java Demo.java:1: error: illegal combination of modifiers: abstract and final final abstract class Demo{ ^ 1 error
- Related Articles
- Why can't a Java class be both abstract and final?
- Can constructors be marked final, abstract or static in Java?
- Can a final class be subclassed in Java?
- Can we declare an abstract method final or static in java?
- Can we define an abstract class with no abstract methods in Java?
- Abstract class in Java
- Can we define an abstract class without abstract method in java?\n\n
- Can a constructor be made final in Java?
- Differences between abstract class and concrete class in Java
- Can we define a parameterized constructor in an abstract class in Java?
- Final class in Java
- Make a class final in Java
- Difference between Abstract Class and Interface in Java
- Differences between abstract class and interface in Java
- Can we create an object of an abstract class in Java?

Advertisements