 
  Data Structure Data Structure
 Networking Networking
 RDBMS RDBMS
 Operating System Operating System
 Java Java
 MS Excel MS Excel
 iOS iOS
 HTML HTML
 CSS CSS
 Android Android
 Python Python
 C Programming C Programming
 C++ C++
 C# C#
 MongoDB MongoDB
 MySQL MySQL
 Javascript Javascript
 PHP 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
Are static methods inherited in Java?
The static keyword is used to create methods that will exist independently of any instances created for the class.
Static methods do not use any instance variables of any object of the class they are defined in. Static methods take all the data from parameters and compute something from those parameters, with no reference to variables.
We can inherit static methods in Java.
Example
In the example we are creating a class named Demo and, declared a static method named display().
We created another class Sample, extended the Demo class and tried to access the display() method using the sub class object.
Example
 class Dem{ public static void display(){} } public class Sample extends Dem { public static void display(){ System.out.println("Hello this is a static method"); } public static void main(String args[]) throws Exception{ new Sample().display(); } }  Output
Hello this is a static method
Advertisements
 