DOC PREVIEW
UB CSE 115 - Java Syntax3

This preview shows page 1-2-3-4 out of 11 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 11 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 11 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 11 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 11 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 11 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Java Syntax, Java Conventions, CSE 115 Conventions (Part 3)XX - ReferencesXXI – Assignment OperatorReview of CompositionClassA has a ClassBXXII – Sending MessagesSyntax of a Method CallFour Main Parts of a MethodCardinalityAssociation RelationshipDog knows a TreeJava Syntax, Java Conventions, CSE 115 Conventions (Part 3)CSE 115 Spring 2006February 6, 8 & 10, 2006XX - ReferencesDeclaring an instance variable creates a reference.All references are initially null.We assign a value to a reference using the assignment operatorXXI – Assignment Operator=Takes the value on the right and assigns it to the variable on the left:_varName = new Object();Review of CompositionDeclare an instance variableCreate an instance of the subpartAssign the instance to the instance variableNote that steps two and three above actually happen in one line of code.ClassA has a ClassBpublic class ClassA {private ClassB _classB;public ClassB() {_classB = new ClassB();}}XXII – Sending MessagesAsking/telling an object to do something, or asking it to perform one of its capabilities.Capabilities are methods inside our class definition.In code, we would be performing a method call/method invocation.Syntax of a Method CallinstanceName.methodName();•Q: What is the name of the () and what are the () used for in a method call?Four Main Parts of a MethodSenderReceiverReturn TypeParametersDescribe the purpose of each of these and what they correspond to in code.CardinalityThe number of a certain type of relationship between objects. An Applet can have 5 BouncingBalls. That means there are 5 instances of the “has-a” relationship present.Association Relationship“knows a” relationshipIn UML, represented by an arrow ( → )In code:Declare an instance variable of the associate.In constructor, accept a parameter whose type is the same as that of the associateAssign the value of the parameter to the instance variableDog knows a Treepublic class Dog {private Tree _tree;public Dog(Tree tree) {_tree =


View Full Document

UB CSE 115 - Java Syntax3

Download Java Syntax3
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Java Syntax3 and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Java Syntax3 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?