aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes return type - doubt Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of JavaScript Promises Essentials this week in the JavaScript forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "return type - doubt" Watch "return type - doubt" New topic
Author

return type - doubt

muskaan gaffor
Ranch Hand

Joined: May 19, 2006
Posts: 50
public class Currency {
private String country, name;
public getCountry() { return country; }//line # 1
}
and:
class Dollar extends Currency {
public String getCountry() { return super.country; }
}

class Inr extends Currency {
public String getCountry(String timeZone) {
return super.getCountry();
}
}
Which statements are correct? (Choose two.)
A. Doller returns correct values.
B. Inr returns correct values.
C. An exception is thrown at runtime.
D. Doller and Inr both return correct values.
E. Compilation fails because of an error at line 25.
F. Compilation fails because of an error at line 30.

b and e is correct answer.

Doubt:
How B is correct? line # 1 is not the constructor...but will the method have such kind of syntax?? (without return type)?? i got confusted.
Plzz help me out !!!

regards,
Mussy.
Sunny Jain
Ranch Hand

Joined: Jul 23, 2007
Posts: 433

Hi,

first of all did you try to compile the code your self..!!!

Please check, you will find your answer !!


Thanks and Regards,
SCJP 1.5 (90%), SCWCD 1.5 (85%), The Jovial Java, java.util.concurrent tutorial
muskaan gaffor
Ranch Hand

Joined: May 19, 2006
Posts: 50
Thanks Sunny

I got the answer!!!
sitaram
Greenhorn

Joined: Jan 24, 2008
Posts: 26
Please write the complete code with lines
Raghavan Muthu
Ranch Hand

Joined: Apr 20, 2006
Posts: 3355

Howdy "d sitaramayya",

Welcome to JavaRanch

Kindly adjust your display names according to the naming policy of Ranch. You can update your name by editing your profile.


Everything has got its own deadline including one's EGO!
[CodeBarn] [Java Concepts-easily] [Corey's articles] [SCJP-SUN] [Servlet Examples] [Java Beginners FAQ] [Sun-Java Tutorials] [Java Coding Guidelines]
Raghavan Muthu
Ranch Hand

Joined: Apr 20, 2006
Posts: 3355

Originally posted by muskaan gaffor:
Thanks Sunny

I got the answer!!!


Muskaan, That's great

As the options say the errors with line numbers but the source code is incomplete. Kindly ensure the same for future posts!
muskaan gaffor
Ranch Hand

Joined: May 19, 2006
Posts: 50
Ooopps!!! I am sorry...

the complete code is..

public class Currency {
private String country, name;
public getCountry() { return country; }//line # 1
}

class Dollar extends Currency {
public String getCountry() { return super.country; }// line # 2
}

class Inr extends Currency {
public String getCountry(String timeZone) {
return super.getCountry();//line # 3
}
}
Which statements are correct? (Choose two.)
A. Doller returns correct values.
B. Inr returns correct values.
C. An exception is thrown at runtime.
D. Doller and Inr both return correct values.
E. Compilation fails because of an error at line 2.
F. Compilation fails because of an error at line 3.

the code wont compile cause of line # 1.
if the line # 1 is corrected as
public String getCountry() { return country; }//line # 1
}

then the answer is E

regards,
Mussy
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: return type - doubt