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

i think they are wrong

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
a) An interface that is declared within the body of a class or interface is known as a nested interface.
b) A class declaration can be a member of an interface.

the two questions are from a mock exam. the answer is that they are right. but I test them. they are wrong.
i.e

interface A{
B b; //if you declare B here, there is a compile error.
A1 a; //the same as above. you have to initialize a.
}
interface B{}
class A1{}
 
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think they meant "defined" rather than "declared." That is...

Which mock exam is this in?
 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think nested interface declaration and classes is available thru this

button.addEventListener(new ActionListener(){
public void actionPerformed(){
//do stuff
}
});

the syntax may be wrong but that is and inner interface being instantiated, and such and interface can be considered to be instantiated and if we use something like WindowAdapter, then that will be a class being instantiated but realy what we are creating is an object that implements the interface
 
feng cao
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
in Dan Chisholm mock exam. chapter10
 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
[Marc]: I think they meant "defined" rather than "declared." That is...

I think "declared" is perfectly fine here. That's the term the JLS would use. The distinction to be made here is that the original poster thought the question was talking about the declaration of a field (at least, that's what his test code is about), and the question was actually about nested class and interface declarations (as shown in Marc's code example).
 
I'm THIS CLOSE to ruling the world! Right after reading this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic