• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

Inner classes

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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."
 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 coderanch, protected, private etc.
Rattan
 
Ranch Hand
Posts: 3271
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 867
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic