- 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
Declare static variables and methods in an abstract class in Java
If a method is declared as static, it is a member of a class rather than belonging to the object of the class. It can be called without creating an object of the class. A static method also has the power to access static data members of the class.
A static variable is a class variable. A single copy of the static variable is created for all instances of the class. It can be directly accessed in a static method.
An abstract class in Java is a class that cannot be instantiated. It is mostly used as the base for subclasses to extend and implement the abstract methods and override or access the implemented methods in abstract class.
Example
abstract class Parent { static void display() { System.out.println("Static method in an abstract class"); } static int x = 100; } public class Example extends Parent { public static void main(String[] args) { Parent obj = new Example(); obj.display(); System.out.print(Parent.x); } }
Output
The output is as follows −
Static method in an abstract class 100
- Related Articles
- Can we declare an abstract method final or static in java?
- Class and Static Variables in Java
- Can we define an abstract class with no abstract methods in Java?
- Demonstrate static variables, methods and blocks in Java
- What is the difference between non-static methods and abstract methods in Java?
- Kotlin static methods and variables
- Class and Static Variables in C#
- How to call a non-static method of an abstract class from a static method in java?
- Static import the Math Class Methods in Java
- What are Class/Static methods in Java?\n
- Instance child class in abstract static method PHP?
- How to declare an Array Variables in Java?
- How do I create static class data and static class methods in Python?
- Abstract class in Java
- Class or Static Variables in Python?

Advertisements