Topic | Basic | Intermediate | Advanced |
---|---|---|---|
Classes |
Follow the naming rules and conventions for class names when writing classes.
List the four things that make up the structure of a class.
Define a simple class with a few instance variables
Create objects of a given class using the
new keyword |
Describe the kind of abstraction a class creates.
Describe the places that you can use a class as a type.
Explain the relationship between a class and its objects
Describe how a class serves as a blueprint for objects
Distinguish between instances of a class and the class itself.
|
Describe how objects are stored in memory and the difference between the object itself and a reference to the object.
Explain how classes contribute to modular program design
|
Instance variables |
Write an instance variable declaration given the name and type.
Remember to include the
private modifier on instance variables declarations. |
Write an instance variable declaration given a name and a description of the purpose of the variable.
Explain why instance variables are almost always made
private .Explain the advantages of making instance variables
final .Explain the difference between local variables and instance variables
|
Write appropriate instance variable declarations based on the described functionality of a class, giving them good names and appropriate types.
Use
final instance variables when appropriate.Explain when the code in an instance variable initializer runs.
Explain the relationship between an object’s memory and where its instance values are stored. Describe how this differs between instance variables of primitive and reference types.
Discuss the concept of encapsulation and its relation to instance variables
Implement a class that maintains invariants using private instance variables
|
Constructors |
Write a constructor that takes arguments and uses them to initialize instance variables given a list of instance variables and their types.
Write an explicit no-args constructor that initiaizes at least one instance variable.
Write code that calls a no-args constructor.
|
Explain the purpose of a constructor.
Write a constructor that initializes an instance variable with a value to passed in as an argument.
Write a constructor that takes arguments that it uses to compute values which it uses to initialize instance variables.
Use the
this.x = x idiom to be able to use the same name for constructor parameters and instance variables.Write code that calls a constructor that takes arguments.
|
Explain the default constructor and when you need to write an explicit no-args constructor.
Write overloaded constructors.
Use
this() to remove duplication from overloaded constructors.Implement a copy constructor
|
Methods |
Describe the role methods play in a class.
Write basic getters and setters.
Implement a toString() method for a class
|
Explain why we use getters and setters rather than making instance variables
public .Write instance methods other than getters that use the values of instance variables to compute values.
Write instance methods other than setters that change the value of instance variables.
Write calls to instance methods.
|
Write methods that take a reference type as an argument and calls methods on the object passed as the argument.
Write methods that maintain class invariants.
|
static members |
Name one method that has to be
static .Declare and use static variables.
Write and call static methods.
|
Explain the difference between static and instance members
Use static members to implement class-wide behavior or data.
|
Implement static methods to be used as more flexible way of obtaining instances of the class.
Discuss the implications of static members on object-oriented design
|
this |
Use
this to disambiguate between instance variables and parameters in constructors and setters.Use
this to call another constructor |
Pass
this as an argument to other methods |
Explain the concept of method chaining and implement it by writing methods that return
this . |