File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

return type - doubt

 
muskaan gaffor
Ranch Hand
Posts: 50
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Deepak Chopra
Ranch Hand
Posts: 433
Eclipse IDE Firefox Browser Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

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

Please check, you will find your answer !!
 
muskaan gaffor
Ranch Hand
Posts: 50
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Sunny

I got the answer!!!
 
sitaram
Greenhorn
Posts: 26
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please write the complete code with lines
 
Raghavan Muthu
Ranch Hand
Posts: 3381
Mac MySQL Database Tomcat Server
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Raghavan Muthu
Ranch Hand
Posts: 3381
Mac MySQL Database Tomcat Server
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 50
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic