SCJP Module-3 Question-7


 

SCJP Module-3 Question-7

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

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.

Ads