t30DJavaIntroExampleAccessSpecifiers

Views:
 
Category: Education
     
 

Presentation Description

Acess Specifiers in Java

Comments

Presentation Transcript

Introduction to Java - Access Specifiers: 

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

Access Modifiers public and private: 

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

Outline: 

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

Outline: 

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

Outline: 

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

Outline: 

6 Outline GradeBook.java (2 of 2)

Outline: 

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

Outline: 

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

Acknowledgements: 

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