<< A Free JDK Finally Arrives | Home | OpenDDS 1.1 Released >>

Friday Java Quiz: Know Your Interfaces

We go back to basics this week.

Q: Given the following interface definition:

interface Foo {
  int ZERO = 0;
  public int ONE = 1;
  public static int TWO = 2;
  public static final int THREE = 3;

  void first();
  abstract void second();
  public abstract void third();
}

Which of the following are true (choose all that apply):

  1. ZERO is not public
  2. ONE is not static
  3. TWO is not final
  4. first() is not abstract
  5. second() is not public
  6. None of the above
  7. One of the above
  8. Two of the above
  9. Three of the above
  10. All of the above

And we revert back to strict rules: no books, no googling, no internet, no compiling. Just stare at the code and think.

Tags :


Re: Friday Java Quiz: Know Your Interfaces

First post! None of the above. ;-)

Re: Friday Java Quiz: Know Your Interfaces

Yeah, what Crazy Bob said.

Re: Friday Java Quiz: Know Your Interfaces

Technically speaking, 6, 7, 8, 9 are all correct answers.

Re: Friday Java Quiz: Know Your Interfaces

huh? please explain for the record I thought #4 was true, all others false

Re: Friday Java Quiz: Know Your Interfaces

JLS 9.4:

Every method declaration in the body of an interface is implicitly abstract, so its body is always represented by a semicolon, not a block.

Every method declaration in the body of an interface is implicitly public.

Re: Friday Java Quiz: Know Your Interfaces

like this!

Add a comment Send a TrackBack