Docsity

Java Programming: Rectangles, Accessor and Mutator Methods, and Object References - Prof. , Study notes of Computer Science

Toggle sidebar
bg1
CSC 1350 Sep. 7
Rectangle rect1;
Rect1 = new Rectangle(10, 5, 80, 100);
Rectangle rect1 = new Rectangle (10, 5, 80, 10);
Accessor and Mutator Methods
Accessor method: does not change the state of its implicit parameter:
- Double width = box.getWidth();
Mutator method: changes the state of its implicit parameter:
- Box.translate(15, 25);
The API Documentation
API: Application Programming Interface
API: documentation: lists classes and methods in the Java library
Packages
Package: a collection of classes with a related…
Object References
Object reference: describes the location of an object
The new operator returns a reference to a new object:
- Rectangle box = new Rectangle();
Multiple object variables can refer to the same object:
- Rectangle box = new Rectangle (5, 10, 20, 30);
- Rectangle box2 = box;
- Box2.translate(15, 25);
Primitive type variables ≠ object variables

Partial preview of the text

Download Java Programming: Rectangles, Accessor and Mutator Methods, and Object References - Prof. and more Study notes Computer Science in PDF only on Docsity!

CSC 1350 Sep. 7 Rectangle rect1; Rect1 = new Rectangle(10, 5, 80, 100); Rectangle rect1 = new Rectangle (10, 5, 80, 10); Accessor and Mutator MethodsAccessor method : does not change the state of its implicit parameter:

  • Double width = box.getWidth();  Mutator method : changes the state of its implicit parameter:
  • Box.translate(15, 25); The API DocumentationAPI : Application Programming Interface  API: documentation : lists classes and methods in the Java library PackagesPackage : a collection of classes with a related… Object ReferencesObject reference : describes the location of an object  The new operator returns a reference to a new object:
  • Rectangle box = new Rectangle();  Multiple object variables can refer to the same object:
  • Rectangle box = new Rectangle (5, 10, 20, 30);
  • Rectangle box2 = box;
  • Box2.translate(15, 25);  Primitive type variables ≠ object variables