# Java – Polymorphism:
ð
Polymorphism is the ability of an object to take
on many forms.
ð
The most common use of polymorphism in OOP
occurs when a parent class reference is used to refer to a child class object.
ð
This is possible because all objects of base
class object of its super class.
ð
It helps to prevent the code from becoming more
complex and cumbersome (unmanageable) by allowing us to make different
implementations of related functionalities under one name object or method.
ð
It is capability of an action or method to do
different things base on the object that it in upon.
ð
Overloading and Overriding are two type of polymorphism.
# Java – Abstraction:
ð
In OOP it means that ability to make a class
abstract.
ð
An abstract class is one that cannot be
instantiated. All other functionality of the class still exists, and its
fields, methods, and constructors are all accessed in the same manner.
ð
If you want a class to contain a particular
method but you want the actual implementation of that method to be determined
by child classes, you can declare the method in the parent class as abstract.
ð
An abstract method consists of a method
signature, but no method body.
Declaring a method as abstract has two results:
Declaring a method as abstract has two results:
ð
The class must also be declared abstract. If a
class contains an abstract method, the class must be abstract as well.
ð
Any child class must either override the
abstract method or declare it abstract.
Overloading
and Overriding:
Overloaded Method
|
Overriding Method
|
1) Method with same name, same signature.
|
1) Method has the same name, same
signature, same return type as a super class method, also same access
modifier but not be more restrictive then super class method. If super class
method is private then cannot be override.
|
2) Different number of parameters or
different type of parameter, different returns type.
|
2) Method that one redefined with an
inherited or subclass.
|
3) It can be exist in the same class or
another class.
|
|
4) It’s a compile type polymorphism.
|
3) It’s a Runtime polymorphism
|
5) exp:
-void sum(int a,int b){} it can be overloaded as-
-void sum(int a,int b,int c){}
- void sum(int a,string b){} - void sum(string a,string b){} etc… |
4) exp:
Class father{ void hand(int h){ smoking; } } class child extends father{ void hand(int h){ drinking; } } } |
#Constructor:
ð
It has
the same name as the name of class to which it belongs.
ð
It has no
return type, it does not return anything.
ð
May
(argumented) or may not (default cons.) include arguments.
# Enum Type :
#varargs:
# Autoboxing :
ð
Auto
boxing is a capability to convert or cast between object wrapper and its
primitive type(int<>Integer).
ð
int =>
Integer =Boxing
ð
Integer
=> int = Unboxing
# wrapper Class :
ð
In java wrappers are class that wrap up
primitive values in classes that offer utility methods to manipulate the
values.Exp: Integer,Boolean Class etc.
# What is Java Servlets?
ð Servlets are server side components that
provide a powerful mechanism for developing server side programs.
ð
A servlet is a Java programming language class
used to extend the capabilities of servers.
ð
Although servlets can respond to any type of
request, they are commonly used to extend the applications hosted by Web
servers.
ð init(),service()[doGet() or
doPost()],destroy()
No comments:
Post a Comment