Chapter 3 PDF Flashcards
What is the function of class
Classes combine data and the methods (code) to manipulate the data. Classes are a template used to create specific objects
What is a requirement for all java programs in relation to classes
All java programs consists of at least one class
What are the two types of classes
Application classes and
Service classes
Why are classes used
Classes allow us to separate the data for each object, while using common code to manipulate each object
Describe the data for a student class (example)
name, year, grade point average
Describe the methods for a student class (example)
store/get the value of the data, promote to next year etc
What is an object reference
An identifier of the object
How do you instantiating an object
Creating an object of a class; assigns initial values to the object data
What is the requirement for objects before being used
Objects need to be instantiated before being used
What is the instance of a class
An object after instantiation
What is the member of a class
The classes fields and methods
What are two types of fields
instance variables and static variables
What is an instance variable
Variables defined in the class and given a value in each object
What can fields be
Any primitive data type and objects of the same or another class
What are methods
Code to manipulate object data
What occurs when you declare an instance variable to be private
They cannot be accessed directly outside of the class. Can only reference the private data of an object by calling methods of the class
What is function of methods in relation to data
It encapsulates the data and provides a protective shell around it
What is the benefit to methods
The classes methods can ensure that the object data is always valid
What is the naming convention for class names
Start with a capital letter
What is the naming convention for object references
Start with a lowercase letter
What is the benefit of reusing code
Class code is already written and tested. New applications can be built faster. The applications will be more reliable
What is the purpose of API
Application programming interface
What information does the API tell us
How to create objects
What methods are available
How to call the methods
What does the object reference do
The object reference holds the address of the object
What is a constructor
A special method that creates an object and assigns initial value to data