File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Inner classes

 
majohnad majohnad
Greenhorn
Posts: 24
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is the below statements are true?
"An abstact class must declare at least one abstract method"
"A local class can be declared abstract."
 
Rattan Mann
Ranch Hand
Posts: 44
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are right on both counts. In fact, local inner class can be declared only abstract or final. It can't be declared public, protected, private etc.
Rattan
 
Corey McGlone
Ranch Hand
Posts: 3271
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"An abstact class must declare at least one abstract method"

False.
If the class contains 1 or more abstract methods, it must be declared abstract, but it is not required that a class contain an abstract method to be declared abstract.
"A local class can be declared abstract."

True.
An Inner Class isn't really that different from a top-level class - they can be abstract.
I hope that helps,
Corey
 
Francis Siu
Ranch Hand
Posts: 867
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi majohnad
"An abstract class must declare at least one abstract method"
I make sure that the above statement is false
because abstract class can contains no abstract method.For example MouseAdapter or KeyAdapter.
 
Roger Chung-Wee
Ranch Hand
Posts: 1683
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
An abstract class does not have to have any abstract methods, or any methods at all, but must be declared abstract if it has any abstract methods.
A method-local class (which is not an anonymous class) can be abstract. It can also be final or strictfp. No other modifiers are allowed, because such a class cannot be accessed from the outside, so the other modifiers make no sense.

[ April 21, 2003: Message edited by: Roger Chung-Wee ]
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic