COMP 202 Lecture Notes - Lecture 16: Static Variable

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

Document Summary

Comp202 lecture 16 intro to oop. An object is a collection of data and it provides a set of methods. For example, a stringis a collection of characters and it provides methods like charat and length. Java is an object- oriented language. This means that is uses objects to represent data and provide methods related to them. Methods can take objects as parameters and produce objects as return values. Type of objects we have seen up to now: string, array, scanner, random. Attributes: variables that belong to an object are usually called attributes (or fields) To access these attributes, java uses dot notation: System. out. println(p1); will print java. awt. point[x=3, y=4] Public static void main (string[] args){ public static point shiftup (point p, int dy){ Point p1 = new point (3,4); Point p2 = shiftup (p1,2); int x = p1. x; int newy = p. y +dy; Point newpoint = new point (p. x, newy); return newpoint;

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

Related Questions