CPSC 233 Lecture Notes - Lecture 13: Class Variable

46 views3 pages

Document Summary

As seen before, this() can be used to invoke other constructors. This() is also used for object self references (e. g. ) Cpsc 233 - 8 feb mon public class point{ private double x,y; public point(double x, double y){ this. x = x; this. y = y; self references are necessary to distinguish instance variables from parameters. This() can be used by an object to send a message to itself. (e. g. ) x = xval; public void setx(double xval) { public void setx(double xval) { x = xval; public class point { public void set(double xval, double yval) { this. setx(xval); this. sety(yval); This() can be used to send a self reference to another object. Where 2 or more methods have the same name but different signatures: signature: the method name plus the parameter list. The return type is not part of the signature. Allows you to give the same name to a related methods. The compiler uses signature matching to determine which method to call.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents