Class Notes (837,548)
Canada (510,312)
CSC207H1 (40)
Lecture

sept19c.docx

1 Page
86 Views
Unlock Document

Department
Computer Science
Course
CSC207H1
Professor
Diane Horton
Semester
Fall

Description
SEPTEMBER 19  Types are Critical o Python uses “duck typing”, doesn’t need to declare type for variable  Types are checked at runtime, and any object with the appropriate capalities (methods) is legal o Java tries to catch errors early, so it checks types before the program is run  This means that some code that could work if the program was run will be ruled illegal  Require casting when pulling items of out Object array  Defining methods o Must have a return type declared  Use void if there is nothing return o To leave a method:  Return expression to return something  Return if there’s nothing to return  A method returns ETC  Parameters o You pass what’s in the box  If a reference type you are passing a reference (just like Python)  If a primitive, you are passing the value (Python can’t do anything like this) o This has crucial implications  You must be aware of whether you are passing a primitive or object  Classes o Instance Variables and Static Variable  Name and starBellied are instance variable  howMany is a static or class variable  SAYING is (static and) final so it’s OK to make it public, never going to change and variable can’t be reassigned  If there’s also a good reason to do that  Convention to capitalize final variables  If indicated static, its static variable,  You can mix instance variable and class variable declarations with method definitions in any order you like  If an instance variable is private, how can client code use it? Why not make everything public  Protect internal details,  Encapsulating  Think of your class as provindg an abstraction or a service  Hide the implementation details
More Less

Related notes for CSC207H1

Log In


OR

Join OneClass

Access over 10 million pages of study
documents for 1.3 million courses.

Sign up

Join to view


OR

By registering, I agree to the Terms and Privacy Policies
Already have an account?
Just a few more details

So we can recommend you notes for your school.

Reset Password

Please enter below the email address you registered with and we will send you a link to reset your password.

Add your courses

Get notes from the top students in your class.


Submit