Вы находитесь на странице: 1из 2

Unit 1 - Basics of JAVA

Unit 2 - Inheritance,types,interface,Abstract and Final classess and methods,


String handling
Unit 3 - Polymorphism and Exception

Polymorphism
Object oriented concept

poly + morph
poly - many
morph - different forms

action in different way

JAVA PROGRAMMING - 2 steps


JAVAC- Compiletime
JAVA - Runtime

Compiletime polymorphism
-action will take place at compiletime
-Method overloading
-doesnot need inheritatnce

Runtime polymorphism
-action will take place at runtime
-Method overriding
- inheritance relationship

Method overloading

class calculator

- add(int x,int y) -> return the added value of x and y


- add(int x,int y,int z) -> add(x+y+z)
- add(int x,int y,int z,int p) -> add(x+y+z+p)
- add(double x,double y) ->add(double x+ double y)

Method overloading in java


2 way
1)by changing the number of paramters
2)by changing the datatype of parameters

method overloading cannot be achieved by changing the returntype of the method

Compiletime polymorphism

- Method overloading // same method name different parameters


- Constructor overloading // same constructor but different parameters
- operator overloading //same operator but different action

Runtime polymorphism
-Method overriding is possible in only inherited classes.
-method should have same name and same parameter

Polymorphic variable
- instance variable/object variable
which takes different form

Вам также может понравиться