
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
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
Define an Abstract Class with No Abstract Methods in Java
Yes, we can declare an abstract class with no abstract methods in Java.
An abstract class means that hiding the implementation and showing the function definition to the user.
An abstract class having both abstract methods and non-abstract methods.
For an abstract class, we are not able to create an object directly. But Indirectly we can create an object using the subclass object.
A Java abstract class can have instance methods that implement a default behavior.
An abstract class can extend only one class or one abstract class at a time.
Declaring a class as abstract with no abstract methods means that we don't allow it to be instantiated on its own.
An abstract class used in Java signifies that we can't create an object of the class directly.
Example
abstract class AbstractDemo { // Abstract class private int i = 0; public void display() { // non-abstract method System.out.print("Welcome to Tutorials Point"); } } public class InheritedClassDemo extends AbstractDemo { public static void main(String args[]) { AbstractDemo demo = new InheritedClassDemo(); demo.display(); } }
In the above example, we have not defined an abstract method in AbstractDemo class. The compiler doesn't throw any compile-time error.
Output
Welcome to Tutorials Point