Share on Google+Share on Google+

SCJP Module-3 Question-7

In this tutorial you will test you knowledge of Inner Classes and Outer classes in Java.

Given below the sample code :

class Demo{
demo() {
public class Demo {
funtion() { }


How can  we correct the above code? Select appropriate option :

1.  inner class should be declare as "static"

2. inner class must also declared it's constructor.

3. change the name of the inner class.

4. no need of correction.

Answer :


Explanation :

An inner class can't have the same name as its enclosing class.


Posted on: July 12, 2010 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.


Advertisement null