Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Beginning Java and the fly likes What is the output ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "What is the output ?" Watch "What is the output ?" New topic
Author

What is the output ?

Jalli Venkat
Greenhorn

Joined: Aug 10, 2006
Posts: 27
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 .


venkat
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3899
    
    9

Best way to find out is, try it your self. Then you can experiment in different ways as well.


SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9405
    
  20

Jalli also UseCodeTags to make the program more readable



SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 20080
    
  30

Vijitha Kumara wrote:Best way to find out is, try it your self. Then you can experiment in different ways as well.



SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
supriya riya
Ranch Hand

Joined: Feb 23, 2009
Posts: 41
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

Joined: Jun 06, 2007
Posts: 2801
    
    9

"supriya java " please check your private messages for an important administrative matter. You can check them by clicking the My Private Messages link above.


SCJP, SCWCD.
|Asking Good Questions|
Sridhar Santhanakrishnan
Ranch Hand

Joined: Mar 20, 2007
Posts: 317
Vijitha Kumara wrote:Best way to find out is, try it your self. Then you can experiment in different ways as well.


+1
 
Have you checked out Aspose?
 
subject: What is the output ?
 
jQuery in Action, 3rd edition