1 / 9

Introduction to Java - Access Specifiers

Department of Computer and Information Science, School of Science, IUPUI. Introduction to Java - Access Specifiers. Dale Roberts, Lecturer Computer Science, IUPUI E-mail: droberts@cs.iupui.edu. Access Modifiers public and private. private keyword Used for most instance variables

clayland
Télécharger la présentation

Introduction to Java - Access Specifiers

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Department of Computer and Information Science,School of Science, IUPUI Introduction to Java- Access Specifiers Dale Roberts, Lecturer Computer Science, IUPUI E-mail: droberts@cs.iupui.edu

  2. Access Modifiers public and private • private keyword • Used for most instance variables • private variables and methods are accessible only to methods of the class in which they are declared • Declaring instance variables private is known as data hiding • public keyword • Exposes variables or methods outside the Class. • Declaring public methods is know as defining the class’ public interface. • Return type • Indicates item returned by method • Declared in method header

  3. Instance variable courseName set method for courseName get method for courseName Call get method Outline • GradeBook.java

  4. Call get method for courseName Outline • GradeBookTest.java • (1 of 2)

  5. Constructor to initialize courseName variable Outline • GradeBook.java • (1 of 2)

  6. Outline • GradeBook.java • (2 of 2)

  7. Call constructor to create first grade book object Create second grade book object Outline • GradeBookTest.java

  8. Call constructor to create first grade book object Create second grade book object Outline • GradeBookTest.java

  9. Acknowledgements • http://java.sun.com/docs/books/tutorial/getStarted/TOC.html • Pearson Education, Lewis and Loftus. • Deitel, Java How to Program • http://www.cs.wustl.edu/~plezbert/contcom/thesis/node6.html • http://www.cs.usfca.edu/~parrt/course/652/lectures-Spring-2004/language.impl.overview.pdf • http://ei.cs.vt.edu/~history/Youmans.Java.html

More Related