class A
{
public void B()
{
System.out.println("B");
}
public void str(Object s)
{
System.out.println("==output="+s);
}
public void str(String s)
{
System.out.println("=Output 2=="+s);
}
public void str(int s)
{
System.out.println("=i=="+s);
}
}
public class Test extends A{
public void B()
{
System.out.println("BB");
}
public static void main(String args[])
{
A a=new Test();
a.B();
a.str(null);
a.str("ss");
// If we overload a method and we pass String in one method and Integer in another So while calling if we pass ‘null’ then which method will be called and why?
a.str(null);
a.str(5);
}
}
OUTPUT
{
public void B()
{
System.out.println("B");
}
public void str(Object s)
{
System.out.println("==output="+s);
}
public void str(String s)
{
System.out.println("=Output 2=="+s);
}
public void str(int s)
{
System.out.println("=i=="+s);
}
}
public class Test extends A{
public void B()
{
System.out.println("BB");
}
public static void main(String args[])
{
A a=new Test();
a.B();
a.str(null);
a.str("ss");
// If we overload a method and we pass String in one method and Integer in another So while calling if we pass ‘null’ then which method will be called and why?
a.str(null);
a.str(5);
}
}
OUTPUT
BB
=output==null
=output2==ss
=Output==null
=i==5
No comments:
Post a Comment