Which is the Best Java Web Framework ?

Java - Things to know before your OCJP exam - Inner Classes

1. Static inner class cannot access instance members of the enclosing class.

2. Local class declared within static method cannot access instance members.

3. * Static inner class can be accessed without instance of the parent class.

4. * In case of local inner classes , we can even instantiate using new with the interface.

new runnable (){

public void run() {}

}

is valid whereas

new runnable(); isn't

5. An inner class can access all elements of the parent class , even declared private.

6. * To instantiate the inner class object following code is used

OuterClass.InnerClass innerRef = outerRef.new InnerClass();

7. From code within the inner class, this refers to inner class. To access outer class we should do OuterClass.this.

8. An anonymous inner class can either extend one class or implement one interface only.

9 Anonymous inner class should be ended with a semi colon after curly brace.

10. * Static inner class can be instantited like this

OuterClass.InnerClass inner = new OuterClass.InnerClass();
Subscribe to Java News and Posts. Get latest updates and posts on Java from Buggybread.com
Enter your email address:
Delivered by FeedBurner
comments powered by Disqus




×

Try our new Java Interview Questions Search Tool.

There are more than 1000 questions with practice tests.

It's updated daily and It's Awesome.


×

Try our new Java Practice Test tool.

There are more than 200 questions and expanding quickly. It's updated daily and It's Awesome.