The Code in java is contained within Methods

A) True
B) False

Showing Answers 1 - 5 of 5 Answers

radha krishna garnepudi

  • Jan 27th, 2006
 

Source Code is normally an entire file.

In Java the actual execution (or result preparation) would be there in methods only.Method will return exact one return value / 0(void).

Methods will change the behaviour of an object (Operations).

Fields contains value or state of an object.

  Was this answer useful?  Yes

lguzinski

  • Apr 17th, 2007
 

I answered false, mostly due to ambiguity in the question.

      1 class Factorial {
      2     // this is a recursive method
      3     int fact(int n) {
      4         int result;
      5         if(n==1) return 1;
      6         result = fact(n-1) * n;
      7         return result;
      8     }
      9 }

This is (line numbered) code, taken from another question on this site. Only four lines of it are actually *in* a method.

  Was this answer useful?  Yes

sukace

  • Nov 20th, 2007
 

Code in java can also be in blocks(Static and non-static) which are not the part of the methods. So, the answer should be false not true.

  Was this answer useful?  Yes

keyvez

  • Mar 19th, 2008
 

Code in Java can also be in instance initializer blocks and static and non-static blocks. So the answer to this question is false.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions