Win a copy of Secure Financial Transactions with Ansible, Terraform, and OpenSCAP this week in the Cloud/Virtualization forum!
  • 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
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Rob Spoor
  • Henry Wong
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh
  • Jj Roberts

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've been selected to go to the moon! All thanks to this tiny ad:
SKIP - a book about connecting industrious people with elderly land owners
https://coderanch.com/t/skip-book
reply
    Bookmark Topic Watch Topic
  • New Topic