Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

What is the output ?  RSS feed

 
Jalli Venkat
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI Friends,
I wrote a class like as follows.

Class A() {
void add(String a,String b) {
System.out.println("add method with strings");
}

void add(Date d1,Date d2) {
System.out.println("add method with dates");
}

}

If I call above add method with parameter values as "null" like as follows, then what will be the output?

add(null,null);

It will throws any exception or displays any message?

please answer this .
 
Vijitha Kumara
Bartender
Posts: 3973
24
Chrome Fedora Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Best way to find out is, try it your self. Then you can experiment in different ways as well.
 
Ankit Garg
Sheriff
Posts: 9608
36
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jalli also UseCodeTags to make the program more readable

 
Rob Spoor
Sheriff
Posts: 20893
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Vijitha Kumara wrote:Best way to find out is, try it your self. Then you can experiment in different ways as well.

 
supriya riya
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think while compiling itself it will give message
ambigious
etc,as null value is applicable both for String and Date .how will compiler know which add?both have null as valid parameters.
 
Amit Ghorpade
Bartender
Posts: 2856
10
Fedora Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"supriya java " please check your private messages for an important administrative matter. You can check them by clicking the My Private Messages link above.
 
Sridhar Santhanakrishnan
Ranch Hand
Posts: 317
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Vijitha Kumara wrote:Best way to find out is, try it your self. Then you can experiment in different ways as well.


+1
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!