What is Java polymorphism and its types in Java training? - PowerPoint PPT Presentation

About This Presentation
Title:

What is Java polymorphism and its types in Java training?

Description:

Java is a most popular, robust, secure, platform independent and multithreading based high level programming language, because of this it is preferably used by many programmers. – PowerPoint PPT presentation

Number of Views:97
Slides: 13
Provided by: adityask
Category: Other

less

Transcript and Presenter's Notes

Title: What is Java polymorphism and its types in Java training?


1
  • What is Java polymorphism and its types in Java
    training?

2
Index
Four types of polymorphism in Java What is
Java polymorphism
3
  • Prepared by
  • Preeti

4
  • You will learn the four types of polymorphism in
    Java-training in this blog, polymorphism refers
    to the ability of some entities occur in
    different forms.
  • It is represented popularly by the butterfly,
    which transforms from larva to pupa to imago.
    Polymorphism also exists in programming
    languages, as a modeling technique that allows
    you to create a single interface to various
    operands, arguments, and objects. Java
    polymorphism leads to code that is more concise
    and easier to maintain.
  • While this tutorial focuses on subtype
    polymorphism, there are several other ways you
    should know. We begin with an overview of all
    four types of polymorphism.
  • Note that code samples in this tutorial under
    Java 12 compile and run.

5
ExlTech has come up with the Exclusive Java
Training course.Hurry and grab the opportunity to
become successful Java professional in worlds up
growing technologies. Types of polymorphism in
Java There are four types of polymorphism in
Java 1. Coercion is an operation serves multiple
types through implicit type conversion. For
example, you divide an integer by another integer
or a floating-point value by another
floating-point value. If an operand is an integer
and the other operand is a floating-point value,
the compiler (implicitly) forces the integer into
a floating-point value to prevent a type error.
(There is no division operation that supports an
integer operand and a floating-point operand.)
Another example is passing a subclass object
reference to the superclass parameter of a
method. The compiler forces the subclass type to
the superclass type to limit operations to those
of the superclass.
6
2. What do you mean? Overload refers to the use
of the same operator symbol or method name in
different contexts. For example, you can use to
perform integer addition, floating-point
addition, or string concatenation, depending on
the types of its operands. In addition, multiple
methods with the same name can appear in a class
(by Declaration and/or inheritance).
7
3. Parametric polymorphism defines that in a
class Declaration, a field name with different
types and a method name with different parameter
and return types can be linked. The field and
method can then take different types in each
class instance (object). For example, a field of
type Double (A member of the Java standard class
library that encloses a double value) and a
method can return a Double in an object. Java
supports parametric polymorphism via generics,
which I will discuss in a future
article. https//www.exltech.in/java-training.html
8
4. Subtype means that a type can serve as a
subtype of another type. When a subtype instance
appears in a Supertype context, running a
supertype operation on the subtype instance will
cause the subtype to run. For example, consider a
code fragment that draws arbitrary shapes. You
can Express these characters code more concise by
introducing a Shape class with a draw () method
by introducing Circle, Rectangle, and other
sub-classes, the draw () override. and by
calling the draw () method for each instance.
When you call draw (), the draw () method of the
Circle, Rectangle, or other Shape instance is
called. We say that there are many forms of the
draw () method of Shape.
9
This tutorial introduces the subtype
polymorphism. Learn more about upcasting and late
binding, abstract classes (cannot be
instantiated) abstract methods (which can not be
called). You will also learn downcasting and
runtime type identification and get a first look
at co-variant return types. I save parametric
polymorphism for a future tutorial.
10
Visit Us https//www.exltech.in/
11
(No Transcript)
12
(No Transcript)
Write a Comment
User Comments (0)
About PowerShow.com