DOC PREVIEW
LETU COSC 2103 - Introduction to Classes and Objects

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:

33.2 Classes, Objects, Methods and Instance Variables3.3 Declaring a Class with a Method and Instantiating an Object of a ClassClass GradeBookClass GradeBookTestCompiling an Application with Multiple Classes3.4 Declaring a Method with a ParameterOutlineNotes on Import Declarations3.5 Instance Variables, set Methods and get MethodsAccess Modifiers public and privateGradeBookTest Class That Demonstrates Class GradeBookPrimitive Types vs. Reference Types3.7 Initializing Objects with ConstructorsAccountTest Class to use Class AccountDisplaying Text in a Dialog BoxSlide 17Entering Text in a Dialog Box3•Introduction to Classes and Objects23.2 Classes, Objects, Methods and Instance Variables•Class provides one or more ______________•Method represents task in a program–Describes the _____________ that actually perform its tasks–Hides from its user the complex tasks that it performs–Method _____________ tells method to perform its task•Classes contain one or more attributes–Specified by instance variables–Carried with the object as it is used33.3 Declaring a Class with a Method and Instantiating an Object of a Class•Each class declaration that begins with keyword public –must be stored in a _______________ –that has the same ___________ as the class and –ends with the .__________ file-name extension.4Class GradeBook•keyword public is an ___________ modifier •Class declarations include:–Access modifier–Keyword clas s–Pair of left and right braces•Method declarations–Keyword ____ ________ indicates method is available to public–Keyword void indicates _______________–Access modifier, return type, name of method and parentheses comprise method header5Class GradeBookTest•Java is ______________________–Programmers can create new classes–Test program the GradeBook class•Class instance creation expression–Keyword _____________–Then name of class to create and parentheses•Calling a method–Object _______________, then dot separator (.)–Then method name and parentheses6Compiling an Application with Multiple Classes•Note we have two classes–Gradebook–GradeBookTest•Compiling multiple classes–Use the compile command in the IDE–Compile each file ___________ (or use Compile Project command)•Requires a ____________ in some IDE’s73.4 Declaring a Method with a Parameter•Method ___________________–Additional information passed to a method–Supplied in the method call with _________•Scanner methods–_______________ reads next line of input–next reads next ___________ of input•See new improved GradeBook class, Figure 3.4 and GradeBookTest program, Figure 3.58OutlineGradeBook.java9Notes on Import Declarations•__________________ is implicitly imported into every program•Default package–Contains classes compiled in the ________________–Implicitly imported into source code of other files in directory•Packages unnecessary if fully-qualified names are used103.5 Instance Variables, se t Methods and get Methods•Variables declared in the body of method–Called _______________ variables–Can only be used within that method•Variables declared in a class declaration–Called fields or _______________ variables–Each object of the class has a separate instance of the variable•Note set and get methods11Access Modifiers public and private•private keyword–Used for most instance variables–private variables and methods are accessible only to methods of the ____________________________________–Declaring instance variables private is known as data ____________________•Return type–Indicates item returned by method–Declared in method header12GradeBookTest Class That Demonstrates Class GradeBook•Default initial value–Provided for all fields not initialized–Equal to _____________ for Strings•Note private instance variables–Cannot be accessed directly by ____________ of the object–Use set methods to ____________ the value–Use ______________ methods to retrieve the value13Primitive Types vs. Reference Types•Types in Java–Primitive•boolean, byte, char, short, _______, long, float, _______________–Reference (sometimes called ____________ types)•Objects•Default value of null•Used to invoke an object’s methods143.7 Initializing Objects with Constructors•Constructors–_____________ an object of a class–Java requires a constructor for every class–Java will provide a default no-argument constructor if none is provided•Called when keyword _________ is followed by the class name and parentheses•Constructors which “incoming” initial value15AccountTest Class to use Class Account•Note use of Scanner object–Input floating point number•Note use of ____________________ %f–Used to output floating-point numbers–Place a decimal and a number between the percent sign and the f to mandate a ________________16Displaying Text in a Dialog Box•Windows and dialog boxes–Many Java applications use these to display output–________________ provides prepackaged dialog boxes called message dialogs•Program to use dialog box17Displaying Text in a Dialog Box•Package javax.swing–Contains classes to help create _______________________________ (GUIs)–Contains class JOptionPane•Declares static method showMessageDialog for displaying a message dialog18Entering Text in a Dialog Box•Input dialog–Allows user to input information–Created using method _____________________ from class


View Full Document

LETU COSC 2103 - Introduction to Classes and Objects

Documents in this Course
Arrays

Arrays

16 pages

Templates

Templates

17 pages

Methods

Methods

22 pages

Methods

Methods

22 pages

Arrays

Arrays

11 pages

Load more
Download Introduction to Classes and Objects
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 Introduction to Classes and Objects 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 Introduction to Classes and Objects 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?