Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Packages and Scope - Introduduction to Jave Programming - Lecture Slides, Slides of Java Programming

In the course of the Introduction to Jave Programming, we study the basic syntax and the basic program in java. In these lecture slides the key points are: Packages, Javadoc, References, Memory, Locations, Solutions on Moodle, Mastering References, Matryoshka Doll, Null, Copying

Typology: Slides

2012/2013

Uploaded on 04/23/2013

sarmistha
sarmistha 🇮🇳

3.8

(22)

113 documents

1 / 14

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Packages and scope
Docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe

Partial preview of the text

Download Packages and Scope - Introduduction to Jave Programming - Lecture Slides and more Slides Java Programming in PDF only on Docsity!

Packages and scope

Halloween

Highlights

  • protected / package scope

Review: Inheritance

Review: Override

Child classes can override methods from their parent's class This means a child can redefine a method to work in a completely different way than the parent's method Can use super to get the parent's version of an overridden method

final

We have used final to declare constants (objects who's value cannot change) You can use the final modifier with methods and classes as well: final classes cannot be the parent for any class final methods cannot be overridden (See: Final.java, FinalClass.java and FinalMethod.java)Docsity.com

Scope modifiers

Var Scope A.x = Any class A.y = Only A B.y = Any class B.z = B, C and any in package C.w = Any in package D.z = Any in package E.x = Any class (See: A, B, C, D.java)Docsity.com

Scope modifiers

Good picture on page 457 of textbook

Some scope oddities

Suppose C extends A...

  • C can access protected variables in A directly
  • C can access protected variables inherited from A in an instance of C
  • C cannot access protected variables from A in an instance of A (See: C.java)

Why should I care about scope?

If you are writing a simple program that only you, yourself, will use... then you do not. But imagine if all programs gave full access to everything...