0% found this document useful (0 votes)
43 views

Java

The document contains code examples demonstrating method overloading, method overriding, and constructor overloading in Java. For method overloading, it shows a class with multiple show methods that differ by parameters. For method overriding, it shows a parent and child class where the child overrides the parent's show method. For constructor overloading, it shows a class with multiple constructors that differ by parameters. The main method in each case calls the various overloaded/overridden methods and constructors.

Uploaded by

umair riaz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
43 views

Java

The document contains code examples demonstrating method overloading, method overriding, and constructor overloading in Java. For method overloading, it shows a class with multiple show methods that differ by parameters. For method overriding, it shows a parent and child class where the child overrides the parent's show method. For constructor overloading, it shows a class with multiple constructors that differ by parameters. The main method in each case calls the various overloaded/overridden methods and constructors.

Uploaded by

umair riaz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

MethodOverLoading

class MethodOverloading

void show()

System.out.println("No args Show Method");

void show(int x)

System.out.println("One args Show Method");

void show(int x,int y)

System.out.println("Two args Show Method");

public static void main(String [] aargs)

MethodOverloading m=new MethodOverloading();

m.show();

m.show(10);

m.show(20,20);

}
//Output
Method Overriding
class Parent

void show()

System.out.println("Show Method Of Parent");

class OverRiding extends Parent

void show()

System.out.println("OverRided Method Of Parent class");

public static void main(String [] args)

OverRiding o=new OverRiding();

o.show();

}
}

//Output

Constructer OverLoading
class Test

Test()

System.out.println("Default Constructer");

Test(int x)

System.out.println("One Args Constructer");

Test(int x,float f)

System.out.println("Two Args Constructer");

public static void main(String [] args)

new Test();

new Test(110);
new Test(10,20.5f);

//Output
Java Programming Lab
(DCO-515)

Practical- :- a)Write a program in java Method Over Loading, Method Overriding and Constructer
Over Loading.

Submitted by:
UMAIR RIAZ
16-DCS-067
Diploma in Computer Engineering-V Semester

Computer Engineering Section


University Polytechnic, Faculty of Engineering and Technology
Jamia Millia Islamia (A Central University)
New Delhi-110025
Session 2018-2019

You might also like