Win a copy of Soft Skills: The software developer's life manual this week in the Jobs Discussion forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Ambiguous use of abstract??

 
Steven Broadbent
Ranch Hand
Posts: 400
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This compiles, as the member class can have modifiers just like
any other member of class Z.
But dosen't this contradict the notion that a class that contains
abstract members must itself be abstract?
class Z {
abstract class A {} // 1
final class B {} // 2
private class C {} // 3
protected class D {} // 4
public class E {} // 5
}
 
Vad Fogel
Ranch Hand
Posts: 504
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Only a class that contains not implemented abstract methods, directly or through inheritance, must be declared abstract. Member classes or interfaces don't count.

8.1.1.1 abstract Classes
An abstract class is a class that is incomplete, or to be considered incomplete. Only abstract classes may have abstract methods (�8.4.3.1, �9.4), that is, methods that are declared but not yet implemented. If a class that is not abstract contains an abstract method, then a compile-time error occurs.
 
Sandhya Jayaram
Greenhorn
Posts: 16
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
is it that only a class having abstract methods has to be abstract itself. but if that abstract class is an inner class then the outer class need not be abstract?
hope i framed the question correctly
-sandhya
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic