UOP PRG421 All Weeks Discussions 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?
PRG421 Java Programming II
Week 2 Discussion
DQ1 Data Conversion
Accepting input and producing output virtually always requires data conversion. Because Java™ students new to I/O are often surprised at the steps necessary to read data and then put it in a form that can actually be used, the purpose of this discussion is to experiment with data conversion techniques and share the issues that arise to arrive at a better understanding of the critical role data conversion plays in Java I/O.
Copy and paste the linked code into a Java™ program (or rename the file using a .java extension) and run it in NetBeans. The purpose of the program is to calculate a salesperson’s total annual compensation. The program asks the user for the total amount dollar amount of sales for a year, and then uses that input to make calculations.
Post your results after running the program to the discussion area.
Discuss with your classmates what errors were produced, what could have caused the errors, and how this code can be fixed. Is there an approach you learned from this code that you can apply to all those situations in which you need to read data and convert it to a usable form?
Note: To interpret your results, you may want to refer to Ch. 5, “Dates, Strings, and Localization,” of OCP: Oracle® Certified Professional Java® SE8, Programmer II Study Guide.
DQ2 Choosing a Data Output Option
Before you can perform data output, you must first decide the form in which you want the output data to appear. Onscreen and flat-file output are sometimes appropriate in a small system, such as a modest inventory application in which updated results display on a screen to be analyzed by a user, and in which output is designed for little more
than backup on a local, secure machine. Displaying information onscreen can be a benefit, since the user does not have to produce and review a program-generated report, while saving small amounts of data to an easily-read file with no requirement to manage a database can be the best approach if program requirements do not dictate otherwise.
However, in high-volume scenarios where one program “feeds” large amounts of data to another program, console output and flat-file data storage may not make practical sense.
Post to the discussion area descriptions of at least two scenarios for which console or flat file output would not be appropriate. For each scenario, describe why console/flat file output would not be appropriate, and identify an alternative approach that might make more sense.
Review your classmates’ posts, then explain what characteristics the scenarios of your classmates and you described share. In general, for what types of programming scenarios are flat file/console output inappropriate?
PRG421 Java Programming II
Week 3 Discussion
DQ1 Benefits of Generics
The purpose of this discussion is to describe the difference between implementing a class as an abstract class (i.e., a
class from which concrete classes can be derived) and a generic class (i.e., a class from which different types of
classes can be derived).
Discuss the benefits of using a generic class.
Share an example of a real-life situation that would benefit from being modeled as a generic class.
Instructions
DQ2 Abstract Methods and Classes
The purpose of this activity is to understand the syntax necessary to declare and implement abstract methods and classes.
A method declared without any body within an abstract class is called an abstract method. The body of an abstract method must be defined by its subclass. Abstract methods can never be declared final or static, and any class that extends an abstract class must implement all the abstract methods declared by the super class. Abstract methods are useful in situations when two or more subclasses are expected to do a similar thing in different ways, extending the same abstract class by providing different implementations of the same abstract methods.
For this activity, you will practice defining an abstract method in one class (class A) and implementing that method in a derived class (class B).
Copy and paste the following code into a JAVA source file in NetBeans; note the abstract and extends keywords in the source:
abstract class A {
abstract void demoabst();
}
class B extends A { // subclass B derives from A
void demoabst () {
System.out.println(“This is a code demo.”);
}
public static void main(String[] args) {
B b = new B(); // class B reference and object
b. demoabst (); // reference demoabst object
}}
Run and debug the JAVA file in NetBeans
PRG421 Java Programming II
Week 4 Discussion
DQ1 Benefits and Drawbacks of Concurrency
The purpose of this discussion is to explore concurrency, which refers to threads that run alongside each other during program execution, as opposed to running serially, or one after the other, and to discuss potential drawbacks and problems associated with concurrency.
Java™ provides built-in support for concurrent programming by allowing the running of multiple threads concurrently within a single program. A thread, also called a lightweight process, is a single sequential flow of programming operations with a definite beginning and end. During the lifetime of a thread, there is only a single point of execution. A thread by itself is not a program, because it cannot run on its own, instead all threads must run within a program.
Research and discuss with your classmates the benefits of concurrency in Java™. What are the potential drawbacks?
DQ2 Localization
The purpose of this activity is to provide you with an explanation for, and some experimentation with, the concept of localization via the Locale object.
Localization is the process of adapting a program so that it displays information in the way local users need to see it, and is important for any program running on the web where users from virtually any country in the world can access it.
A program that has been effectively localized displays currency in pounds and dates in day/month/year format to United Kingdom audiences, currency in dollars and dates in month/day/year format to United States audiences, etc.
Localization is particularly significant in that it allows for organizing all user-facing text so that it display text in different languages, as necessary.
Note: This course does not address localization in detail, however it does introduce the topic and demonstrate how setting a Locale object allows Java™ programmers to take advantage of pre-built formatting.
For this supporting activity, you will run an existing Java™ program to see how changing the Locale object automatically changes date formats.
Download the linked Java™ file, or cut-and-paste it into a new Java™ project in NetBeans using a name of your choosing.
Examine the Java™ code, paying special attention to the main() method, in which three Locale objects are created: one for France, one for Germany, and one for the United States. Notice that passing different Locale objects to the same methods (e.g., showDateStyles(), showTimeStyles(), and showBothStyles()) results in a customized display.
Note: Refer to the linked list of standardized codes to see which codes represent which countries.
Insert the following code at the beginning of the main() method, just after the opening curly brace:
Date now = new Date();
System.out.println(“Here is default date format: ” +
DateFormat.getInstance().format(now));
Save the program, and run it in NetBeans again. What locale does the Java™ runtime environment assume by default: U.S. or European? (Hint: Typically, the Java™ runtime environment sets the default locale on download/install based on your computer system.)
PRG421 Java Programming II
Week 5 Discussion
DQ1 Databases Accessible via JDBC
The purpose of this discussion is to identify the purpose and utility of JDBC to Java™ programmers, including the data formats that JDBC allows Java™ programmers to interact with. Research and discuss the differences between a flat database and a relational database. Does JDBC provide a way for Java™ programmers to access flat databases, relational databases, or both? What specific relational databases can be accessed via JDBC?
DQ2 Basic SQL Statements
The purpose of this activity is for you to familiarize yourself with the basics of SQL syntax, which is required for retrieving data from a database using JDBC. As a Java™ programmer, you do not have to be an expert at Structured Query Language (SQL), the language used to access and manipulate data stored in relational databases. However, to retrieve or update data in a relational database, you will need a passing familiarity with SQL statements, because you will need to pass these SQL statements as arguments to one or more JDBC API calls and should understand enough to see the issue if they do not work.
Familiarize yourself with basic SQL statements by taking the linked 25-question “W3Schools SQL Quiz.” Use the answers to each quiz question to familiarize yourself with basic SQL query statements and keywords, such as SELECT and JOIN.

Having Trouble Meeting Your Deadline?
Get your assignment on UOP PRG421 All Weeks Discussions Latest 2020 completed on time. avoid delay and – ORDER NOW