COMP 202 Lecture Notes - Lecture 17: Instance Variable, Class Variable

38 views2 pages
jc123 and 40170 others unlocked
COMP 202 Full Course Notes
100
COMP 202 Full Course Notes
Verified Note
100 documents

Document Summary

Entire class (one per class) Instance of a class (one per object/instance) How to call (methods) from outside the class. How to reference (data) from outside the class. A method that is executed when a new object of that class is created. The syntax for constructors is similar to that of other methods, except: The name of the constructor method mustbe the same as the name of the class. It has no return type (not even void!) // some data declared here. ; public classname(){ Comp202 lecture 17 more on static vs non static. Recap writing the blueprint: public class classname { Static v non static recap: To prevent someone from making an instance in your class, you can make the constructor private: private classname(){ We have seen that the value of a final variable cannot be changed after it has been assigned. Final variables must be initialized! (otherwise compile- time error)

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