DOC PREVIEW
UVA CS 101 - Review for Midterm

This preview shows page 1-2-3-4-5-6 out of 18 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 18 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 18 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 18 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 18 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 18 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 18 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 18 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Review for Midterm 2Test focusChapter 4ConstructionMember variablesMethodsParametersMethod typesMiscJFrame and GraphicsChapter 5Logical expressionsLogical operatorsEqualityOrderingIf statementsSwitchesSlide 1811Review for Midterm 2Review for Midterm 2Aaron BloomfieldAaron BloomfieldCS 101-ECS 101-E22 Test focusTest focusTest will focus on the material covered Test will focus on the material covered since the last midtermsince the last midtermChapters 4 and 5Chapters 4 and 5The test is cumulative, though, and can The test is cumulative, though, and can include any material covered so farinclude any material covered so far33 Chapter 4Chapter 444 ConstructionConstructionConstructors should initialize all the data fields to Constructors should initialize all the data fields to some sane valuesome sane valueA constructor has the same name as the classA constructor has the same name as the classA default constructor takes in no parametersA default constructor takes in no parametersIf a default constructor is not specified, then If a default constructor is not specified, then Java supplies one for you that does nothingJava supplies one for you that does nothingAll instance variables are initialized to default All instance variables are initialized to default values (0, false, or null) before the constructor values (0, false, or null) before the constructor startsstartsTo create an object, you declare the object To create an object, you declare the object reference then call the constructor to create the reference then call the constructor to create the objectobject55 Member variablesMember variablesEach object has its own copy of an Each object has its own copy of an instance variableinstance variableInstance variables are normally privateInstance variables are normally privatePrivate variables and methods can only be Private variables and methods can only be accessed by code within that classaccessed by code within that classInstance variable = member variable: a Instance variable = member variable: a data field in an objectdata field in an object66 MethodsMethodsFlow of control passes from the invoking statement block Flow of control passes from the invoking statement block to the invoked method, then returns (once the method to the invoked method, then returns (once the method completes) back to the statement blockcompletes) back to the statement blockTo define a method, state it's prototype (name, return To define a method, state it's prototype (name, return type, parameters) and the body (the statement block)type, parameters) and the body (the statement block)You use return to return a valueYou use return to return a valueA method that does not return a value has return type A method that does not return a value has return type voidvoidObject behaviors are implemented using methodsObject behaviors are implemented using methodsInstance methods are associated with an object, as Instance methods are associated with an object, as opposed to class methods, which are associated with the opposed to class methods, which are associated with the classclassMethods can access the member variablesMethods can access the member variables77 ParametersParametersJava uses pass-by-valueJava uses pass-by-valueHowever, an object as a parameter has the However, an object as a parameter has the reference passed in, so it's sort of like pass-reference passed in, so it's sort of like pass-by-reference for objectsby-reference for objectsActual parameter: the value passed into Actual parameter: the value passed into the methodthe methodFormal parameter: the value within the Formal parameter: the value within the methodmethod88 Method typesMethod typesAn accessor method allows access to an An accessor method allows access to an attribute (member variable) of an object attribute (member variable) of an object (that is most likely private)(that is most likely private)A mutator method allows the changing of A mutator method allows the changing of an attribute (member variable) of an object an attribute (member variable) of an object (that is most likely private)(that is most likely private)A facilitator method performs a task for the A facilitator method performs a task for the objectobject99 MiscMiscA statement block is denoted by curly A statement block is denoted by curly bracesbracesActivation record is the name for the copy Activation record is the name for the copy of the parameters within a methodof the parameters within a methodData abstraction: hide the internals of how Data abstraction: hide the internals of how a method operates.a method operates.An variable that is an object is really a An variable that is an object is really a referencereferenceThe programmer “interface” is made up of The programmer “interface” is made up of the public methodsthe public methods1010 JFrame and GraphicsJFrame and GraphicsJFrame is the class that represents a GUI JFrame is the class that represents a GUI windowwindowJFrame has methods setVisible() and setSize()JFrame has methods setVisible() and setSize()Drawing on a JFrame is done by accessing its Drawing on a JFrame is done by accessing its Graphics object via the getGraphics() methodGraphics object via the getGraphics() methodGraphics has methods setColor(), fillRect(), Graphics has methods setColor(), fillRect(), drawRect(), etc.drawRect(), etc.When drawing on a Graphics object, (0,0) is in When drawing on a Graphics object, (0,0) is in the upper-leftthe upper-left1111 Chapter 5Chapter 51212 Logical expressionsLogical expressionsLogical expression has values either true Logical expression has values either true or falseor falseJava has the boolean type with values true Java has the boolean type with values true or falseor falseTruth table: method to dissect a logical Truth table: method to dissect a logical expressionexpression1313 Logical operatorsLogical operatorsThree primary logical operators: and, or, notThree primary logical operators: and, or, notAn and operation is only true when both parts An and operation is only true when both parts are


View Full Document

UVA CS 101 - Review for Midterm

Documents in this Course
Classes

Classes

53 pages

Recursion

Recursion

15 pages

Iteration

Iteration

88 pages

PLEDGED

PLEDGED

6 pages

Objects

Objects

33 pages

PLEDGED

PLEDGED

11 pages

CS 101

CS 101

42 pages

Classes

Classes

83 pages

Iteration

Iteration

92 pages

Classes

Classes

186 pages

Classes

Classes

208 pages

Hardware

Hardware

21 pages

Arrays

Arrays

70 pages

Load more
Download Review for Midterm
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 Review for Midterm 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 Review for Midterm 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?