ProductsLogo
LogoStudy Documents
LogoAI Grader
LogoAI Answer
LogoAI Code Checker
LogoPlagiarism Checker
LogoAI Paraphraser
LogoAI Quiz
LogoAI Detector
PricingBlogAbout Us
logo

Java Programming

Verified

Added on  2023/04/23

|4
|710
|381
AI Summary
This document discusses Java Programming concepts such as Polymorphism, Abstract classes, and more. It explains the use of @Override declaration, superclass and subclass references, and the instanceof operator. The document also provides references for further reading.

Contribute Materials

Your contribution can guide someone’s learning journey. Share your documents today.
Document Page
Running head: JAVA PROGRAMMING
Java Programming
Name of the Student
Name of the University

Secure Best Marks with AI Grader

Need help grading? Try our AI Grader for instant feedback on your assignments.
Document Page
2
JAVA PROGRAMMING
Chapter 9
9.9 a) As commented by Potts & Friedel (2018), the method earnings () has been overridden in
a sub class. The statement calls its parent class earnings method from the sub class that is inherits
methods from parent class.
o super.earnings()
In this case, super is a keyword which, is utilized for calling parent class method earnings ().
b) @Override declaration -Description
The declaration @Override method has been helping in indicating method is override method of
its super class method. The super class @Override method signature and child class @Override
method signature are equal. Method definitions of super class and child class may or may not be
same.
c) It is used to call the constructor of the parent class by passing the two mentioned arguments.
The parent class constructor will accept this arguments and initialize the object attributes
accordingly.
Chapter 10
10.6 Polymorphism has been allowing creation of new subclasses for extending behavior. In
the absence of polymorphism, conditional code needs to be written for testing new behavior
being implemented. The new class has been becoming part of the classification. Polymorphism
helps in using same functions with different class type. This concept refers to overriding
Document Page
3
JAVA PROGRAMMING
(Gavrilović et al., 2018). Overriding methods helps in allowing a subclass for overriding a
functionality provided in the super class.
10.7 There are various ways by which subclass and superclass references can be assigned to
variables of subclass and superclass types as mentioned below:
1. Assigning a superclass reference to a super class variable
2. Assigning a subclass reference to a subclass variable
3. Assigning a subclass object’s reference to a superclass
This reference need to be utilized in the superclass members. However, this code tends to
subclass only members with help of superclass variable. Attempting for assigning a superclass
object’s reference to a subclass variable has been providing compilation error (Sebesta, 2016).
Therefore, for avoiding this error, the superclass reference needs to be downcast to a subclass
type. Therefore, at execution time, the object needs to be refers to not a subclass object. The
instanceof operator has been used for ensuring has been performed if the object is a subclass
object.
10.8 An abstract refers to general notion that means to be an object of same class. Abstract
classes contain data and methods that can be declared abstract as the methods are not able to use
in other cases. Therefore, objects of an abstract class cannot be instantiated. Subclasses needs to
be declared for implementation of abstract methods which, has been appropriate for each specific
methods (Carpenter et al., 2017). Classes that are related to the interface whereas concrete
subclass of the same abstract. Interface references has been used for evoking polymorphic
behavior of an abstract superclass references. Interface has only abstract methods and supports
Document Page
4
JAVA PROGRAMMING
multiple inheritance. An interface has been implemented by the help of keyword named as
implement.
References
Carpenter, B., Gelman, A., Hoffman, M. D., Lee, D., Goodrich, B., Betancourt, M., ... & Riddell,
A. (2017). Stan: A probabilistic programming language. Journal of statistical
software, 76(1).
Gavrilović, N., Arsić, A., Domazet, D., & Mishra, A. (2018). Algorithm for adaptive learning
process and improving learners’ skills in Java programming language. Computer
Applications in Engineering Education, 26(5), 1362-1382.
Potts, A., & Friedel, D. H. (2018). Java programming language handbook. Coriolis Group
Books.
Sebesta, R. W. (2016). Concepts of programming languages.
1 out of 4
[object Object]

Your All-in-One AI-Powered Toolkit for Academic Success.

Available 24*7 on WhatsApp / Email

[object Object]