Discuss the benefits of using a generic class.
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
Collepals.com Plagiarism Free Papers
Are you looking for custom essay writing service or even dissertation writing services? Just request for our write my paper service, and we'll match you with the best essay writer in your subject! With an exceptional team of professional academic experts in a wide range of subjects, we can guarantee you an unrivaled quality of custom-written papers.
Get ZERO PLAGIARISM, HUMAN WRITTEN ESSAYS
Why Hire Collepals.com writers to do your paper?
Quality- We are experienced and have access to ample research materials.
We write plagiarism Free Content
Confidential- We never share or sell your personal information to third parties.
Support-Chat with us today! We are always waiting to answer all your questions.
