Thursday, October 20, 2011

Collaborative Review

The students in my software engineering class are reviewing for the midterm.
To contribute to the group study session, here are 5 review questions (and answers)
of my own:

1) Name three features often provided by an IDE.

The most common features include:

  • Language-aware editing (syntax-highlighting)
  • Integrated compilation (and execution)
  • Integrated debugger
  • Project definition facilities

Extra features may also include: wizards (class creation, etc), content assistance, refactoring, diagramming, project file manager, plugins (for tools such as configuration management, QA testing, JUnit, etc).

2) Give an example of an annotation tag commonly used in Java.

The Java compiler recognizes: @Override, @Deprecated, and @SuppressWarnings.

JUnit uses: @Test, @Before, @After, @BeforeClass, @AfterClass, and @Ignore.

Annotations can also take parameters, as in: @Test(expected=UnsupportedOperationException.class).

3) Which two methods in class Object should you override if you suspect that instances of your class might some day be need to be stored in a Collection?

equals and hashCode.

4) How do you use @Override in Java? What does it do?

@Override is an annotation that you should add at the beginning of a method definition if that method is intended to override a method in a superclass or interface. Example:

  public String toSting() { ...

Thanks to the @Override tag, I would now get a compile-time warning that toSting() does not actually override a method. (This is because I misspelled String.)

Using @Override when overriding interface methods is only supported with Java 1.6+.

5) Ant is a build system. Name another one.

Maven and Make are also build systems.


  1. A good review question too?

    If you're still the TA for ICS 111/211, I hope you tell your students not to commit this mistake.

  2. Yeah, I've been teaching them that in 111. :) Using == is particularly insidious when comparing Strings. If both Strings compared were initially created as literals, it will work successfully. But if one of the Strings came from the user or elsewhere, then it fails.