CS 2110 Lecture 2: CS 2110 Day 2 Notes

13 views2 pages
Published on 21 Jan 2017
School
Cornell University
Department
Computer Science
Course
CS 2110
Professor
CS 2110 Day 2 Lecture Notes
8/25/2016
Notes:
I. Objects
a. Methods
i. Function: returns a value, call on it is an expression
ii. Procedure: does not return a value; call on it is a statement
b. When java creates an object, it creates a name and a memory location is
hexadecimal
c. New expression
i. Creates an object and gives as its value the name of the object
ii. New expression gives you the name of the object.
1. Only a pointer to the object
iii. Class variables when declared and assigned contain the name of the
object
d. If variable contains the name of an object you can call methods of the object
using dot notation
e. Null: does not contain a pointer to an object
II. Classes
a. Class definition
i. Describes format of an object (instance) of the class
ii. public: can be used anywhere
iii. extends (inherits the methods and instance variables of the class that is
extended)
1. Makes the class a subclass of the extended class (super class)
2. Object has 2 partitions, one for inherited methods one for its own.
b. Function definition
i. The whole method is inside the object not just a pointer
ii. Public (function can be accessed anywhere)
iii. If we want it to return something we must type the datatype in the
definition
iv. Must include return statement if we want something to be returned
v. Function calls automatically call functions that are in the object or in the
superclass
c. Procedure definition
i. Public (procedure can be accessed anywhere)
ii. Void (does not return anything)
Homework:
Study material
find more resources at oneclass.com
find more resources at oneclass.com
Unlock document

This preview shows half of the first page of the document.
Unlock all 2 pages and 3 million more documents.

Already have an account? Log in

Get OneClass Grade+

Unlimited access to all notes and study guides.

YearlyMost Popular
75% OFF
$9.98/m
Monthly
$39.98/m
Single doc
$39.98

or

You will be charged $119.76 upfront and auto renewed at the end of each cycle. You may cancel anytime under Payment Settings. For more information, see our Terms and Privacy.
Payments are encrypted using 256-bit SSL. Powered by Stripe.