CS2_45_Review

CS2_45_Review - CS2 Module 45 Category Course Information...

Info iconThis preview shows pages 1–12. Sign up to view the full content.

View Full Document Right Arrow Icon
CS2 Module 45 Category: Course Information Topic: Review Objectives Final Review
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
CS 2 Introduction to Object Oriented Programming Module 45 Course Information Review
Background image of page 2
Java Basics Primitive Data Types boolean, char, byte, short, int, long, float, double Implementation precisely defined i.e. not machine dependent Declarations int x; int x = 42; Casting: Potential loss of information requires cast Main Method Invoked automatically when a class is sent to JVM (java) Could be invoked like any other method (not typical)
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Java Basics Control Structures Loops while do. ..while for Conditionals switch if/else System.out.println Debugging (bDEBUG) Tracing
Background image of page 4
Java Basics Modularity methods procedures: no return functions: return a value parameters pass by value (in parameters only) type and order designate “signature” returns return causes immediate return to calling program return with value for function return with no value for procedure (optional)
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Java Basics Visibility Specifiers public protected -- ??? private Method Overloading Overriding Instance Class
Background image of page 6
Java Basics Recursion Comments Multiline /* */ Single line // Javadoc //* Plus Doc-Comment Tags @return @param @version @throws etc.
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
OO Objects Strings 1D arrays int[ ] gradeArray = new int[10]; references null <ClassName> <identifier> creates a reference to an object which is either an instance of <ClassName> or a instance of a child class of <ClassName> == versus .equals( )
Background image of page 8
Objects and References Objects and References When working with References to Objects, Java has two logical operations: Creates a new area in memory so each named reference points to its own object It assigns references to objects, i.e., it manipulates the pointers. Used in the form: box1 = box2; The The assignment assignment operator, operator, = Two references to a single area of memory The method The method clone ( ) clone ( ) It copies the object itself. Used in the form: box2 = box1.clone(); Not available for all types (requires cloneable interface, discussed later). 1. 1. 2. 2.
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Assignment with References to Objects: Example Example But str1 = str2.clone(); would give: str1 str2 omega omega Two distinct areas of memory The statement str1 = str2; would give: str1 str2 omega alpha Two references to one object str1 str2 omega alpha Given two Strings, str1 and str2:
Background image of page 10
Equality with References to Objects: Two different logical tests available: 1. The operator = = (equality) It evaluates whether two references point to the same object . 2. The method equals( ) It evaluates whether the internal state (i.e., contents ) of one object is identical to the internal state of another object. It is a special method built-in to the class Object, and is available to all classes you create. In practice you will want to code a version of equals() in your classes, so that you can compare objects.
Background image of page 11

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 12
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page1 / 62

CS2_45_Review - CS2 Module 45 Category Course Information...

This preview shows document pages 1 - 12. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online