- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
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
What is method hiding in Java and how to use it?
When super class and sub class contains same method including parameters and if they are static.
The method in the super class will be hidden by the one that is in the sub class. This mechanism is known as method hiding.
Example
class Demo{ public static void demoMethod() { System.out.println("method of super class"); } } public class Sample extends Demo { public static void demoMethod() { System.out.println("method of sub class"); } public static void main(String args[] ) { Sample.demoMethod(); } }
Output
method of sub class
- Related Articles
- What is the difference between method hiding and method overriding in Java?
- What is the difference between method overloading and method hiding in Java?
- What is method hiding in C#?
- What is the ‘if’ statement in Java and how to use it?
- What is a break statement in Java and how to use it?
- What is a continue statement in Java and how to use it?
- What is instance variable hiding in Java?
- What is the type conversion operator ( ) in Java and how to use it?
- What is the ‘if else’ statement in Java and how to use it?
- What is the ‘nested if’ statement in Java and how to use it?
- What is a switch case statement in Java and how to use it?
- What is the difference between function overriding and method hiding in C#?
- What is SignalR and how to use it?
- What is the ‘if...else if...else’ statement in Java and how to use it?
- Difference between Method Overriding and Method Hiding in C#

Advertisements