Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In Java programming, class Overload { void ovlDemo ( ) { System.out.println ( No parameters ) ; } / / Overload ovlDemo for one

In Java programming,
class Overload
{
void ovlDemo()
{
System.out.println("No parameters");
}
// Overload ovlDemo for one integer parameter.
void ovlDemo(int a)
{
System.out.println("One parameter: "+ a);
}
//Overload ovlDemo for two integer parameters.
int ovlDemo(int a, int b)
{
System.out.println("Two parameters: "+ a +""+ b);
return a + b;
}
//Overload ovlDemo for two double parameters.
double ovlDemo(double a, double b)
{
System.out.println("Two double parameters: "+ a +""+ b);
return a + b;
}
}
class OverloadDemo
{
public static void main(String args[])
{
Overload ob = new Overload();
int resI;
double resD;
// call all versions of ovlDemo()
ob.ovlDemo();
System.out.println();
ob.ovlDemo(2);
System.out.println();
resI = ob.ovlDemo(4,6);
System.out.println("Result of ob.ovlDemo(4,6): "+ resI);
resD = ob.ovlDemo(1.1,2.32);
System.out.println("Result of ob.ovlDemo(1.1,2.32): "+ resD);
}
} A. How does void ovlDemo() and int ovlDemo() impact the output of the program?
B. What will the program output when the method is overloaded with the same type and numbers of parameters?

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Jeffrey A. Hoffer Fred R. McFadden

4th Edition

0805360476, 978-0805360479

More Books

Students also viewed these Databases questions