Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

A question about container!

 
laura_zpf
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the list below, which subclass(es) of Component cannot be directly instantiated:
a) Panel
b) Dialog
c) Container
d) Frame
The answer is Container. But why the Container can not be instantiated directly?
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
'cos Container is an abstract class.
 
laura_zpf
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have checked the document, but I do not find that the Container is abstract. It is defined as public class Container extends component.
 
laura_zpf
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have checked the document, but I do not find that the Container is abstract. It is defined as public class Container extends component.
 
ramani2020
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
from Bill Brogden's Java2 Exam Cram,

Container was an abstract class in Java 1.0 and 1.1,but for the Java JDK1.2 it is no longer declared abstract.

HTH,
Ramani.
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Laura,
All the options you have given can be instantiated.
In fact (d) is also correct. You can try this out:
Container c = new Container();
Ramani has correctly pointed out that Conatiner is no longer an abstract class.
Hope this helps
-sampaths
 
laura_zpf
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you! sampaths77! you means this question only correct in the JDK1.0 but not correct for now.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic