File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes abstract inner classes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "abstract inner classes" Watch "abstract inner classes" New topic
Author

abstract inner classes

Rachana Sharma
Greenhorn

Joined: Jun 21, 2005
Posts: 15
hello everyone,

could anyone please tell me how is an abstract inner class implemented by other classes.
some sort of code snippet would be really helpful as iam very confused.

Thanks in advance.
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
Try to write something yourself, compile and run it. If it does not work post it - for discussion and help. You will learn much better that way.


Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
Devender Thareja
Ranch Hand

Joined: Jul 14, 2005
Posts: 187
Here you go:

public class SychTest
{
abstract public class InnerTest
{
abstract public void test();
}

private class InnerTest1 extends InnerTest
{
public void test()
{
return;
}
} ;
InnerTest1 test1= new InnerTest1();

}


Devender Thareja
SCEA, SCBCD, SCJP
Rachana Sharma
Greenhorn

Joined: Jun 21, 2005
Posts: 15
Thanks for the answer.

Just go through the code and my doubt is why does the compiler show error when we don't extend the outer class and just want to extend the outer.inner in the TestInner.

Rahul Krishan
Greenhorn

Joined: Jan 01, 2003
Posts: 2
While extending the inner classes, we have to explicitly set some relation between the extending class and the outer class for this inner class. So, the issue is resolved when we go by the second approach. The other approach could be

public class Test{
class TestInner extends Outer.Inner{
TestInner(Outer o){
o.super();
}

public void show(){
System.out.println("in the test1 class!!");
}
}

public static void main(String ar[]){
Test test=new Test();
Outer oo = new Outer();
Test.TestInner in=test.new TestInner(oo);
in.show();
}
}

Hope this solves the issue.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: abstract inner classes
 
Similar Threads
access modifiers.
inner classes
I still have problems creating abstract inner classes?
abstract private combination (Exam Lab)
static and abstract inner class