- 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 you extend a static inner class in Java?
A static inner class is a nested class which is a static member of the outer class. It can be accessed without instantiating the outer class, using other static members. Just like static members, a static nested class does not have access to the instance variables and methods of the outer class.
You can extend static inner class with another inner class.
Example
public class SampleClass { static abstract class Test{ int num = 300; public abstract void display(); } class DemoClass extends Test{ public void display() { System.out.println("Hi how are you"); } } public static void main(String args[]){ SampleClass obj = new SampleClass(); obj.new DemoClass().display(); } }
Output
Hi how are you
- Related Articles
- How to access Static variable of Outer class from Static Inner class in java?
- Can Enum extend any class in java?
- How to instantiate a static inner class with reflection in Java?
- Inner class in Java
- Local inner class in Java
- Static class in Java
- Can a method local inner class access the local final variables in Java?
- What is a static class in Java?
- Can we extend interfaces in Java? Explain?
- Can we extend an enum in Java?
- Can a diamond operator be used with an anonymous inner class in Java 9?
- What is an Inner class in Java?
- What is the difference between static classes and non-static inner classes in Java?
- Extend data class in Kotlin
- What happens if we try to extend a final class in java?

Advertisements