Flow Control Statements in Java

Flow Control Statements in Java

1.what are control statements?

A: control statements are the statements which alter the flow of execution and provide better control to the programmer on the flow of execution .They are useful to write better and complex programs.

2. What is the difference between a while statement and a do statement?

A:A while statement (pre test) checks at the beginning of a loop to see whether the next loop iteration should occur. A do while statement (post test) checks at the end of a loop to see whether the next iteration of a loop should occur. The do statement will always execute the loop body at least once.

3.What is a collection?

A:A collection represents a group of elements like integer values or objects.Example for collections are arrays and java.util classes

4.why goto statements are not available in java?

A:goto statements lead to confusion for a prohgrammer .Especially , in a large program,if several goto statements are used ,the programmer would be perplexed while understanding the flow from where to where the control is jumping.

5.What is the difference between return and System.exit(0)?

A:return statement is used inside a method to come out of it.System.exit(0)is used in any method to come out of the program.

6.What is the difference between System.exit(0) and System.exit(1)?

A:System.exit(0) terminates the program normally.Where as System.exit(1) terminates the program because of some error encounterd in the program.

7.What is the difference between System.out and System.err?

A:System.out and System.err both represents the monitor by default and hence can be used to send data or results to the monitor.But system .out is used to display normal messages and results where asa system.err is used to display error messages.

8.What is a tranfer statemnts?what is that?

A:These statements are used for transfering the contrlo from one location to another location.We have three statements are available.they are

9.What is the purpose of break statement?

A:break statement is a transfer statement.Which is used to transfer the control from inside the switch to outside the switch statement..so that we don't execute the remaining cases.

10.What is continue statement?

A:The continue statement can we used in only loops.This statement will skip the current iteration and continue with the remaining iterations in the loop.

11.What is the use of conditional statements? What are they?

A:conditional statements will executes a group of statements based on a condition or a value .In this category we have 2 statements are available.They are
1.if -else


Post a Comment