Overloading Concepts in java-polymorphism and Overloading in java programming
Overloading
what is method overloading in java?
how many types of overloading in java?
Types of overloading
- constructor overloading ---> Default constructor(without any arguments)Parameterized constructor(with some arguments)
- method overloading ---> Method Without any argument and method with arguments
- operator overloading ---> The + symbol can be implemented in two ways one is addition operator and another one is concatenation operator,same symbol used to perform two purposes.It is called operator overloading
Polymorphism
Types of polymorphism
- Compile time polymorphism ---> compile time polymorphism is achieved by implementing method overloading conceptThis is called static binding
- Runtime polymorphism ---> Runtime polymorphism is achieved by implementing method overriding concepts.This is called dynamic binding
Q:Which java class programming technique shows the use of polymorphism?
A: polymorphism in java, is achieved by implementing the overloading concepts
sample program constructor overloading
class Student { Student() { System.out.println(); System.out.println("This is a default consructor"); System.out.println("____________"); } Student(String str,int i) { System.out.println("This is a parametrized constructor"); System.out.println("Name :"+str+" Age :"+i); System.out.println("____________"); } } class Constructor { public static void main(String args[]) { Student std=new Student(); Student std1=new Student("Bilal",10); } }
Comments
Post a Comment