//partI
public class Aquestion
{
Public void method(Object o)
{
System.out.println("object version");
}
Public void method(String s)
{
System.out.println("string version");
}
public static void main(String[] args)
{
AQuestion q =new AQuestion();
q.method(null);
}
}
//part II
public class Aquestion
{
Public void method(StringBuffer sb)
{
System.out.println("string buffer version");
}
Public void method(String s)
{
System.out.println("string version");
}
public static void main(String[] args)
{
AQuestion q =new AQuestion();
q.method(null);
}
}
/* 1)why will ther be a compile time error in partII and not in PartI.
2)In PartI how does the compiler know which method() to call when both mehtods can take null value as argument */
public class Aquestion
{
Public void method(Object o)
{
System.out.println("object version");
}
Public void method(String s)
{
System.out.println("string version");
}
public static void main(String[] args)
{
AQuestion q =new AQuestion();
q.method(null);
}
}
//part II
public class Aquestion
{
Public void method(StringBuffer sb)
{
System.out.println("string buffer version");
}
Public void method(String s)
{
System.out.println("string version");
}
public static void main(String[] args)
{
AQuestion q =new AQuestion();
q.method(null);
}
}
/* 1)why will ther be a compile time error in partII and not in PartI.
2)In PartI how does the compiler know which method() to call when both mehtods can take null value as argument */