Is it possible to do method overloading and overriding at a
time

Answer Posted / sathishkumar.m

class A
{
int c;
void add()
{
System.out.println("hai");
}
void add(int b)
{
c=b;
System.out.println("value of b:"+c);
}
}
class B
{
int e;
void add(int d)
{
System.out.println("value of d:"+e);
}
}
class Demo
{
public static void main(String aa[])
{
A o1=new B();
o1.add();
}
}

Is This Answer Correct ?    0 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are thread local variables?

747


What is an immutable object? How do you create one in java?

789


How do you declare a variable?

811


How do you convert an int to a double in java?

775


Explain about the security aspect of java?

742






Can we create our own wrapper class in java?

718


Explain different types of wrapper classes in java?

778


What modifiers may be used with a top-level class?

758


What is the public method modifier?

716


How do you test a method for an exception using junit?

763


Can we extend singleton class in java?

720


Explain the difference between arraylist and linkedlist in java?

680


What is ordered map in java?

736


How is garbage collection controlled?

899


What is lifetime variable?

702