Your Name:

5.1 If a method has no accessibility modifier, then it will be visible

(a) only within objects of its class
(b) to any object of a class in its package
(c) to any other object
(d) not at all

5.2 In the following while-statements, how many characters will be printed if the data are KALAMZOO?

int ch = ' ';
while (ch != 'Z') {

(a) 6
(b) 5
(c) 0
(d) cannot say

5.3 After the following switch-statement, what will value be ?

int coin = 5; switch (coin)
{ case 1: value = 0.01;
case 2: value = 0.02;
case 3: value = 0.05;
case 4: value = 0.20;
case 5: value = 0.50;
case 6: value = 1.00;
case 7: value = 2.00;
default: value = 0;

(a) 0.50
(b) 2.00
(c) 5
(d) 0

5.4 What happens when a switch-statement is entered with a value for which there is no case- statement and there is also no default case?
(a) execution error
(b) a case-statement is selected at random
(c) the last case-statement is executed
(d) nothing happens in the switch, and the program proceeds

5.5 A while-loop ends when
(a) its condition evaluates to true
(b) its condition evaluates to false
(c) its condition evaluates to false or a break is executed
(d) its condition evaluates to false and a break is executed

5.6 Given a character ch, the next character value alphabetically can be obtained by:
(a) ch ++
(b) nextChar(ch)
(c) ((int) ch) ++
(d) can't be done

5.7 When we throw a user-defined exception, the exception is a
(a) class
(b) variable
(c) object
(d) formal parameter

5.8 In the case study, how could the following condition be made more efficient?

while (yourchoice! = 'R' & yourchoice!= 'S' & yourchoice!='P'& yourchoice ! = 'Q');

(a) replace the & operators by && operators
(b) put brackets around each of the four comparisons
(c) rewrite it as while (yourchoice != {'R', 'S', 'P', 'Q'});
(d) can't be done

5.9 A rewrite of the while-loop in the HCF as a do-while loop would be:
(a) do {if (a>b) a-=b else b-=a;} while (a != b);
(b) do {if (a>b) a-=b else b-=a;} while (a == b);
(c) if (a!=b) do {if (a>b) a-=b else b-=a;} while (a!=b);
(d) if (a!=b) do {if (a>b) a-=b else b-=a;} while (a == b);

5.10 The idea of keeping input-output out of a class which describes an object and keeping it in the main driving class which instantiates the class is called:
(a) separation of concerns
(b) anti-coherence
(c) information hiding
(d) private accessibility