(a) (i) int res = 'A';
What is the value of res?
Show SolutionHide Solution↓
Value of res is 65 which is the ASCII code of A. As res is an int variable and we are trying to assign it the character A so through implicit type conversion the ASCII code of A is assigned to res.
(ii) Name the package that contains wrapper classes.
java.lang
(b) State the difference between while and do while loop.
| while | do-while |
|---|---|
| It is an entry-controlled loop. | It is an exit-controlled loop. |
| It is helpful in situations where numbers of iterations are not known. | It is suitable when we need to display a menu to the user. |
(c) System.out.print("BEST ");
System.out.println("OF LUCK");
Choose the correct option for the output of the above statements
- BEST OF LUCK
- BEST
OF LUCK
Option 1 — BEST OF LUCK is the correct option.
System.out.print does not print a newline at the end of its output so the println statement begins printing on the same line. So the output is BEST OF LUCK printed on a single line.
(d) Write the prototype of a function check which takes an integer as an argument and returns a character.
char check(int a)
(e) Write the return data type of the following function.
- endsWith()
- log()
- boolean
- double