© 2014 Firstsoft Technologies (P) Limited. login
Hi 'Guest'
Home SiteMap Contact Us Disclaimer
enggedu

Home Placements Interview Questions Java Interview Questions And Answers Java Interview Questions On Flow Control and Exception Handling ▼

Java Interview Questions On Flow Control and Exception Handling

1. Explain About If else statement

Answer

  • The if() statement takes a boolean argument.
  • l The else part is optional.
  • l Can have 'n' number of else if constructs.
  • In Java or any other languages like C/C++, it takes a boolean argument as the basis of its choice.

2. Explain About Switch statements

Answer

  • The structure of switch statement consists of series of case labels and optional default case.
  •  An if statement can be used to make decisions based on range of values or conditions, whereas a switch statement can make decisions based only on a single integer value, and the value provided to each case statement must be unique.
  • l The switch construct will accepts only byte, char, short, and int only.
  • l It does not accepts boolean and floating numbers.

3. Explain About for loop

Answer

  • The for statement provides a most common way to iterate over a range of values.
  • The for() construct has three parts.
  • The ini_statement is a starting point of the loop execution.
  • The boolean_condition is an expression that tells you when to terminate the loop.
  • This expression is evaluated at the top of each iteration of the loop. When the boolean_condition expression evaluates to false, the loop terminates.
  • The ite_increment is an expression that gets invoked for each iteration through the loop (immediately after the body of the loop).

4. Explain About while statement

Answer

The while statement will execute a block of statements until a condition remains true. The while statement evaluates expression, which must return a boolean value. If the expression returns true, then the while statement executes the statement(s) associated with it or if expression returns false then while loop terminates. If the expression is false before encountering the loop then the body of the loop never gets executed.

Next
1 2 3 4 5 6 7 8 9
SLogix Student Projects
bottom