ICSE Board Computer Application Syllabus (2012-2013)
[1] Elementary Concept of Objects and Classes, [2] Values and types, [3] Conditionals and non-nested loops, [4] Class as the Basis of all Computation, [5] Constructors, [6] Functions, [7] Class as a User Defined Type, [8] Iterations, [9] Using Library Classes, [10] Encapsulation, [11] Arrays, [12] Input/Output.

Sunday, October 9, 2011


Q. What are iteration statements? Name the iteration statements provided by Java?
Ans: Iteration statements are statements that allows a set of instructions to be executed repeatedly till some condition is satisfied. The iteration statements provided by Java are: for loop, while loop, do-while loop.

Q. What is the difference between entry controlled and exit controlled loop?                          
What is the difference between while and do-while loop?
Ans: while loop is known as entry controlled loop and do-while loop is known as exit-controlled loop. The differences between these two loops are: (1) In while loop the test expression is evaluated at the beginning where as in do-while loop test expression is evaluated at the bottom, after the body of the loop. (2) In while loop if the test expression is false loop does not continued but in do-while what ever the test expression the loop execute at least once.

Q. Explain the difference between break and continue with an example.
Ans: Both statements are used as a jumped statement. But there is a difference between Break and Continue statement. The break statement terminate the loop, but the continue statement skip the rest of the loop statement and continued the next iteration of the loop.e.g. of Break Statementint i=0;while(i<=10){  i++;  if(i==5)    break;  System.out.println(i);}e.g. of Continue Statementint i=0;while(i<=10){  i++;  if(i==5)    continue;  System.out.println(i);}

Q. Compare and discuss the suitability of three loops in different situation?
Ans: (i) The for loop should be preferred if number of iteration is known beforehand. (ii) The while loop should be preferred if the number iteration is dependent upon some control variable. (iii) The do-while loop should be preferred if the number of iterations is dependent upon user response.

Q. Explain the term for loop with an example.
Ans: In Java the 'for' statement is the most common iterative statement. the general syntax of the for loop is,for(initialization; test-expression; increment){  body of the loop}This loop is executed at initial value, condition and increment. Three statement separated by semi colons are placed with in the parenthesis. for example:for(int i=1;i<=10;i++){  System.out.println(i);}

Q. State one similarity and one difference between while and do-while loop.
Ans: Similarity: In both loops there is a chances to forget the increment statement inside the loop. Difference: In while loop the test expression is evaluated at the beginning where as in do-while loop test expression is evaluated at the bottom, after the body of the loop.

Q. What do you meant by an infinite loop? Give an example. [2008]   ORQ. What do you meant by an endless loop? Give an example.
Ans: Infinite loop is an endless loop whose number of iterations are not fixed.eg: for(;;)     System.out.println("java");

Q. Differentiate fixed and variable iterative type of loops.
Ans: Fixed type of iterative loop is created when the process is to be repeated for defined number of times. Variable iterative loop repeats the process till a given condition is true.

Q. Differentiate Null loop and Infinite loop.
Ans: A Null loop does not contains any statement to repeat where as infinite loop repeats execution of the statements for endless iterations.e.g. of null loops  for(int i=1;i<=10;i++);e.g. for infinite loop  for(int i=10;i>=1;i++)

Q. What do you mean by delay loop?
Ans: A null loop is also called delay loop which does not repeat the execution of any statement but keeps the control engaged until the iterations are completed.

No comments:

Post a Comment