• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Reg. some statements

 
Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Consider the below statements :
1. The keyword "continue" can never occur inside a switch
statement ( True/False )

>> I suppose it can occur provided there is a for,while,
do-while within the case label code statements.
So it should be false.
2. MouseMotionListener can be registered on all objects that
are instances of Container.For eg : List
>> Can someone explain me the above.
3. An inner class can extend any class
or interface.
>> An inner class can even extend
the class inside which it is nested also.
See the below code :

What is reason behind doing so ?

[This message has been edited by Angela Narain (edited October 01, 2001).]
 
Author & Gold Digger
Posts: 7617
6
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Angela,
Concerning the first statement, continue cannot appear in a switch block. If you have a loop inside the switch block the continue does not appear inside the switch at all but inside the loop as you pointed out...
Concerning the second statement, MouseMotionListeners may be added to Components, since Container is a subclass of Component you can add MouseMotionListeners to Containers too !
HIH
------------------
Valentin Crettaz
Sun Certified Programmer for the Java 2 Platform
 
Angela Narain
Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Val,
W.r.t to the first statement regarding continue will
it be considered as false.
 
Valentin Crettaz
Author & Gold Digger
Posts: 7617
6
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yep continue will not be allowed DIRECTLY inside a switch block. But if the continue appears in a nested loop it is legal, so as the question is worded I would say false because continue may appear inside a nested loop in the switch...
------------------
Valentin Crettaz
Sun Certified Programmer for the Java 2 Platform
 
Ranch Hand
Posts: 2120
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Regarding the third point:
Nested classes have some limitations. This is one. Other could be constructing a hierarquy of Nested clasess with two, three or more levels.
One reason for using nested classes could be adding funtionality (a new type, implying multiple inheritance) to the containning class. But a nested class that extends from the outer would be adding the same methods as the outer. Thus it isn't very useful.

Now a bit of Java-fiction: The nested class could override some methods of the outer in a diferent way as they are implemented in the outer. Doing this an instance of the inner would be a diferent type of the outer class than the instances of the outer are. Having an object that is a type but can do also diferent things seems to me more dangerous than useful. Any comments?
reply
    Bookmark Topic Watch Topic
  • New Topic