UOP PRG421 Week 3 Discussion Latest 2020

Question # 00786626 Posted By: rey_writer Updated on: 12/10/2020 12:19 PM Due on: 12/10/2020
Subject Education Topic General Education Tutorials:
Question
Dot Image

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

Dot Image
Tutorials for this Question
  1. Tutorial # 00786542 Posted By: rey_writer Posted on: 12/10/2020 12:22 PM
    Puchased By: 2
    Tutorial Preview
    The solution of UOP PRG421 Week 3 Discussion Latest 2020...
    Attachments
    UOP_PRG421_Week_3_Discussion_Latest_2020.ZIP (18.96 KB)

Great! We have found the solution of this question!

Whatsapp Lisa