Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Other

CP213 Object-Oriented Programming ACTUAL VERIFIED Practice sample Final EXAM 2025 REVIEW UPDATE Wilfrid Laurier University

Rating
-
Sold
-
Pages
22
Uploaded on
16-09-2025
Written in
2025/2026

CP213 Object-Oriented Programming ACTUAL VERIFIED Practice sample Final EXAM 2025 REVIEW UPDATE Wilfrid Laurier University

Institution
WLU CP213
Course
WLU CP213

Content preview

CP213 Object-Oriented Programming ACTUAL VERIFIED Practice sample Final EXAM 2025 REVIEW
UPDATE Wilfrid Laurier University




213 FINAL EXAM REVIEW

Protected access: child classes to this class can access the method/variables even if
they aren't in the same package
**There are 2 classifications of instance variables & methods that allow them to be accessed
by name in a derived class** → one of them is protected access (always gives access)


➔ If a method/instance variable is modified by protected (rather than
public/private) → it can be accessed by name inside its own class definition
◆ it can be accessed by name inside any class derived from it
◆ it can also be accessed by name in the definition of any class in the
same package (even if the class in the same package is not derived
from it)
◆ Can be accessed in a different package if the class is derived from it

★ Example: consider the class HourlyEmployee that was derived from the base class
Employee.




If the private instance variables name & hireDate had been marked protected in the
class Employee, the definition of toString in the derived class HourlyEmployee could
be simplified to the following: (basically removed the “get”)




Pitfall: A Restriction on Protected Access ★

● A class can access its own classes’ inherited variables & methods that are marked
protected in the base class, but cannot directly access any such instance variables
● For example, n is an instance variable of the base class B & an instance variable of the
derived class D. D can access n whenever n is used as an instance variable of D, but D
cannot access n when n is used as an instance variable of B.

, ● If the classes B and D are in the same package, you will not get the error message
because, in Java, protected access implies package access.


Package/Friendly/Default access: each class that is derived from the same
package has access to this method/variables
**There are 2 classifications of instance variables & methods that allow them to be accessed
by name in a derived class** → one of them is package access (gives access if the derived class
is in the same package as the base class)


● If you do not place any of these modifiers (public, private, or protected) before
an instance variable or method definition → then the instance variable/method
can bg accgssgd bD namg insidg Ēhg dgfiniĒion of anD class in Ēhg samg
packagg buĒ noĒ ouĒsidg of Ēhg packagg → package access
○ Use package access in situations → package of cooperating classes that
act as a single encapsulated unit
○ Package access is more restricted than protected
○ Package access gives more control to the programmer defining the
classes
○ If you control the package directory (folder) → you control who is allowed
package access

Pitfall: Forgetting about the default package ★

● If a class in your current directory is not in any other package → then it is in
the default package
● If an instance variable/method has package access → then it can be accessed
by name in the definition of any other class in the default package




Public access: Any class can access this regardless of package or whatever
➔ The public access modifier is the direct opposite of the private access
modifier
◆ A class, method or variable can be declared as public → is accessible
from any class
◆ It can be accessed in its own class
◆ Can be accessed from a different class
◆ Can be accessed from a different package

, Private access: Means that only members of this class have access to this method/
variable

➔ The most restricted access level
◆ Can only be accgssgd in iĒs own class C samg packagg

➔ Class & interfaces cannot be private
➔ Variables that are declared private can be accessed outside the class → if
public getter methods are present in the class


★ ALL 4 ACCESS (private, public, package, protected)

Written for

Institution
WLU CP213
Course
WLU CP213

Document information

Uploaded on
September 16, 2025
Number of pages
22
Written in
2025/2026
Type
OTHER
Person
Unknown

Subjects

$15.99
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF


Also available in package deal

Thumbnail
Package deal
WLU somayeh fatahi COMBINED EXAM SOLUTIONS TIPS FOR CP213 Object Oriented Programming 2025-2026
-
5 2025
$ 40.37 More info

Get to know the seller

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
smartzone Liberty University
View profile
Follow You need to be logged in order to follow users or courses
Sold
3404
Member since
6 year
Number of followers
2297
Documents
14731
Last sold
6 hours ago
AMAIZING EDUCATION WORLD

GET ALL KIND OF EXAMS ON THIS PAGE ,COMPLETE TEST BANKS,SUMMARIES,STUDY GUIDES,PROJECT PAPERS,ASSIGNMENTS,CASE STUDIES, YOU CAN ALSO COMMUNICATE WITH THE SELLER FOR ANY PRE-ORDER,ORDER AND ETC.

3.6

615 reviews

5
271
4
98
3
109
2
32
1
105

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions