Syntax Quiz 2, Step 1

Assignment:

Write a class declaration for a class named QuizClass.

My solution:

class QuizClass
  {
  }
or
public class QuizClass
  {
  }
(the "public" is optional.)

Common mistakes:

Leaving out the word class.
This keyword is required, before the name of the class, to tell Java that you're defining a new class.
Putting quotation marks around the class name.
A class name, like a method name or a variable name, cannot contain quotation marks. If it's in quotation marks, it's a literal string instead of a name.
Putting the curly-braces before class QuizClass.
A class definition can be broken into a header and a body. The header consists of the word class and the name of the class, optionally with some modifiers like public or extends SomeOtherClass. The body consists of the curly braces and everything in between them.
Putting parentheses after the class name.
There are no parentheses in a class header; you're confusing it with a method header.
Putting a semicolon after the class header.
There are no semicolons in a class header; semicolons occur only at the ends of variable declaration statements and action statements.

Last modified:
Stephen Bloch / sbloch@adelphi.edu