Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Polymorphism/Data.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.Polymorphism;

public class Data extends DataMember {
{
int x=20;
}

}
9 changes: 9 additions & 0 deletions Polymorphism/DataDriver.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.Polymorphism;

public class DataDriver {
public static void main(String[] args) {
DataMember d=new Data();
System.out.println(d.x);
}

}
8 changes: 8 additions & 0 deletions Polymorphism/DataMember.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.Polymorphism;

public class DataMember {
{
int x=20;
}

}
11 changes: 11 additions & 0 deletions Polymorphism/Driver.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.Polymorphism;

public class Driver {
public static void main(String[] args) {
Father f=new Father();
f.role();


}

}
11 changes: 11 additions & 0 deletions Polymorphism/Father.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.Polymorphism;

public class Father extends Person {

@Override
void role() {
System.out.println("I am a father");
super.role();
}

}
14 changes: 14 additions & 0 deletions Polymorphism/Helper.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.Polymorphism;

public class Helper {

static int multiplyTwoNumbers(int a, int b)
{
return a*b;
}
static double multiplyTwoNumbers(double a,double b)
{
return a*b;
}
}

11 changes: 11 additions & 0 deletions Polymorphism/HelperDriver.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.Polymorphism;

public class HelperDriver {
public static void main(String[] args) {

System.out.println(Helper.multiplyTwoNumbers(5, 10));
System.out.println(Helper.multiplyTwoNumbers(5.5, 6.3));
}

}

18 changes: 18 additions & 0 deletions Polymorphism/MethodOverloading.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.Polymorphism;

public class MethodOverloading {
void show(int a)
{
System.out.println(a);
}
void show(int a,int b)
{
System.out.println("number1 :" + a + " number2 :" + b);
}
public static void main(String[] args) {
MethodOverloading obj = new MethodOverloading();
obj.show(10);
obj.show(10, 20);

}
}
21 changes: 21 additions & 0 deletions Polymorphism/OperatorOverloading.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.Polymorphism;

public class OperatorOverloading {

void add(int a,int b)
{
int sum=a+b;
System.out.println("Addition of two integer :" + sum);
}
void add(String s1,String s2)
{
String con=s1+s2;
System.out.println("Addition of two String:" + con);
}
public static void main(String[] args) {
OperatorOverloading obj=new OperatorOverloading();
obj.add(10, 20);
obj.add("Operator", " Overloading");
}

}
17 changes: 17 additions & 0 deletions Polymorphism/Overloading.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.Polymorphism;

public class Overloading {

static void show(int a,int b)
{
System.out.println("This is integer function");
}
static void show(double a,double b)
{
System.out.println("This is double function");
}
public static void main(String[] args) {
Overloading.show(10, 20);
Overloading.show(1.2, 2.2);
}
}
8 changes: 8 additions & 0 deletions Polymorphism/Person.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.Polymorphism;

public class Person {
void role() {
System.out.println("I am a person");
}

}