aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Marcus Mock 3 question #60 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Marcus Mock 3 question #60" Watch "Marcus Mock 3 question #60" New topic
Author

Marcus Mock 3 question #60

Jason
Ranch Hand

Joined: Dec 06, 2000
Posts: 35
here is the code for question 60:
I think the answer is none of the given answer. My argument is that the method fliton() has a return value, should it be assigned to a variable ?
Anyone plz help me with this!!

import java.io.*;
public class Ppvg{
public static void main(String argv[]){
Ppvg p = new Ppvg();
//note: fliton method return an int value, does this //need to assign the return value to a variable?
p.fliton();
}
public int fliton(){
try{
DataInputStream din = new DataInputStream(System.in);
din.readChar();
}catch(IOException ioe){
System.out.println("flytwick");
return 99;
}finally{
System.out.println("fliton");
}

return -1;
}

}
Which of the following statements are true if you try to compile and run the program?
1) The program will run and output only "flytwick"
2) The program will run and output only "fliton"
3) The program will run and output both "fliton" and "flytwick"
4) An error will occur at compile time because the method fliton attempts to return two values

hemanshow
Greenhorn

Joined: Jun 26, 2000
Posts: 25
Its not necessary to assign a return value. Try it yourself. ;-)
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Hi Jason,
the answer is 2 the reason is that just because a method has a return value does not mean that one should save this value. it is based on a need assessement. if i do not want it i may not save the return value else I may.
Thus It is not compulsory to save the value returned by a method.
Regards.
Rahul.
dan pahl
Greenhorn

Joined: Aug 08, 2007
Posts: 3
Where can I find Marcus Mock 3?
Thanks!
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
Marcus has carefully hidden it next to his Exam 2. Just look at the URL, and make a guess at where exam 3 might be located.


"I'm not back." - Bill Harding, Twister
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Marcus Mock 3 question #60