codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  need help with quiz  indianj at 03:56 on Monday, December 05, 2005
 

hello, i am preparing for java exam. i am going this exercise, i get confuse with this one. let me know if you have any idea.

void quiz(int i)
{
if (i > 1)
{ quiz(i / 2);
quiz(i / 2);
}
System.out.print("*");
}
How many asterisks are printed by the method call quiz(5)?
A. 3
B. 4
C. 7
D. 8
E. Some other number

  Re: need help with quiz  crwood at 09:10 on Monday, December 05, 2005
 

Let's try it

class Quiz
{
public static void main(String[] args)
{
quiz(5);
}

private static void quiz(int n)
{
if(n > 1)
quiz(n/2);
System.out.print("*");
}
}
Output:
C:\jexp>java Quiz
***


  Re: need help with quiz  indianj at 21:56 on Monday, December 05, 2005
 

hi, thanks for your responce.i have one question. when a method call is executed, which information is not saved in the activation record? formal parameters or local variables?








CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums








Recent Forum Threads
•  Re: sorting and Linked list
•  Re: need help linked list
•  Re: Help with arrays
•  Re: Reading from a file
•  Re: Why Use Method?
•  Re: Help with a simple program
•  Re: need help with quiz
•  Re: Help with filesystem object & displaying in a table
•  Re: Genetic Algorithm Help


Recent Articles
Multiple submit buttons with form validation
Understanding Hibernate ORM for Java/J2EE
HTTP screen-scraping and caching
a javascript calculator
A simple way to JTable
Java Native Interface (JNI)
Parsing Dynamic Layouts
MagicGrid
Caching With ASP.Net
Creating CSS Buttons


Site Survey
Help us serve you better. Take a five minute survey. Click here!

© Copyright codetoad.com 2001-2005