Variables, Objects, and Classes Flashcards
The goal of object technology is to allow you to write software that better models the natural world. (T/F)
True
A unit within a computer program that combines data and operations
Object
Variables internal to an object that hold data defining the object’s state
Instance variable
An operation that an object can perform
Method
A plan that tells the computer how to build objects
Class
Specifies the variables that are to be included in objects of the class
Field declaration
Specifies the methods that are to be included in objects of the class
Method declaration
A special method that, when called, initializes the object being built
Constructor
A constructor that is automatically provided by the compiler
Implicit constructor
A constructor that is written out within the text of the class
Explicit constructor
Specified by a static field declaration, a variable shared by all objects of a class
Class variable
Specified by a static method declaraion, a method shared by all objects of a class
Class method
Indicates that a field or method belongs to the entire class and not to individual objects of the class
Static
Object-oriented programmers refer to an object as __________ of a class.
An instance
You can always identify an explicit constructor within a class declaration because it has the same identifier as the class. (T/F)
True
Given this Die class, which is its field?
public class Die { public int faceUp; public void roll( ) { faceUp = (int) (Math.random( ) * 6 + 1); }}
faceUp
Given this Die class, which is its method?
public class Die { public int faceUp; public void roll( ) { faceUp = (int) (Math.random( ) * 6 + 1); }}
roll( )
Given this Die class, does it have an implicit or explicit constructor?
public class Die { public int faceUp; public void roll( ) { faceUp = (int) (Math.random( ) * 6 + 1); }}
Implicit