Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

PolyExample.

java

package ooconcepts;

//Polymorphism --> 1. Overloading 2. Overriding

public class PolyExample {

//Constructor Overloading

//global variable

int x, y,z;

int sum;

public PolyExample(){

public PolyExample(int x, int y){

this.x = x;

this.y = y;

public PolyExample(int x, int y,int z){

this.x = x;

this.y = y;

this.z = z;

}
public void sumValue(){

sum = x + y + z;

System.out.println("Sum Value of X any Y is : " + sum);

public static void main(String[] args) {

PolyExample pe = new PolyExample();

PolyExample pe1 = new PolyExample(10,20);

PolyExample pe2 = new PolyExample(10,20,30);

pe.sumValue();

pe1.sumValue();

pe2.sumValue();

/*

pe --- > |x=0|y=0|

*/

You might also like