what is difference between method overloading & method
overridding with example?
Answer Posted / sirisha
overridding:
same method name and same signature.
import java.io.*;
class sum
{
int a=10,b=15;
void sum()
{
int sum=a+b;
System.out.println("sum is:"+sum);
}
}
class sum1 extends sum
{
int c=20;
void sum()
{
int sum1=a+b+c;
System.out.println("sum1 is:"+sum1);
}
}
class override{
public static void main(String[] arg){
sum s=new sum();
s.sum();
sum1 s1=new sum1();
s1.sum();
}
}
over loading:
method name same but different signature.
class sum{
void add(int a,int b){
}
class sum{
void add(string s1,string s2){
}
| Is This Answer Correct ? | 2 Yes | 0 No |
Post New Answer View All Answers
What are local variables?
What are the 8 primitive data types in java?
What is t in parametric equations?
Is there any way to find whether software installed in the
system is registered by just providing the .exe file?
I have tried the following code but its just displaying the
directory structure in the registry.
Here the code :
package com.msi.intaller;
import java.util.Iterator;
import ca.beq.util.win32.registry.RegistryKey;
import ca.beq.util.win32.registry.RootKey;
public class RegistryFinder {
public static void main(String... args) throws Exception
{
RegistryKey.initialize(RegistryFinder.class.getResource("jRe
gistryKey.dll").getFile());
RegistryKey key = new RegistryKey(RootKey.HKLM,
"Software\\ODBC");
for (Iterator
why doesn't java run on all platforms?
Why is logger singleton?
What is equlas() and hashcode() contract in java? Where does it used?
What are the two types of exceptions in java? Which are the differences between them?
What are controls and their different types in awt?
What are void pointers?
How many JVMs can run on a single machine and what is the meaning of Just-In-Time (JIT) compiler?
How do you end a program?
Can a final variable be null?
how to create constants in java?
What are methods of a class?