Presentation is loading. Please wait.

Presentation is loading. Please wait.

Dale Roberts Introduction to Java - Access Specifiers Dale Roberts, Lecturer Computer Science, IUPUI Department of Computer.

Similar presentations


Presentation on theme: "Dale Roberts Introduction to Java - Access Specifiers Dale Roberts, Lecturer Computer Science, IUPUI Department of Computer."— Presentation transcript:

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

2 Dale Roberts 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 Dale Roberts 3Outline GradeBo ok.java Instance variable courseName set method for courseName get method for courseName Call get method

4 Dale Roberts 4Outline GradeBo okTest.j ava (1 of 2) Call get method for courseName

5 Dale Roberts 5Outline GradeBo ok.java (1 of 2) Constructor to initialize courseName variable

6 Dale Roberts 6Outline GradeBook.j ava (2 of 2)

7 Dale Roberts 7Outline GradeBookT est.java Call constructor to create first grade book object Create second grade book object

8 Dale Roberts 8Outline GradeBo okTest.j ava Call constructor to create first grade book object Create second grade book object

9 Dale Roberts 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://www.cs.usfca.edu/~parrt/course/652/lectures-Spring- 2004/language.impl.overview.pdf http://ei.cs.vt.edu/~history/Youmans.Java.html


Download ppt "Dale Roberts Introduction to Java - Access Specifiers Dale Roberts, Lecturer Computer Science, IUPUI Department of Computer."

Similar presentations


Ads by Google