Download presentation
Presentation is loading. Please wait.
Published byEmerald Dean Modified over 9 years ago
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
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.