GeekInterview.com
   Home |  Tech FAQ  |   Interview Questions |  Placement Papers |  Tech Articles |  Learn |  Freelance Projects |  Online Testing |  Geeks Talk |  Job Postings |  Knowledge Base | Site Search |  Add/Ask Question

GeekInterview.com  >  Interview Questions  >  J2EE  >  Java
Go To First  |  Previous Question  |  Next Question 
 Java  |  Question 116 of 923    Print  
What is the difference between a while statement and a do statement
A while statement checks at the beginning of a loop to see whether the next loop iterationshould occur. A do statement checks at the end of a loop to see whether the next iterationof a loop should occur. The do statement will always execute the body of a loop at leastonce.


  
Total Answers and Comments: 2 Last Update: July 29, 2007   
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
October 26, 2006 05:59:15   #1  
MANISHA PATHAK Member Since: October 2006   Contribution: 14    

RE: What is the difference between a while statement a...

syntax of while is as :

while(condition)

{

}

In while statement,first condition is checked,if the condition is true then the statements within loop are  executed otherwise statements within loop are not executed.

syntax of do-while as :

do

{

}

while(condition);

In do-while statement,first the statements are executed then condition is checked,if the condition is true then only further the loop is executed otherwise not.


 
Is this answer useful? Yes | No
July 29, 2007 05:50:02   #2  
sujatham Member Since: January 2006   Contribution: 142    

RE: What is the difference between a while statement a...
while is an entry controlled loop.
do-while is a exit controlled loop.

 
Is this answer useful? Yes | No

 Related Questions

The >> operator carries the sign bit when shifting right. The >>> zero-fills bits that havebeen shifted out. 
Latest Answer : While dealing with (+)ve numbers there is no difference between >>> and >> operators.Both operators shift zeros into the upper bits of a number.The difference arises when dealing with (-)ve numbers.Since (-)ve numbers,(-)ve numbers have ...

When a task invokes its yield() method, it returns to the ready state. When a task invokesits sleep() method, it returns to the waiting state. 
Latest Answer : yield method is mainly used to release the lock of resource and pull up in to steady state from wait pool. Sleep() will pull the thread to sleep for the given time. It will throws exception while trying to intrupt in b/w the sleep state ...

A package statement must appear as the first line in a source code file (excluding blanklines and comments). 
Latest Answer : package statement must appear as the first line in a source code file and one public class declaration. ...

Under preemptive scheduling, the highest priority task executes until it enters the waitingor dead states or a higher priority task comes into existence. Under time slicing, a taskexecutes for a predefined 
Latest Answer : 1.    Pre-emptive Scheduling.Ways for a thread to leave running state -·         It can cease to be ready to execute ( by calling a blocking i/o method)·         ...

Yes, a for statement can loop indefinitely. For example, consider the following:for(;;) ; 
Latest Answer : The for loop will be working fine even without the initialization.Hence for(;;) will create a indefinite loop. ...

The CheckboxMenuItem class extends the MenuItem class to support a menu item thatmay be checked or unchecked. 

If an expression involving the Boolean & operator is evaluated, both operands areevaluated. Then the & operator is applied to the operand. When an expression involvingthe && operator is evaluated, the 
Latest Answer : & -> for bitwise operation&&-> for logical comparison ...

The finally clause is used to provide the capability to execute code no matter whether ornot an exception is thrown or caught. 
Latest Answer : In try,catch clauses either try clause(If exception is not happend) or catch clause(If exception occures) is exicuted.If we want to exicute a block of statements doesn't depend on exception then we put those block of statements in finally ...

A break statement results in the termination of the statement to which it applies (switch,for, do, or while). A continue statement is used to end the current loop iteration andreturn control to the loop 
Latest Answer : The break keyword halts the execution of the current loop and forces control out of the loop. The continue is similar to break, except that instead of halting the execution of the loop, it starts the next iteration. ...

Commas are used to separate multiple statements within the initialization and iterationparts of a for statement. 


 Sponsored Links

 
Related Articles

Service Oriented Java Business Integration Review

Service Oriented Java Business Integration Review Introduction If you ve read through the texts which give you an introduction to SOA or Web Services you will often find them to be quite frustrating and the reason for this is because they spend too much time referencing business processes which are
 

Java and Client Server Models

Java and Client Server Models The Role of Client Servers on the Web Client server models provide the essential mechanisms for working with the Internet In fact most of the World Wide Web is built according to this paradigm In client server models the web browsers run by millions of users are the cli
 

What is difference between call by value and call by reference in function?

The arguments passed to function can be of two types 1. Values passed 2. Address passed The first type refers to call by value and the second type refers to call by reference. For instance consider program1 main() { int x=50, y=70; interchange(x,y); printf(“x=%d y=%d”,x,
 

What are the limitations with switch statement?

Switch statement is a powerful statement used to handle many alternatives and provides good presentation for C program. But there are some limitations with switch statement which are given below: Logical operators cannot be used with switch statement. For instance case k>=20: is not allowe
 

goto Statement

Why to avoid goto in C C has goto statement but one must ensure not to use too much of goto statement in their program because its functionality is limited and it is only recommended as a last resort if structured solutions are much more complicated. First let us understand the goto statement, its
 

The Interview Snafu

How to turn someone else’s mistake to your advantage Your dream job is about to become reality. A recruiter gave you the heads up about the perfect position at Humungous Conglomerate, Inc. You went through five interviews as well as a battery of psychological tests mandated by their HR de
 

Winning a Job Interview with a Winning Resume

Does your resume unlock your potential, take your skills to the highest level and win you the interview and the job you want now? The job market today is highly competitive and even if you think you have what it takes to get an interview you won’t get over the line without a polished, prof
 

Using UML with Java

Using UML with Java While Java is not a new language its application for the development of embedded systems is quite new Developers are beginning to take a second look at modeling languages such as UML and many feel it can be a powerful tool in their development arsenal mosgoogle center Introductio
 

Importance of Proper English during Job Interview

Importance of Proper English during Job Interview Your job interview is crucially important and it will determine whether or not you will get the job Depending on the type of job you re going for it is very important for you to use proper English In most cases jobs which offer higher salaries will h
 

Java Technology Trends

Technology Trends Involving Java Java is an object oriented programming language OOP for Web browsers It is organized around data rather than actions and supports polymorphism which allows the same code to be written generically so it can function with different datatypes inheritance which allows on
 

Sponsored Links

 




About Us  |   Privacy Policy  |   Terms and Conditions  |   Contact  |   Site Map  |   Add Question  |   Propose Category  |   RSS Feeds  |   Articles Sitemap  |   Site Updates  |   Add Resource

Copyright © 2005 - 2008 GeekInterview.com. All Rights Reserved
Page copy protected against web site content infringement by Copyscape