UOP PRG421 Week 1 Discussion Latest 2020
PRG421 Java Programming II
Week 1 Discussion
DQ1 Data Hiding
Data hiding is the way in which programmers implement encapsulation. Java™ programmers use the keywords private and protected to control what data is visible outside of a class; in other words, to control what code can access and manipulate class data.
Read Table 1-2, "Determining Access to Class Members," in "Java - Protected Members Accessed in Derived Class
Using Base Class Instance" on the Stack Overflow website.
Note: This table is similar, though not identical, to Table 1-1, "Access Modifiers," in Ch. 1, "Advanced Class Design," of OCP: Oracle® Certified Professional Java® SE 8 Programmer II Study Guide.
Discuss the following by posting to the discussion area:
If Class A contains private data and Class B inherits from Class A, is it possible to make Class A's private data visible to Class B? If so, how? Be sure to provide reasons for your answer based on this week's textbook readings or this week's assignment code.
DQ2 Static Variables and Methods
For this assignment, you will predict the output of Java™ code that includes a static (class) variable accessed by a static method. Completing this assignment will help you understand the utility of using static variables and methods, as well as recognize the syntax required to create static variables and methods.
Read through the linked Java™ code carefully.
Predict the result of running the Java™ code; specifically, what text you think will appear on the console after running the Java™ code. Can you think of other uses for static variables and methods? In other words, can you think of other situations in which you might want all instances of a class to be able to access a single class variable?
-
Rating:
/5
Solution: UOP PRG421 Week 1 Discussion Latest 2020