This week's book giveaway is in the General Computing forum. We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line! See this thread for details.
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
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.